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,71 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MEDIA_REMOVE_INSERTED = exports.MEDIA_PERSIST_SUCCESS = exports.MEDIA_PERSIST_REQUEST = exports.MEDIA_PERSIST_FAILURE = exports.MEDIA_LOAD_SUCCESS = exports.MEDIA_LOAD_REQUEST = exports.MEDIA_LOAD_FAILURE = exports.MEDIA_LIBRARY_OPEN = exports.MEDIA_LIBRARY_CREATE = exports.MEDIA_LIBRARY_CLOSE = exports.MEDIA_INSERT = exports.MEDIA_DISPLAY_URL_SUCCESS = exports.MEDIA_DISPLAY_URL_REQUEST = exports.MEDIA_DISPLAY_URL_FAILURE = exports.MEDIA_DELETE_SUCCESS = exports.MEDIA_DELETE_REQUEST = exports.MEDIA_DELETE_FAILURE = void 0;
|
|
7
|
-
exports.clearMediaControl = clearMediaControl;
|
|
8
|
-
exports.closeMediaLibrary = closeMediaLibrary;
|
|
9
|
-
exports.createMediaLibrary = createMediaLibrary;
|
|
10
|
-
exports.deleteMedia = deleteMedia;
|
|
11
|
-
exports.getMediaDisplayURL = getMediaDisplayURL;
|
|
12
|
-
exports.getMediaFile = getMediaFile;
|
|
13
|
-
exports.insertMedia = insertMedia;
|
|
14
|
-
exports.loadMedia = loadMedia;
|
|
15
|
-
exports.loadMediaDisplayURL = loadMediaDisplayURL;
|
|
16
|
-
exports.mediaDeleteFailed = mediaDeleteFailed;
|
|
17
|
-
exports.mediaDeleted = mediaDeleted;
|
|
18
|
-
exports.mediaDeleting = mediaDeleting;
|
|
19
|
-
exports.mediaDisplayURLFailure = mediaDisplayURLFailure;
|
|
20
|
-
exports.mediaDisplayURLRequest = mediaDisplayURLRequest;
|
|
21
|
-
exports.mediaDisplayURLSuccess = mediaDisplayURLSuccess;
|
|
22
|
-
exports.mediaLoadFailed = mediaLoadFailed;
|
|
23
|
-
exports.mediaLoaded = mediaLoaded;
|
|
24
|
-
exports.mediaLoading = mediaLoading;
|
|
25
|
-
exports.mediaPersistFailed = mediaPersistFailed;
|
|
26
|
-
exports.mediaPersisted = mediaPersisted;
|
|
27
|
-
exports.mediaPersisting = mediaPersisting;
|
|
28
|
-
exports.openMediaLibrary = openMediaLibrary;
|
|
29
|
-
exports.persistMedia = persistMedia;
|
|
30
|
-
exports.removeInsertedMedia = removeInsertedMedia;
|
|
31
|
-
exports.removeMediaControl = removeMediaControl;
|
|
32
|
-
exports.waitForMediaLibraryToLoad = waitForMediaLibraryToLoad;
|
|
33
|
-
var _immutable = require("immutable");
|
|
34
|
-
var _decapCmsLibUtil = require("decap-cms-lib-util");
|
|
35
|
-
var _backend = require("../backend");
|
|
36
|
-
var _AssetProxy = require("../valueObjects/AssetProxy");
|
|
37
|
-
var _reducers = require("../reducers");
|
|
38
|
-
var _entries = require("../reducers/entries");
|
|
39
|
-
var _mediaLibrary = require("../reducers/mediaLibrary");
|
|
40
|
-
var _integrations = require("../integrations");
|
|
41
|
-
var _media = require("./media");
|
|
42
|
-
var _entries2 = require("./entries");
|
|
43
|
-
var _urlHelper = require("../lib/urlHelper");
|
|
44
|
-
var _waitUntil = require("./waitUntil");
|
|
45
|
-
var _notifications = require("./notifications");
|
|
46
1
|
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; }
|
|
47
2
|
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; }
|
|
48
3
|
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; }
|
|
49
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
50
5
|
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); }
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
6
|
+
import { Map } from 'immutable';
|
|
7
|
+
import { basename, getBlobSHA } from 'decap-cms-lib-util';
|
|
8
|
+
import { currentBackend } from '../backend';
|
|
9
|
+
import { createAssetProxy } from '../valueObjects/AssetProxy';
|
|
10
|
+
import { selectIntegration } from '../reducers';
|
|
11
|
+
import { selectMediaFilePath, selectMediaFilePublicPath, selectEditingDraft } from '../reducers/entries';
|
|
12
|
+
import { selectMediaDisplayURL, selectMediaFiles } from '../reducers/mediaLibrary';
|
|
13
|
+
import { getIntegrationProvider } from '../integrations';
|
|
14
|
+
import { addAsset, removeAsset } from './media';
|
|
15
|
+
import { addDraftEntryMediaFile, removeDraftEntryMediaFile } from './entries';
|
|
16
|
+
import { sanitizeSlug } from '../lib/urlHelper';
|
|
17
|
+
import { waitUntilWithTimeout } from './waitUntil';
|
|
18
|
+
import { addNotification } from './notifications';
|
|
19
|
+
export const MEDIA_LIBRARY_OPEN = 'MEDIA_LIBRARY_OPEN';
|
|
20
|
+
export const MEDIA_LIBRARY_CLOSE = 'MEDIA_LIBRARY_CLOSE';
|
|
21
|
+
export const MEDIA_LIBRARY_CREATE = 'MEDIA_LIBRARY_CREATE';
|
|
22
|
+
export const MEDIA_INSERT = 'MEDIA_INSERT';
|
|
23
|
+
export const MEDIA_REMOVE_INSERTED = 'MEDIA_REMOVE_INSERTED';
|
|
24
|
+
export const MEDIA_LOAD_REQUEST = 'MEDIA_LOAD_REQUEST';
|
|
25
|
+
export const MEDIA_LOAD_SUCCESS = 'MEDIA_LOAD_SUCCESS';
|
|
26
|
+
export const MEDIA_LOAD_FAILURE = 'MEDIA_LOAD_FAILURE';
|
|
27
|
+
export const MEDIA_PERSIST_REQUEST = 'MEDIA_PERSIST_REQUEST';
|
|
28
|
+
export const MEDIA_PERSIST_SUCCESS = 'MEDIA_PERSIST_SUCCESS';
|
|
29
|
+
export const MEDIA_PERSIST_FAILURE = 'MEDIA_PERSIST_FAILURE';
|
|
30
|
+
export const MEDIA_DELETE_REQUEST = 'MEDIA_DELETE_REQUEST';
|
|
31
|
+
export const MEDIA_DELETE_SUCCESS = 'MEDIA_DELETE_SUCCESS';
|
|
32
|
+
export const MEDIA_DELETE_FAILURE = 'MEDIA_DELETE_FAILURE';
|
|
33
|
+
export const MEDIA_DISPLAY_URL_REQUEST = 'MEDIA_DISPLAY_URL_REQUEST';
|
|
34
|
+
export const MEDIA_DISPLAY_URL_SUCCESS = 'MEDIA_DISPLAY_URL_SUCCESS';
|
|
35
|
+
export const MEDIA_DISPLAY_URL_FAILURE = 'MEDIA_DISPLAY_URL_FAILURE';
|
|
36
|
+
export function createMediaLibrary(instance) {
|
|
69
37
|
const api = {
|
|
70
38
|
show: instance.show || (() => undefined),
|
|
71
39
|
hide: instance.hide || (() => undefined),
|
|
@@ -78,7 +46,7 @@ function createMediaLibrary(instance) {
|
|
|
78
46
|
payload: api
|
|
79
47
|
};
|
|
80
48
|
}
|
|
81
|
-
function clearMediaControl(id) {
|
|
49
|
+
export function clearMediaControl(id) {
|
|
82
50
|
return (_dispatch, getState) => {
|
|
83
51
|
const state = getState();
|
|
84
52
|
const mediaLibrary = state.mediaLibrary.get('externalLibrary');
|
|
@@ -89,7 +57,7 @@ function clearMediaControl(id) {
|
|
|
89
57
|
}
|
|
90
58
|
};
|
|
91
59
|
}
|
|
92
|
-
function removeMediaControl(id) {
|
|
60
|
+
export function removeMediaControl(id) {
|
|
93
61
|
return (_dispatch, getState) => {
|
|
94
62
|
const state = getState();
|
|
95
63
|
const mediaLibrary = state.mediaLibrary.get('externalLibrary');
|
|
@@ -100,7 +68,7 @@ function removeMediaControl(id) {
|
|
|
100
68
|
}
|
|
101
69
|
};
|
|
102
70
|
}
|
|
103
|
-
function openMediaLibrary(payload = {}) {
|
|
71
|
+
export function openMediaLibrary(payload = {}) {
|
|
104
72
|
return (dispatch, getState) => {
|
|
105
73
|
const state = getState();
|
|
106
74
|
const mediaLibrary = state.mediaLibrary.get('externalLibrary');
|
|
@@ -108,7 +76,7 @@ function openMediaLibrary(payload = {}) {
|
|
|
108
76
|
const {
|
|
109
77
|
controlID: id,
|
|
110
78
|
value,
|
|
111
|
-
config =
|
|
79
|
+
config = Map(),
|
|
112
80
|
allowMultiple,
|
|
113
81
|
forImage
|
|
114
82
|
} = payload;
|
|
@@ -123,7 +91,7 @@ function openMediaLibrary(payload = {}) {
|
|
|
123
91
|
dispatch(mediaLibraryOpened(payload));
|
|
124
92
|
};
|
|
125
93
|
}
|
|
126
|
-
function closeMediaLibrary() {
|
|
94
|
+
export function closeMediaLibrary() {
|
|
127
95
|
return (dispatch, getState) => {
|
|
128
96
|
const state = getState();
|
|
129
97
|
const mediaLibrary = state.mediaLibrary.get('externalLibrary');
|
|
@@ -133,7 +101,7 @@ function closeMediaLibrary() {
|
|
|
133
101
|
dispatch(mediaLibraryClosed());
|
|
134
102
|
};
|
|
135
103
|
}
|
|
136
|
-
function insertMedia(mediaPath, field) {
|
|
104
|
+
export function insertMedia(mediaPath, field) {
|
|
137
105
|
return (dispatch, getState) => {
|
|
138
106
|
const state = getState();
|
|
139
107
|
const config = state.config;
|
|
@@ -141,14 +109,14 @@ function insertMedia(mediaPath, field) {
|
|
|
141
109
|
const collectionName = state.entryDraft.getIn(['entry', 'collection']);
|
|
142
110
|
const collection = state.collections.get(collectionName);
|
|
143
111
|
if (Array.isArray(mediaPath)) {
|
|
144
|
-
mediaPath = mediaPath.map(path =>
|
|
112
|
+
mediaPath = mediaPath.map(path => selectMediaFilePublicPath(config, collection, path, entry, field));
|
|
145
113
|
} else {
|
|
146
|
-
mediaPath =
|
|
114
|
+
mediaPath = selectMediaFilePublicPath(config, collection, mediaPath, entry, field);
|
|
147
115
|
}
|
|
148
116
|
dispatch(mediaInserted(mediaPath));
|
|
149
117
|
};
|
|
150
118
|
}
|
|
151
|
-
function removeInsertedMedia(controlID) {
|
|
119
|
+
export function removeInsertedMedia(controlID) {
|
|
152
120
|
return {
|
|
153
121
|
type: MEDIA_REMOVE_INSERTED,
|
|
154
122
|
payload: {
|
|
@@ -156,7 +124,7 @@ function removeInsertedMedia(controlID) {
|
|
|
156
124
|
}
|
|
157
125
|
};
|
|
158
126
|
}
|
|
159
|
-
function loadMedia(opts = {}) {
|
|
127
|
+
export function loadMedia(opts = {}) {
|
|
160
128
|
const {
|
|
161
129
|
delay = 0,
|
|
162
130
|
query = '',
|
|
@@ -165,10 +133,10 @@ function loadMedia(opts = {}) {
|
|
|
165
133
|
} = opts;
|
|
166
134
|
return async (dispatch, getState) => {
|
|
167
135
|
const state = getState();
|
|
168
|
-
const backend =
|
|
169
|
-
const integration =
|
|
136
|
+
const backend = currentBackend(state.config);
|
|
137
|
+
const integration = selectIntegration(state, null, 'assetStore');
|
|
170
138
|
if (integration) {
|
|
171
|
-
const provider =
|
|
139
|
+
const provider = getIntegrationProvider(state.integrations, backend.getToken, integration);
|
|
172
140
|
dispatch(mediaLoading(page));
|
|
173
141
|
try {
|
|
174
142
|
const files = await provider.retrieve(query, page, privateUpload);
|
|
@@ -215,7 +183,7 @@ function createMediaFileFromAsset({
|
|
|
215
183
|
}) {
|
|
216
184
|
const mediaFile = {
|
|
217
185
|
id,
|
|
218
|
-
name:
|
|
186
|
+
name: basename(assetProxy.path),
|
|
219
187
|
displayURL: assetProxy.url,
|
|
220
188
|
draft,
|
|
221
189
|
file,
|
|
@@ -226,19 +194,19 @@ function createMediaFileFromAsset({
|
|
|
226
194
|
};
|
|
227
195
|
return mediaFile;
|
|
228
196
|
}
|
|
229
|
-
function persistMedia(file, opts = {}) {
|
|
197
|
+
export function persistMedia(file, opts = {}) {
|
|
230
198
|
const {
|
|
231
199
|
privateUpload,
|
|
232
200
|
field
|
|
233
201
|
} = opts;
|
|
234
202
|
return async (dispatch, getState) => {
|
|
235
203
|
const state = getState();
|
|
236
|
-
const backend =
|
|
237
|
-
const integration =
|
|
238
|
-
const files =
|
|
239
|
-
const fileName =
|
|
204
|
+
const backend = currentBackend(state.config);
|
|
205
|
+
const integration = selectIntegration(state, null, 'assetStore');
|
|
206
|
+
const files = selectMediaFiles(state, field);
|
|
207
|
+
const fileName = sanitizeSlug(file.name.toLowerCase(), state.config.slug);
|
|
240
208
|
const existingFile = files.find(existingFile => existingFile.name.toLowerCase() === fileName);
|
|
241
|
-
const editingDraft =
|
|
209
|
+
const editingDraft = selectEditingDraft(state.entryDraft);
|
|
242
210
|
|
|
243
211
|
/**
|
|
244
212
|
* Check for existing files of the same name before persisting. If no asset
|
|
@@ -262,14 +230,14 @@ function persistMedia(file, opts = {}) {
|
|
|
262
230
|
let assetProxy;
|
|
263
231
|
if (integration) {
|
|
264
232
|
try {
|
|
265
|
-
const provider =
|
|
233
|
+
const provider = getIntegrationProvider(state.integrations, backend.getToken, integration);
|
|
266
234
|
const response = await provider.upload(file, privateUpload);
|
|
267
|
-
assetProxy =
|
|
235
|
+
assetProxy = createAssetProxy({
|
|
268
236
|
url: response.asset.url,
|
|
269
237
|
path: response.asset.url
|
|
270
238
|
});
|
|
271
239
|
} catch (error) {
|
|
272
|
-
assetProxy =
|
|
240
|
+
assetProxy = createAssetProxy({
|
|
273
241
|
file,
|
|
274
242
|
path: fileName
|
|
275
243
|
});
|
|
@@ -279,17 +247,17 @@ function persistMedia(file, opts = {}) {
|
|
|
279
247
|
} else {
|
|
280
248
|
const entry = state.entryDraft.get('entry');
|
|
281
249
|
const collection = state.collections.get(entry === null || entry === void 0 ? void 0 : entry.get('collection'));
|
|
282
|
-
const path =
|
|
283
|
-
assetProxy =
|
|
250
|
+
const path = selectMediaFilePath(state.config, collection, entry, fileName, field);
|
|
251
|
+
assetProxy = createAssetProxy({
|
|
284
252
|
file,
|
|
285
253
|
path,
|
|
286
254
|
field
|
|
287
255
|
});
|
|
288
256
|
}
|
|
289
|
-
dispatch(
|
|
257
|
+
dispatch(addAsset(assetProxy));
|
|
290
258
|
let mediaFile;
|
|
291
259
|
if (integration) {
|
|
292
|
-
const id = await
|
|
260
|
+
const id = await getBlobSHA(file);
|
|
293
261
|
// integration assets are persisted immediately, thus draft is false
|
|
294
262
|
mediaFile = createMediaFileFromAsset({
|
|
295
263
|
id,
|
|
@@ -298,14 +266,14 @@ function persistMedia(file, opts = {}) {
|
|
|
298
266
|
draft: false
|
|
299
267
|
});
|
|
300
268
|
} else if (editingDraft) {
|
|
301
|
-
const id = await
|
|
269
|
+
const id = await getBlobSHA(file);
|
|
302
270
|
mediaFile = createMediaFileFromAsset({
|
|
303
271
|
id,
|
|
304
272
|
file,
|
|
305
273
|
assetProxy,
|
|
306
274
|
draft: editingDraft
|
|
307
275
|
});
|
|
308
|
-
return dispatch(
|
|
276
|
+
return dispatch(addDraftEntryMediaFile(mediaFile));
|
|
309
277
|
} else {
|
|
310
278
|
mediaFile = await backend.persistMedia(state.config, assetProxy);
|
|
311
279
|
}
|
|
@@ -314,7 +282,7 @@ function persistMedia(file, opts = {}) {
|
|
|
314
282
|
}));
|
|
315
283
|
} catch (error) {
|
|
316
284
|
console.error(error);
|
|
317
|
-
dispatch(
|
|
285
|
+
dispatch(addNotification({
|
|
318
286
|
message: `Failed to persist media: ${error}`,
|
|
319
287
|
type: 'error',
|
|
320
288
|
dismissAfter: 8000
|
|
@@ -325,16 +293,16 @@ function persistMedia(file, opts = {}) {
|
|
|
325
293
|
}
|
|
326
294
|
};
|
|
327
295
|
}
|
|
328
|
-
function deleteMedia(file, opts = {}) {
|
|
296
|
+
export function deleteMedia(file, opts = {}) {
|
|
329
297
|
const {
|
|
330
298
|
privateUpload
|
|
331
299
|
} = opts;
|
|
332
300
|
return async (dispatch, getState) => {
|
|
333
301
|
const state = getState();
|
|
334
|
-
const backend =
|
|
335
|
-
const integration =
|
|
302
|
+
const backend = currentBackend(state.config);
|
|
303
|
+
const integration = selectIntegration(state, null, 'assetStore');
|
|
336
304
|
if (integration) {
|
|
337
|
-
const provider =
|
|
305
|
+
const provider = getIntegrationProvider(state.integrations, backend.getToken, integration);
|
|
338
306
|
dispatch(mediaDeleting());
|
|
339
307
|
try {
|
|
340
308
|
await provider.delete(file.id);
|
|
@@ -343,7 +311,7 @@ function deleteMedia(file, opts = {}) {
|
|
|
343
311
|
}));
|
|
344
312
|
} catch (error) {
|
|
345
313
|
console.error(error);
|
|
346
|
-
dispatch(
|
|
314
|
+
dispatch(addNotification({
|
|
347
315
|
message: `Failed to delete media: ${error.message}`,
|
|
348
316
|
type: 'error',
|
|
349
317
|
dismissAfter: 8000
|
|
@@ -355,25 +323,25 @@ function deleteMedia(file, opts = {}) {
|
|
|
355
323
|
}
|
|
356
324
|
try {
|
|
357
325
|
if (file.draft) {
|
|
358
|
-
dispatch(
|
|
359
|
-
dispatch(
|
|
326
|
+
dispatch(removeAsset(file.path));
|
|
327
|
+
dispatch(removeDraftEntryMediaFile({
|
|
360
328
|
id: file.id
|
|
361
329
|
}));
|
|
362
330
|
} else {
|
|
363
|
-
const editingDraft =
|
|
331
|
+
const editingDraft = selectEditingDraft(state.entryDraft);
|
|
364
332
|
dispatch(mediaDeleting());
|
|
365
|
-
dispatch(
|
|
333
|
+
dispatch(removeAsset(file.path));
|
|
366
334
|
await backend.deleteMedia(state.config, file.path);
|
|
367
335
|
dispatch(mediaDeleted(file));
|
|
368
336
|
if (editingDraft) {
|
|
369
|
-
dispatch(
|
|
337
|
+
dispatch(removeDraftEntryMediaFile({
|
|
370
338
|
id: file.id
|
|
371
339
|
}));
|
|
372
340
|
}
|
|
373
341
|
}
|
|
374
342
|
} catch (error) {
|
|
375
343
|
console.error(error);
|
|
376
|
-
dispatch(
|
|
344
|
+
dispatch(addNotification({
|
|
377
345
|
message: `Failed to delete media: ${error.message}`,
|
|
378
346
|
type: 'error',
|
|
379
347
|
dismissAfter: 8000
|
|
@@ -382,8 +350,8 @@ function deleteMedia(file, opts = {}) {
|
|
|
382
350
|
}
|
|
383
351
|
};
|
|
384
352
|
}
|
|
385
|
-
async function getMediaFile(state, path) {
|
|
386
|
-
const backend =
|
|
353
|
+
export async function getMediaFile(state, path) {
|
|
354
|
+
const backend = currentBackend(state.config);
|
|
387
355
|
const {
|
|
388
356
|
url
|
|
389
357
|
} = await backend.getMediaFile(path);
|
|
@@ -391,14 +359,14 @@ async function getMediaFile(state, path) {
|
|
|
391
359
|
url
|
|
392
360
|
};
|
|
393
361
|
}
|
|
394
|
-
function loadMediaDisplayURL(file) {
|
|
362
|
+
export function loadMediaDisplayURL(file) {
|
|
395
363
|
return async (dispatch, getState) => {
|
|
396
364
|
const {
|
|
397
365
|
displayURL,
|
|
398
366
|
id
|
|
399
367
|
} = file;
|
|
400
368
|
const state = getState();
|
|
401
|
-
const displayURLState =
|
|
369
|
+
const displayURLState = selectMediaDisplayURL(state, id);
|
|
402
370
|
if (!id || !displayURL || displayURLState.get('url') || displayURLState.get('isFetching') || displayURLState.get('err')) {
|
|
403
371
|
return Promise.resolve();
|
|
404
372
|
}
|
|
@@ -408,7 +376,7 @@ function loadMediaDisplayURL(file) {
|
|
|
408
376
|
return;
|
|
409
377
|
}
|
|
410
378
|
try {
|
|
411
|
-
const backend =
|
|
379
|
+
const backend = currentBackend(state.config);
|
|
412
380
|
dispatch(mediaDisplayURLRequest(id));
|
|
413
381
|
const newURL = await backend.getMediaDisplayURL(displayURL);
|
|
414
382
|
if (newURL) {
|
|
@@ -441,7 +409,7 @@ function mediaInserted(mediaPath) {
|
|
|
441
409
|
}
|
|
442
410
|
};
|
|
443
411
|
}
|
|
444
|
-
function mediaLoading(page) {
|
|
412
|
+
export function mediaLoading(page) {
|
|
445
413
|
return {
|
|
446
414
|
type: MEDIA_LOAD_REQUEST,
|
|
447
415
|
payload: {
|
|
@@ -449,7 +417,7 @@ function mediaLoading(page) {
|
|
|
449
417
|
}
|
|
450
418
|
};
|
|
451
419
|
}
|
|
452
|
-
function mediaLoaded(files, opts = {}) {
|
|
420
|
+
export function mediaLoaded(files, opts = {}) {
|
|
453
421
|
return {
|
|
454
422
|
type: MEDIA_LOAD_SUCCESS,
|
|
455
423
|
payload: _objectSpread({
|
|
@@ -457,7 +425,7 @@ function mediaLoaded(files, opts = {}) {
|
|
|
457
425
|
}, opts)
|
|
458
426
|
};
|
|
459
427
|
}
|
|
460
|
-
function mediaLoadFailed(opts = {}) {
|
|
428
|
+
export function mediaLoadFailed(opts = {}) {
|
|
461
429
|
const {
|
|
462
430
|
privateUpload
|
|
463
431
|
} = opts;
|
|
@@ -468,12 +436,12 @@ function mediaLoadFailed(opts = {}) {
|
|
|
468
436
|
}
|
|
469
437
|
};
|
|
470
438
|
}
|
|
471
|
-
function mediaPersisting() {
|
|
439
|
+
export function mediaPersisting() {
|
|
472
440
|
return {
|
|
473
441
|
type: MEDIA_PERSIST_REQUEST
|
|
474
442
|
};
|
|
475
443
|
}
|
|
476
|
-
function mediaPersisted(file, opts = {}) {
|
|
444
|
+
export function mediaPersisted(file, opts = {}) {
|
|
477
445
|
const {
|
|
478
446
|
privateUpload
|
|
479
447
|
} = opts;
|
|
@@ -485,7 +453,7 @@ function mediaPersisted(file, opts = {}) {
|
|
|
485
453
|
}
|
|
486
454
|
};
|
|
487
455
|
}
|
|
488
|
-
function mediaPersistFailed(opts = {}) {
|
|
456
|
+
export function mediaPersistFailed(opts = {}) {
|
|
489
457
|
const {
|
|
490
458
|
privateUpload
|
|
491
459
|
} = opts;
|
|
@@ -496,12 +464,12 @@ function mediaPersistFailed(opts = {}) {
|
|
|
496
464
|
}
|
|
497
465
|
};
|
|
498
466
|
}
|
|
499
|
-
function mediaDeleting() {
|
|
467
|
+
export function mediaDeleting() {
|
|
500
468
|
return {
|
|
501
469
|
type: MEDIA_DELETE_REQUEST
|
|
502
470
|
};
|
|
503
471
|
}
|
|
504
|
-
function mediaDeleted(file, opts = {}) {
|
|
472
|
+
export function mediaDeleted(file, opts = {}) {
|
|
505
473
|
const {
|
|
506
474
|
privateUpload
|
|
507
475
|
} = opts;
|
|
@@ -513,7 +481,7 @@ function mediaDeleted(file, opts = {}) {
|
|
|
513
481
|
}
|
|
514
482
|
};
|
|
515
483
|
}
|
|
516
|
-
function mediaDeleteFailed(opts = {}) {
|
|
484
|
+
export function mediaDeleteFailed(opts = {}) {
|
|
517
485
|
const {
|
|
518
486
|
privateUpload
|
|
519
487
|
} = opts;
|
|
@@ -524,7 +492,7 @@ function mediaDeleteFailed(opts = {}) {
|
|
|
524
492
|
}
|
|
525
493
|
};
|
|
526
494
|
}
|
|
527
|
-
function mediaDisplayURLRequest(key) {
|
|
495
|
+
export function mediaDisplayURLRequest(key) {
|
|
528
496
|
return {
|
|
529
497
|
type: MEDIA_DISPLAY_URL_REQUEST,
|
|
530
498
|
payload: {
|
|
@@ -532,7 +500,7 @@ function mediaDisplayURLRequest(key) {
|
|
|
532
500
|
}
|
|
533
501
|
};
|
|
534
502
|
}
|
|
535
|
-
function mediaDisplayURLSuccess(key, url) {
|
|
503
|
+
export function mediaDisplayURLSuccess(key, url) {
|
|
536
504
|
return {
|
|
537
505
|
type: MEDIA_DISPLAY_URL_SUCCESS,
|
|
538
506
|
payload: {
|
|
@@ -541,7 +509,7 @@ function mediaDisplayURLSuccess(key, url) {
|
|
|
541
509
|
}
|
|
542
510
|
};
|
|
543
511
|
}
|
|
544
|
-
function mediaDisplayURLFailure(key, err) {
|
|
512
|
+
export function mediaDisplayURLFailure(key, err) {
|
|
545
513
|
return {
|
|
546
514
|
type: MEDIA_DISPLAY_URL_FAILURE,
|
|
547
515
|
payload: {
|
|
@@ -550,9 +518,9 @@ function mediaDisplayURLFailure(key, err) {
|
|
|
550
518
|
}
|
|
551
519
|
};
|
|
552
520
|
}
|
|
553
|
-
async function waitForMediaLibraryToLoad(dispatch, state) {
|
|
521
|
+
export async function waitForMediaLibraryToLoad(dispatch, state) {
|
|
554
522
|
if (state.mediaLibrary.get('isLoading') !== false && !state.mediaLibrary.get('externalLibrary')) {
|
|
555
|
-
await
|
|
523
|
+
await waitUntilWithTimeout(dispatch, resolve => ({
|
|
556
524
|
predicate: ({
|
|
557
525
|
type
|
|
558
526
|
}) => type === MEDIA_LOAD_SUCCESS || type === MEDIA_LOAD_FAILURE,
|
|
@@ -560,8 +528,8 @@ async function waitForMediaLibraryToLoad(dispatch, state) {
|
|
|
560
528
|
}));
|
|
561
529
|
}
|
|
562
530
|
}
|
|
563
|
-
async function getMediaDisplayURL(dispatch, state, file) {
|
|
564
|
-
const displayURLState =
|
|
531
|
+
export async function getMediaDisplayURL(dispatch, state, file) {
|
|
532
|
+
const displayURLState = selectMediaDisplayURL(state, file.id);
|
|
565
533
|
let url;
|
|
566
534
|
if (displayURLState.get('url')) {
|
|
567
535
|
// url was already loaded
|
|
@@ -572,7 +540,7 @@ async function getMediaDisplayURL(dispatch, state, file) {
|
|
|
572
540
|
} else {
|
|
573
541
|
var _await$promise;
|
|
574
542
|
const key = file.id;
|
|
575
|
-
const promise =
|
|
543
|
+
const promise = waitUntilWithTimeout(dispatch, resolve => ({
|
|
576
544
|
predicate: ({
|
|
577
545
|
type,
|
|
578
546
|
payload
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NOTIFICATION_SEND = exports.NOTIFICATION_DISMISS = exports.NOTIFICATIONS_CLEAR = void 0;
|
|
7
|
-
exports.addNotification = addNotification;
|
|
8
|
-
exports.clearNotifications = clearNotifications;
|
|
9
|
-
exports.dismissNotification = dismissNotification;
|
|
10
|
-
const NOTIFICATION_SEND = exports.NOTIFICATION_SEND = 'NOTIFICATION_SEND';
|
|
11
|
-
const NOTIFICATION_DISMISS = exports.NOTIFICATION_DISMISS = 'NOTIFICATION_DISMISS';
|
|
12
|
-
const NOTIFICATIONS_CLEAR = exports.NOTIFICATIONS_CLEAR = 'NOTIFICATION_CLEAR';
|
|
1
|
+
export const NOTIFICATION_SEND = 'NOTIFICATION_SEND';
|
|
2
|
+
export const NOTIFICATION_DISMISS = 'NOTIFICATION_DISMISS';
|
|
3
|
+
export const NOTIFICATIONS_CLEAR = 'NOTIFICATION_CLEAR';
|
|
13
4
|
function addNotification(notification) {
|
|
14
5
|
return {
|
|
15
6
|
type: NOTIFICATION_SEND,
|
|
@@ -26,4 +17,5 @@ function clearNotifications() {
|
|
|
26
17
|
return {
|
|
27
18
|
type: NOTIFICATIONS_CLEAR
|
|
28
19
|
};
|
|
29
|
-
}
|
|
20
|
+
}
|
|
21
|
+
export { addNotification, dismissNotification, clearNotifications };
|