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,52 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _immutable = require("immutable");
|
|
16
|
-
var _decapCmsLibUtil = require("decap-cms-lib-util");
|
|
17
|
-
var _backend = require("../backend");
|
|
18
|
-
var _reducers = require("../reducers");
|
|
19
|
-
var _entries = require("../reducers/entries");
|
|
20
|
-
var _publishModes = require("../constants/publishModes");
|
|
21
|
-
var _entries2 = require("./entries");
|
|
22
|
-
var _AssetProxy = require("../valueObjects/AssetProxy");
|
|
23
|
-
var _media = require("./media");
|
|
24
|
-
var _mediaLibrary = require("./mediaLibrary");
|
|
25
|
-
var _validationErrorTypes = _interopRequireDefault(require("../constants/validationErrorTypes"));
|
|
26
|
-
var _history = require("../routing/history");
|
|
27
|
-
var _notifications = require("./notifications");
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import _get from "lodash/get";
|
|
2
|
+
import { Map, List } from 'immutable';
|
|
3
|
+
import { EDITORIAL_WORKFLOW_ERROR } from 'decap-cms-lib-util';
|
|
4
|
+
import { currentBackend, slugFromCustomPath } from '../backend';
|
|
5
|
+
import { selectPublishedSlugs, selectUnpublishedSlugs, selectEntry, selectUnpublishedEntry } from '../reducers';
|
|
6
|
+
import { selectEditingDraft } from '../reducers/entries';
|
|
7
|
+
import { EDITORIAL_WORKFLOW, status } from '../constants/publishModes';
|
|
8
|
+
import { loadEntry, entryDeleted, getMediaAssets, createDraftFromEntry, loadEntries, getSerializedEntry } from './entries';
|
|
9
|
+
import { createAssetProxy } from '../valueObjects/AssetProxy';
|
|
10
|
+
import { addAssets } from './media';
|
|
11
|
+
import { loadMedia } from './mediaLibrary';
|
|
12
|
+
import ValidationErrorTypes from '../constants/validationErrorTypes';
|
|
13
|
+
import { navigateToEntry } from '../routing/history';
|
|
14
|
+
import { addNotification } from './notifications';
|
|
29
15
|
/*
|
|
30
16
|
* Constant Declarations
|
|
31
17
|
*/
|
|
32
|
-
const UNPUBLISHED_ENTRY_REQUEST =
|
|
33
|
-
const UNPUBLISHED_ENTRY_SUCCESS =
|
|
34
|
-
const UNPUBLISHED_ENTRY_REDIRECT =
|
|
35
|
-
const UNPUBLISHED_ENTRIES_REQUEST =
|
|
36
|
-
const UNPUBLISHED_ENTRIES_SUCCESS =
|
|
37
|
-
const UNPUBLISHED_ENTRIES_FAILURE =
|
|
38
|
-
const UNPUBLISHED_ENTRY_PERSIST_REQUEST =
|
|
39
|
-
const UNPUBLISHED_ENTRY_PERSIST_SUCCESS =
|
|
40
|
-
const UNPUBLISHED_ENTRY_PERSIST_FAILURE =
|
|
41
|
-
const UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST =
|
|
42
|
-
const UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS =
|
|
43
|
-
const UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE =
|
|
44
|
-
const UNPUBLISHED_ENTRY_PUBLISH_REQUEST =
|
|
45
|
-
const UNPUBLISHED_ENTRY_PUBLISH_SUCCESS =
|
|
46
|
-
const UNPUBLISHED_ENTRY_PUBLISH_FAILURE =
|
|
47
|
-
const UNPUBLISHED_ENTRY_DELETE_REQUEST =
|
|
48
|
-
const UNPUBLISHED_ENTRY_DELETE_SUCCESS =
|
|
49
|
-
const UNPUBLISHED_ENTRY_DELETE_FAILURE =
|
|
18
|
+
export const UNPUBLISHED_ENTRY_REQUEST = 'UNPUBLISHED_ENTRY_REQUEST';
|
|
19
|
+
export const UNPUBLISHED_ENTRY_SUCCESS = 'UNPUBLISHED_ENTRY_SUCCESS';
|
|
20
|
+
export const UNPUBLISHED_ENTRY_REDIRECT = 'UNPUBLISHED_ENTRY_REDIRECT';
|
|
21
|
+
export const UNPUBLISHED_ENTRIES_REQUEST = 'UNPUBLISHED_ENTRIES_REQUEST';
|
|
22
|
+
export const UNPUBLISHED_ENTRIES_SUCCESS = 'UNPUBLISHED_ENTRIES_SUCCESS';
|
|
23
|
+
export const UNPUBLISHED_ENTRIES_FAILURE = 'UNPUBLISHED_ENTRIES_FAILURE';
|
|
24
|
+
export const UNPUBLISHED_ENTRY_PERSIST_REQUEST = 'UNPUBLISHED_ENTRY_PERSIST_REQUEST';
|
|
25
|
+
export const UNPUBLISHED_ENTRY_PERSIST_SUCCESS = 'UNPUBLISHED_ENTRY_PERSIST_SUCCESS';
|
|
26
|
+
export const UNPUBLISHED_ENTRY_PERSIST_FAILURE = 'UNPUBLISHED_ENTRY_PERSIST_FAILURE';
|
|
27
|
+
export const UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST = 'UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST';
|
|
28
|
+
export const UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS = 'UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS';
|
|
29
|
+
export const UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE = 'UNPUBLISHED_ENTRY_STATUS_CHANGE_FAILURE';
|
|
30
|
+
export const UNPUBLISHED_ENTRY_PUBLISH_REQUEST = 'UNPUBLISHED_ENTRY_PUBLISH_REQUEST';
|
|
31
|
+
export const UNPUBLISHED_ENTRY_PUBLISH_SUCCESS = 'UNPUBLISHED_ENTRY_PUBLISH_SUCCESS';
|
|
32
|
+
export const UNPUBLISHED_ENTRY_PUBLISH_FAILURE = 'UNPUBLISHED_ENTRY_PUBLISH_FAILURE';
|
|
33
|
+
export const UNPUBLISHED_ENTRY_DELETE_REQUEST = 'UNPUBLISHED_ENTRY_DELETE_REQUEST';
|
|
34
|
+
export const UNPUBLISHED_ENTRY_DELETE_SUCCESS = 'UNPUBLISHED_ENTRY_DELETE_SUCCESS';
|
|
35
|
+
export const UNPUBLISHED_ENTRY_DELETE_FAILURE = 'UNPUBLISHED_ENTRY_DELETE_FAILURE';
|
|
50
36
|
|
|
51
37
|
/*
|
|
52
38
|
* Simple Action Creators (Internal)
|
|
@@ -216,11 +202,11 @@ function unpublishedEntryDeleteError(collection, slug) {
|
|
|
216
202
|
* Exported Thunk Action Creators
|
|
217
203
|
*/
|
|
218
204
|
|
|
219
|
-
function loadUnpublishedEntry(collection, slug) {
|
|
205
|
+
export function loadUnpublishedEntry(collection, slug) {
|
|
220
206
|
return async (dispatch, getState) => {
|
|
221
207
|
const state = getState();
|
|
222
|
-
const backend =
|
|
223
|
-
const entriesLoaded = (
|
|
208
|
+
const backend = currentBackend(state.config);
|
|
209
|
+
const entriesLoaded = _get(state.editorialWorkflow.toJS(), 'pages.ids', false);
|
|
224
210
|
//run possible unpublishedEntries migration
|
|
225
211
|
if (!entriesLoaded) {
|
|
226
212
|
try {
|
|
@@ -239,20 +225,20 @@ function loadUnpublishedEntry(collection, slug) {
|
|
|
239
225
|
url,
|
|
240
226
|
file,
|
|
241
227
|
path
|
|
242
|
-
}) =>
|
|
228
|
+
}) => createAssetProxy({
|
|
243
229
|
path,
|
|
244
230
|
url,
|
|
245
231
|
file
|
|
246
232
|
})));
|
|
247
|
-
dispatch(
|
|
233
|
+
dispatch(addAssets(assetProxies));
|
|
248
234
|
dispatch(unpublishedEntryLoaded(collection, entry));
|
|
249
|
-
dispatch(
|
|
235
|
+
dispatch(createDraftFromEntry(entry));
|
|
250
236
|
} catch (error) {
|
|
251
|
-
if (error.name ===
|
|
237
|
+
if (error.name === EDITORIAL_WORKFLOW_ERROR && error.notUnderEditorialWorkflow) {
|
|
252
238
|
dispatch(unpublishedEntryRedirected(collection, slug));
|
|
253
|
-
dispatch(
|
|
239
|
+
dispatch(loadEntry(collection, slug));
|
|
254
240
|
} else {
|
|
255
|
-
dispatch(
|
|
241
|
+
dispatch(addNotification({
|
|
256
242
|
message: {
|
|
257
243
|
key: 'ui.toast.onFailToLoadEntries',
|
|
258
244
|
details: error
|
|
@@ -264,17 +250,17 @@ function loadUnpublishedEntry(collection, slug) {
|
|
|
264
250
|
}
|
|
265
251
|
};
|
|
266
252
|
}
|
|
267
|
-
function loadUnpublishedEntries(collections) {
|
|
253
|
+
export function loadUnpublishedEntries(collections) {
|
|
268
254
|
return (dispatch, getState) => {
|
|
269
255
|
const state = getState();
|
|
270
|
-
const backend =
|
|
271
|
-
const entriesLoaded = (
|
|
272
|
-
if (state.config.publish_mode !==
|
|
256
|
+
const backend = currentBackend(state.config);
|
|
257
|
+
const entriesLoaded = _get(state.editorialWorkflow.toJS(), 'pages.ids', false);
|
|
258
|
+
if (state.config.publish_mode !== EDITORIAL_WORKFLOW || entriesLoaded) {
|
|
273
259
|
return;
|
|
274
260
|
}
|
|
275
261
|
dispatch(unpublishedEntriesLoading());
|
|
276
262
|
backend.unpublishedEntries(collections).then(response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination))).catch(error => {
|
|
277
|
-
dispatch(
|
|
263
|
+
dispatch(addNotification({
|
|
278
264
|
message: {
|
|
279
265
|
key: 'ui.toast.onFailToLoadEntries',
|
|
280
266
|
details: error
|
|
@@ -287,24 +273,24 @@ function loadUnpublishedEntries(collections) {
|
|
|
287
273
|
});
|
|
288
274
|
};
|
|
289
275
|
}
|
|
290
|
-
function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
276
|
+
export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
291
277
|
return async (dispatch, getState) => {
|
|
292
278
|
const state = getState();
|
|
293
279
|
const entryDraft = state.entryDraft;
|
|
294
280
|
const fieldsErrors = entryDraft.get('fieldsErrors');
|
|
295
|
-
const unpublishedSlugs =
|
|
296
|
-
const publishedSlugs =
|
|
281
|
+
const unpublishedSlugs = selectUnpublishedSlugs(state, collection.get('name'));
|
|
282
|
+
const publishedSlugs = selectPublishedSlugs(state, collection.get('name'));
|
|
297
283
|
const usedSlugs = publishedSlugs.concat(unpublishedSlugs);
|
|
298
|
-
const entriesLoaded = (
|
|
284
|
+
const entriesLoaded = _get(state.editorialWorkflow.toJS(), 'pages.ids', false);
|
|
299
285
|
|
|
300
286
|
//load unpublishedEntries
|
|
301
287
|
!entriesLoaded && dispatch(loadUnpublishedEntries(state.collections));
|
|
302
288
|
|
|
303
289
|
// Early return if draft contains validation errors
|
|
304
290
|
if (!fieldsErrors.isEmpty()) {
|
|
305
|
-
const hasPresenceErrors = fieldsErrors.some(errors => errors.some(error => error.type && error.type ===
|
|
291
|
+
const hasPresenceErrors = fieldsErrors.some(errors => errors.some(error => error.type && error.type === ValidationErrorTypes.PRESENCE));
|
|
306
292
|
if (hasPresenceErrors) {
|
|
307
|
-
dispatch(
|
|
293
|
+
dispatch(addNotification({
|
|
308
294
|
message: {
|
|
309
295
|
key: 'ui.toast.missingRequiredField'
|
|
310
296
|
},
|
|
@@ -314,12 +300,12 @@ function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
|
314
300
|
}
|
|
315
301
|
return Promise.reject();
|
|
316
302
|
}
|
|
317
|
-
const backend =
|
|
303
|
+
const backend = currentBackend(state.config);
|
|
318
304
|
const entry = entryDraft.get('entry');
|
|
319
|
-
const assetProxies =
|
|
305
|
+
const assetProxies = getMediaAssets({
|
|
320
306
|
entry
|
|
321
307
|
});
|
|
322
|
-
const serializedEntry =
|
|
308
|
+
const serializedEntry = getSerializedEntry(collection, entry);
|
|
323
309
|
const serializedEntryDraft = entryDraft.set('entry', serializedEntry);
|
|
324
310
|
dispatch(unpublishedEntryPersisting(collection, entry.get('slug')));
|
|
325
311
|
const persistAction = existingUnpublishedEntry ? backend.persistUnpublishedEntry : backend.persistEntry;
|
|
@@ -331,7 +317,7 @@ function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
|
331
317
|
assetProxies,
|
|
332
318
|
usedSlugs
|
|
333
319
|
});
|
|
334
|
-
dispatch(
|
|
320
|
+
dispatch(addNotification({
|
|
335
321
|
message: {
|
|
336
322
|
key: 'ui.toast.entrySaved'
|
|
337
323
|
},
|
|
@@ -341,10 +327,10 @@ function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
|
341
327
|
dispatch(unpublishedEntryPersisted(collection, serializedEntry));
|
|
342
328
|
if (entry.get('slug') !== newSlug) {
|
|
343
329
|
await dispatch(loadUnpublishedEntry(collection, newSlug));
|
|
344
|
-
|
|
330
|
+
navigateToEntry(collection.get('name'), newSlug);
|
|
345
331
|
}
|
|
346
332
|
} catch (error) {
|
|
347
|
-
dispatch(
|
|
333
|
+
dispatch(addNotification({
|
|
348
334
|
message: {
|
|
349
335
|
key: 'ui.toast.onFailToPersist',
|
|
350
336
|
details: error
|
|
@@ -356,14 +342,14 @@ function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|
|
356
342
|
}
|
|
357
343
|
};
|
|
358
344
|
}
|
|
359
|
-
function updateUnpublishedEntryStatus(collection, slug, oldStatus, newStatus) {
|
|
345
|
+
export function updateUnpublishedEntryStatus(collection, slug, oldStatus, newStatus) {
|
|
360
346
|
return (dispatch, getState) => {
|
|
361
347
|
if (oldStatus === newStatus) return;
|
|
362
348
|
const state = getState();
|
|
363
|
-
const backend =
|
|
349
|
+
const backend = currentBackend(state.config);
|
|
364
350
|
dispatch(unpublishedEntryStatusChangeRequest(collection, slug));
|
|
365
351
|
backend.updateUnpublishedEntryStatus(collection, slug, newStatus).then(() => {
|
|
366
|
-
dispatch(
|
|
352
|
+
dispatch(addNotification({
|
|
367
353
|
message: {
|
|
368
354
|
key: 'ui.toast.entryUpdated'
|
|
369
355
|
},
|
|
@@ -372,7 +358,7 @@ function updateUnpublishedEntryStatus(collection, slug, oldStatus, newStatus) {
|
|
|
372
358
|
}));
|
|
373
359
|
dispatch(unpublishedEntryStatusChangePersisted(collection, slug, newStatus));
|
|
374
360
|
}).catch(error => {
|
|
375
|
-
dispatch(
|
|
361
|
+
dispatch(addNotification({
|
|
376
362
|
message: {
|
|
377
363
|
key: 'ui.toast.onFailToUpdateStatus',
|
|
378
364
|
details: error
|
|
@@ -384,13 +370,13 @@ function updateUnpublishedEntryStatus(collection, slug, oldStatus, newStatus) {
|
|
|
384
370
|
});
|
|
385
371
|
};
|
|
386
372
|
}
|
|
387
|
-
function deleteUnpublishedEntry(collection, slug) {
|
|
373
|
+
export function deleteUnpublishedEntry(collection, slug) {
|
|
388
374
|
return (dispatch, getState) => {
|
|
389
375
|
const state = getState();
|
|
390
|
-
const backend =
|
|
376
|
+
const backend = currentBackend(state.config);
|
|
391
377
|
dispatch(unpublishedEntryDeleteRequest(collection, slug));
|
|
392
378
|
return backend.deleteUnpublishedEntry(collection, slug).then(() => {
|
|
393
|
-
dispatch(
|
|
379
|
+
dispatch(addNotification({
|
|
394
380
|
message: {
|
|
395
381
|
key: 'ui.toast.onDeleteUnpublishedChanges'
|
|
396
382
|
},
|
|
@@ -399,7 +385,7 @@ function deleteUnpublishedEntry(collection, slug) {
|
|
|
399
385
|
}));
|
|
400
386
|
dispatch(unpublishedEntryDeleted(collection, slug));
|
|
401
387
|
}).catch(error => {
|
|
402
|
-
dispatch(
|
|
388
|
+
dispatch(addNotification({
|
|
403
389
|
message: {
|
|
404
390
|
key: 'ui.toast.onDeleteUnpublishedChanges',
|
|
405
391
|
details: error
|
|
@@ -411,18 +397,18 @@ function deleteUnpublishedEntry(collection, slug) {
|
|
|
411
397
|
});
|
|
412
398
|
};
|
|
413
399
|
}
|
|
414
|
-
function publishUnpublishedEntry(collectionName, slug) {
|
|
400
|
+
export function publishUnpublishedEntry(collectionName, slug) {
|
|
415
401
|
return async (dispatch, getState) => {
|
|
416
402
|
const state = getState();
|
|
417
403
|
const collections = state.collections;
|
|
418
|
-
const backend =
|
|
419
|
-
const entry =
|
|
404
|
+
const backend = currentBackend(state.config);
|
|
405
|
+
const entry = selectUnpublishedEntry(state, collectionName, slug);
|
|
420
406
|
dispatch(unpublishedEntryPublishRequest(collectionName, slug));
|
|
421
407
|
try {
|
|
422
408
|
await backend.publishUnpublishedEntry(entry);
|
|
423
409
|
// re-load media after entry was published
|
|
424
|
-
dispatch(
|
|
425
|
-
dispatch(
|
|
410
|
+
dispatch(loadMedia());
|
|
411
|
+
dispatch(addNotification({
|
|
426
412
|
message: {
|
|
427
413
|
key: 'ui.toast.entryPublished'
|
|
428
414
|
},
|
|
@@ -432,17 +418,17 @@ function publishUnpublishedEntry(collectionName, slug) {
|
|
|
432
418
|
dispatch(unpublishedEntryPublished(collectionName, slug));
|
|
433
419
|
const collection = collections.get(collectionName);
|
|
434
420
|
if (collection.has('nested')) {
|
|
435
|
-
dispatch(
|
|
436
|
-
const newSlug =
|
|
437
|
-
|
|
438
|
-
if (slug !== newSlug &&
|
|
439
|
-
|
|
421
|
+
dispatch(loadEntries(collection));
|
|
422
|
+
const newSlug = slugFromCustomPath(collection, entry.get('path'));
|
|
423
|
+
loadEntry(collection, newSlug);
|
|
424
|
+
if (slug !== newSlug && selectEditingDraft(state.entryDraft)) {
|
|
425
|
+
navigateToEntry(collection.get('name'), newSlug);
|
|
440
426
|
}
|
|
441
427
|
} else {
|
|
442
|
-
return dispatch(
|
|
428
|
+
return dispatch(loadEntry(collection, slug));
|
|
443
429
|
}
|
|
444
430
|
} catch (error) {
|
|
445
|
-
dispatch(
|
|
431
|
+
dispatch(addNotification({
|
|
446
432
|
message: {
|
|
447
433
|
key: 'ui.toast.onFailToPublishEntry',
|
|
448
434
|
details: error
|
|
@@ -454,25 +440,25 @@ function publishUnpublishedEntry(collectionName, slug) {
|
|
|
454
440
|
}
|
|
455
441
|
};
|
|
456
442
|
}
|
|
457
|
-
function unpublishPublishedEntry(collection, slug) {
|
|
443
|
+
export function unpublishPublishedEntry(collection, slug) {
|
|
458
444
|
return (dispatch, getState) => {
|
|
459
445
|
const state = getState();
|
|
460
|
-
const backend =
|
|
461
|
-
const entry =
|
|
462
|
-
const entryDraft =
|
|
446
|
+
const backend = currentBackend(state.config);
|
|
447
|
+
const entry = selectEntry(state, collection.get('name'), slug);
|
|
448
|
+
const entryDraft = Map().set('entry', entry);
|
|
463
449
|
dispatch(unpublishedEntryPersisting(collection, slug));
|
|
464
450
|
return backend.deleteEntry(state, collection, slug).then(() => backend.persistEntry({
|
|
465
451
|
config: state.config,
|
|
466
452
|
collection,
|
|
467
453
|
entryDraft,
|
|
468
454
|
assetProxies: [],
|
|
469
|
-
usedSlugs:
|
|
470
|
-
status:
|
|
455
|
+
usedSlugs: List(),
|
|
456
|
+
status: status.get('PENDING_PUBLISH')
|
|
471
457
|
})).then(() => {
|
|
472
458
|
dispatch(unpublishedEntryPersisted(collection, entry));
|
|
473
|
-
dispatch(
|
|
459
|
+
dispatch(entryDeleted(collection, slug));
|
|
474
460
|
dispatch(loadUnpublishedEntry(collection, slug));
|
|
475
|
-
dispatch(
|
|
461
|
+
dispatch(addNotification({
|
|
476
462
|
message: {
|
|
477
463
|
key: 'ui.toast.entryUnpublished'
|
|
478
464
|
},
|
|
@@ -480,7 +466,7 @@ function unpublishPublishedEntry(collection, slug) {
|
|
|
480
466
|
dismissAfter: 4000
|
|
481
467
|
}));
|
|
482
468
|
}).catch(error => {
|
|
483
|
-
dispatch(
|
|
469
|
+
dispatch(addNotification({
|
|
484
470
|
message: {
|
|
485
471
|
key: 'ui.toast.onFailToUnpublishEntry',
|
|
486
472
|
details: error
|