@pranaysahith/decap-cms-core 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/@pranaysahith/decap-cms-core.js +52 -0
- package/dist/@pranaysahith/decap-cms-core.js.LICENSE.txt +141 -0
- package/dist/@pranaysahith/decap-cms-core.js.map +1 -0
- package/dist/decap-cms-core.js +47 -0
- package/dist/decap-cms-core.js.LICENSE.txt +116 -0
- package/dist/decap-cms-core.js.map +1 -0
- package/dist/esm/actions/auth.js +97 -0
- package/dist/esm/actions/collections.js +15 -0
- package/dist/esm/actions/config.js +493 -0
- package/dist/esm/actions/deploys.js +79 -0
- package/dist/esm/actions/editorialWorkflow.js +480 -0
- package/dist/esm/actions/entries.js +865 -0
- package/dist/esm/actions/media.js +147 -0
- package/dist/esm/actions/mediaLibrary.js +552 -0
- package/dist/esm/actions/notifications.js +21 -0
- package/dist/esm/actions/search.js +149 -0
- package/dist/esm/actions/status.js +74 -0
- package/dist/esm/actions/waitUntil.js +32 -0
- package/dist/esm/backend.js +1082 -0
- package/dist/esm/bootstrap.js +101 -0
- package/dist/esm/components/App/App.js +289 -0
- package/dist/esm/components/App/Header.js +172 -0
- package/dist/esm/components/App/NotFoundPage.js +19 -0
- package/dist/esm/components/Collection/Collection.js +198 -0
- package/dist/esm/components/Collection/CollectionControls.js +46 -0
- package/dist/esm/components/Collection/CollectionSearch.js +222 -0
- package/dist/esm/components/Collection/CollectionTop.js +68 -0
- package/dist/esm/components/Collection/ControlButton.js +17 -0
- package/dist/esm/components/Collection/Entries/Entries.js +73 -0
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +241 -0
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +113 -0
- package/dist/esm/components/Collection/Entries/EntryCard.js +177 -0
- package/dist/esm/components/Collection/Entries/EntryListing.js +143 -0
- package/dist/esm/components/Collection/FilterControl.js +33 -0
- package/dist/esm/components/Collection/FolderRenameControl.js +403 -0
- package/dist/esm/components/Collection/GroupControl.js +33 -0
- package/dist/esm/components/Collection/NestedCollection.js +308 -0
- package/dist/esm/components/Collection/Sidebar.js +91 -0
- package/dist/esm/components/Collection/SortControl.js +59 -0
- package/dist/esm/components/Collection/ViewStyleControl.js +38 -0
- package/dist/esm/components/Editor/Editor.js +466 -0
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +395 -0
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +254 -0
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +374 -0
- package/dist/esm/components/Editor/EditorInterface.js +386 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +47 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +66 -0
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +288 -0
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +27 -0
- package/dist/esm/components/Editor/EditorToolbar.js +536 -0
- package/dist/esm/components/Editor/EntryPathEditor.js +272 -0
- package/dist/esm/components/Editor/withWorkflow.js +56 -0
- package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +18 -0
- package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +20 -0
- package/dist/esm/components/EditorWidgets/index.js +4 -0
- package/dist/esm/components/MediaLibrary/EmptyMessage.js +22 -0
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +446 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +93 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +99 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +198 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +32 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +156 -0
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +51 -0
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +123 -0
- package/dist/esm/components/UI/DragDrop.js +67 -0
- package/dist/esm/components/UI/ErrorBoundary.js +173 -0
- package/dist/esm/components/UI/FileUploadButton.js +27 -0
- package/dist/esm/components/UI/Modal.js +104 -0
- package/dist/esm/components/UI/Notifications.js +62 -0
- package/dist/esm/components/UI/SettingsDropdown.js +107 -0
- package/dist/esm/components/UI/index.js +6 -0
- package/dist/esm/components/Workflow/Workflow.js +133 -0
- package/dist/esm/components/Workflow/WorkflowCard.js +128 -0
- package/dist/esm/components/Workflow/WorkflowList.js +204 -0
- package/dist/esm/constants/collectionTypes.js +2 -0
- package/dist/esm/constants/collectionViews.js +2 -0
- package/dist/esm/constants/commitProps.js +2 -0
- package/dist/esm/constants/configSchema.js +644 -0
- package/dist/esm/constants/fieldInference.js +57 -0
- package/dist/esm/constants/publishModes.js +18 -0
- package/dist/esm/constants/validationErrorTypes.js +6 -0
- package/dist/esm/formats/formats.js +83 -0
- package/dist/esm/formats/frontmatter.js +146 -0
- package/dist/esm/formats/helpers.js +12 -0
- package/dist/esm/formats/json.js +8 -0
- package/dist/esm/formats/toml.js +32 -0
- package/dist/esm/formats/yaml.js +51 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/integrations/index.js +28 -0
- package/dist/esm/integrations/providers/algolia/implementation.js +174 -0
- package/dist/esm/integrations/providers/assetStore/implementation.js +165 -0
- package/dist/esm/lib/consoleError.js +3 -0
- package/dist/esm/lib/formatters.js +191 -0
- package/dist/esm/lib/i18n.js +367 -0
- package/dist/esm/lib/phrases.js +6 -0
- package/dist/esm/lib/polyfill.js +8 -0
- package/dist/esm/lib/registry.js +329 -0
- package/dist/esm/lib/serializeEntryValues.js +67 -0
- package/dist/esm/lib/stega.js +142 -0
- package/dist/esm/lib/textHelper.js +9 -0
- package/dist/esm/lib/urlHelper.js +111 -0
- package/dist/esm/mediaLibrary.js +37 -0
- package/dist/esm/reducers/auth.js +27 -0
- package/dist/esm/reducers/collections.js +428 -0
- package/dist/esm/reducers/combinedReducer.js +8 -0
- package/dist/esm/reducers/config.js +29 -0
- package/dist/esm/reducers/cursors.js +31 -0
- package/dist/esm/reducers/deploys.js +45 -0
- package/dist/esm/reducers/editorialWorkflow.js +83 -0
- package/dist/esm/reducers/entries.js +568 -0
- package/dist/esm/reducers/entryDraft.js +212 -0
- package/dist/esm/reducers/globalUI.js +25 -0
- package/dist/esm/reducers/index.js +66 -0
- package/dist/esm/reducers/integrations.js +53 -0
- package/dist/esm/reducers/mediaLibrary.js +252 -0
- package/dist/esm/reducers/medias.js +68 -0
- package/dist/esm/reducers/notifications.js +23 -0
- package/dist/esm/reducers/search.js +92 -0
- package/dist/esm/reducers/status.js +30 -0
- package/dist/esm/redux/index.js +7 -0
- package/dist/esm/redux/middleware/waitUntilAction.js +48 -0
- package/dist/esm/routing/history.js +12 -0
- package/dist/esm/types/diacritics.d.js +0 -0
- package/dist/esm/types/global.d.js +1 -0
- package/dist/esm/types/immutable.js +7 -0
- package/dist/esm/types/redux.js +14 -0
- package/dist/esm/types/tomlify-j0.4.d.js +0 -0
- package/dist/esm/valueObjects/AssetProxy.js +44 -0
- package/dist/esm/valueObjects/EditorComponent.js +34 -0
- package/dist/esm/valueObjects/Entry.js +20 -0
- package/index.d.ts +618 -0
- package/package.json +106 -0
- package/src/__tests__/backend.spec.js +1161 -0
- package/src/actions/__tests__/config.spec.js +1009 -0
- package/src/actions/__tests__/editorialWorkflow.spec.js +216 -0
- package/src/actions/__tests__/entries.spec.js +596 -0
- package/src/actions/__tests__/media.spec.ts +171 -0
- package/src/actions/__tests__/mediaLibrary.spec.js +327 -0
- package/src/actions/__tests__/search.spec.js +209 -0
- package/src/actions/auth.ts +127 -0
- package/src/actions/collections.ts +18 -0
- package/src/actions/config.ts +565 -0
- package/src/actions/deploys.ts +104 -0
- package/src/actions/editorialWorkflow.ts +567 -0
- package/src/actions/entries.ts +1055 -0
- package/src/actions/media.ts +139 -0
- package/src/actions/mediaLibrary.ts +574 -0
- package/src/actions/notifications.ts +36 -0
- package/src/actions/search.ts +221 -0
- package/src/actions/status.ts +99 -0
- package/src/actions/waitUntil.ts +49 -0
- package/src/backend.ts +1400 -0
- package/src/bootstrap.js +104 -0
- package/src/components/App/App.js +286 -0
- package/src/components/App/Header.js +266 -0
- package/src/components/App/NotFoundPage.js +23 -0
- package/src/components/Collection/Collection.js +210 -0
- package/src/components/Collection/CollectionControls.js +58 -0
- package/src/components/Collection/CollectionSearch.js +243 -0
- package/src/components/Collection/CollectionTop.js +81 -0
- package/src/components/Collection/ControlButton.js +27 -0
- package/src/components/Collection/Entries/Entries.js +82 -0
- package/src/components/Collection/Entries/EntriesCollection.js +277 -0
- package/src/components/Collection/Entries/EntriesSearch.js +102 -0
- package/src/components/Collection/Entries/EntryCard.js +246 -0
- package/src/components/Collection/Entries/EntryListing.js +151 -0
- package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +163 -0
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +46 -0
- package/src/components/Collection/FilterControl.js +39 -0
- package/src/components/Collection/GroupControl.js +39 -0
- package/src/components/Collection/NestedCollection.js +330 -0
- package/src/components/Collection/Sidebar.js +136 -0
- package/src/components/Collection/SortControl.js +68 -0
- package/src/components/Collection/ViewStyleControl.js +50 -0
- package/src/components/Collection/__tests__/Collection.spec.js +75 -0
- package/src/components/Collection/__tests__/NestedCollection.spec.js +445 -0
- package/src/components/Collection/__tests__/Sidebar.spec.js +87 -0
- package/src/components/Collection/__tests__/__snapshots__/Collection.spec.js.snap +144 -0
- package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +550 -0
- package/src/components/Collection/__tests__/__snapshots__/Sidebar.spec.js.snap +312 -0
- package/src/components/Editor/Editor.js +497 -0
- package/src/components/Editor/EditorControlPane/EditorControl.js +452 -0
- package/src/components/Editor/EditorControlPane/EditorControlPane.js +269 -0
- package/src/components/Editor/EditorControlPane/Widget.js +384 -0
- package/src/components/Editor/EditorInterface.js +444 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreview.js +40 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +74 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +333 -0
- package/src/components/Editor/EditorPreviewPane/PreviewHOC.js +33 -0
- package/src/components/Editor/EditorToolbar.js +691 -0
- package/src/components/Editor/__tests__/Editor.spec.js +221 -0
- package/src/components/Editor/__tests__/EditorToolbar.spec.js +120 -0
- package/src/components/Editor/__tests__/__snapshots__/Editor.spec.js.snap +45 -0
- package/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap +4233 -0
- package/src/components/Editor/withWorkflow.js +61 -0
- package/src/components/EditorWidgets/Unknown/UnknownControl.js +17 -0
- package/src/components/EditorWidgets/Unknown/UnknownPreview.js +19 -0
- package/src/components/EditorWidgets/index.js +5 -0
- package/src/components/MediaLibrary/EmptyMessage.js +28 -0
- package/src/components/MediaLibrary/MediaLibrary.js +411 -0
- package/src/components/MediaLibrary/MediaLibraryButtons.js +136 -0
- package/src/components/MediaLibrary/MediaLibraryCard.js +128 -0
- package/src/components/MediaLibrary/MediaLibraryCardGrid.js +199 -0
- package/src/components/MediaLibrary/MediaLibraryHeader.js +48 -0
- package/src/components/MediaLibrary/MediaLibraryModal.js +200 -0
- package/src/components/MediaLibrary/MediaLibrarySearch.js +61 -0
- package/src/components/MediaLibrary/MediaLibraryTop.js +143 -0
- package/src/components/MediaLibrary/__tests__/MediaLibraryButtons.spec.js +45 -0
- package/src/components/MediaLibrary/__tests__/MediaLibraryCard.spec.js +49 -0
- package/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap +264 -0
- package/src/components/UI/DragDrop.js +66 -0
- package/src/components/UI/ErrorBoundary.js +214 -0
- package/src/components/UI/FileUploadButton.js +24 -0
- package/src/components/UI/Modal.js +112 -0
- package/src/components/UI/Notifications.tsx +83 -0
- package/src/components/UI/SettingsDropdown.js +103 -0
- package/src/components/UI/__tests__/ErrorBoundary.spec.js +57 -0
- package/src/components/UI/index.js +6 -0
- package/src/components/Workflow/Workflow.js +169 -0
- package/src/components/Workflow/WorkflowCard.js +177 -0
- package/src/components/Workflow/WorkflowList.js +272 -0
- package/src/constants/__tests__/configSchema.spec.js +611 -0
- package/src/constants/collectionTypes.ts +2 -0
- package/src/constants/collectionViews.js +2 -0
- package/src/constants/commitProps.ts +2 -0
- package/src/constants/configSchema.js +441 -0
- package/src/constants/fieldInference.tsx +78 -0
- package/src/constants/publishModes.ts +22 -0
- package/src/constants/validationErrorTypes.js +6 -0
- package/src/formats/__tests__/formats.spec.js +87 -0
- package/src/formats/__tests__/frontmatter.spec.js +429 -0
- package/src/formats/__tests__/toml.spec.js +9 -0
- package/src/formats/__tests__/yaml.spec.js +162 -0
- package/src/formats/formats.ts +97 -0
- package/src/formats/frontmatter.ts +150 -0
- package/src/formats/helpers.ts +14 -0
- package/src/formats/json.ts +9 -0
- package/src/formats/toml.ts +33 -0
- package/src/formats/yaml.ts +58 -0
- package/src/index.js +8 -0
- package/src/integrations/index.js +35 -0
- package/src/integrations/providers/algolia/implementation.js +176 -0
- package/src/integrations/providers/assetStore/implementation.js +148 -0
- package/src/lib/__tests__/formatters.spec.js +751 -0
- package/src/lib/__tests__/i18n.spec.js +792 -0
- package/src/lib/__tests__/phrases.spec.js +119 -0
- package/src/lib/__tests__/registry.spec.js +261 -0
- package/src/lib/__tests__/serializeEntryValues.spec.js +22 -0
- package/src/lib/__tests__/urlHelper.spec.js +138 -0
- package/src/lib/consoleError.js +7 -0
- package/src/lib/formatters.ts +286 -0
- package/src/lib/i18n.ts +454 -0
- package/src/lib/phrases.js +8 -0
- package/src/lib/polyfill.js +9 -0
- package/src/lib/registry.js +312 -0
- package/src/lib/serializeEntryValues.js +75 -0
- package/src/lib/stega.ts +145 -0
- package/src/lib/textHelper.js +11 -0
- package/src/lib/urlHelper.ts +128 -0
- package/src/mediaLibrary.ts +51 -0
- package/src/reducers/__tests__/auth.spec.ts +38 -0
- package/src/reducers/__tests__/collections.spec.js +610 -0
- package/src/reducers/__tests__/config.spec.js +38 -0
- package/src/reducers/__tests__/entries.spec.js +694 -0
- package/src/reducers/__tests__/entryDraft.spec.js +297 -0
- package/src/reducers/__tests__/globalUI.js +43 -0
- package/src/reducers/__tests__/integrations.spec.ts +76 -0
- package/src/reducers/__tests__/mediaLibrary.spec.js +154 -0
- package/src/reducers/__tests__/medias.spec.ts +49 -0
- package/src/reducers/auth.ts +46 -0
- package/src/reducers/collections.ts +535 -0
- package/src/reducers/combinedReducer.ts +11 -0
- package/src/reducers/config.ts +38 -0
- package/src/reducers/cursors.js +36 -0
- package/src/reducers/deploys.ts +52 -0
- package/src/reducers/editorialWorkflow.ts +163 -0
- package/src/reducers/entries.ts +819 -0
- package/src/reducers/entryDraft.js +260 -0
- package/src/reducers/globalUI.ts +45 -0
- package/src/reducers/index.ts +82 -0
- package/src/reducers/integrations.ts +59 -0
- package/src/reducers/mediaLibrary.ts +296 -0
- package/src/reducers/medias.ts +66 -0
- package/src/reducers/notifications.ts +52 -0
- package/src/reducers/search.ts +111 -0
- package/src/reducers/status.ts +40 -0
- package/src/redux/index.ts +18 -0
- package/src/redux/middleware/waitUntilAction.ts +64 -0
- package/src/routing/__tests__/history.spec.ts +49 -0
- package/src/routing/history.ts +17 -0
- package/src/types/diacritics.d.ts +1 -0
- package/src/types/global.d.ts +8 -0
- package/src/types/immutable.ts +49 -0
- package/src/types/redux.ts +827 -0
- package/src/types/tomlify-j0.4.d.ts +13 -0
- package/src/valueObjects/AssetProxy.ts +48 -0
- package/src/valueObjects/EditorComponent.js +38 -0
- package/src/valueObjects/Entry.ts +63 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { connect } from 'react-redux';
|
|
6
|
+
import { translate } from 'react-polyglot';
|
|
7
|
+
import { lengths, components } from 'decap-cms-ui-default';
|
|
8
|
+
|
|
9
|
+
import { getNewEntryUrl } from '../../lib/urlHelper';
|
|
10
|
+
import Sidebar from './Sidebar';
|
|
11
|
+
import CollectionTop from './CollectionTop';
|
|
12
|
+
import EntriesCollection from './Entries/EntriesCollection';
|
|
13
|
+
import EntriesSearch from './Entries/EntriesSearch';
|
|
14
|
+
import CollectionControls from './CollectionControls';
|
|
15
|
+
import { sortByField, filterByField, changeViewStyle, groupByField } from '../../actions/entries';
|
|
16
|
+
import {
|
|
17
|
+
selectSortableFields,
|
|
18
|
+
selectViewFilters,
|
|
19
|
+
selectViewGroups,
|
|
20
|
+
} from '../../reducers/collections';
|
|
21
|
+
import {
|
|
22
|
+
selectEntriesSort,
|
|
23
|
+
selectEntriesFilter,
|
|
24
|
+
selectEntriesGroup,
|
|
25
|
+
selectViewStyle,
|
|
26
|
+
} from '../../reducers/entries';
|
|
27
|
+
|
|
28
|
+
const CollectionContainer = styled.div`
|
|
29
|
+
margin: ${lengths.pageMargin};
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const CollectionMain = styled.main`
|
|
33
|
+
padding-left: 280px;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const SearchResultContainer = styled.div`
|
|
37
|
+
${components.cardTop};
|
|
38
|
+
margin-bottom: 22px;
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const SearchResultHeading = styled.h1`
|
|
42
|
+
${components.cardTopHeading};
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export class Collection extends React.Component {
|
|
46
|
+
static propTypes = {
|
|
47
|
+
searchTerm: PropTypes.string,
|
|
48
|
+
collectionName: PropTypes.string,
|
|
49
|
+
isSearchResults: PropTypes.bool,
|
|
50
|
+
isSingleSearchResult: PropTypes.bool,
|
|
51
|
+
collection: ImmutablePropTypes.map.isRequired,
|
|
52
|
+
collections: ImmutablePropTypes.map.isRequired,
|
|
53
|
+
sortableFields: PropTypes.array,
|
|
54
|
+
sort: ImmutablePropTypes.orderedMap,
|
|
55
|
+
onSortClick: PropTypes.func.isRequired,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
componentDidMount() {
|
|
59
|
+
// Manually validate PropTypes - React 19 breaking change
|
|
60
|
+
PropTypes.checkPropTypes(Collection.propTypes, this.props, 'prop', 'Collection');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
renderEntriesCollection = () => {
|
|
64
|
+
const { collection, filterTerm, viewStyle } = this.props;
|
|
65
|
+
return (
|
|
66
|
+
<EntriesCollection collection={collection} viewStyle={viewStyle} filterTerm={filterTerm} />
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
renderEntriesSearch = () => {
|
|
71
|
+
const { searchTerm, collections, collection, isSingleSearchResult } = this.props;
|
|
72
|
+
return (
|
|
73
|
+
<EntriesSearch
|
|
74
|
+
collections={isSingleSearchResult ? collections.filter(c => c === collection) : collections}
|
|
75
|
+
searchTerm={searchTerm}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
render() {
|
|
81
|
+
const {
|
|
82
|
+
collection,
|
|
83
|
+
collections,
|
|
84
|
+
collectionName,
|
|
85
|
+
isSearchEnabled,
|
|
86
|
+
isSearchResults,
|
|
87
|
+
isSingleSearchResult,
|
|
88
|
+
searchTerm,
|
|
89
|
+
sortableFields,
|
|
90
|
+
onSortClick,
|
|
91
|
+
sort,
|
|
92
|
+
viewFilters,
|
|
93
|
+
viewGroups,
|
|
94
|
+
filterTerm,
|
|
95
|
+
t,
|
|
96
|
+
onFilterClick,
|
|
97
|
+
onGroupClick,
|
|
98
|
+
filter,
|
|
99
|
+
group,
|
|
100
|
+
onChangeViewStyle,
|
|
101
|
+
viewStyle,
|
|
102
|
+
} = this.props;
|
|
103
|
+
|
|
104
|
+
let newEntryUrl = collection.get('create') ? getNewEntryUrl(collectionName) : '';
|
|
105
|
+
if (newEntryUrl && filterTerm) {
|
|
106
|
+
newEntryUrl = getNewEntryUrl(collectionName);
|
|
107
|
+
if (filterTerm) {
|
|
108
|
+
newEntryUrl = `${newEntryUrl}?path=${filterTerm}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const searchResultKey =
|
|
113
|
+
'collection.collectionTop.searchResults' + (isSingleSearchResult ? 'InCollection' : '');
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<CollectionContainer>
|
|
117
|
+
<Sidebar
|
|
118
|
+
collections={collections}
|
|
119
|
+
collection={(!isSearchResults || isSingleSearchResult) && collection}
|
|
120
|
+
isSearchEnabled={isSearchEnabled}
|
|
121
|
+
searchTerm={searchTerm}
|
|
122
|
+
filterTerm={filterTerm}
|
|
123
|
+
/>
|
|
124
|
+
<CollectionMain>
|
|
125
|
+
{isSearchResults ? (
|
|
126
|
+
<SearchResultContainer>
|
|
127
|
+
<SearchResultHeading>
|
|
128
|
+
{t(searchResultKey, { searchTerm, collection: collection.get('label') })}
|
|
129
|
+
</SearchResultHeading>
|
|
130
|
+
</SearchResultContainer>
|
|
131
|
+
) : (
|
|
132
|
+
<>
|
|
133
|
+
<CollectionTop collection={collection} newEntryUrl={newEntryUrl} />
|
|
134
|
+
<CollectionControls
|
|
135
|
+
viewStyle={viewStyle}
|
|
136
|
+
onChangeViewStyle={onChangeViewStyle}
|
|
137
|
+
sortableFields={sortableFields}
|
|
138
|
+
onSortClick={onSortClick}
|
|
139
|
+
sort={sort}
|
|
140
|
+
viewFilters={viewFilters}
|
|
141
|
+
viewGroups={viewGroups}
|
|
142
|
+
t={t}
|
|
143
|
+
onFilterClick={onFilterClick}
|
|
144
|
+
onGroupClick={onGroupClick}
|
|
145
|
+
filter={filter}
|
|
146
|
+
group={group}
|
|
147
|
+
/>
|
|
148
|
+
</>
|
|
149
|
+
)}
|
|
150
|
+
{isSearchResults ? this.renderEntriesSearch() : this.renderEntriesCollection()}
|
|
151
|
+
</CollectionMain>
|
|
152
|
+
</CollectionContainer>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function mapStateToProps(state, ownProps) {
|
|
158
|
+
const { collections } = state;
|
|
159
|
+
const isSearchEnabled = state.config && state.config.search != false;
|
|
160
|
+
const { isSearchResults, match, t } = ownProps;
|
|
161
|
+
const { name, searchTerm = '', filterTerm = '' } = match.params;
|
|
162
|
+
const collection = name ? collections.get(name) : collections.first();
|
|
163
|
+
const sort = selectEntriesSort(state.entries, collection.get('name'));
|
|
164
|
+
const sortableFields = selectSortableFields(collection, t);
|
|
165
|
+
const viewFilters = selectViewFilters(collection);
|
|
166
|
+
const viewGroups = selectViewGroups(collection);
|
|
167
|
+
const filter = selectEntriesFilter(state.entries, collection.get('name'));
|
|
168
|
+
const group = selectEntriesGroup(state.entries, collection.get('name'));
|
|
169
|
+
const viewStyle = selectViewStyle(state.entries);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
collection,
|
|
173
|
+
collections,
|
|
174
|
+
collectionName: name,
|
|
175
|
+
isSearchEnabled,
|
|
176
|
+
isSearchResults,
|
|
177
|
+
searchTerm,
|
|
178
|
+
filterTerm,
|
|
179
|
+
sort,
|
|
180
|
+
sortableFields,
|
|
181
|
+
viewFilters,
|
|
182
|
+
viewGroups,
|
|
183
|
+
filter,
|
|
184
|
+
group,
|
|
185
|
+
viewStyle,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const mapDispatchToProps = {
|
|
190
|
+
sortByField,
|
|
191
|
+
filterByField,
|
|
192
|
+
changeViewStyle,
|
|
193
|
+
groupByField,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
function mergeProps(stateProps, dispatchProps, ownProps) {
|
|
197
|
+
return {
|
|
198
|
+
...stateProps,
|
|
199
|
+
...ownProps,
|
|
200
|
+
onSortClick: (key, direction) =>
|
|
201
|
+
dispatchProps.sortByField(stateProps.collection, key, direction),
|
|
202
|
+
onFilterClick: filter => dispatchProps.filterByField(stateProps.collection, filter),
|
|
203
|
+
onGroupClick: group => dispatchProps.groupByField(stateProps.collection, group),
|
|
204
|
+
onChangeViewStyle: viewStyle => dispatchProps.changeViewStyle(viewStyle),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const ConnectedCollection = connect(mapStateToProps, mapDispatchToProps, mergeProps)(Collection);
|
|
209
|
+
|
|
210
|
+
export default translate()(ConnectedCollection);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { lengths } from 'decap-cms-ui-default';
|
|
4
|
+
|
|
5
|
+
import ViewStyleControl from './ViewStyleControl';
|
|
6
|
+
import SortControl from './SortControl';
|
|
7
|
+
import FilterControl from './FilterControl';
|
|
8
|
+
import GroupControl from './GroupControl';
|
|
9
|
+
|
|
10
|
+
const CollectionControlsContainer = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
flex-direction: row-reverse;
|
|
14
|
+
margin-top: 22px;
|
|
15
|
+
width: ${lengths.topCardWidth};
|
|
16
|
+
max-width: 100%;
|
|
17
|
+
|
|
18
|
+
& > div {
|
|
19
|
+
margin-left: 6px;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
function CollectionControls({
|
|
24
|
+
viewStyle,
|
|
25
|
+
onChangeViewStyle,
|
|
26
|
+
sortableFields,
|
|
27
|
+
onSortClick,
|
|
28
|
+
sort,
|
|
29
|
+
viewFilters,
|
|
30
|
+
viewGroups,
|
|
31
|
+
onFilterClick,
|
|
32
|
+
onGroupClick,
|
|
33
|
+
t,
|
|
34
|
+
filter,
|
|
35
|
+
group,
|
|
36
|
+
}) {
|
|
37
|
+
return (
|
|
38
|
+
<CollectionControlsContainer>
|
|
39
|
+
<ViewStyleControl viewStyle={viewStyle} onChangeViewStyle={onChangeViewStyle} />
|
|
40
|
+
{viewGroups.length > 0 && (
|
|
41
|
+
<GroupControl viewGroups={viewGroups} onGroupClick={onGroupClick} t={t} group={group} />
|
|
42
|
+
)}
|
|
43
|
+
{viewFilters.length > 0 && (
|
|
44
|
+
<FilterControl
|
|
45
|
+
viewFilters={viewFilters}
|
|
46
|
+
onFilterClick={onFilterClick}
|
|
47
|
+
t={t}
|
|
48
|
+
filter={filter}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
{sortableFields.length > 0 && (
|
|
52
|
+
<SortControl fields={sortableFields} sort={sort} onSortClick={onSortClick} />
|
|
53
|
+
)}
|
|
54
|
+
</CollectionControlsContainer>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default CollectionControls;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { colorsRaw, colors, Icon, lengths, zIndex } from 'decap-cms-ui-default';
|
|
4
|
+
import { translate } from 'react-polyglot';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
7
|
+
|
|
8
|
+
const SearchContainer = styled.div`
|
|
9
|
+
margin: 0 12px;
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
${Icon} {
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 6px;
|
|
16
|
+
z-index: ${zIndex.zIndex2};
|
|
17
|
+
height: 100%;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const InputContainer = styled.div`
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
position: relative;
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const SearchInput = styled.input`
|
|
31
|
+
background-color: #eff0f4;
|
|
32
|
+
border-radius: ${lengths.borderRadius};
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
padding: 10px 6px 10px 34px;
|
|
35
|
+
width: 100%;
|
|
36
|
+
position: relative;
|
|
37
|
+
z-index: ${zIndex.zIndex1};
|
|
38
|
+
|
|
39
|
+
&:focus {
|
|
40
|
+
outline: none;
|
|
41
|
+
box-shadow: inset 0 0 0 2px ${colorsRaw.blue};
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const SuggestionsContainer = styled.div`
|
|
46
|
+
position: relative;
|
|
47
|
+
width: 100%;
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const Suggestions = styled.ul`
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 6px;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
padding: 10px 0;
|
|
56
|
+
margin: 0;
|
|
57
|
+
list-style: none;
|
|
58
|
+
background-color: #fff;
|
|
59
|
+
border-radius: ${lengths.borderRadius};
|
|
60
|
+
border: 1px solid ${colors.textFieldBorder};
|
|
61
|
+
z-index: ${zIndex.zIndex1};
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const SuggestionHeader = styled.li`
|
|
65
|
+
padding: 0 6px 6px 34px;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
color: ${colors.text};
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
const SuggestionItem = styled.li(
|
|
71
|
+
({ isActive }) => `
|
|
72
|
+
color: ${isActive ? colors.active : colorsRaw.grayDark};
|
|
73
|
+
background-color: ${isActive ? colors.activeBackground : 'inherit'};
|
|
74
|
+
padding: 6px 6px 6px 34px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
position: relative;
|
|
77
|
+
|
|
78
|
+
&:hover {
|
|
79
|
+
color: ${colors.active};
|
|
80
|
+
background-color: ${colors.activeBackground};
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const SuggestionDivider = styled.div`
|
|
86
|
+
width: 100%;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
class CollectionSearch extends React.Component {
|
|
90
|
+
static propTypes = {
|
|
91
|
+
collections: ImmutablePropTypes.map.isRequired,
|
|
92
|
+
collection: ImmutablePropTypes.map,
|
|
93
|
+
searchTerm: PropTypes.string.isRequired,
|
|
94
|
+
onSubmit: PropTypes.func.isRequired,
|
|
95
|
+
t: PropTypes.func.isRequired,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
state = {
|
|
99
|
+
query: this.props.searchTerm,
|
|
100
|
+
suggestionsVisible: false,
|
|
101
|
+
// default to the currently selected
|
|
102
|
+
selectedCollectionIdx: this.getSelectedSelectionBasedOnProps(),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
componentDidMount() {
|
|
106
|
+
// Manually validate PropTypes - React 19 breaking change
|
|
107
|
+
PropTypes.checkPropTypes(CollectionSearch.propTypes, this.props, 'prop', 'CollectionSearch');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
componentDidUpdate(prevProps) {
|
|
111
|
+
if (prevProps.collection !== this.props.collection) {
|
|
112
|
+
const selectedCollectionIdx = this.getSelectedSelectionBasedOnProps();
|
|
113
|
+
this.setState({ selectedCollectionIdx });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getSelectedSelectionBasedOnProps() {
|
|
118
|
+
const { collection, collections } = this.props;
|
|
119
|
+
return collection ? collections.keySeq().indexOf(collection.get('name')) : -1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
toggleSuggestions(visible) {
|
|
123
|
+
this.setState({ suggestionsVisible: visible });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
selectNextSuggestion() {
|
|
127
|
+
const { collections } = this.props;
|
|
128
|
+
const { selectedCollectionIdx } = this.state;
|
|
129
|
+
this.setState({
|
|
130
|
+
selectedCollectionIdx: Math.min(selectedCollectionIdx + 1, collections.size - 1),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
selectPreviousSuggestion() {
|
|
135
|
+
const { selectedCollectionIdx } = this.state;
|
|
136
|
+
this.setState({
|
|
137
|
+
selectedCollectionIdx: Math.max(selectedCollectionIdx - 1, -1),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
resetSelectedSuggestion() {
|
|
142
|
+
this.setState({
|
|
143
|
+
selectedCollectionIdx: -1,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
submitSearch = () => {
|
|
148
|
+
const { onSubmit, collections } = this.props;
|
|
149
|
+
const { selectedCollectionIdx, query } = this.state;
|
|
150
|
+
|
|
151
|
+
this.toggleSuggestions(false);
|
|
152
|
+
if (selectedCollectionIdx !== -1) {
|
|
153
|
+
onSubmit(query, collections.toIndexedSeq().getIn([selectedCollectionIdx, 'name']));
|
|
154
|
+
} else {
|
|
155
|
+
onSubmit(query);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
handleKeyDown = event => {
|
|
160
|
+
const { suggestionsVisible } = this.state;
|
|
161
|
+
|
|
162
|
+
if (event.key === 'Enter') {
|
|
163
|
+
this.submitSearch();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (suggestionsVisible) {
|
|
167
|
+
// allow closing of suggestions with escape key
|
|
168
|
+
if (event.key === 'Escape') {
|
|
169
|
+
this.toggleSuggestions(false);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (event.key === 'ArrowDown') {
|
|
173
|
+
this.selectNextSuggestion();
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
} else if (event.key === 'ArrowUp') {
|
|
176
|
+
this.selectPreviousSuggestion();
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
handleQueryChange = query => {
|
|
183
|
+
this.setState({ query });
|
|
184
|
+
this.toggleSuggestions(query !== '');
|
|
185
|
+
if (query === '') {
|
|
186
|
+
this.resetSelectedSuggestion();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
handleSuggestionClick = (event, idx) => {
|
|
191
|
+
this.setState({ selectedCollectionIdx: idx }, this.submitSearch);
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
render() {
|
|
196
|
+
const { collections, t } = this.props;
|
|
197
|
+
const { suggestionsVisible, selectedCollectionIdx, query } = this.state;
|
|
198
|
+
return (
|
|
199
|
+
<SearchContainer
|
|
200
|
+
onBlur={() => this.toggleSuggestions(false)}
|
|
201
|
+
onFocus={() => this.toggleSuggestions(query !== '')}
|
|
202
|
+
>
|
|
203
|
+
<InputContainer>
|
|
204
|
+
<Icon type="search" />
|
|
205
|
+
<SearchInput
|
|
206
|
+
onChange={e => this.handleQueryChange(e.target.value)}
|
|
207
|
+
onKeyDown={this.handleKeyDown}
|
|
208
|
+
onClick={() => this.toggleSuggestions(true)}
|
|
209
|
+
placeholder={t('collection.sidebar.searchAll')}
|
|
210
|
+
value={query}
|
|
211
|
+
/>
|
|
212
|
+
</InputContainer>
|
|
213
|
+
{suggestionsVisible && (
|
|
214
|
+
<SuggestionsContainer>
|
|
215
|
+
<Suggestions>
|
|
216
|
+
<SuggestionHeader>{t('collection.sidebar.searchIn')}</SuggestionHeader>
|
|
217
|
+
<SuggestionItem
|
|
218
|
+
isActive={selectedCollectionIdx === -1}
|
|
219
|
+
onClick={e => this.handleSuggestionClick(e, -1)}
|
|
220
|
+
onMouseDown={e => e.preventDefault()}
|
|
221
|
+
>
|
|
222
|
+
{t('collection.sidebar.allCollections')}
|
|
223
|
+
</SuggestionItem>
|
|
224
|
+
<SuggestionDivider />
|
|
225
|
+
{collections.toIndexedSeq().map((collection, idx) => (
|
|
226
|
+
<SuggestionItem
|
|
227
|
+
key={idx}
|
|
228
|
+
isActive={idx === selectedCollectionIdx}
|
|
229
|
+
onClick={e => this.handleSuggestionClick(e, idx)}
|
|
230
|
+
onMouseDown={e => e.preventDefault()}
|
|
231
|
+
>
|
|
232
|
+
{collection.get('label')}
|
|
233
|
+
</SuggestionItem>
|
|
234
|
+
))}
|
|
235
|
+
</Suggestions>
|
|
236
|
+
</SuggestionsContainer>
|
|
237
|
+
)}
|
|
238
|
+
</SearchContainer>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export default translate()(CollectionSearch);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { translate } from 'react-polyglot';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
7
|
+
import { components, buttons, shadows } from 'decap-cms-ui-default';
|
|
8
|
+
|
|
9
|
+
const CollectionTopContainer = styled.div`
|
|
10
|
+
${components.cardTop};
|
|
11
|
+
margin-bottom: 22px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const CollectionTopRow = styled.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const CollectionTopHeading = styled.h1`
|
|
21
|
+
${components.cardTopHeading};
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const CollectionTopNewButton = styled(Link)`
|
|
25
|
+
${buttons.button};
|
|
26
|
+
${shadows.dropDeep};
|
|
27
|
+
${buttons.default};
|
|
28
|
+
${buttons.gray};
|
|
29
|
+
|
|
30
|
+
padding: 0 30px;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const CollectionTopDescription = styled.p`
|
|
34
|
+
${components.cardTopDescription};
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
function getCollectionProps(collection) {
|
|
39
|
+
const collectionLabel = collection.get('label');
|
|
40
|
+
const collectionLabelSingular = collection.get('label_singular');
|
|
41
|
+
const collectionDescription = collection.get('description');
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
collectionLabel,
|
|
45
|
+
collectionLabelSingular,
|
|
46
|
+
collectionDescription,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CollectionTop({ collection, newEntryUrl, t }) {
|
|
51
|
+
const { collectionLabel, collectionLabelSingular, collectionDescription } = getCollectionProps(
|
|
52
|
+
collection,
|
|
53
|
+
t,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<CollectionTopContainer>
|
|
58
|
+
<CollectionTopRow>
|
|
59
|
+
<CollectionTopHeading>{collectionLabel}</CollectionTopHeading>
|
|
60
|
+
{newEntryUrl ? (
|
|
61
|
+
<CollectionTopNewButton to={newEntryUrl}>
|
|
62
|
+
{t('collection.collectionTop.newButton', {
|
|
63
|
+
collectionLabel: collectionLabelSingular || collectionLabel,
|
|
64
|
+
})}
|
|
65
|
+
</CollectionTopNewButton>
|
|
66
|
+
) : null}
|
|
67
|
+
</CollectionTopRow>
|
|
68
|
+
{collectionDescription ? (
|
|
69
|
+
<CollectionTopDescription>{collectionDescription}</CollectionTopDescription>
|
|
70
|
+
) : null}
|
|
71
|
+
</CollectionTopContainer>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
CollectionTop.propTypes = {
|
|
76
|
+
collection: ImmutablePropTypes.map.isRequired,
|
|
77
|
+
newEntryUrl: PropTypes.string,
|
|
78
|
+
t: PropTypes.func.isRequired,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default translate()(CollectionTop);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { buttons, StyledDropdownButton, colors } from 'decap-cms-ui-default';
|
|
5
|
+
|
|
6
|
+
const Button = styled(StyledDropdownButton)`
|
|
7
|
+
${buttons.button};
|
|
8
|
+
${buttons.medium};
|
|
9
|
+
${buttons.grayText};
|
|
10
|
+
font-size: 14px;
|
|
11
|
+
|
|
12
|
+
&:after {
|
|
13
|
+
top: 11px;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export function ControlButton({ active, title }) {
|
|
18
|
+
return (
|
|
19
|
+
<Button
|
|
20
|
+
css={css`
|
|
21
|
+
color: ${active ? colors.active : undefined};
|
|
22
|
+
`}
|
|
23
|
+
>
|
|
24
|
+
{title}
|
|
25
|
+
</Button>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
5
|
+
import { translate } from 'react-polyglot';
|
|
6
|
+
import { Loader, lengths } from 'decap-cms-ui-default';
|
|
7
|
+
|
|
8
|
+
import EntryListing from './EntryListing';
|
|
9
|
+
|
|
10
|
+
const PaginationMessage = styled.div`
|
|
11
|
+
width: ${lengths.topCardWidth};
|
|
12
|
+
padding: 16px;
|
|
13
|
+
text-align: center;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const NoEntriesMessage = styled(PaginationMessage)`
|
|
17
|
+
margin-top: 16px;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
function Entries({
|
|
21
|
+
collections,
|
|
22
|
+
entries,
|
|
23
|
+
isFetching,
|
|
24
|
+
viewStyle,
|
|
25
|
+
cursor,
|
|
26
|
+
handleCursorActions,
|
|
27
|
+
t,
|
|
28
|
+
page,
|
|
29
|
+
getWorkflowStatus,
|
|
30
|
+
getUnpublishedEntries,
|
|
31
|
+
filterTerm,
|
|
32
|
+
}) {
|
|
33
|
+
const loadingMessages = [
|
|
34
|
+
t('collection.entries.loadingEntries'),
|
|
35
|
+
t('collection.entries.cachingEntries'),
|
|
36
|
+
t('collection.entries.longerLoading'),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
if (isFetching && page === undefined) {
|
|
40
|
+
return <Loader active>{loadingMessages}</Loader>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const hasEntries = (entries && entries.size > 0) || cursor?.actions?.has('append_next');
|
|
44
|
+
if (hasEntries) {
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<EntryListing
|
|
48
|
+
collections={collections}
|
|
49
|
+
entries={entries}
|
|
50
|
+
viewStyle={viewStyle}
|
|
51
|
+
cursor={cursor}
|
|
52
|
+
handleCursorActions={handleCursorActions}
|
|
53
|
+
page={page}
|
|
54
|
+
getWorkflowStatus={getWorkflowStatus}
|
|
55
|
+
getUnpublishedEntries={getUnpublishedEntries}
|
|
56
|
+
filterTerm={filterTerm}
|
|
57
|
+
/>
|
|
58
|
+
{isFetching && page !== undefined && entries.size > 0 ? (
|
|
59
|
+
<PaginationMessage>{t('collection.entries.loadingEntries')}</PaginationMessage>
|
|
60
|
+
) : null}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <NoEntriesMessage>{t('collection.entries.noEntries')}</NoEntriesMessage>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Entries.propTypes = {
|
|
69
|
+
collections: ImmutablePropTypes.iterable.isRequired,
|
|
70
|
+
entries: ImmutablePropTypes.list,
|
|
71
|
+
page: PropTypes.number,
|
|
72
|
+
isFetching: PropTypes.bool,
|
|
73
|
+
viewStyle: PropTypes.string,
|
|
74
|
+
cursor: PropTypes.any.isRequired,
|
|
75
|
+
handleCursorActions: PropTypes.func.isRequired,
|
|
76
|
+
t: PropTypes.func.isRequired,
|
|
77
|
+
getWorkflowStatus: PropTypes.func,
|
|
78
|
+
getUnpublishedEntries: PropTypes.func,
|
|
79
|
+
filterTerm: PropTypes.string,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default translate()(Entries);
|