diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index 51ed9664..608ab477 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -338,7 +338,7 @@ class Nav extends React.PureComponent { > Add to Collection - } + } { __process.env.EXAMPLES_ENABLED &&
  • My collections - +
  • }
  • diff --git a/client/modules/IDE/components/CollectionList/CollectionList.jsx b/client/modules/IDE/components/CollectionList/CollectionList.jsx index 58b9bc45..930ce797 100644 --- a/client/modules/IDE/components/CollectionList/CollectionList.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionList.jsx @@ -36,6 +36,7 @@ class CollectionList extends React.Component { componentDidUpdate(prevProps) { if (prevProps.loading === true && this.props.loading === false) { + // eslint-disable-next-line react/no-did-update-set-state this.setState({ hasLoadedData: true, }); @@ -142,11 +143,14 @@ const ItemsShape = PropTypes.shape({ }); CollectionList.propTypes = { + addMode: PropTypes.bool, user: PropTypes.shape({ username: PropTypes.string, authenticated: PropTypes.bool.isRequired }).isRequired, + projectId: PropTypes.string.isRequired, getCollections: PropTypes.func.isRequired, + getProject: PropTypes.func.isRequired, collections: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, @@ -172,6 +176,7 @@ CollectionList.propTypes = { }; CollectionList.defaultProps = { + addMode: false, project: { id: undefined, owner: undefined diff --git a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx index 69a04219..07aaf74d 100644 --- a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx @@ -183,7 +183,7 @@ class CollectionListRowBase extends React.Component { renderCollectionName = () => { const { addMode, collection, username } = this.props; const { renameOpen, renameValue } = this.state; - + if (addMode) { return collection.name; } @@ -204,7 +204,7 @@ class CollectionListRowBase extends React.Component { /> } - ) + ); } render() { @@ -236,6 +236,10 @@ CollectionListRowBase.propTypes = { id: PropTypes.string.isRequired, name: PropTypes.string.isRequired }).isRequired, + addMode: PropTypes.bool.isRequired, + project: PropTypes.shape({ + id: PropTypes.string.isRequired, + }).isRequired, username: PropTypes.string.isRequired, user: PropTypes.shape({ username: PropTypes.string, diff --git a/client/modules/IDE/components/SketchList.jsx b/client/modules/IDE/components/SketchList.jsx index 09d19168..268d5d89 100644 --- a/client/modules/IDE/components/SketchList.jsx +++ b/client/modules/IDE/components/SketchList.jsx @@ -212,20 +212,16 @@ class SketchListRowBase extends React.Component { ); } - renderAddRemoveButtons = () => { - return ( - { - this.props.inCollection ? - : - - } - - ); - } + renderAddRemoveButtons = () => ( + { + this.props.inCollection ? + : + + } + + ) - renderActions = () => { - return this.props.addMode === true ? this.renderAddRemoveButtons() : this.renderDropdown(); - } + renderActions = () => (this.props.addMode === true ? this.renderAddRemoveButtons() : this.renderDropdown()) render() { const { sketch, username } = this.props; @@ -262,6 +258,8 @@ class SketchListRowBase extends React.Component { } SketchListRowBase.propTypes = { + addMode: PropTypes.bool.isRequired, + inCollection: PropTypes.bool.isRequired, sketch: PropTypes.shape({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired @@ -275,7 +273,9 @@ SketchListRowBase.propTypes = { showShareModal: PropTypes.func.isRequired, cloneProject: PropTypes.func.isRequired, exportProjectAsZip: PropTypes.func.isRequired, - changeProjectName: PropTypes.func.isRequired + changeProjectName: PropTypes.func.isRequired, + onCollectionAdd: PropTypes.func.isRequired, + onCollectionRemove: PropTypes.func.isRequired, }; function mapDispatchToPropsSketchListRow(dispatch) { @@ -394,6 +394,15 @@ SketchList.propTypes = { createdAt: PropTypes.string.isRequired, updatedAt: PropTypes.string.isRequired })).isRequired, + collection: PropTypes.shape({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + items: PropTypes.arrayOf(PropTypes.shape({ + project: PropTypes.shape({ + id: PropTypes.string.isRequired, + }), + })), + }).isRequired, username: PropTypes.string, loading: PropTypes.bool.isRequired, toggleDirectionForField: PropTypes.func.isRequired, @@ -402,14 +411,13 @@ SketchList.propTypes = { field: PropTypes.string.isRequired, direction: PropTypes.string.isRequired }).isRequired, + addToCollection: PropTypes.func.isRequired, + removeFromCollection: PropTypes.func.isRequired, addMode: PropTypes.bool, }; SketchList.defaultProps = { - project: { - id: undefined, - owner: undefined - }, + addMode: false, username: undefined }; diff --git a/client/modules/User/components/Collection.jsx b/client/modules/User/components/Collection.jsx index 78eff1e8..5b6eb890 100644 --- a/client/modules/User/components/Collection.jsx +++ b/client/modules/User/components/Collection.jsx @@ -42,6 +42,10 @@ const ShareURL = ({ value }) => { ); }; +ShareURL.propTypes = { + value: PropTypes.string.isRequired, +}; + class CollectionItemRowBase extends React.Component { constructor(props) { super(props); @@ -229,6 +233,11 @@ CollectionItemRowBase.propTypes = { id: PropTypes.string.isRequired, name: PropTypes.string.isRequired }).isRequired, + item: PropTypes.shape({ + project: PropTypes.shape({ + name: PropTypes.string.isRequired, + }).isRequired, + }).isRequired, username: PropTypes.string.isRequired, user: PropTypes.shape({ username: PropTypes.string, @@ -474,12 +483,19 @@ Collection.propTypes = { }).isRequired, getCollections: PropTypes.func.isRequired, collection: PropTypes.shape({ + id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, + slug: PropTypes.string, description: PropTypes.string, + owner: PropTypes.shape({ + username: PropTypes.string.isRequired, + }).isRequired, + items: PropTypes.arrayOf(PropTypes.shape({})), }).isRequired, username: PropTypes.string, loading: PropTypes.bool.isRequired, toggleDirectionForField: PropTypes.func.isRequired, + editCollection: PropTypes.func.isRequired, resetSorting: PropTypes.func.isRequired, sorting: PropTypes.shape({ field: PropTypes.string.isRequired, diff --git a/client/modules/User/pages/CollectionView.jsx b/client/modules/User/pages/CollectionView.jsx index 4ab26a8f..145e96c2 100644 --- a/client/modules/User/pages/CollectionView.jsx +++ b/client/modules/User/pages/CollectionView.jsx @@ -89,7 +89,7 @@ CollectionView.propTypes = { collection_id: PropTypes.string.isRequired, username: PropTypes.string.isRequired, }).isRequired, - previousPath: PropTypes.string.isRequired, + // previousPath: PropTypes.string.isRequired, theme: PropTypes.string.isRequired, user: PropTypes.shape({ username: PropTypes.string.isRequired,