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.
Files changed (141) hide show
  1. package/dist/decap-cms-core.js +10 -10
  2. package/dist/decap-cms-core.js.map +1 -1
  3. package/dist/esm/actions/auth.js +22 -37
  4. package/dist/esm/actions/collections.js +9 -17
  5. package/dist/esm/actions/config.js +58 -74
  6. package/dist/esm/actions/deploys.js +10 -17
  7. package/dist/esm/actions/editorialWorkflow.js +87 -101
  8. package/dist/esm/actions/entries.js +161 -211
  9. package/dist/esm/actions/media.js +31 -46
  10. package/dist/esm/actions/mediaLibrary.js +94 -126
  11. package/dist/esm/actions/notifications.js +5 -13
  12. package/dist/esm/actions/search.js +30 -47
  13. package/dist/esm/actions/status.js +13 -23
  14. package/dist/esm/actions/waitUntil.js +4 -11
  15. package/dist/esm/backend.js +132 -148
  16. package/dist/esm/bootstrap.js +37 -44
  17. package/dist/esm/components/App/App.js +82 -89
  18. package/dist/esm/components/App/Header.js +46 -52
  19. package/dist/esm/components/App/NotFoundPage.js +11 -18
  20. package/dist/esm/components/Collection/Collection.js +55 -63
  21. package/dist/esm/components/Collection/CollectionControls.js +15 -22
  22. package/dist/esm/components/Collection/CollectionSearch.js +35 -42
  23. package/dist/esm/components/Collection/CollectionTop.js +23 -30
  24. package/dist/esm/components/Collection/ControlButton.js +10 -16
  25. package/dist/esm/components/Collection/Entries/Entries.js +24 -31
  26. package/dist/esm/components/Collection/Entries/EntriesCollection.js +60 -63
  27. package/dist/esm/components/Collection/Entries/EntriesSearch.js +26 -33
  28. package/dist/esm/components/Collection/Entries/EntryCard.js +38 -45
  29. package/dist/esm/components/Collection/Entries/EntryListing.js +24 -32
  30. package/dist/esm/components/Collection/FilterControl.js +9 -16
  31. package/dist/esm/components/Collection/GroupControl.js +9 -16
  32. package/dist/esm/components/Collection/NestedCollection.js +56 -64
  33. package/dist/esm/components/Collection/Sidebar.js +36 -43
  34. package/dist/esm/components/Collection/SortControl.js +19 -26
  35. package/dist/esm/components/Collection/ViewStyleControl.js +17 -24
  36. package/dist/esm/components/Editor/Editor.js +100 -108
  37. package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +105 -112
  38. package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +68 -62
  39. package/dist/esm/components/Editor/EditorControlPane/Widget.js +87 -73
  40. package/dist/esm/components/Editor/EditorInterface.js +95 -98
  41. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +13 -21
  42. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +64 -23
  43. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +94 -78
  44. package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +9 -16
  45. package/dist/esm/components/Editor/EditorToolbar.js +133 -140
  46. package/dist/esm/components/Editor/withWorkflow.js +15 -22
  47. package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +9 -16
  48. package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +9 -16
  49. package/dist/esm/components/EditorWidgets/index.js +4 -7
  50. package/dist/esm/components/MediaLibrary/EmptyMessage.js +12 -19
  51. package/dist/esm/components/MediaLibrary/MediaLibrary.js +55 -62
  52. package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +28 -35
  53. package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +36 -43
  54. package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +50 -57
  55. package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +16 -23
  56. package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +59 -64
  57. package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +18 -25
  58. package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +39 -46
  59. package/dist/esm/components/UI/DragDrop.js +21 -30
  60. package/dist/esm/components/UI/ErrorBoundary.js +35 -43
  61. package/dist/esm/components/UI/FileUploadButton.js +11 -18
  62. package/dist/esm/components/UI/Modal.js +19 -26
  63. package/dist/esm/components/UI/Notifications.js +21 -28
  64. package/dist/esm/components/UI/SettingsDropdown.js +28 -34
  65. package/dist/esm/components/UI/index.js +6 -60
  66. package/dist/esm/components/Workflow/Workflow.js +52 -61
  67. package/dist/esm/components/Workflow/WorkflowCard.js +45 -51
  68. package/dist/esm/components/Workflow/WorkflowList.js +43 -49
  69. package/dist/esm/constants/collectionTypes.js +2 -8
  70. package/dist/esm/constants/collectionViews.js +2 -8
  71. package/dist/esm/constants/commitProps.js +2 -8
  72. package/dist/esm/constants/configSchema.js +23 -27
  73. package/dist/esm/constants/fieldInference.js +8 -15
  74. package/dist/esm/constants/publishModes.js +6 -11
  75. package/dist/esm/constants/validationErrorTypes.js +1 -7
  76. package/dist/esm/formats/formats.js +32 -41
  77. package/dist/esm/formats/frontmatter.js +18 -30
  78. package/dist/esm/formats/helpers.js +1 -7
  79. package/dist/esm/formats/json.js +1 -7
  80. package/dist/esm/formats/toml.js +11 -18
  81. package/dist/esm/formats/yaml.js +7 -14
  82. package/dist/esm/index.js +5 -12
  83. package/dist/esm/integrations/index.js +8 -16
  84. package/dist/esm/integrations/providers/algolia/implementation.js +14 -22
  85. package/dist/esm/integrations/providers/assetStore/implementation.js +10 -18
  86. package/dist/esm/lib/consoleError.js +1 -7
  87. package/dist/esm/lib/formatters.js +34 -47
  88. package/dist/esm/lib/i18n.js +37 -66
  89. package/dist/esm/lib/phrases.js +4 -11
  90. package/dist/esm/lib/registry.js +40 -75
  91. package/dist/esm/lib/serializeEntryValues.js +11 -18
  92. package/dist/esm/lib/textHelper.js +1 -7
  93. package/dist/esm/lib/urlHelper.js +28 -43
  94. package/dist/esm/mediaLibrary.js +12 -16
  95. package/dist/esm/reducers/auth.js +10 -16
  96. package/dist/esm/reducers/collections.js +70 -102
  97. package/dist/esm/reducers/combinedReducer.js +4 -11
  98. package/dist/esm/reducers/config.js +11 -19
  99. package/dist/esm/reducers/cursors.js +12 -18
  100. package/dist/esm/reducers/deploys.js +8 -15
  101. package/dist/esm/reducers/editorialWorkflow.js +37 -47
  102. package/dist/esm/reducers/entries.js +107 -132
  103. package/dist/esm/reducers/entryDraft.js +64 -72
  104. package/dist/esm/reducers/globalUI.js +5 -11
  105. package/dist/esm/reducers/index.js +43 -64
  106. package/dist/esm/reducers/integrations.js +8 -16
  107. package/dist/esm/reducers/mediaLibrary.js +43 -52
  108. package/dist/esm/reducers/medias.js +11 -18
  109. package/dist/esm/reducers/notifications.js +9 -15
  110. package/dist/esm/reducers/search.js +12 -18
  111. package/dist/esm/reducers/status.js +7 -13
  112. package/dist/esm/redux/index.js +7 -13
  113. package/dist/esm/redux/middleware/waitUntilAction.js +3 -10
  114. package/dist/esm/routing/history.js +7 -15
  115. package/dist/esm/types/diacritics.d.js +0 -1
  116. package/dist/esm/types/global.d.js +1 -5
  117. package/dist/esm/types/immutable.js +1 -5
  118. package/dist/esm/types/redux.js +7 -8
  119. package/dist/esm/types/tomlify-j0.4.d.js +0 -1
  120. package/dist/esm/valueObjects/AssetProxy.js +2 -10
  121. package/dist/esm/valueObjects/EditorComponent.js +5 -12
  122. package/dist/esm/valueObjects/Entry.js +3 -10
  123. package/index.d.ts +1 -0
  124. package/package.json +3 -2
  125. package/src/components/Collection/Entries/EntriesCollection.js +21 -10
  126. package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +7 -7
  127. package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +9 -9
  128. package/src/components/Collection/NestedCollection.js +11 -2
  129. package/src/components/Collection/__tests__/NestedCollection.spec.js +3 -0
  130. package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +68 -0
  131. package/src/components/Editor/EditorControlPane/EditorControl.js +0 -3
  132. package/src/components/Editor/EditorControlPane/EditorControlPane.js +21 -8
  133. package/src/components/Editor/EditorControlPane/Widget.js +22 -1
  134. package/src/components/Editor/EditorInterface.js +6 -1
  135. package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +51 -11
  136. package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +33 -1
  137. package/src/constants/configSchema.js +1 -0
  138. package/src/types/redux.ts +1 -1
  139. package/dist/esm/actions/editorControl.js +0 -14
  140. package/dist/esm/reducers/editorComponent.js +0 -1
  141. package/dist/esm/reducers/editorControl.js +0 -17
@@ -1,65 +1,50 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.USE_OPEN_AUTHORING = exports.LOGOUT = exports.AUTH_SUCCESS = exports.AUTH_REQUEST_DONE = exports.AUTH_REQUEST = exports.AUTH_FAILURE = void 0;
7
- exports.authError = authError;
8
- exports.authenticate = authenticate;
9
- exports.authenticateUser = authenticateUser;
10
- exports.authenticating = authenticating;
11
- exports.doneAuthenticating = doneAuthenticating;
12
- exports.loginUser = loginUser;
13
- exports.logout = logout;
14
- exports.logoutUser = logoutUser;
15
- exports.useOpenAuthoring = useOpenAuthoring;
16
- var _backend = require("../backend");
17
- var _notifications = require("./notifications");
18
- const AUTH_REQUEST = exports.AUTH_REQUEST = 'AUTH_REQUEST';
19
- const AUTH_SUCCESS = exports.AUTH_SUCCESS = 'AUTH_SUCCESS';
20
- const AUTH_FAILURE = exports.AUTH_FAILURE = 'AUTH_FAILURE';
21
- const AUTH_REQUEST_DONE = exports.AUTH_REQUEST_DONE = 'AUTH_REQUEST_DONE';
22
- const USE_OPEN_AUTHORING = exports.USE_OPEN_AUTHORING = 'USE_OPEN_AUTHORING';
23
- const LOGOUT = exports.LOGOUT = 'LOGOUT';
24
- function authenticating() {
1
+ import { currentBackend } from '../backend';
2
+ import { addNotification, clearNotifications } from './notifications';
3
+ export const AUTH_REQUEST = 'AUTH_REQUEST';
4
+ export const AUTH_SUCCESS = 'AUTH_SUCCESS';
5
+ export const AUTH_FAILURE = 'AUTH_FAILURE';
6
+ export const AUTH_REQUEST_DONE = 'AUTH_REQUEST_DONE';
7
+ export const USE_OPEN_AUTHORING = 'USE_OPEN_AUTHORING';
8
+ export const LOGOUT = 'LOGOUT';
9
+ export function authenticating() {
25
10
  return {
26
11
  type: AUTH_REQUEST
27
12
  };
28
13
  }
29
- function authenticate(userData) {
14
+ export function authenticate(userData) {
30
15
  return {
31
16
  type: AUTH_SUCCESS,
32
17
  payload: userData
33
18
  };
34
19
  }
35
- function authError(error) {
20
+ export function authError(error) {
36
21
  return {
37
22
  type: AUTH_FAILURE,
38
23
  error: 'Failed to authenticate',
39
24
  payload: error
40
25
  };
41
26
  }
42
- function doneAuthenticating() {
27
+ export function doneAuthenticating() {
43
28
  return {
44
29
  type: AUTH_REQUEST_DONE
45
30
  };
46
31
  }
47
- function useOpenAuthoring() {
32
+ export function useOpenAuthoring() {
48
33
  return {
49
34
  type: USE_OPEN_AUTHORING
50
35
  };
51
36
  }
52
- function logout() {
37
+ export function logout() {
53
38
  return {
54
39
  type: LOGOUT
55
40
  };
56
41
  }
57
42
 
58
43
  // Check if user data token is cached and is valid
59
- function authenticateUser() {
44
+ export function authenticateUser() {
60
45
  return (dispatch, getState) => {
61
46
  const state = getState();
62
- const backend = (0, _backend.currentBackend)(state.config);
47
+ const backend = currentBackend(state.config);
63
48
  dispatch(authenticating());
64
49
  return Promise.resolve(backend.currentUser()).then(user => {
65
50
  if (user) {
@@ -76,10 +61,10 @@ function authenticateUser() {
76
61
  });
77
62
  };
78
63
  }
79
- function loginUser(credentials) {
64
+ export function loginUser(credentials) {
80
65
  return (dispatch, getState) => {
81
66
  const state = getState();
82
- const backend = (0, _backend.currentBackend)(state.config);
67
+ const backend = currentBackend(state.config);
83
68
  dispatch(authenticating());
84
69
  return backend.authenticate(credentials).then(user => {
85
70
  if (user.useOpenAuthoring) {
@@ -88,7 +73,7 @@ function loginUser(credentials) {
88
73
  dispatch(authenticate(user));
89
74
  }).catch(error => {
90
75
  console.error(error);
91
- dispatch((0, _notifications.addNotification)({
76
+ dispatch(addNotification({
92
77
  message: {
93
78
  details: error.message,
94
79
  key: 'ui.toast.onFailToAuth'
@@ -100,13 +85,13 @@ function loginUser(credentials) {
100
85
  });
101
86
  };
102
87
  }
103
- function logoutUser() {
88
+ export function logoutUser() {
104
89
  return (dispatch, getState) => {
105
90
  const state = getState();
106
- const backend = (0, _backend.currentBackend)(state.config);
91
+ const backend = currentBackend(state.config);
107
92
  Promise.resolve(backend.logout()).then(() => {
108
93
  dispatch(logout());
109
- dispatch((0, _notifications.clearNotifications)());
94
+ dispatch(clearNotifications());
110
95
  });
111
96
  };
112
97
  }
@@ -1,23 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createNewEntry = createNewEntry;
7
- exports.searchCollections = searchCollections;
8
- exports.showCollection = showCollection;
9
- var _history = require("../routing/history");
10
- var _urlHelper = require("../lib/urlHelper");
11
- function searchCollections(query, collection) {
1
+ import { history } from '../routing/history';
2
+ import { getCollectionUrl, getNewEntryUrl } from '../lib/urlHelper';
3
+ export function searchCollections(query, collection) {
12
4
  if (collection) {
13
- _history.history.push(`/collections/${collection}/search/${query}`);
5
+ history.push(`/collections/${collection}/search/${query}`);
14
6
  } else {
15
- _history.history.push(`/search/${query}`);
7
+ history.push(`/search/${query}`);
16
8
  }
17
9
  }
18
- function showCollection(collectionName) {
19
- _history.history.push((0, _urlHelper.getCollectionUrl)(collectionName));
10
+ export function showCollection(collectionName) {
11
+ history.push(getCollectionUrl(collectionName));
20
12
  }
21
- function createNewEntry(collectionName) {
22
- _history.history.push((0, _urlHelper.getNewEntryUrl)(collectionName));
13
+ export function createNewEntry(collectionName) {
14
+ history.push(getNewEntryUrl(collectionName));
23
15
  }
@@ -1,34 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CONFIG_SUCCESS = exports.CONFIG_REQUEST = exports.CONFIG_FAILURE = void 0;
7
- exports.applyDefaults = applyDefaults;
8
- exports.configFailed = configFailed;
9
- exports.configLoaded = configLoaded;
10
- exports.configLoading = configLoading;
11
- exports.detectProxyServer = detectProxyServer;
12
- exports.handleLocalBackend = handleLocalBackend;
13
- exports.loadConfig = loadConfig;
14
- exports.normalizeConfig = normalizeConfig;
15
- exports.parseConfig = parseConfig;
16
- var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
17
- var _trim2 = _interopRequireDefault(require("lodash/trim"));
18
- var _trimStart2 = _interopRequireDefault(require("lodash/trimStart"));
19
- var _yaml = _interopRequireDefault(require("yaml"));
20
- var _immutable = require("immutable");
21
- var _deepmerge = _interopRequireDefault(require("deepmerge"));
22
- var _immer = require("immer");
23
- var _publishModes = require("../constants/publishModes");
24
- var _configSchema = require("../constants/configSchema");
25
- var _collections = require("../reducers/collections");
26
- var _integrations = require("../reducers/integrations");
27
- var _backend = require("../backend");
28
- var _i18n = require("../lib/i18n");
29
- var _collectionTypes = require("../constants/collectionTypes");
1
+ import _isEmpty from "lodash/isEmpty";
2
+ import _trim from "lodash/trim";
3
+ import _trimStart from "lodash/trimStart";
30
4
  const _excluded = ["sortableFields"];
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
5
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
33
6
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
34
7
  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; }
@@ -36,9 +9,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
36
9
  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; }
37
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
38
11
  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); }
39
- const CONFIG_REQUEST = exports.CONFIG_REQUEST = 'CONFIG_REQUEST';
40
- const CONFIG_SUCCESS = exports.CONFIG_SUCCESS = 'CONFIG_SUCCESS';
41
- const CONFIG_FAILURE = exports.CONFIG_FAILURE = 'CONFIG_FAILURE';
12
+ import yaml from 'yaml';
13
+ import { fromJS } from 'immutable';
14
+ import deepmerge from 'deepmerge';
15
+ import { produce } from 'immer';
16
+ import { SIMPLE as SIMPLE_PUBLISH_MODE } from '../constants/publishModes';
17
+ import { validateConfig } from '../constants/configSchema';
18
+ import { selectDefaultSortableFields } from '../reducers/collections';
19
+ import { getIntegrations, selectIntegration } from '../reducers/integrations';
20
+ import { resolveBackend } from '../backend';
21
+ import { I18N, I18N_FIELD, I18N_STRUCTURE } from '../lib/i18n';
22
+ import { FILES, FOLDER } from '../constants/collectionTypes';
23
+ export const CONFIG_REQUEST = 'CONFIG_REQUEST';
24
+ export const CONFIG_SUCCESS = 'CONFIG_SUCCESS';
25
+ export const CONFIG_FAILURE = 'CONFIG_FAILURE';
42
26
  function isObjectField(field) {
43
27
  return 'fields' in field;
44
28
  }
@@ -109,13 +93,13 @@ function setSnakeCaseConfig(field) {
109
93
  return Object.assign({}, field, ...snakeValues);
110
94
  }
111
95
  function setI18nField(field) {
112
- if (field[_i18n.I18N] === true) {
96
+ if (field[I18N] === true) {
113
97
  return _objectSpread(_objectSpread({}, field), {}, {
114
- [_i18n.I18N]: _i18n.I18N_FIELD.TRANSLATE
98
+ [I18N]: I18N_FIELD.TRANSLATE
115
99
  });
116
- } else if (field[_i18n.I18N] === false || !field[_i18n.I18N]) {
100
+ } else if (field[I18N] === false || !field[I18N]) {
117
101
  return _objectSpread(_objectSpread({}, field), {}, {
118
- [_i18n.I18N]: _i18n.I18N_FIELD.NONE
102
+ [I18N]: I18N_FIELD.NONE
119
103
  });
120
104
  }
121
105
  return field;
@@ -126,7 +110,7 @@ function getI18nDefaults(collectionOrFileI18n, defaultI18n) {
126
110
  } else {
127
111
  const locales = collectionOrFileI18n.locales || defaultI18n.locales;
128
112
  const defaultLocale = collectionOrFileI18n.default_locale || locales[0];
129
- const mergedI18n = (0, _deepmerge.default)(defaultI18n, collectionOrFileI18n);
113
+ const mergedI18n = deepmerge(defaultI18n, collectionOrFileI18n);
130
114
  mergedI18n.locales = locales;
131
115
  mergedI18n.default_locale = defaultLocale;
132
116
  throwOnMissingDefaultLocale(mergedI18n);
@@ -139,14 +123,14 @@ function setI18nDefaultsForFields(collectionOrFileFields, hasI18n) {
139
123
  } else {
140
124
  return traverseFieldsJS(collectionOrFileFields, field => {
141
125
  const newField = _objectSpread({}, field);
142
- delete newField[_i18n.I18N];
126
+ delete newField[I18N];
143
127
  return newField;
144
128
  });
145
129
  }
146
130
  }
147
131
  function throwOnInvalidFileCollectionStructure(i18n) {
148
- if (i18n && i18n.structure !== _i18n.I18N_STRUCTURE.SINGLE_FILE) {
149
- throw new Error(`i18n configuration for files collections is limited to ${_i18n.I18N_STRUCTURE.SINGLE_FILE} structure`);
132
+ if (i18n && i18n.structure !== I18N_STRUCTURE.SINGLE_FILE) {
133
+ throw new Error(`i18n configuration for files collections is limited to ${I18N_STRUCTURE.SINGLE_FILE} structure`);
150
134
  }
151
135
  }
152
136
  function throwOnMissingDefaultLocale(i18n) {
@@ -156,11 +140,11 @@ function throwOnMissingDefaultLocale(i18n) {
156
140
  }
157
141
  function hasIntegration(config, collection) {
158
142
  // TODO remove fromJS when Immutable is removed from the integrations state slice
159
- const integrations = (0, _integrations.getIntegrations)((0, _immutable.fromJS)(config));
160
- const integration = (0, _integrations.selectIntegration)(integrations, collection.name, 'listEntries');
143
+ const integrations = getIntegrations(fromJS(config));
144
+ const integration = selectIntegration(integrations, collection.name, 'listEntries');
161
145
  return !!integration;
162
146
  }
163
- function normalizeConfig(config) {
147
+ export function normalizeConfig(config) {
164
148
  const {
165
149
  collections = []
166
150
  } = config;
@@ -203,9 +187,9 @@ function normalizeConfig(config) {
203
187
  collections: normalizedCollections
204
188
  });
205
189
  }
206
- function applyDefaults(originalConfig) {
207
- return (0, _immer.produce)(originalConfig, config => {
208
- config.publish_mode = config.publish_mode || _publishModes.SIMPLE;
190
+ export function applyDefaults(originalConfig) {
191
+ return produce(originalConfig, config => {
192
+ config.publish_mode = config.publish_mode || SIMPLE_PUBLISH_MODE;
209
193
  config.slug = config.slug || {};
210
194
  config.collections = config.collections || [];
211
195
 
@@ -215,7 +199,7 @@ function applyDefaults(originalConfig) {
215
199
  }
216
200
 
217
201
  // Use media_folder as default public_folder.
218
- const defaultPublicFolder = `/${(0, _trimStart2.default)(config.media_folder, '/')}`;
202
+ const defaultPublicFolder = `/${_trimStart(config.media_folder, '/')}`;
219
203
  if (!('public_folder' in config)) {
220
204
  config.public_folder = defaultPublicFolder;
221
205
  }
@@ -230,23 +214,23 @@ function applyDefaults(originalConfig) {
230
214
  if (!('sanitize_replacement' in config.slug)) {
231
215
  config.slug.sanitize_replacement = '-';
232
216
  }
233
- const i18n = config[_i18n.I18N];
217
+ const i18n = config[I18N];
234
218
  if (i18n) {
235
219
  i18n.default_locale = i18n.default_locale || i18n.locales[0];
236
220
  }
237
221
  throwOnMissingDefaultLocale(i18n);
238
- const backend = (0, _backend.resolveBackend)(config);
222
+ const backend = resolveBackend(config);
239
223
  for (const collection of config.collections) {
240
224
  if (!('publish' in collection)) {
241
225
  collection.publish = true;
242
226
  }
243
- let collectionI18n = collection[_i18n.I18N];
227
+ let collectionI18n = collection[I18N];
244
228
  if (i18n && collectionI18n) {
245
229
  collectionI18n = getI18nDefaults(collectionI18n, i18n);
246
- collection[_i18n.I18N] = collectionI18n;
230
+ collection[I18N] = collectionI18n;
247
231
  } else {
248
232
  collectionI18n = undefined;
249
- delete collection[_i18n.I18N];
233
+ delete collection[I18N];
250
234
  }
251
235
  if (collection.fields) {
252
236
  collection.fields = setI18nDefaultsForFields(collection.fields, Boolean(collectionI18n));
@@ -259,7 +243,7 @@ function applyDefaults(originalConfig) {
259
243
  meta
260
244
  } = collection;
261
245
  if (folder) {
262
- collection.type = _collectionTypes.FOLDER;
246
+ collection.type = FOLDER;
263
247
  if (collection.path && !collection.media_folder) {
264
248
  // default value for media folder when using the path config
265
249
  collection.media_folder = '';
@@ -270,7 +254,7 @@ function applyDefaults(originalConfig) {
270
254
  if (collection.fields) {
271
255
  collection.fields = traverseFieldsJS(collection.fields, setDefaultPublicFolderForField);
272
256
  }
273
- collection.folder = (0, _trim2.default)(folder, '/');
257
+ collection.folder = _trim(folder, '/');
274
258
  if (meta && meta.path) {
275
259
  const metaField = _objectSpread({
276
260
  name: 'path',
@@ -281,25 +265,25 @@ function applyDefaults(originalConfig) {
281
265
  }
282
266
  }
283
267
  if (files) {
284
- collection.type = _collectionTypes.FILES;
268
+ collection.type = FILES;
285
269
  throwOnInvalidFileCollectionStructure(collectionI18n);
286
270
  delete collection.nested;
287
271
  delete collection.meta;
288
272
  for (const file of files) {
289
- file.file = (0, _trimStart2.default)(file.file, '/');
273
+ file.file = _trimStart(file.file, '/');
290
274
  if ('media_folder' in file && !('public_folder' in file)) {
291
275
  file.public_folder = file.media_folder;
292
276
  }
293
277
  if (file.fields) {
294
278
  file.fields = traverseFieldsJS(file.fields, setDefaultPublicFolderForField);
295
279
  }
296
- let fileI18n = file[_i18n.I18N];
280
+ let fileI18n = file[I18N];
297
281
  if (fileI18n && collectionI18n) {
298
282
  fileI18n = getI18nDefaults(fileI18n, collectionI18n);
299
- file[_i18n.I18N] = fileI18n;
283
+ file[I18N] = fileI18n;
300
284
  } else {
301
285
  fileI18n = undefined;
302
- delete file[_i18n.I18N];
286
+ delete file[I18N];
303
287
  }
304
288
  throwOnInvalidFileCollectionStructure(fileI18n);
305
289
  if (file.fields) {
@@ -308,9 +292,9 @@ function applyDefaults(originalConfig) {
308
292
  }
309
293
  }
310
294
  if (!collection.sortable_fields) {
311
- collection.sortable_fields = (0, _collections.selectDefaultSortableFields)(
295
+ collection.sortable_fields = selectDefaultSortableFields(
312
296
  // TODO remove fromJS when Immutable is removed from the collections state slice
313
- (0, _immutable.fromJS)(collection), backend, hasIntegration(config, collection));
297
+ fromJS(collection), backend, hasIntegration(config, collection));
314
298
  }
315
299
  collection.view_filters = (view_filters || []).map(filter => {
316
300
  return _objectSpread(_objectSpread({}, filter), {}, {
@@ -330,8 +314,8 @@ function applyDefaults(originalConfig) {
330
314
  }
331
315
  });
332
316
  }
333
- function parseConfig(data) {
334
- const config = _yaml.default.parse(data, {
317
+ export function parseConfig(data) {
318
+ const config = yaml.parse(data, {
335
319
  maxAliasCount: -1,
336
320
  prettyErrors: true,
337
321
  merge: true
@@ -365,25 +349,25 @@ async function getConfigYaml(file, hasManualConfig) {
365
349
  }
366
350
  return parseConfig(await response.text());
367
351
  }
368
- function configLoaded(config) {
352
+ export function configLoaded(config) {
369
353
  return {
370
354
  type: CONFIG_SUCCESS,
371
355
  payload: config
372
356
  };
373
357
  }
374
- function configLoading() {
358
+ export function configLoading() {
375
359
  return {
376
360
  type: CONFIG_REQUEST
377
361
  };
378
362
  }
379
- function configFailed(err) {
363
+ export function configFailed(err) {
380
364
  return {
381
365
  type: CONFIG_FAILURE,
382
366
  error: 'Error loading config',
383
367
  payload: err
384
368
  };
385
369
  }
386
- async function detectProxyServer(localBackend) {
370
+ export async function detectProxyServer(localBackend) {
387
371
  const allowedHosts = ['localhost', '127.0.0.1', ...(typeof localBackend === 'boolean' ? [] : (localBackend === null || localBackend === void 0 ? void 0 : localBackend.allowed_hosts) || [])];
388
372
  if (!allowedHosts.includes(location.hostname) || !localBackend) {
389
373
  return {};
@@ -430,7 +414,7 @@ function getPublishMode(config, publishModes, backendType) {
430
414
  }
431
415
  return config.publish_mode;
432
416
  }
433
- async function handleLocalBackend(originalConfig) {
417
+ export async function handleLocalBackend(originalConfig) {
434
418
  if (!originalConfig.local_backend) {
435
419
  return originalConfig;
436
420
  }
@@ -442,7 +426,7 @@ async function handleLocalBackend(originalConfig) {
442
426
  if (!proxyUrl) {
443
427
  return originalConfig;
444
428
  }
445
- return (0, _immer.produce)(originalConfig, config => {
429
+ return produce(originalConfig, config => {
446
430
  config.backend.name = 'proxy';
447
431
  config.backend.proxy_url = proxyUrl;
448
432
  if (config.publish_mode) {
@@ -450,7 +434,7 @@ async function handleLocalBackend(originalConfig) {
450
434
  }
451
435
  });
452
436
  }
453
- function loadConfig(manualConfig = {}, onLoad) {
437
+ export function loadConfig(manualConfig = {}, onLoad) {
454
438
  if (window.CMS_CONFIG) {
455
439
  return configLoaded(window.CMS_CONFIG);
456
440
  }
@@ -458,12 +442,12 @@ function loadConfig(manualConfig = {}, onLoad) {
458
442
  dispatch(configLoading());
459
443
  try {
460
444
  const configUrl = getConfigUrl();
461
- const hasManualConfig = !(0, _isEmpty2.default)(manualConfig);
445
+ const hasManualConfig = !_isEmpty(manualConfig);
462
446
  const configYaml = manualConfig.load_config_file === false ? {} : await getConfigYaml(configUrl, hasManualConfig);
463
447
 
464
448
  // Merge manual config into the config.yml one
465
- const mergedConfig = (0, _deepmerge.default)(configYaml, manualConfig);
466
- (0, _configSchema.validateConfig)(mergedConfig);
449
+ const mergedConfig = deepmerge(configYaml, manualConfig);
450
+ validateConfig(mergedConfig);
467
451
  const withLocalBackend = await handleLocalBackend(mergedConfig);
468
452
  const normalizedConfig = normalizeConfig(withLocalBackend);
469
453
  const config = applyDefaults(normalizedConfig);
@@ -1,16 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DEPLOY_PREVIEW_SUCCESS = exports.DEPLOY_PREVIEW_REQUEST = exports.DEPLOY_PREVIEW_FAILURE = void 0;
7
- exports.loadDeployPreview = loadDeployPreview;
8
- var _backend = require("../backend");
9
- var _reducers = require("../reducers");
10
- var _notifications = require("./notifications");
11
- const DEPLOY_PREVIEW_REQUEST = exports.DEPLOY_PREVIEW_REQUEST = 'DEPLOY_PREVIEW_REQUEST';
12
- const DEPLOY_PREVIEW_SUCCESS = exports.DEPLOY_PREVIEW_SUCCESS = 'DEPLOY_PREVIEW_SUCCESS';
13
- const DEPLOY_PREVIEW_FAILURE = exports.DEPLOY_PREVIEW_FAILURE = 'DEPLOY_PREVIEW_FAILURE';
1
+ import { currentBackend } from '../backend';
2
+ import { selectDeployPreview } from '../reducers';
3
+ import { addNotification } from './notifications';
4
+ export const DEPLOY_PREVIEW_REQUEST = 'DEPLOY_PREVIEW_REQUEST';
5
+ export const DEPLOY_PREVIEW_SUCCESS = 'DEPLOY_PREVIEW_SUCCESS';
6
+ export const DEPLOY_PREVIEW_FAILURE = 'DEPLOY_PREVIEW_FAILURE';
14
7
  function deployPreviewLoading(collection, slug) {
15
8
  return {
16
9
  type: DEPLOY_PREVIEW_REQUEST,
@@ -48,14 +41,14 @@ function deployPreviewError(collection, slug) {
48
41
  /**
49
42
  * Requests a deploy preview object from the registered backend.
50
43
  */
51
- function loadDeployPreview(collection, slug, entry, published, opts) {
44
+ export function loadDeployPreview(collection, slug, entry, published, opts) {
52
45
  return async (dispatch, getState) => {
53
46
  const state = getState();
54
- const backend = (0, _backend.currentBackend)(state.config);
47
+ const backend = currentBackend(state.config);
55
48
  const collectionName = collection.get('name');
56
49
 
57
50
  // Exit if currently fetching
58
- const deployState = (0, _reducers.selectDeployPreview)(state, collectionName, slug);
51
+ const deployState = selectDeployPreview(state, collectionName, slug);
59
52
  if (deployState && deployState.isFetching) {
60
53
  return;
61
54
  }
@@ -72,7 +65,7 @@ function loadDeployPreview(collection, slug, entry, published, opts) {
72
65
  return dispatch(deployPreviewError(collectionName, slug));
73
66
  } catch (error) {
74
67
  console.error(error);
75
- dispatch((0, _notifications.addNotification)({
68
+ dispatch(addNotification({
76
69
  message: {
77
70
  details: error.message,
78
71
  key: 'ui.toast.onFailToLoadDeployPreview'