UNPKG

decap-cms-core

Version:

Decap CMS core application, see decap-cms package for the main distribution.

93 lines (83 loc) 2.63 kB
import PropTypes from 'prop-types'; import styled from '@emotion/styled'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { translate } from 'react-polyglot'; import { Loader, lengths } from 'decap-cms-ui-default'; import EntryListing from './EntryListing'; const PaginationMessage = styled.div` width: ${lengths.topCardWidth}; max-width: 100%; padding: 16px; text-align: center; `; const NoEntriesMessage = styled(PaginationMessage)` margin-top: 16px; `; function Entries({ collections, entries, isFetching, viewStyle, cursor, handleCursorActions, t, page, getWorkflowStatus, getUnpublishedEntries, filterTerm, sortFields, showPublishedEntries = true, showUnpublishedEntries = true, }) { const loadingMessages = [ t('collection.entries.loadingEntries'), t('collection.entries.cachingEntries'), t('collection.entries.longerLoading'), ]; if (showPublishedEntries && isFetching && page === undefined) { return <Loader active>{loadingMessages}</Loader>; } const hasEntries = showPublishedEntries && ((entries && entries.size > 0) || cursor?.actions?.has('append_next')); if (hasEntries || !showPublishedEntries) { return ( <> <EntryListing collections={collections} entries={entries} viewStyle={viewStyle} cursor={cursor} handleCursorActions={handleCursorActions} page={page} getWorkflowStatus={getWorkflowStatus} getUnpublishedEntries={getUnpublishedEntries} filterTerm={filterTerm} sortFields={sortFields} showPublishedEntries={showPublishedEntries} showUnpublishedEntries={showUnpublishedEntries} /> {showPublishedEntries && isFetching && page !== undefined && entries.size > 0 ? ( <PaginationMessage>{t('collection.entries.loadingEntries')}</PaginationMessage> ) : null} </> ); } return <NoEntriesMessage>{t('collection.entries.noEntries')}</NoEntriesMessage>; } Entries.propTypes = { collections: ImmutablePropTypes.iterable.isRequired, entries: ImmutablePropTypes.list, page: PropTypes.number, isFetching: PropTypes.bool, viewStyle: PropTypes.string, cursor: PropTypes.any.isRequired, handleCursorActions: PropTypes.func.isRequired, t: PropTypes.func.isRequired, getWorkflowStatus: PropTypes.func, getUnpublishedEntries: PropTypes.func, filterTerm: PropTypes.string, sortFields: PropTypes.array, showPublishedEntries: PropTypes.bool, showUnpublishedEntries: PropTypes.bool, }; export default translate()(Entries);