From ed1945ab4b9cf089e847fc785c9de2520bbd00b4 Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Sun, 10 Nov 2019 20:28:13 +0100 Subject: [PATCH] Rename collection from collection list view --- .../CollectionList/CollectionListRow.jsx | 53 ++++++++++++++++--- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx index be460306..38658093 100644 --- a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx @@ -11,11 +11,6 @@ import * as IdeActions from '../../actions/ide'; import * as ToastActions from '../../actions/toast'; 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) { @@ -26,7 +21,9 @@ class CollectionListRowBase extends React.Component { super(props); this.state = { optionsOpen: false, - isFocused: false + isFocused: false, + renameOpen: false, + renameValue: props.collection.name, }; } @@ -65,7 +62,8 @@ class CollectionListRowBase extends React.Component { closeAll = () => { this.setState({ - optionsOpen: false + optionsOpen: false, + renameOpen: false, }); } @@ -81,6 +79,33 @@ class CollectionListRowBase extends React.Component { } } + handleRenameOpen = () => { + this.closeAll(); + this.setState({ + renameOpen: true, + }); + } + + handleRenameChange = (e) => { + this.setState({ + renameValue: e.target.value + }); + } + + handleRenameEnter = (e) => { + if (e.key === 'Enter') { + this.props.editCollection(this.props.collection.id, { name: this.state.renameValue }); + this.closeAll(); + } + } + + resetSketchName = () => { + this.setState({ + renameValue: this.props.collection.name + }); + } + + renderActions = () => { const { optionsOpen } = this.state; const userIsOwner = this.props.user.username === this.props.username; @@ -110,6 +135,17 @@ class CollectionListRowBase extends React.Component { Delete } + {userIsOwner && +
  • + +
  • } } @@ -179,7 +215,8 @@ CollectionListRowBase.propTypes = { username: PropTypes.string, authenticated: PropTypes.bool.isRequired }).isRequired, - deleteCollection: PropTypes.func.isRequired + deleteCollection: PropTypes.func.isRequired, + editCollection: PropTypes.func.isRequired, }; function mapDispatchToPropsSketchListRow(dispatch) {