From 35732535049b0926aed5498220bf9920bb16e279 Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Sat, 19 Oct 2019 19:20:00 +0200 Subject: [PATCH] Add/Remove sketch to collection by clicking on entire row --- .../CollectionList/CollectionListRow.jsx | 49 ++++++++++++++++--- client/styles/components/_sketch-list.scss | 27 ++++++++++ 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx index 07aaf74d..cf646d54 100644 --- a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx @@ -9,9 +9,13 @@ import * as ProjectActions from '../../actions/project'; import * as CollectionsActions from '../../actions/collections'; import * as IdeActions from '../../actions/ide'; import * as ToastActions from '../../actions/toast'; -import AddRemoveButton from '../../../../components/AddRemoveButton'; const downFilledTriangle = require('../../../../images/down-filled-triangle.svg'); +const check = require('../../../../images/check.svg'); + +const checkIcon = ( + +); class CollectionListRowBase extends React.Component { static projectInCollection(project, collection) { @@ -139,16 +143,30 @@ class CollectionListRowBase extends React.Component { this.props.removeFromCollection(this.props.collection.id, this.props.project.id); } + handleAddRemove = (evt) => { + // Clicking on View action should not perform add/remove + const didOriginateInLink = evt.target.nodeName === 'A'; + + if (didOriginateInLink) { + return; + } + + if (CollectionListRowBase.projectInCollection(this.props.project, this.props.collection)) { + this.handleCollectionRemove(); + } else { + this.handleCollectionAdd(); + } + } + renderActions = () => { const { optionsOpen } = this.state; const userIsOwner = this.props.user.username === this.props.username; if (this.props.addMode === true && this.props.project) { - return CollectionListRowBase.projectInCollection(this.props.project, this.props.collection) ? - : - ; + return View; } + return (