Add Copy List option on Popups and Collection Content Sidebar

This commit is contained in:
saltrafael 2021-08-24 09:54:41 -03:00
parent 34913e33fc
commit bd1b2df5b7
No known key found for this signature in database
GPG key ID: 9C7F1DC0B0F54515
6 changed files with 87 additions and 22 deletions

View file

@ -19,9 +19,11 @@ const select = (state, props) => {
if (collectionId) { if (collectionId) {
items = makeSelectUrlsForCollectionId(collectionId)(state); items = makeSelectUrlsForCollectionId(collectionId)(state);
items.map((uri) => { if (items) {
itemsClaims.push(makeSelectClaimForUri(uri)(state)); items.map((uri) => {
}); itemsClaims.push(makeSelectClaimForUri(uri)(state));
});
}
} }
return { return {

View file

@ -9,6 +9,8 @@ import {
COLLECTIONS_CONSTS, COLLECTIONS_CONSTS,
makeSelectEditedCollectionForId, makeSelectEditedCollectionForId,
makeSelectClaimIsMine, makeSelectClaimIsMine,
doFetchItemsInCollection,
makeSelectUrlsForCollectionId,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked'; import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { doChannelMute, doChannelUnmute } from 'redux/actions/blocked'; import { doChannelMute, doChannelUnmute } from 'redux/actions/blocked';
@ -33,6 +35,8 @@ import fs from 'fs';
const select = (state, props) => { const select = (state, props) => {
const claim = makeSelectClaimForUri(props.uri, false)(state); const claim = makeSelectClaimForUri(props.uri, false)(state);
const collectionId = props.collectionId;
const resolvedList = makeSelectUrlsForCollectionId(collectionId)(state);
const repostedClaim = claim && claim.reposted_claim; const repostedClaim = claim && claim.reposted_claim;
const contentClaim = repostedClaim || claim; const contentClaim = repostedClaim || claim;
const contentSigningChannel = contentClaim && contentClaim.signing_channel; const contentSigningChannel = contentClaim && contentClaim.signing_channel;
@ -60,10 +64,11 @@ const select = (state, props) => {
isSubscribed: makeSelectIsSubscribed(contentChannelUri, true)(state), isSubscribed: makeSelectIsSubscribed(contentChannelUri, true)(state),
channelIsAdminBlocked: makeSelectChannelIsAdminBlocked(props.uri)(state), channelIsAdminBlocked: makeSelectChannelIsAdminBlocked(props.uri)(state),
isAdmin: selectHasAdminChannel(state), isAdmin: selectHasAdminChannel(state),
claimInCollection: makeSelectCollectionForIdHasClaimUrl(props.collectionId, contentPermanentUri)(state), claimInCollection: makeSelectCollectionForIdHasClaimUrl(collectionId, contentPermanentUri)(state),
isMyCollection: makeSelectCollectionIsMine(props.collectionId)(state), isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
editedCollection: makeSelectEditedCollectionForId(props.collectionId)(state), editedCollection: makeSelectEditedCollectionForId(collectionId)(state),
isAuthenticated: Boolean(selectUserVerifiedEmail(state)), isAuthenticated: Boolean(selectUserVerifiedEmail(state)),
resolvedList,
}; };
}; };
@ -90,6 +95,7 @@ const perform = (dispatch) => ({
doChannelSubscribe: (subscription) => dispatch(doChannelSubscribe(subscription)), doChannelSubscribe: (subscription) => dispatch(doChannelSubscribe(subscription)),
doChannelUnsubscribe: (subscription) => dispatch(doChannelUnsubscribe(subscription)), doChannelUnsubscribe: (subscription) => dispatch(doChannelUnsubscribe(subscription)),
doCollectionEdit: (collection, props) => dispatch(doCollectionEdit(collection, props)), doCollectionEdit: (collection, props) => dispatch(doCollectionEdit(collection, props)),
fetchCollectionItems: (collectionId) => dispatch(doFetchItemsInCollection({ collectionId })),
}); });
export default connect(select, perform)(ClaimPreview); export default connect(select, perform)(ClaimPreview);

View file

@ -56,6 +56,8 @@ type Props = {
isChannelPage: boolean, isChannelPage: boolean,
editedCollection: Collection, editedCollection: Collection,
isAuthenticated: boolean, isAuthenticated: boolean,
fetchCollectionItems: (string) => void,
resolvedList: boolean,
}; };
function ClaimMenuList(props: Props) { function ClaimMenuList(props: Props) {
@ -93,6 +95,8 @@ function ClaimMenuList(props: Props) {
isChannelPage = false, isChannelPage = false,
editedCollection, editedCollection,
isAuthenticated, isAuthenticated,
fetchCollectionItems,
resolvedList,
} = props; } = props;
const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@'); const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@');
const isChannel = !incognitoClaim && !contentSigningChannel; const isChannel = !incognitoClaim && !contentSigningChannel;
@ -106,6 +110,12 @@ function ClaimMenuList(props: Props) {
? __('Unfollow') ? __('Unfollow')
: __('Follow'); : __('Follow');
const fetchItems = React.useCallback(() => {
if (collectionId) {
fetchCollectionItems(collectionId);
}
}, [collectionId, fetchCollectionItems]);
const { push, replace } = useHistory(); const { push, replace } = useHistory();
if (!claim) { if (!claim) {
return null; return null;
@ -251,6 +261,18 @@ function ClaimMenuList(props: Props) {
{__('View List')} {__('View List')}
</div> </div>
</MenuItem> </MenuItem>
<MenuItem
className="comment__menu-option"
onSelect={() => {
fetchItems();
openModal(MODALS.COLLECTION_ADD, { collectionId });
}}
>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.COPY} />
{__('Copy List')}
</div>
</MenuItem>
{isMyCollection && ( {isMyCollection && (
<> <>
<MenuItem <MenuItem

View file

@ -7,9 +7,8 @@ import {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectClaimIsMine, makeSelectClaimIsMine,
} from 'lbry-redux'; } from 'lbry-redux';
import { import { selectPlayingUri } from 'redux/selectors/content';
selectPlayingUri, import { doOpenModal } from 'redux/actions/app';
} from 'redux/selectors/content';
const select = (state, props) => { const select = (state, props) => {
const playingUri = selectPlayingUri(state); const playingUri = selectPlayingUri(state);
@ -26,4 +25,6 @@ const select = (state, props) => {
}; };
}; };
export default connect(select)(CollectionContent); export default connect(select, {
doOpenModal,
})(CollectionContent);

View file

@ -4,6 +4,7 @@ import ClaimList from 'component/claimList';
import Card from 'component/common/card'; import Card from 'component/common/card';
import Button from 'component/button'; import Button from 'component/button';
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
import * as MODALS from 'constants/modal_types';
import Icon from 'component/common/icon'; import Icon from 'component/common/icon';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import { COLLECTIONS_CONSTS } from 'lbry-redux'; import { COLLECTIONS_CONSTS } from 'lbry-redux';
@ -16,28 +17,52 @@ type Props = {
collectionName: string, collectionName: string,
collection: any, collection: any,
createUnpublishedCollection: (string, Array<any>, ?string) => void, createUnpublishedCollection: (string, Array<any>, ?string) => void,
doOpenModal: (id: string, { collectionId: string }) => void,
}; };
export default function CollectionContent(props: Props) { export default function CollectionContent(props: Props) {
const { collectionUrls, collectionName, id, url } = props; const {
collectionUrls,
collectionName,
id,
url,
doOpenModal,
} = props;
return ( return (
<Card <Card
isBodyList isBodyList
className="file-page__recommended" className="file-page__recommended"
title={ title={
<span> <>
<Icon <span className="file-page__recommended-collection__row">
icon={(id === COLLECTIONS_CONSTS.WATCH_LATER_ID && ICONS.TIME) || <Icon
(id === COLLECTIONS_CONSTS.FAVORITES_ID && ICONS.STAR) || ICONS.STACK} icon={
className="icon--margin-right" /> (id === COLLECTIONS_CONSTS.WATCH_LATER_ID && ICONS.TIME) ||
{collectionName} (id === COLLECTIONS_CONSTS.FAVORITES_ID && ICONS.STAR) ||
</span> ICONS.STACK
}
className="icon--margin-right"
/>
{collectionName}
</span>
</>
} }
titleActions={ titleActions={
<div className="card__title-actions--link"> <>
{/* TODO: BUTTON TO SAVE COLLECTION - Probably save/copy modal */} <div className="card__title-actions--link">
<Button label={'View List'} button="link" navigate={`/$/${PAGES.LIST}/${id}`} /> <Button label={'View List'} button="link" navigate={`/$/${PAGES.LIST}/${id}`} />
</div> </div>
<span>
<Button
button="alt"
title={__('Copy')}
icon={ICONS.COPY}
className="button--file-action--right"
onClick={() => doOpenModal(MODALS.COLLECTION_ADD, { collectionId: id })}
/>
</span>
</>
} }
body={ body={
<ClaimList <ClaimList

View file

@ -40,6 +40,15 @@ function CollectionMenuList(props: Props) {
{__('View List')} {__('View List')}
</div> </div>
</MenuItem> </MenuItem>
<MenuItem
className="comment__menu-option"
onSelect={() => doOpenModal(MODALS.COLLECTION_ADD, { collectionId })}
>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.COPY} />
{__('Copy List')}
</div>
</MenuItem>
<MenuItem <MenuItem
className="comment__menu-option" className="comment__menu-option"
onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}?view=edit`)} onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}?view=edit`)}