decap-cms-core 3.5.0 → 3.6.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/dist/decap-cms-core.js +10 -10
- package/dist/decap-cms-core.js.map +1 -1
- package/dist/esm/actions/auth.js +22 -37
- package/dist/esm/actions/collections.js +9 -17
- package/dist/esm/actions/config.js +58 -74
- package/dist/esm/actions/deploys.js +10 -17
- package/dist/esm/actions/editorialWorkflow.js +87 -101
- package/dist/esm/actions/entries.js +161 -211
- package/dist/esm/actions/media.js +31 -46
- package/dist/esm/actions/mediaLibrary.js +94 -126
- package/dist/esm/actions/notifications.js +5 -13
- package/dist/esm/actions/search.js +30 -47
- package/dist/esm/actions/status.js +13 -23
- package/dist/esm/actions/waitUntil.js +4 -11
- package/dist/esm/backend.js +132 -148
- package/dist/esm/bootstrap.js +37 -44
- package/dist/esm/components/App/App.js +82 -89
- package/dist/esm/components/App/Header.js +46 -52
- package/dist/esm/components/App/NotFoundPage.js +11 -18
- package/dist/esm/components/Collection/Collection.js +55 -63
- package/dist/esm/components/Collection/CollectionControls.js +15 -22
- package/dist/esm/components/Collection/CollectionSearch.js +35 -42
- package/dist/esm/components/Collection/CollectionTop.js +23 -30
- package/dist/esm/components/Collection/ControlButton.js +10 -16
- package/dist/esm/components/Collection/Entries/Entries.js +24 -31
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +60 -63
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +26 -33
- package/dist/esm/components/Collection/Entries/EntryCard.js +38 -45
- package/dist/esm/components/Collection/Entries/EntryListing.js +24 -32
- package/dist/esm/components/Collection/FilterControl.js +9 -16
- package/dist/esm/components/Collection/GroupControl.js +9 -16
- package/dist/esm/components/Collection/NestedCollection.js +56 -64
- package/dist/esm/components/Collection/Sidebar.js +36 -43
- package/dist/esm/components/Collection/SortControl.js +19 -26
- package/dist/esm/components/Collection/ViewStyleControl.js +17 -24
- package/dist/esm/components/Editor/Editor.js +100 -108
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +105 -112
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +68 -62
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +87 -73
- package/dist/esm/components/Editor/EditorInterface.js +95 -98
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +13 -21
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +64 -23
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +94 -78
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +9 -16
- package/dist/esm/components/Editor/EditorToolbar.js +133 -140
- package/dist/esm/components/Editor/withWorkflow.js +15 -22
- package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +9 -16
- package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +9 -16
- package/dist/esm/components/EditorWidgets/index.js +4 -7
- package/dist/esm/components/MediaLibrary/EmptyMessage.js +12 -19
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +55 -62
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +28 -35
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +36 -43
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +50 -57
- package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +16 -23
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +59 -64
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +18 -25
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +39 -46
- package/dist/esm/components/UI/DragDrop.js +21 -30
- package/dist/esm/components/UI/ErrorBoundary.js +35 -43
- package/dist/esm/components/UI/FileUploadButton.js +11 -18
- package/dist/esm/components/UI/Modal.js +19 -26
- package/dist/esm/components/UI/Notifications.js +21 -28
- package/dist/esm/components/UI/SettingsDropdown.js +28 -34
- package/dist/esm/components/UI/index.js +6 -60
- package/dist/esm/components/Workflow/Workflow.js +52 -61
- package/dist/esm/components/Workflow/WorkflowCard.js +45 -51
- package/dist/esm/components/Workflow/WorkflowList.js +43 -49
- package/dist/esm/constants/collectionTypes.js +2 -8
- package/dist/esm/constants/collectionViews.js +2 -8
- package/dist/esm/constants/commitProps.js +2 -8
- package/dist/esm/constants/configSchema.js +23 -27
- package/dist/esm/constants/fieldInference.js +8 -15
- package/dist/esm/constants/publishModes.js +6 -11
- package/dist/esm/constants/validationErrorTypes.js +1 -7
- package/dist/esm/formats/formats.js +32 -41
- package/dist/esm/formats/frontmatter.js +18 -30
- package/dist/esm/formats/helpers.js +1 -7
- package/dist/esm/formats/json.js +1 -7
- package/dist/esm/formats/toml.js +11 -18
- package/dist/esm/formats/yaml.js +7 -14
- package/dist/esm/index.js +5 -12
- package/dist/esm/integrations/index.js +8 -16
- package/dist/esm/integrations/providers/algolia/implementation.js +14 -22
- package/dist/esm/integrations/providers/assetStore/implementation.js +10 -18
- package/dist/esm/lib/consoleError.js +1 -7
- package/dist/esm/lib/formatters.js +34 -47
- package/dist/esm/lib/i18n.js +37 -66
- package/dist/esm/lib/phrases.js +4 -11
- package/dist/esm/lib/registry.js +40 -75
- package/dist/esm/lib/serializeEntryValues.js +11 -18
- package/dist/esm/lib/textHelper.js +1 -7
- package/dist/esm/lib/urlHelper.js +28 -43
- package/dist/esm/mediaLibrary.js +12 -16
- package/dist/esm/reducers/auth.js +10 -16
- package/dist/esm/reducers/collections.js +70 -102
- package/dist/esm/reducers/combinedReducer.js +4 -11
- package/dist/esm/reducers/config.js +11 -19
- package/dist/esm/reducers/cursors.js +12 -18
- package/dist/esm/reducers/deploys.js +8 -15
- package/dist/esm/reducers/editorialWorkflow.js +37 -47
- package/dist/esm/reducers/entries.js +107 -132
- package/dist/esm/reducers/entryDraft.js +64 -72
- package/dist/esm/reducers/globalUI.js +5 -11
- package/dist/esm/reducers/index.js +43 -64
- package/dist/esm/reducers/integrations.js +8 -16
- package/dist/esm/reducers/mediaLibrary.js +43 -52
- package/dist/esm/reducers/medias.js +11 -18
- package/dist/esm/reducers/notifications.js +9 -15
- package/dist/esm/reducers/search.js +12 -18
- package/dist/esm/reducers/status.js +7 -13
- package/dist/esm/redux/index.js +7 -13
- package/dist/esm/redux/middleware/waitUntilAction.js +3 -10
- package/dist/esm/routing/history.js +7 -15
- package/dist/esm/types/diacritics.d.js +0 -1
- package/dist/esm/types/global.d.js +1 -5
- package/dist/esm/types/immutable.js +1 -5
- package/dist/esm/types/redux.js +7 -8
- package/dist/esm/types/tomlify-j0.4.d.js +0 -1
- package/dist/esm/valueObjects/AssetProxy.js +2 -10
- package/dist/esm/valueObjects/EditorComponent.js +5 -12
- package/dist/esm/valueObjects/Entry.js +3 -10
- package/index.d.ts +1 -0
- package/package.json +3 -2
- package/src/components/Collection/Entries/EntriesCollection.js +21 -10
- package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +7 -7
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +9 -9
- package/src/components/Collection/NestedCollection.js +11 -2
- package/src/components/Collection/__tests__/NestedCollection.spec.js +3 -0
- package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +68 -0
- package/src/components/Editor/EditorControlPane/EditorControl.js +0 -3
- package/src/components/Editor/EditorControlPane/EditorControlPane.js +21 -8
- package/src/components/Editor/EditorControlPane/Widget.js +22 -1
- package/src/components/Editor/EditorInterface.js +6 -1
- package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +51 -11
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +33 -1
- package/src/constants/configSchema.js +1 -0
- package/src/types/redux.ts +1 -1
- package/dist/esm/actions/editorControl.js +0 -14
- package/dist/esm/reducers/editorComponent.js +0 -1
- package/dist/esm/reducers/editorControl.js +0 -17
|
@@ -1,122 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SORT_ENTRIES_SUCCESS = exports.SORT_ENTRIES_REQUEST = exports.SORT_ENTRIES_FAILURE = exports.REMOVE_DRAFT_ENTRY_MEDIA_FILE = exports.GROUP_ENTRIES_SUCCESS = exports.GROUP_ENTRIES_REQUEST = exports.GROUP_ENTRIES_FAILURE = exports.FILTER_ENTRIES_SUCCESS = exports.FILTER_ENTRIES_REQUEST = exports.FILTER_ENTRIES_FAILURE = exports.ENTRY_SUCCESS = exports.ENTRY_REQUEST = exports.ENTRY_PERSIST_SUCCESS = exports.ENTRY_PERSIST_REQUEST = exports.ENTRY_PERSIST_FAILURE = exports.ENTRY_FAILURE = exports.ENTRY_DELETE_SUCCESS = exports.ENTRY_DELETE_REQUEST = exports.ENTRY_DELETE_FAILURE = exports.ENTRIES_SUCCESS = exports.ENTRIES_REQUEST = exports.ENTRIES_FAILURE = exports.DRAFT_VALIDATION_ERRORS = exports.DRAFT_LOCAL_BACKUP_RETRIEVED = exports.DRAFT_DISCARD = exports.DRAFT_CREATE_FROM_LOCAL_BACKUP = exports.DRAFT_CREATE_FROM_ENTRY = exports.DRAFT_CREATE_EMPTY = exports.DRAFT_CREATE_DUPLICATE_FROM_ENTRY = exports.DRAFT_CLEAR_ERRORS = exports.DRAFT_CHANGE_FIELD = exports.CHANGE_VIEW_STYLE = exports.ADD_DRAFT_ENTRY_MEDIA_FILE = void 0;
|
|
7
|
-
exports.addDraftEntryMediaFile = addDraftEntryMediaFile;
|
|
8
|
-
exports.changeDraftField = changeDraftField;
|
|
9
|
-
exports.changeDraftFieldValidation = changeDraftFieldValidation;
|
|
10
|
-
exports.changeViewStyle = changeViewStyle;
|
|
11
|
-
exports.clearFieldErrors = clearFieldErrors;
|
|
12
|
-
exports.createDraftDuplicateFromEntry = createDraftDuplicateFromEntry;
|
|
13
|
-
exports.createDraftFromEntry = createDraftFromEntry;
|
|
14
|
-
exports.createEmptyDraft = createEmptyDraft;
|
|
15
|
-
exports.createEmptyDraftData = createEmptyDraftData;
|
|
16
|
-
exports.deleteEntry = deleteEntry;
|
|
17
|
-
exports.deleteLocalBackup = deleteLocalBackup;
|
|
18
|
-
exports.discardDraft = discardDraft;
|
|
19
|
-
exports.draftDuplicateEntry = draftDuplicateEntry;
|
|
20
|
-
exports.emptyDraftCreated = emptyDraftCreated;
|
|
21
|
-
exports.entriesFailed = entriesFailed;
|
|
22
|
-
exports.entriesLoaded = entriesLoaded;
|
|
23
|
-
exports.entriesLoading = entriesLoading;
|
|
24
|
-
exports.entryDeleteFail = entryDeleteFail;
|
|
25
|
-
exports.entryDeleted = entryDeleted;
|
|
26
|
-
exports.entryDeleting = entryDeleting;
|
|
27
|
-
exports.entryLoadError = entryLoadError;
|
|
28
|
-
exports.entryLoaded = entryLoaded;
|
|
29
|
-
exports.entryLoading = entryLoading;
|
|
30
|
-
exports.entryPersistFail = entryPersistFail;
|
|
31
|
-
exports.entryPersisted = entryPersisted;
|
|
32
|
-
exports.entryPersisting = entryPersisting;
|
|
33
|
-
exports.filterByField = filterByField;
|
|
34
|
-
exports.getAllEntries = getAllEntries;
|
|
35
|
-
exports.getMediaAssets = getMediaAssets;
|
|
36
|
-
exports.getSerializedEntry = getSerializedEntry;
|
|
37
|
-
exports.groupByField = groupByField;
|
|
38
|
-
exports.loadEntries = loadEntries;
|
|
39
|
-
exports.loadEntry = loadEntry;
|
|
40
|
-
exports.loadLocalBackup = loadLocalBackup;
|
|
41
|
-
exports.localBackupRetrieved = localBackupRetrieved;
|
|
42
|
-
exports.persistEntry = persistEntry;
|
|
43
|
-
exports.persistLocalBackup = persistLocalBackup;
|
|
44
|
-
exports.removeDraftEntryMediaFile = removeDraftEntryMediaFile;
|
|
45
|
-
exports.retrieveLocalBackup = retrieveLocalBackup;
|
|
46
|
-
exports.sortByField = sortByField;
|
|
47
|
-
exports.traverseCollectionCursor = traverseCollectionCursor;
|
|
48
|
-
exports.tryLoadEntry = tryLoadEntry;
|
|
49
|
-
exports.validateMetaField = validateMetaField;
|
|
50
|
-
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
51
|
-
var _immutable = require("immutable");
|
|
52
|
-
var _decapCmsLibUtil = require("decap-cms-lib-util");
|
|
53
|
-
var _cursors = require("../reducers/cursors");
|
|
54
|
-
var _collections = require("../reducers/collections");
|
|
55
|
-
var _reducers = require("../reducers");
|
|
56
|
-
var _integrations = require("../integrations");
|
|
57
|
-
var _backend = require("../backend");
|
|
58
|
-
var _serializeEntryValues = require("../lib/serializeEntryValues");
|
|
59
|
-
var _Entry = require("../valueObjects/Entry");
|
|
60
|
-
var _AssetProxy = require("../valueObjects/AssetProxy");
|
|
61
|
-
var _validationErrorTypes = _interopRequireDefault(require("../constants/validationErrorTypes"));
|
|
62
|
-
var _media = require("./media");
|
|
63
|
-
var _redux = require("../types/redux");
|
|
64
|
-
var _mediaLibrary = require("./mediaLibrary");
|
|
65
|
-
var _waitUntil = require("./waitUntil");
|
|
66
|
-
var _entries = require("../reducers/entries");
|
|
67
|
-
var _entryDraft = require("../reducers/entryDraft");
|
|
68
|
-
var _history = require("../routing/history");
|
|
69
|
-
var _formatters = require("../lib/formatters");
|
|
70
|
-
var _i18n = require("../lib/i18n");
|
|
71
|
-
var _notifications = require("./notifications");
|
|
72
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import _isEqual from "lodash/isEqual";
|
|
73
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
74
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
75
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
76
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
77
6
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { fromJS, List, Map } from 'immutable';
|
|
8
|
+
import { Cursor } from 'decap-cms-lib-util';
|
|
9
|
+
import { selectCollectionEntriesCursor } from '../reducers/cursors';
|
|
10
|
+
import { selectFields, updateFieldByKey } from '../reducers/collections';
|
|
11
|
+
import { selectIntegration, selectPublishedSlugs } from '../reducers';
|
|
12
|
+
import { getIntegrationProvider } from '../integrations';
|
|
13
|
+
import { currentBackend } from '../backend';
|
|
14
|
+
import { serializeValues } from '../lib/serializeEntryValues';
|
|
15
|
+
import { createEntry } from '../valueObjects/Entry';
|
|
16
|
+
import { createAssetProxy } from '../valueObjects/AssetProxy';
|
|
17
|
+
import ValidationErrorTypes from '../constants/validationErrorTypes';
|
|
18
|
+
import { addAssets, getAsset } from './media';
|
|
19
|
+
import { SortDirection } from '../types/redux';
|
|
20
|
+
import { waitForMediaLibraryToLoad, loadMedia } from './mediaLibrary';
|
|
21
|
+
import { waitUntil } from './waitUntil';
|
|
22
|
+
import { selectIsFetching, selectEntriesSortFields, selectEntryByPath } from '../reducers/entries';
|
|
23
|
+
import { selectCustomPath } from '../reducers/entryDraft';
|
|
24
|
+
import { navigateToEntry } from '../routing/history';
|
|
25
|
+
import { getProcessSegment } from '../lib/formatters';
|
|
26
|
+
import { hasI18n, duplicateDefaultI18nFields, serializeI18n, I18N, I18N_FIELD } from '../lib/i18n';
|
|
27
|
+
import { addNotification } from './notifications';
|
|
78
28
|
/*
|
|
79
29
|
* Constant Declarations
|
|
80
30
|
*/
|
|
81
|
-
const ENTRY_REQUEST =
|
|
82
|
-
const ENTRY_SUCCESS =
|
|
83
|
-
const ENTRY_FAILURE =
|
|
84
|
-
const ENTRIES_REQUEST =
|
|
85
|
-
const ENTRIES_SUCCESS =
|
|
86
|
-
const ENTRIES_FAILURE =
|
|
87
|
-
const SORT_ENTRIES_REQUEST =
|
|
88
|
-
const SORT_ENTRIES_SUCCESS =
|
|
89
|
-
const SORT_ENTRIES_FAILURE =
|
|
90
|
-
const FILTER_ENTRIES_REQUEST =
|
|
91
|
-
const FILTER_ENTRIES_SUCCESS =
|
|
92
|
-
const FILTER_ENTRIES_FAILURE =
|
|
93
|
-
const GROUP_ENTRIES_REQUEST =
|
|
94
|
-
const GROUP_ENTRIES_SUCCESS =
|
|
95
|
-
const GROUP_ENTRIES_FAILURE =
|
|
96
|
-
const DRAFT_CREATE_FROM_ENTRY =
|
|
97
|
-
const DRAFT_CREATE_EMPTY =
|
|
98
|
-
const DRAFT_DISCARD =
|
|
99
|
-
const DRAFT_CHANGE_FIELD =
|
|
100
|
-
const DRAFT_VALIDATION_ERRORS =
|
|
101
|
-
const DRAFT_CLEAR_ERRORS =
|
|
102
|
-
const DRAFT_LOCAL_BACKUP_RETRIEVED =
|
|
103
|
-
const DRAFT_CREATE_FROM_LOCAL_BACKUP =
|
|
104
|
-
const DRAFT_CREATE_DUPLICATE_FROM_ENTRY =
|
|
105
|
-
const ENTRY_PERSIST_REQUEST =
|
|
106
|
-
const ENTRY_PERSIST_SUCCESS =
|
|
107
|
-
const ENTRY_PERSIST_FAILURE =
|
|
108
|
-
const ENTRY_DELETE_REQUEST =
|
|
109
|
-
const ENTRY_DELETE_SUCCESS =
|
|
110
|
-
const ENTRY_DELETE_FAILURE =
|
|
111
|
-
const ADD_DRAFT_ENTRY_MEDIA_FILE =
|
|
112
|
-
const REMOVE_DRAFT_ENTRY_MEDIA_FILE =
|
|
113
|
-
const CHANGE_VIEW_STYLE =
|
|
31
|
+
export const ENTRY_REQUEST = 'ENTRY_REQUEST';
|
|
32
|
+
export const ENTRY_SUCCESS = 'ENTRY_SUCCESS';
|
|
33
|
+
export const ENTRY_FAILURE = 'ENTRY_FAILURE';
|
|
34
|
+
export const ENTRIES_REQUEST = 'ENTRIES_REQUEST';
|
|
35
|
+
export const ENTRIES_SUCCESS = 'ENTRIES_SUCCESS';
|
|
36
|
+
export const ENTRIES_FAILURE = 'ENTRIES_FAILURE';
|
|
37
|
+
export const SORT_ENTRIES_REQUEST = 'SORT_ENTRIES_REQUEST';
|
|
38
|
+
export const SORT_ENTRIES_SUCCESS = 'SORT_ENTRIES_SUCCESS';
|
|
39
|
+
export const SORT_ENTRIES_FAILURE = 'SORT_ENTRIES_FAILURE';
|
|
40
|
+
export const FILTER_ENTRIES_REQUEST = 'FILTER_ENTRIES_REQUEST';
|
|
41
|
+
export const FILTER_ENTRIES_SUCCESS = 'FILTER_ENTRIES_SUCCESS';
|
|
42
|
+
export const FILTER_ENTRIES_FAILURE = 'FILTER_ENTRIES_FAILURE';
|
|
43
|
+
export const GROUP_ENTRIES_REQUEST = 'GROUP_ENTRIES_REQUEST';
|
|
44
|
+
export const GROUP_ENTRIES_SUCCESS = 'GROUP_ENTRIES_SUCCESS';
|
|
45
|
+
export const GROUP_ENTRIES_FAILURE = 'GROUP_ENTRIES_FAILURE';
|
|
46
|
+
export const DRAFT_CREATE_FROM_ENTRY = 'DRAFT_CREATE_FROM_ENTRY';
|
|
47
|
+
export const DRAFT_CREATE_EMPTY = 'DRAFT_CREATE_EMPTY';
|
|
48
|
+
export const DRAFT_DISCARD = 'DRAFT_DISCARD';
|
|
49
|
+
export const DRAFT_CHANGE_FIELD = 'DRAFT_CHANGE_FIELD';
|
|
50
|
+
export const DRAFT_VALIDATION_ERRORS = 'DRAFT_VALIDATION_ERRORS';
|
|
51
|
+
export const DRAFT_CLEAR_ERRORS = 'DRAFT_CLEAR_ERRORS';
|
|
52
|
+
export const DRAFT_LOCAL_BACKUP_RETRIEVED = 'DRAFT_LOCAL_BACKUP_RETRIEVED';
|
|
53
|
+
export const DRAFT_CREATE_FROM_LOCAL_BACKUP = 'DRAFT_CREATE_FROM_LOCAL_BACKUP';
|
|
54
|
+
export const DRAFT_CREATE_DUPLICATE_FROM_ENTRY = 'DRAFT_CREATE_DUPLICATE_FROM_ENTRY';
|
|
55
|
+
export const ENTRY_PERSIST_REQUEST = 'ENTRY_PERSIST_REQUEST';
|
|
56
|
+
export const ENTRY_PERSIST_SUCCESS = 'ENTRY_PERSIST_SUCCESS';
|
|
57
|
+
export const ENTRY_PERSIST_FAILURE = 'ENTRY_PERSIST_FAILURE';
|
|
58
|
+
export const ENTRY_DELETE_REQUEST = 'ENTRY_DELETE_REQUEST';
|
|
59
|
+
export const ENTRY_DELETE_SUCCESS = 'ENTRY_DELETE_SUCCESS';
|
|
60
|
+
export const ENTRY_DELETE_FAILURE = 'ENTRY_DELETE_FAILURE';
|
|
61
|
+
export const ADD_DRAFT_ENTRY_MEDIA_FILE = 'ADD_DRAFT_ENTRY_MEDIA_FILE';
|
|
62
|
+
export const REMOVE_DRAFT_ENTRY_MEDIA_FILE = 'REMOVE_DRAFT_ENTRY_MEDIA_FILE';
|
|
63
|
+
export const CHANGE_VIEW_STYLE = 'CHANGE_VIEW_STYLE';
|
|
114
64
|
|
|
115
65
|
/*
|
|
116
66
|
* Simple Action Creators (Internal)
|
|
117
67
|
* We still need to export them for tests
|
|
118
68
|
*/
|
|
119
|
-
function entryLoading(collection, slug) {
|
|
69
|
+
export function entryLoading(collection, slug) {
|
|
120
70
|
return {
|
|
121
71
|
type: ENTRY_REQUEST,
|
|
122
72
|
payload: {
|
|
@@ -125,7 +75,7 @@ function entryLoading(collection, slug) {
|
|
|
125
75
|
}
|
|
126
76
|
};
|
|
127
77
|
}
|
|
128
|
-
function entryLoaded(collection, entry) {
|
|
78
|
+
export function entryLoaded(collection, entry) {
|
|
129
79
|
return {
|
|
130
80
|
type: ENTRY_SUCCESS,
|
|
131
81
|
payload: {
|
|
@@ -134,7 +84,7 @@ function entryLoaded(collection, entry) {
|
|
|
134
84
|
}
|
|
135
85
|
};
|
|
136
86
|
}
|
|
137
|
-
function entryLoadError(error, collection, slug) {
|
|
87
|
+
export function entryLoadError(error, collection, slug) {
|
|
138
88
|
return {
|
|
139
89
|
type: ENTRY_FAILURE,
|
|
140
90
|
payload: {
|
|
@@ -144,7 +94,7 @@ function entryLoadError(error, collection, slug) {
|
|
|
144
94
|
}
|
|
145
95
|
};
|
|
146
96
|
}
|
|
147
|
-
function entriesLoading(collection) {
|
|
97
|
+
export function entriesLoading(collection) {
|
|
148
98
|
return {
|
|
149
99
|
type: ENTRIES_REQUEST,
|
|
150
100
|
payload: {
|
|
@@ -152,19 +102,19 @@ function entriesLoading(collection) {
|
|
|
152
102
|
}
|
|
153
103
|
};
|
|
154
104
|
}
|
|
155
|
-
function entriesLoaded(collection, entries, pagination, cursor, append = true) {
|
|
105
|
+
export function entriesLoaded(collection, entries, pagination, cursor, append = true) {
|
|
156
106
|
return {
|
|
157
107
|
type: ENTRIES_SUCCESS,
|
|
158
108
|
payload: {
|
|
159
109
|
collection: collection.get('name'),
|
|
160
110
|
entries,
|
|
161
111
|
page: pagination,
|
|
162
|
-
cursor:
|
|
112
|
+
cursor: Cursor.create(cursor),
|
|
163
113
|
append
|
|
164
114
|
}
|
|
165
115
|
};
|
|
166
116
|
}
|
|
167
|
-
function entriesFailed(collection, error) {
|
|
117
|
+
export function entriesFailed(collection, error) {
|
|
168
118
|
return {
|
|
169
119
|
type: ENTRIES_FAILURE,
|
|
170
120
|
error: 'Failed to load entries',
|
|
@@ -174,18 +124,18 @@ function entriesFailed(collection, error) {
|
|
|
174
124
|
}
|
|
175
125
|
};
|
|
176
126
|
}
|
|
177
|
-
async function getAllEntries(state, collection) {
|
|
178
|
-
const backend =
|
|
179
|
-
const integration =
|
|
180
|
-
const provider = integration ?
|
|
127
|
+
export async function getAllEntries(state, collection) {
|
|
128
|
+
const backend = currentBackend(state.config);
|
|
129
|
+
const integration = selectIntegration(state, collection.get('name'), 'listEntries');
|
|
130
|
+
const provider = integration ? getIntegrationProvider(state.integrations, backend.getToken, integration) : backend;
|
|
181
131
|
const entries = await provider.listAllEntries(collection);
|
|
182
132
|
return entries;
|
|
183
133
|
}
|
|
184
|
-
function sortByField(collection, key, direction =
|
|
134
|
+
export function sortByField(collection, key, direction = SortDirection.Ascending) {
|
|
185
135
|
return async (dispatch, getState) => {
|
|
186
136
|
const state = getState();
|
|
187
137
|
// if we're already fetching we update the sort key, but skip loading entries
|
|
188
|
-
const isFetching =
|
|
138
|
+
const isFetching = selectIsFetching(state.entries, collection.get('name'));
|
|
189
139
|
dispatch({
|
|
190
140
|
type: SORT_ENTRIES_REQUEST,
|
|
191
141
|
payload: {
|
|
@@ -221,11 +171,11 @@ function sortByField(collection, key, direction = _redux.SortDirection.Ascending
|
|
|
221
171
|
}
|
|
222
172
|
};
|
|
223
173
|
}
|
|
224
|
-
function filterByField(collection, filter) {
|
|
174
|
+
export function filterByField(collection, filter) {
|
|
225
175
|
return async (dispatch, getState) => {
|
|
226
176
|
const state = getState();
|
|
227
177
|
// if we're already fetching we update the filter key, but skip loading entries
|
|
228
|
-
const isFetching =
|
|
178
|
+
const isFetching = selectIsFetching(state.entries, collection.get('name'));
|
|
229
179
|
dispatch({
|
|
230
180
|
type: FILTER_ENTRIES_REQUEST,
|
|
231
181
|
payload: {
|
|
@@ -258,10 +208,10 @@ function filterByField(collection, filter) {
|
|
|
258
208
|
}
|
|
259
209
|
};
|
|
260
210
|
}
|
|
261
|
-
function groupByField(collection, group) {
|
|
211
|
+
export function groupByField(collection, group) {
|
|
262
212
|
return async (dispatch, getState) => {
|
|
263
213
|
const state = getState();
|
|
264
|
-
const isFetching =
|
|
214
|
+
const isFetching = selectIsFetching(state.entries, collection.get('name'));
|
|
265
215
|
dispatch({
|
|
266
216
|
type: GROUP_ENTRIES_REQUEST,
|
|
267
217
|
payload: {
|
|
@@ -294,7 +244,7 @@ function groupByField(collection, group) {
|
|
|
294
244
|
}
|
|
295
245
|
};
|
|
296
246
|
}
|
|
297
|
-
function changeViewStyle(viewStyle) {
|
|
247
|
+
export function changeViewStyle(viewStyle) {
|
|
298
248
|
return {
|
|
299
249
|
type: CHANGE_VIEW_STYLE,
|
|
300
250
|
payload: {
|
|
@@ -302,7 +252,7 @@ function changeViewStyle(viewStyle) {
|
|
|
302
252
|
}
|
|
303
253
|
};
|
|
304
254
|
}
|
|
305
|
-
function entryPersisting(collection, entry) {
|
|
255
|
+
export function entryPersisting(collection, entry) {
|
|
306
256
|
return {
|
|
307
257
|
type: ENTRY_PERSIST_REQUEST,
|
|
308
258
|
payload: {
|
|
@@ -311,7 +261,7 @@ function entryPersisting(collection, entry) {
|
|
|
311
261
|
}
|
|
312
262
|
};
|
|
313
263
|
}
|
|
314
|
-
function entryPersisted(collection, entry, slug) {
|
|
264
|
+
export function entryPersisted(collection, entry, slug) {
|
|
315
265
|
return {
|
|
316
266
|
type: ENTRY_PERSIST_SUCCESS,
|
|
317
267
|
payload: {
|
|
@@ -324,7 +274,7 @@ function entryPersisted(collection, entry, slug) {
|
|
|
324
274
|
}
|
|
325
275
|
};
|
|
326
276
|
}
|
|
327
|
-
function entryPersistFail(collection, entry, error) {
|
|
277
|
+
export function entryPersistFail(collection, entry, error) {
|
|
328
278
|
return {
|
|
329
279
|
type: ENTRY_PERSIST_FAILURE,
|
|
330
280
|
error: 'Failed to persist entry',
|
|
@@ -335,7 +285,7 @@ function entryPersistFail(collection, entry, error) {
|
|
|
335
285
|
}
|
|
336
286
|
};
|
|
337
287
|
}
|
|
338
|
-
function entryDeleting(collection, slug) {
|
|
288
|
+
export function entryDeleting(collection, slug) {
|
|
339
289
|
return {
|
|
340
290
|
type: ENTRY_DELETE_REQUEST,
|
|
341
291
|
payload: {
|
|
@@ -344,7 +294,7 @@ function entryDeleting(collection, slug) {
|
|
|
344
294
|
}
|
|
345
295
|
};
|
|
346
296
|
}
|
|
347
|
-
function entryDeleted(collection, slug) {
|
|
297
|
+
export function entryDeleted(collection, slug) {
|
|
348
298
|
return {
|
|
349
299
|
type: ENTRY_DELETE_SUCCESS,
|
|
350
300
|
payload: {
|
|
@@ -353,7 +303,7 @@ function entryDeleted(collection, slug) {
|
|
|
353
303
|
}
|
|
354
304
|
};
|
|
355
305
|
}
|
|
356
|
-
function entryDeleteFail(collection, slug, error) {
|
|
306
|
+
export function entryDeleteFail(collection, slug, error) {
|
|
357
307
|
return {
|
|
358
308
|
type: ENTRY_DELETE_FAILURE,
|
|
359
309
|
payload: {
|
|
@@ -363,7 +313,7 @@ function entryDeleteFail(collection, slug, error) {
|
|
|
363
313
|
}
|
|
364
314
|
};
|
|
365
315
|
}
|
|
366
|
-
function emptyDraftCreated(entry) {
|
|
316
|
+
export function emptyDraftCreated(entry) {
|
|
367
317
|
return {
|
|
368
318
|
type: DRAFT_CREATE_EMPTY,
|
|
369
319
|
payload: entry
|
|
@@ -372,7 +322,7 @@ function emptyDraftCreated(entry) {
|
|
|
372
322
|
/*
|
|
373
323
|
* Exported simple Action Creators
|
|
374
324
|
*/
|
|
375
|
-
function createDraftFromEntry(entry) {
|
|
325
|
+
export function createDraftFromEntry(entry) {
|
|
376
326
|
return {
|
|
377
327
|
type: DRAFT_CREATE_FROM_ENTRY,
|
|
378
328
|
payload: {
|
|
@@ -380,21 +330,21 @@ function createDraftFromEntry(entry) {
|
|
|
380
330
|
}
|
|
381
331
|
};
|
|
382
332
|
}
|
|
383
|
-
function draftDuplicateEntry(entry) {
|
|
333
|
+
export function draftDuplicateEntry(entry) {
|
|
384
334
|
return {
|
|
385
335
|
type: DRAFT_CREATE_DUPLICATE_FROM_ENTRY,
|
|
386
|
-
payload:
|
|
336
|
+
payload: createEntry(entry.get('collection'), '', '', {
|
|
387
337
|
data: entry.get('data'),
|
|
388
338
|
mediaFiles: entry.get('mediaFiles').toJS()
|
|
389
339
|
})
|
|
390
340
|
};
|
|
391
341
|
}
|
|
392
|
-
function discardDraft() {
|
|
342
|
+
export function discardDraft() {
|
|
393
343
|
return {
|
|
394
344
|
type: DRAFT_DISCARD
|
|
395
345
|
};
|
|
396
346
|
}
|
|
397
|
-
function changeDraftField({
|
|
347
|
+
export function changeDraftField({
|
|
398
348
|
field,
|
|
399
349
|
value,
|
|
400
350
|
metadata,
|
|
@@ -412,7 +362,7 @@ function changeDraftField({
|
|
|
412
362
|
}
|
|
413
363
|
};
|
|
414
364
|
}
|
|
415
|
-
function changeDraftFieldValidation(uniquefieldId, errors) {
|
|
365
|
+
export function changeDraftFieldValidation(uniquefieldId, errors) {
|
|
416
366
|
return {
|
|
417
367
|
type: DRAFT_VALIDATION_ERRORS,
|
|
418
368
|
payload: {
|
|
@@ -421,7 +371,7 @@ function changeDraftFieldValidation(uniquefieldId, errors) {
|
|
|
421
371
|
}
|
|
422
372
|
};
|
|
423
373
|
}
|
|
424
|
-
function clearFieldErrors(uniqueFieldId) {
|
|
374
|
+
export function clearFieldErrors(uniqueFieldId) {
|
|
425
375
|
return {
|
|
426
376
|
type: DRAFT_CLEAR_ERRORS,
|
|
427
377
|
payload: {
|
|
@@ -429,7 +379,7 @@ function clearFieldErrors(uniqueFieldId) {
|
|
|
429
379
|
}
|
|
430
380
|
};
|
|
431
381
|
}
|
|
432
|
-
function localBackupRetrieved(entry) {
|
|
382
|
+
export function localBackupRetrieved(entry) {
|
|
433
383
|
return {
|
|
434
384
|
type: DRAFT_LOCAL_BACKUP_RETRIEVED,
|
|
435
385
|
payload: {
|
|
@@ -437,18 +387,18 @@ function localBackupRetrieved(entry) {
|
|
|
437
387
|
}
|
|
438
388
|
};
|
|
439
389
|
}
|
|
440
|
-
function loadLocalBackup() {
|
|
390
|
+
export function loadLocalBackup() {
|
|
441
391
|
return {
|
|
442
392
|
type: DRAFT_CREATE_FROM_LOCAL_BACKUP
|
|
443
393
|
};
|
|
444
394
|
}
|
|
445
|
-
function addDraftEntryMediaFile(file) {
|
|
395
|
+
export function addDraftEntryMediaFile(file) {
|
|
446
396
|
return {
|
|
447
397
|
type: ADD_DRAFT_ENTRY_MEDIA_FILE,
|
|
448
398
|
payload: file
|
|
449
399
|
};
|
|
450
400
|
}
|
|
451
|
-
function removeDraftEntryMediaFile({
|
|
401
|
+
export function removeDraftEntryMediaFile({
|
|
452
402
|
id
|
|
453
403
|
}) {
|
|
454
404
|
return {
|
|
@@ -458,16 +408,16 @@ function removeDraftEntryMediaFile({
|
|
|
458
408
|
}
|
|
459
409
|
};
|
|
460
410
|
}
|
|
461
|
-
function persistLocalBackup(entry, collection) {
|
|
411
|
+
export function persistLocalBackup(entry, collection) {
|
|
462
412
|
return (_dispatch, getState) => {
|
|
463
413
|
const state = getState();
|
|
464
|
-
const backend =
|
|
414
|
+
const backend = currentBackend(state.config);
|
|
465
415
|
return backend.persistLocalDraftBackup(entry, collection);
|
|
466
416
|
};
|
|
467
417
|
}
|
|
468
|
-
function createDraftDuplicateFromEntry(entry) {
|
|
418
|
+
export function createDraftDuplicateFromEntry(entry) {
|
|
469
419
|
return dispatch => {
|
|
470
|
-
dispatch(
|
|
420
|
+
dispatch(waitUntil({
|
|
471
421
|
predicate: ({
|
|
472
422
|
type
|
|
473
423
|
}) => type === DRAFT_CREATE_EMPTY,
|
|
@@ -475,10 +425,10 @@ function createDraftDuplicateFromEntry(entry) {
|
|
|
475
425
|
}));
|
|
476
426
|
};
|
|
477
427
|
}
|
|
478
|
-
function retrieveLocalBackup(collection, slug) {
|
|
428
|
+
export function retrieveLocalBackup(collection, slug) {
|
|
479
429
|
return async (dispatch, getState) => {
|
|
480
430
|
const state = getState();
|
|
481
|
-
const backend =
|
|
431
|
+
const backend = currentBackend(state.config);
|
|
482
432
|
const {
|
|
483
433
|
entry
|
|
484
434
|
} = await backend.getLocalDraftBackup(collection, slug);
|
|
@@ -487,30 +437,30 @@ function retrieveLocalBackup(collection, slug) {
|
|
|
487
437
|
const mediaFiles = entry.mediaFiles || [];
|
|
488
438
|
const assetProxies = await Promise.all(mediaFiles.map(file => {
|
|
489
439
|
if (file.file || file.url) {
|
|
490
|
-
return
|
|
440
|
+
return createAssetProxy({
|
|
491
441
|
path: file.path,
|
|
492
442
|
file: file.file,
|
|
493
443
|
url: file.url,
|
|
494
444
|
field: file.field
|
|
495
445
|
});
|
|
496
446
|
} else {
|
|
497
|
-
return
|
|
447
|
+
return getAsset({
|
|
498
448
|
collection,
|
|
499
|
-
entry:
|
|
449
|
+
entry: fromJS(entry),
|
|
500
450
|
path: file.path,
|
|
501
451
|
field: file.field
|
|
502
452
|
})(dispatch, getState);
|
|
503
453
|
}
|
|
504
454
|
}));
|
|
505
|
-
dispatch(
|
|
455
|
+
dispatch(addAssets(assetProxies));
|
|
506
456
|
return dispatch(localBackupRetrieved(entry));
|
|
507
457
|
}
|
|
508
458
|
};
|
|
509
459
|
}
|
|
510
|
-
function deleteLocalBackup(collection, slug) {
|
|
460
|
+
export function deleteLocalBackup(collection, slug) {
|
|
511
461
|
return (_dispatch, getState) => {
|
|
512
462
|
const state = getState();
|
|
513
|
-
const backend =
|
|
463
|
+
const backend = currentBackend(state.config);
|
|
514
464
|
return backend.deleteLocalDraftBackup(collection, slug);
|
|
515
465
|
};
|
|
516
466
|
}
|
|
@@ -519,16 +469,16 @@ function deleteLocalBackup(collection, slug) {
|
|
|
519
469
|
* Exported Thunk Action Creators
|
|
520
470
|
*/
|
|
521
471
|
|
|
522
|
-
function loadEntry(collection, slug) {
|
|
472
|
+
export function loadEntry(collection, slug) {
|
|
523
473
|
return async (dispatch, getState) => {
|
|
524
|
-
await
|
|
474
|
+
await waitForMediaLibraryToLoad(dispatch, getState());
|
|
525
475
|
dispatch(entryLoading(collection, slug));
|
|
526
476
|
try {
|
|
527
477
|
const loadedEntry = await tryLoadEntry(getState(), collection, slug);
|
|
528
478
|
dispatch(entryLoaded(collection, loadedEntry));
|
|
529
479
|
dispatch(createDraftFromEntry(loadedEntry));
|
|
530
480
|
} catch (error) {
|
|
531
|
-
dispatch(
|
|
481
|
+
dispatch(addNotification({
|
|
532
482
|
message: {
|
|
533
483
|
details: error.message,
|
|
534
484
|
key: 'ui.toast.onFailToLoadEntries'
|
|
@@ -540,40 +490,40 @@ function loadEntry(collection, slug) {
|
|
|
540
490
|
}
|
|
541
491
|
};
|
|
542
492
|
}
|
|
543
|
-
async function tryLoadEntry(state, collection, slug) {
|
|
544
|
-
const backend =
|
|
493
|
+
export async function tryLoadEntry(state, collection, slug) {
|
|
494
|
+
const backend = currentBackend(state.config);
|
|
545
495
|
const loadedEntry = await backend.getEntry(state, collection, slug);
|
|
546
496
|
return loadedEntry;
|
|
547
497
|
}
|
|
548
|
-
const appendActions =
|
|
498
|
+
const appendActions = fromJS({
|
|
549
499
|
['append_next']: {
|
|
550
500
|
action: 'next',
|
|
551
501
|
append: true
|
|
552
502
|
}
|
|
553
503
|
});
|
|
554
504
|
function addAppendActionsToCursor(cursor) {
|
|
555
|
-
return
|
|
505
|
+
return Cursor.create(cursor).updateStore('actions', actions => {
|
|
556
506
|
return actions.union(appendActions.filter(v => actions.has(v.get('action'))).keySeq());
|
|
557
507
|
});
|
|
558
508
|
}
|
|
559
|
-
function loadEntries(collection, page = 0) {
|
|
509
|
+
export function loadEntries(collection, page = 0) {
|
|
560
510
|
return async (dispatch, getState) => {
|
|
561
511
|
if (collection.get('isFetching')) {
|
|
562
512
|
return;
|
|
563
513
|
}
|
|
564
514
|
const state = getState();
|
|
565
|
-
const sortFields =
|
|
515
|
+
const sortFields = selectEntriesSortFields(state.entries, collection.get('name'));
|
|
566
516
|
if (sortFields && sortFields.length > 0) {
|
|
567
517
|
const field = sortFields[0];
|
|
568
518
|
return dispatch(sortByField(collection, field.get('key'), field.get('direction')));
|
|
569
519
|
}
|
|
570
|
-
const backend =
|
|
571
|
-
const integration =
|
|
572
|
-
const provider = integration ?
|
|
520
|
+
const backend = currentBackend(state.config);
|
|
521
|
+
const integration = selectIntegration(state, collection.get('name'), 'listEntries');
|
|
522
|
+
const provider = integration ? getIntegrationProvider(state.integrations, backend.getToken, integration) : backend;
|
|
573
523
|
const append = !!(page && !isNaN(page) && page > 0);
|
|
574
524
|
dispatch(entriesLoading(collection));
|
|
575
525
|
try {
|
|
576
|
-
const loadAllEntries = collection.has('nested') ||
|
|
526
|
+
const loadAllEntries = collection.has('nested') || hasI18n(collection);
|
|
577
527
|
let response = await (loadAllEntries ?
|
|
578
528
|
// nested collections require all entries to construct the tree
|
|
579
529
|
provider.listAllEntries(collection).then(entries => ({
|
|
@@ -586,7 +536,7 @@ function loadEntries(collection, page = 0) {
|
|
|
586
536
|
// determine whether or not this is using the old integer-based
|
|
587
537
|
// pagination API. Other backends will simply store an empty
|
|
588
538
|
// cursor, which behaves identically to no cursor at all.
|
|
589
|
-
cursor: integration ?
|
|
539
|
+
cursor: integration ? Cursor.create({
|
|
590
540
|
actions: ['next'],
|
|
591
541
|
meta: {
|
|
592
542
|
usingOldPaginationAPI: true
|
|
@@ -594,11 +544,11 @@ function loadEntries(collection, page = 0) {
|
|
|
594
544
|
data: {
|
|
595
545
|
nextPage: page + 1
|
|
596
546
|
}
|
|
597
|
-
}) :
|
|
547
|
+
}) : Cursor.create(response.cursor)
|
|
598
548
|
});
|
|
599
549
|
dispatch(entriesLoaded(collection, response.cursor.meta.get('usingOldPaginationAPI') ? response.entries.reverse() : response.entries, response.pagination, addAppendActionsToCursor(response.cursor), append));
|
|
600
550
|
} catch (err) {
|
|
601
|
-
dispatch(
|
|
551
|
+
dispatch(addNotification({
|
|
602
552
|
message: {
|
|
603
553
|
details: err,
|
|
604
554
|
key: 'ui.toast.onFailToLoadEntries'
|
|
@@ -616,14 +566,14 @@ function traverseCursor(backend, cursor, action) {
|
|
|
616
566
|
}
|
|
617
567
|
return backend.traverseCursor(cursor, action);
|
|
618
568
|
}
|
|
619
|
-
function traverseCollectionCursor(collection, action) {
|
|
569
|
+
export function traverseCollectionCursor(collection, action) {
|
|
620
570
|
return async (dispatch, getState) => {
|
|
621
571
|
const state = getState();
|
|
622
572
|
const collectionName = collection.get('name');
|
|
623
573
|
if (state.entries.getIn(['pages', `${collectionName}`, 'isFetching'])) {
|
|
624
574
|
return;
|
|
625
575
|
}
|
|
626
|
-
const backend =
|
|
576
|
+
const backend = currentBackend(state.config);
|
|
627
577
|
const {
|
|
628
578
|
action: realAction,
|
|
629
579
|
append
|
|
@@ -631,7 +581,7 @@ function traverseCollectionCursor(collection, action) {
|
|
|
631
581
|
action,
|
|
632
582
|
append: false
|
|
633
583
|
};
|
|
634
|
-
const cursor =
|
|
584
|
+
const cursor = selectCollectionEntriesCursor(state.cursors, collection.get('name'));
|
|
635
585
|
|
|
636
586
|
// Handle cursors representing pages in the old, integer-based
|
|
637
587
|
// pagination API
|
|
@@ -649,7 +599,7 @@ function traverseCollectionCursor(collection, action) {
|
|
|
649
599
|
return dispatch(entriesLoaded(collection, entries, pagination, addAppendActionsToCursor(newCursor), append));
|
|
650
600
|
} catch (err) {
|
|
651
601
|
console.error(err);
|
|
652
|
-
dispatch(
|
|
602
|
+
dispatch(addNotification({
|
|
653
603
|
message: {
|
|
654
604
|
details: err,
|
|
655
605
|
key: 'ui.toast.onFailToLoadEntries'
|
|
@@ -679,24 +629,24 @@ function getDataFields(fields) {
|
|
|
679
629
|
function getMetaFields(fields) {
|
|
680
630
|
return fields.filter(f => f.get('meta') === true).toList();
|
|
681
631
|
}
|
|
682
|
-
function createEmptyDraft(collection, search) {
|
|
632
|
+
export function createEmptyDraft(collection, search) {
|
|
683
633
|
return async (dispatch, getState) => {
|
|
684
634
|
const params = new URLSearchParams(search);
|
|
685
635
|
params.forEach((value, key) => {
|
|
686
|
-
collection =
|
|
636
|
+
collection = updateFieldByKey(collection, key, field => field.set('default', processValue(value)));
|
|
687
637
|
});
|
|
688
|
-
const fields = collection.get('fields',
|
|
638
|
+
const fields = collection.get('fields', List());
|
|
689
639
|
const dataFields = getDataFields(fields);
|
|
690
640
|
const data = createEmptyDraftData(dataFields);
|
|
691
641
|
const metaFields = getMetaFields(fields);
|
|
692
642
|
const meta = createEmptyDraftData(metaFields);
|
|
693
643
|
const state = getState();
|
|
694
|
-
const backend =
|
|
644
|
+
const backend = currentBackend(state.config);
|
|
695
645
|
if (!collection.has('media_folder')) {
|
|
696
|
-
await
|
|
646
|
+
await waitForMediaLibraryToLoad(dispatch, getState());
|
|
697
647
|
}
|
|
698
648
|
const i18nFields = createEmptyDraftI18nData(collection, dataFields);
|
|
699
|
-
let newEntry =
|
|
649
|
+
let newEntry = createEntry(collection.get('name'), '', '', {
|
|
700
650
|
data,
|
|
701
651
|
i18n: i18nFields,
|
|
702
652
|
mediaFiles: [],
|
|
@@ -707,7 +657,7 @@ function createEmptyDraft(collection, search) {
|
|
|
707
657
|
dispatch(emptyDraftCreated(newEntry));
|
|
708
658
|
};
|
|
709
659
|
}
|
|
710
|
-
function createEmptyDraftData(fields, skipField = () => false) {
|
|
660
|
+
export function createEmptyDraftData(fields, skipField = () => false) {
|
|
711
661
|
return fields.reduce((reduction, value) => {
|
|
712
662
|
const acc = reduction;
|
|
713
663
|
const item = value;
|
|
@@ -719,14 +669,14 @@ function createEmptyDraftData(fields, skipField = () => false) {
|
|
|
719
669
|
const name = item.get('name');
|
|
720
670
|
const defaultValue = item.get('default', null);
|
|
721
671
|
function isEmptyDefaultValue(val) {
|
|
722
|
-
return [[{}], {}].some(e => (
|
|
672
|
+
return [[{}], {}].some(e => _isEqual(val, e));
|
|
723
673
|
}
|
|
724
|
-
const hasSubfields =
|
|
674
|
+
const hasSubfields = List.isList(subfields) || Map.isMap(subfields);
|
|
725
675
|
if (hasSubfields) {
|
|
726
|
-
if (list &&
|
|
676
|
+
if (list && List.isList(defaultValue)) {
|
|
727
677
|
acc[name] = defaultValue;
|
|
728
678
|
} else {
|
|
729
|
-
const asList =
|
|
679
|
+
const asList = List.isList(subfields) ? subfields : List([subfields]);
|
|
730
680
|
const subDefaultValue = list ? [createEmptyDraftData(asList, skipField)] : createEmptyDraftData(asList, skipField);
|
|
731
681
|
if (!isEmptyDefaultValue(subDefaultValue)) {
|
|
732
682
|
acc[name] = subDefaultValue;
|
|
@@ -741,20 +691,20 @@ function createEmptyDraftData(fields, skipField = () => false) {
|
|
|
741
691
|
}, {});
|
|
742
692
|
}
|
|
743
693
|
function createEmptyDraftI18nData(collection, dataFields) {
|
|
744
|
-
if (!
|
|
694
|
+
if (!hasI18n(collection)) {
|
|
745
695
|
return {};
|
|
746
696
|
}
|
|
747
697
|
function skipField(field) {
|
|
748
|
-
return field.get(
|
|
698
|
+
return field.get(I18N) !== I18N_FIELD.DUPLICATE && field.get(I18N) !== I18N_FIELD.TRANSLATE;
|
|
749
699
|
}
|
|
750
700
|
const i18nData = createEmptyDraftData(dataFields, skipField);
|
|
751
|
-
return
|
|
701
|
+
return duplicateDefaultI18nFields(collection, i18nData);
|
|
752
702
|
}
|
|
753
|
-
function getMediaAssets({
|
|
703
|
+
export function getMediaAssets({
|
|
754
704
|
entry
|
|
755
705
|
}) {
|
|
756
706
|
const filesArray = entry.get('mediaFiles').toArray();
|
|
757
|
-
const assets = filesArray.filter(file => file.get('draft')).map(file =>
|
|
707
|
+
const assets = filesArray.filter(file => file.get('draft')).map(file => createAssetProxy({
|
|
758
708
|
path: file.get('path'),
|
|
759
709
|
file: file.get('file'),
|
|
760
710
|
url: file.get('url'),
|
|
@@ -762,36 +712,36 @@ function getMediaAssets({
|
|
|
762
712
|
}));
|
|
763
713
|
return assets;
|
|
764
714
|
}
|
|
765
|
-
function getSerializedEntry(collection, entry) {
|
|
715
|
+
export function getSerializedEntry(collection, entry) {
|
|
766
716
|
/**
|
|
767
717
|
* Serialize the values of any fields with registered serializers, and
|
|
768
718
|
* update the entry and entryDraft with the serialized values.
|
|
769
719
|
*/
|
|
770
|
-
const fields =
|
|
720
|
+
const fields = selectFields(collection, entry.get('slug'));
|
|
771
721
|
|
|
772
722
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
773
723
|
function serializeData(data) {
|
|
774
|
-
return
|
|
724
|
+
return serializeValues(data, fields);
|
|
775
725
|
}
|
|
776
726
|
const serializedData = serializeData(entry.get('data'));
|
|
777
727
|
let serializedEntry = entry.set('data', serializedData);
|
|
778
|
-
if (
|
|
779
|
-
serializedEntry =
|
|
728
|
+
if (hasI18n(collection)) {
|
|
729
|
+
serializedEntry = serializeI18n(collection, serializedEntry, serializeData);
|
|
780
730
|
}
|
|
781
731
|
return serializedEntry;
|
|
782
732
|
}
|
|
783
|
-
function persistEntry(collection) {
|
|
733
|
+
export function persistEntry(collection) {
|
|
784
734
|
return async (dispatch, getState) => {
|
|
785
735
|
const state = getState();
|
|
786
736
|
const entryDraft = state.entryDraft;
|
|
787
737
|
const fieldsErrors = entryDraft.get('fieldsErrors');
|
|
788
|
-
const usedSlugs =
|
|
738
|
+
const usedSlugs = selectPublishedSlugs(state, collection.get('name'));
|
|
789
739
|
|
|
790
740
|
// Early return if draft contains validation errors
|
|
791
741
|
if (!fieldsErrors.isEmpty()) {
|
|
792
|
-
const hasPresenceErrors = fieldsErrors.some(errors => errors.some(error => error.type && error.type ===
|
|
742
|
+
const hasPresenceErrors = fieldsErrors.some(errors => errors.some(error => error.type && error.type === ValidationErrorTypes.PRESENCE));
|
|
793
743
|
if (hasPresenceErrors) {
|
|
794
|
-
dispatch(
|
|
744
|
+
dispatch(addNotification({
|
|
795
745
|
message: {
|
|
796
746
|
key: 'ui.toast.missingRequiredField'
|
|
797
747
|
},
|
|
@@ -801,7 +751,7 @@ function persistEntry(collection) {
|
|
|
801
751
|
}
|
|
802
752
|
return Promise.reject();
|
|
803
753
|
}
|
|
804
|
-
const backend =
|
|
754
|
+
const backend = currentBackend(state.config);
|
|
805
755
|
const entry = entryDraft.get('entry');
|
|
806
756
|
const assetProxies = getMediaAssets({
|
|
807
757
|
entry
|
|
@@ -816,7 +766,7 @@ function persistEntry(collection) {
|
|
|
816
766
|
assetProxies,
|
|
817
767
|
usedSlugs
|
|
818
768
|
}).then(async newSlug => {
|
|
819
|
-
dispatch(
|
|
769
|
+
dispatch(addNotification({
|
|
820
770
|
message: {
|
|
821
771
|
key: 'ui.toast.entrySaved'
|
|
822
772
|
},
|
|
@@ -826,7 +776,7 @@ function persistEntry(collection) {
|
|
|
826
776
|
|
|
827
777
|
// re-load media library if entry had media files
|
|
828
778
|
if (assetProxies.length > 0) {
|
|
829
|
-
await dispatch(
|
|
779
|
+
await dispatch(loadMedia());
|
|
830
780
|
}
|
|
831
781
|
dispatch(entryPersisted(collection, serializedEntry, newSlug));
|
|
832
782
|
if (collection.has('nested')) {
|
|
@@ -834,11 +784,11 @@ function persistEntry(collection) {
|
|
|
834
784
|
}
|
|
835
785
|
if (entry.get('slug') !== newSlug) {
|
|
836
786
|
await dispatch(loadEntry(collection, newSlug));
|
|
837
|
-
|
|
787
|
+
navigateToEntry(collection.get('name'), newSlug);
|
|
838
788
|
}
|
|
839
789
|
}).catch(error => {
|
|
840
790
|
console.error(error);
|
|
841
|
-
dispatch(
|
|
791
|
+
dispatch(addNotification({
|
|
842
792
|
message: {
|
|
843
793
|
details: error,
|
|
844
794
|
key: 'ui.toast.onFailToPersist'
|
|
@@ -850,15 +800,15 @@ function persistEntry(collection) {
|
|
|
850
800
|
});
|
|
851
801
|
};
|
|
852
802
|
}
|
|
853
|
-
function deleteEntry(collection, slug) {
|
|
803
|
+
export function deleteEntry(collection, slug) {
|
|
854
804
|
return (dispatch, getState) => {
|
|
855
805
|
const state = getState();
|
|
856
|
-
const backend =
|
|
806
|
+
const backend = currentBackend(state.config);
|
|
857
807
|
dispatch(entryDeleting(collection, slug));
|
|
858
808
|
return backend.deleteEntry(state, collection, slug).then(() => {
|
|
859
809
|
return dispatch(entryDeleted(collection, slug));
|
|
860
810
|
}).catch(error => {
|
|
861
|
-
dispatch(
|
|
811
|
+
dispatch(addNotification({
|
|
862
812
|
message: {
|
|
863
813
|
details: error,
|
|
864
814
|
key: 'ui.toast.onFailToDelete'
|
|
@@ -874,31 +824,31 @@ function deleteEntry(collection, slug) {
|
|
|
874
824
|
function getPathError(path, key, t) {
|
|
875
825
|
return {
|
|
876
826
|
error: {
|
|
877
|
-
type:
|
|
827
|
+
type: ValidationErrorTypes.CUSTOM,
|
|
878
828
|
message: t(`editor.editorControlPane.widget.${key}`, {
|
|
879
829
|
path
|
|
880
830
|
})
|
|
881
831
|
}
|
|
882
832
|
};
|
|
883
833
|
}
|
|
884
|
-
function validateMetaField(state, collection, field, value, t) {
|
|
834
|
+
export function validateMetaField(state, collection, field, value, t) {
|
|
885
835
|
if (field.get('meta') && field.get('name') === 'path') {
|
|
886
836
|
var _state$entryDraft;
|
|
887
837
|
if (!value) {
|
|
888
838
|
return getPathError(value, 'invalidPath', t);
|
|
889
839
|
}
|
|
890
|
-
const sanitizedPath = value.split('/').map(
|
|
840
|
+
const sanitizedPath = value.split('/').map(getProcessSegment(state.config.slug)).join('/');
|
|
891
841
|
if (value !== sanitizedPath) {
|
|
892
842
|
return getPathError(value, 'invalidPath', t);
|
|
893
843
|
}
|
|
894
|
-
const customPath =
|
|
844
|
+
const customPath = selectCustomPath(collection, fromJS({
|
|
895
845
|
entry: {
|
|
896
846
|
meta: {
|
|
897
847
|
path: value
|
|
898
848
|
}
|
|
899
849
|
}
|
|
900
850
|
}));
|
|
901
|
-
const existingEntry = customPath ?
|
|
851
|
+
const existingEntry = customPath ? selectEntryByPath(state.entries, collection.get('name'), customPath) : undefined;
|
|
902
852
|
const existingEntryPath = existingEntry === null || existingEntry === void 0 ? void 0 : existingEntry.get('path');
|
|
903
853
|
const draftPath = (_state$entryDraft = state.entryDraft) === null || _state$entryDraft === void 0 ? void 0 : _state$entryDraft.getIn(['entry', 'path']);
|
|
904
854
|
if (existingEntryPath && existingEntryPath !== draftPath) {
|