// @flow import React from 'react'; import ClaimList from 'component/claimList'; import Page from 'component/page'; import * as PAGES from 'constants/pages'; import { useHistory } from 'react-router-dom'; import CollectionEdit from 'component/collectionEdit'; import Card from 'component/common/card'; import Button from 'component/button'; import CollectionActions from 'component/collectionActions'; import classnames from 'classnames'; import ClaimAuthor from 'component/claimAuthor'; import FileDescription from 'component/fileDescription'; import * as COLLECTIONS_CONSTS from 'constants/collections'; import Icon from 'component/common/icon'; import * as ICONS from 'constants/icons'; import Spinner from 'component/spinner'; export const PAGE_VIEW_QUERY = 'view'; export const EDIT_PAGE = 'edit'; type Props = { collectionId: string, uri: string, claim: Claim, title: string, thumbnail: string, collection: Collection, collectionUrls: Array, collectionCount: number, isResolvingCollection: boolean, isMyClaim: boolean, isMyCollection: boolean, claimIsPending: boolean, collectionHasEdits: boolean, deleteCollection: (string, string) => void, editCollection: (string, CollectionEditParams) => void, fetchCollectionItems: (string, () => void) => void, resolveUris: (string) => void, user: ?User, }; export default function CollectionPage(props: Props) { const { collectionId, uri, claim, collection, collectionUrls, collectionCount, collectionHasEdits, claimIsPending, isResolvingCollection, fetchCollectionItems, deleteCollection, } = props; const { replace, location: { search }, } = useHistory(); const [didTryResolve, setDidTryResolve] = React.useState(false); const [showInfo, setShowInfo] = React.useState(false); const { name, totalItems } = collection || {}; const isBuiltin = COLLECTIONS_CONSTS.BUILTIN_LISTS.includes(collectionId); const urlParams = new URLSearchParams(search); const editing = urlParams.get(PAGE_VIEW_QUERY) === EDIT_PAGE; const urlsReady = collectionUrls && (totalItems === undefined || (totalItems && totalItems === collectionUrls.length)); React.useEffect(() => { if (collectionId && !urlsReady && !didTryResolve && !collection) { fetchCollectionItems(collectionId, () => setDidTryResolve(true)); } }, [collectionId, urlsReady, didTryResolve, setDidTryResolve, fetchCollectionItems, collection]); const pending = (
{__('Your publish is being confirmed and will be live soon')}
); const unpublished = (