From 1369fbb064fee2840c8714d95b08d5a397c389f2 Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Wed, 23 Mar 2022 10:42:40 -0300 Subject: [PATCH] Allow users to rename private/unpublished lists. --- ui/component/collectionMenuList/view.jsx | 17 +++++- ui/component/collectionPreviewTile/index.js | 3 +- ui/component/collectionPreviewTile/view.jsx | 60 ++++++++++++++++++--- ui/constants/action_types.js | 1 + ui/redux/actions/collections.js | 8 +++ ui/redux/reducers/collections.js | 13 +++++ 6 files changed, 93 insertions(+), 9 deletions(-) diff --git a/ui/component/collectionMenuList/view.jsx b/ui/component/collectionMenuList/view.jsx index 8607a22dc..8c30b73ff 100644 --- a/ui/component/collectionMenuList/view.jsx +++ b/ui/component/collectionMenuList/view.jsx @@ -16,10 +16,19 @@ type Props = { collectionId: string, playNextUri: string, doToggleShuffleList: (string) => void, + onRenameList: () => void, }; function CollectionMenuList(props: Props) { - const { inline = false, collectionId, collectionName, doOpenModal, playNextUri, doToggleShuffleList } = props; + const { + inline = false, + collectionId, + collectionName, + doOpenModal, + playNextUri, + doToggleShuffleList, + onRenameList, + } = props; const [doShuffle, setDoShuffle] = React.useState(false); const { push } = useHistory(); @@ -86,6 +95,12 @@ function CollectionMenuList(props: Props) { {__('Delete List')} + +
+ + {__('Rename List')} +
+
)} diff --git a/ui/component/collectionPreviewTile/index.js b/ui/component/collectionPreviewTile/index.js index 82cdd90b8..74f31dd09 100644 --- a/ui/component/collectionPreviewTile/index.js +++ b/ui/component/collectionPreviewTile/index.js @@ -16,7 +16,7 @@ import { makeSelectCountForCollectionId, makeSelectIsResolvingCollectionForId, } from 'redux/selectors/collections'; -import { doFetchItemsInCollection, doCollectionDelete } from 'redux/actions/collections'; +import { doFetchItemsInCollection, doCollectionDelete, doCollectionRename } from 'redux/actions/collections'; import { doResolveUri } from 'redux/actions/claims'; import { selectMutedChannels } from 'redux/selectors/blocked'; import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; @@ -54,6 +54,7 @@ const perform = (dispatch) => ({ resolveUri: (uri) => dispatch(doResolveUri(uri)), resolveCollectionItems: (options) => doFetchItemsInCollection(options), deleteCollection: (id) => dispatch(doCollectionDelete(id)), + renameCollection: (id, name) => dispatch(doCollectionRename(id, name)), }); export default connect(select, perform)(CollectionPreviewTile); diff --git a/ui/component/collectionPreviewTile/view.jsx b/ui/component/collectionPreviewTile/view.jsx index 33e36f39f..982aefcd8 100644 --- a/ui/component/collectionPreviewTile/view.jsx +++ b/ui/component/collectionPreviewTile/view.jsx @@ -1,7 +1,10 @@ // @flow import React from 'react'; import classnames from 'classnames'; +import * as ICONS from 'constants/icons'; import { NavLink, useHistory } from 'react-router-dom'; +import { FormField } from 'component/common/form'; +import Button from 'component/button'; import ClaimPreviewTile from 'component/claimPreviewTile'; import TruncatedText from 'component/common/truncated-text'; import CollectionCount from './collectionCount'; @@ -40,6 +43,7 @@ type Props = { deleteCollection: (string) => void, resolveCollectionItems: (any) => void, isResolvingCollectionClaims: boolean, + renameCollection: (string, string) => void, }; function CollectionPreviewTile(props: Props) { @@ -53,10 +57,15 @@ function CollectionPreviewTile(props: Props) { collectionItemUrls, claim, resolveCollectionItems, + renameCollection, } = props; const { push } = useHistory(); const hasClaim = Boolean(claim); + + const [isRenamingList, setIsRenamingList] = React.useState(false); + const [newName, setNewName] = React.useState(collectionName); + React.useEffect(() => { if (collectionId && hasClaim && resolveCollectionItems) { resolveCollectionItems({ collectionId, page_size: 5 }); @@ -69,11 +78,16 @@ function CollectionPreviewTile(props: Props) { formatLbryUrlForWeb(collectionItemUrls[0] || '/') + (collectionId ? generateListSearchUrlParams(collectionId) : ''); function handleClick(e) { - if (navigateUrl) { + if (navigateUrl && !isRenamingList) { push(navigateUrl); } } + function handleRenameCollection() { + renameCollection(collectionId, newName); + setIsRenamingList(false); + } + const navLinkProps = { to: navigateUrl, onClick: (e) => e.stopPropagation(), @@ -144,12 +158,44 @@ function CollectionPreviewTile(props: Props) { - -

- - -

-
+ {isRenamingList && ( + +