decap-cms-core 3.14.0 → 3.16.0

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 (63) hide show
  1. package/dist/decap-cms-core.js +19 -19
  2. package/dist/decap-cms-core.js.LICENSE.txt +0 -2
  3. package/dist/decap-cms-core.js.map +1 -1
  4. package/dist/esm/bootstrap.js +2 -2
  5. package/dist/esm/components/App/App.js +6 -6
  6. package/dist/esm/components/Collection/Collection.js +7 -7
  7. package/dist/esm/components/Collection/CollectionControls.js +1 -1
  8. package/dist/esm/components/Collection/CollectionTop.js +13 -9
  9. package/dist/esm/components/Collection/ControlButton.js +2 -2
  10. package/dist/esm/components/Collection/Entries/Entries.js +2 -2
  11. package/dist/esm/components/Collection/Sidebar.js +6 -6
  12. package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +48 -9
  13. package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +7 -9
  14. package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +5 -5
  15. package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +15 -3
  16. package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +4 -1
  17. package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +6 -6
  18. package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +14 -24
  19. package/dist/esm/components/UI/ErrorBoundary.js +2 -2
  20. package/dist/esm/components/UI/Modal.js +11 -4
  21. package/dist/esm/components/Workflow/Workflow.js +5 -5
  22. package/dist/esm/components/Workflow/WorkflowCard.js +14 -14
  23. package/dist/esm/components/Workflow/WorkflowList.js +18 -42
  24. package/dist/esm/constants/configSchema.js +1 -2
  25. package/dist/esm/lib/urlHelper.js +3 -7
  26. package/dist/esm/reducers/entries.js +9 -7
  27. package/dist/esm/reducers/entryDraft.js +3 -4
  28. package/dist/esm/reducers/mediaLibrary.js +2 -3
  29. package/dist/esm/reducers/notifications.js +1 -2
  30. package/index.d.ts +2 -2
  31. package/package.json +7 -9
  32. package/src/actions/__tests__/editorialWorkflow.spec.js +1 -3
  33. package/src/components/App/App.js +0 -1
  34. package/src/components/Collection/Collection.js +10 -3
  35. package/src/components/Collection/CollectionControls.js +4 -3
  36. package/src/components/Collection/CollectionTop.js +10 -3
  37. package/src/components/Collection/ControlButton.js +1 -0
  38. package/src/components/Collection/Entries/Entries.js +1 -0
  39. package/src/components/Collection/Sidebar.js +8 -7
  40. package/src/components/Collection/__tests__/__snapshots__/Collection.spec.js.snap +76 -12
  41. package/src/components/Collection/__tests__/__snapshots__/Sidebar.spec.js.snap +76 -16
  42. package/src/components/MediaLibrary/MediaLibraryButtons.js +39 -7
  43. package/src/components/MediaLibrary/MediaLibraryCard.js +1 -3
  44. package/src/components/MediaLibrary/MediaLibraryCardGrid.js +2 -2
  45. package/src/components/MediaLibrary/MediaLibraryHeader.js +32 -17
  46. package/src/components/MediaLibrary/MediaLibraryModal.js +8 -4
  47. package/src/components/MediaLibrary/MediaLibrarySearch.js +3 -1
  48. package/src/components/MediaLibrary/MediaLibraryTop.js +19 -1
  49. package/src/components/MediaLibrary/__tests__/__snapshots__/MediaLibraryCard.spec.js.snap +6 -6
  50. package/src/components/UI/Modal.js +10 -3
  51. package/src/components/Workflow/Workflow.js +7 -1
  52. package/src/components/Workflow/WorkflowCard.js +52 -14
  53. package/src/components/Workflow/WorkflowList.js +50 -31
  54. package/src/constants/configSchema.js +1 -2
  55. package/src/lib/urlHelper.ts +3 -4
  56. package/src/reducers/__tests__/entryDraft.spec.js +1 -1
  57. package/src/reducers/__tests__/mediaLibrary.spec.js +0 -1
  58. package/src/reducers/entries.ts +9 -7
  59. package/src/reducers/entryDraft.js +3 -4
  60. package/src/reducers/mediaLibrary.ts +2 -3
  61. package/src/reducers/notifications.ts +1 -2
  62. package/src/types/redux.ts +3 -3
  63. package/src/lib/textHelper.js +0 -11
@@ -3,7 +3,7 @@ import { Map, fromJS } from 'immutable';
3
3
  import * as actions from '../../actions/entries';
4
4
  import reducer from '../entryDraft';
5
5
 
6
- jest.mock('uuid', () => ({ v4: jest.fn(() => '1') }));
6
+ global.crypto.randomUUID = jest.fn(() => '1');
7
7
 
8
8
  const initialState = Map({
9
9
  entry: Map(),
@@ -7,7 +7,6 @@ import mediaLibrary, {
7
7
  selectMediaDisplayURL,
8
8
  } from '../mediaLibrary';
9
9
 
10
- jest.mock('uuid');
11
10
  jest.mock('../entries');
12
11
  jest.mock('../');
13
12
 
@@ -474,14 +474,16 @@ function getGroup(entry: EntryMap, selectedGroup: GroupMap) {
474
474
  if (selectedGroup.has('pattern')) {
475
475
  const pattern = selectedGroup.get('pattern');
476
476
  let value = '';
477
- try {
478
- const regex = new RegExp(pattern);
479
- const matched = dataAsString.match(regex);
480
- if (matched) {
481
- value = matched[0];
477
+ if (pattern !== undefined) {
478
+ try {
479
+ const regex = new RegExp(pattern);
480
+ const matched = dataAsString.match(regex);
481
+ if (matched) {
482
+ value = matched[0];
483
+ }
484
+ } catch (e) {
485
+ console.warn(`Invalid view group pattern '${pattern}' for field '${field}'`, e);
482
486
  }
483
- } catch (e) {
484
- console.warn(`Invalid view group pattern '${pattern}' for field '${field}'`, e);
485
487
  }
486
488
  return {
487
489
  id: `${label}${value}`,
@@ -1,5 +1,4 @@
1
1
  import { Map, List, fromJS } from 'immutable';
2
- import { v4 as uuid } from 'uuid';
3
2
  import get from 'lodash/get';
4
3
  import { join, basename } from 'path';
5
4
 
@@ -53,7 +52,7 @@ function entryDraftReducer(state = Map(), action) {
53
52
  state.set('fieldsMetaData', Map());
54
53
  state.set('fieldsErrors', Map());
55
54
  state.set('hasChanged', false);
56
- state.set('key', uuid());
55
+ state.set('key', crypto.randomUUID());
57
56
  });
58
57
  case DRAFT_CREATE_EMPTY:
59
58
  // New Entry
@@ -63,7 +62,7 @@ function entryDraftReducer(state = Map(), action) {
63
62
  state.set('fieldsMetaData', Map());
64
63
  state.set('fieldsErrors', Map());
65
64
  state.set('hasChanged', false);
66
- state.set('key', uuid());
65
+ state.set('key', crypto.randomUUID());
67
66
  });
68
67
  case DRAFT_CREATE_FROM_LOCAL_BACKUP:
69
68
  // Local Backup
@@ -76,7 +75,7 @@ function entryDraftReducer(state = Map(), action) {
76
75
  state.set('fieldsMetaData', Map());
77
76
  state.set('fieldsErrors', Map());
78
77
  state.set('hasChanged', true);
79
- state.set('key', uuid());
78
+ state.set('key', crypto.randomUUID());
80
79
  });
81
80
  case DRAFT_CREATE_DUPLICATE_FROM_ENTRY:
82
81
  // Duplicate Entry
@@ -1,5 +1,4 @@
1
1
  import { Map, List } from 'immutable';
2
- import { v4 as uuid } from 'uuid';
3
2
  import { dirname } from 'path';
4
3
 
5
4
  import {
@@ -150,7 +149,7 @@ function mediaLibrary(state = Map(defaultState), action: MediaLibraryAction) {
150
149
  return state;
151
150
  }
152
151
 
153
- const filesWithKeys = files.map(file => ({ ...file, key: uuid() }));
152
+ const filesWithKeys = files.map(file => ({ ...file, key: crypto.randomUUID() }));
154
153
  return state.withMutations(map => {
155
154
  map.set('isLoading', false);
156
155
  map.set('isPaginating', false);
@@ -186,7 +185,7 @@ function mediaLibrary(state = Map(defaultState), action: MediaLibraryAction) {
186
185
  return state;
187
186
  }
188
187
  return state.withMutations(map => {
189
- const fileWithKey = { ...file, key: uuid() };
188
+ const fileWithKey = { ...file, key: crypto.randomUUID() };
190
189
  const files = map.get('files') as MediaFile[];
191
190
  const updatedFiles = [fileWithKey, ...files];
192
191
  map.set('files', updatedFiles);
@@ -1,5 +1,4 @@
1
1
  import { produce } from 'immer';
2
- import { v4 as uuid } from 'uuid';
3
2
 
4
3
  import {
5
4
  NOTIFICATION_SEND,
@@ -41,7 +40,7 @@ const notifications = produce((state: NotificationsState, action: NotificationsA
41
40
  state.notifications = [
42
41
  ...state.notifications,
43
42
  {
44
- id: uuid(),
43
+ id: crypto.randomUUID(),
45
44
  ...(action.payload as NotificationPayload),
46
45
  },
47
46
  ];
@@ -72,7 +72,7 @@ export interface CmsFieldBase {
72
72
  label?: string;
73
73
  required?: boolean;
74
74
  hint?: string;
75
- pattern?: [string, string];
75
+ pattern?: [string | RegExp, string];
76
76
  i18n?: boolean | 'translate' | 'duplicate' | 'none';
77
77
  media_folder?: string;
78
78
  public_folder?: string;
@@ -315,14 +315,14 @@ export interface CmsCollectionFile {
315
315
  export interface ViewFilter {
316
316
  label: string;
317
317
  field: string;
318
- pattern: string;
318
+ pattern: string | boolean;
319
319
  id: string;
320
320
  }
321
321
 
322
322
  export interface ViewGroup {
323
323
  label: string;
324
324
  field: string;
325
- pattern: string;
325
+ pattern?: string;
326
326
  id: string;
327
327
  }
328
328
 
@@ -1,11 +0,0 @@
1
- export function stringToRGB(str) {
2
- if (!str) return '000000';
3
- let hash = 0;
4
- for (let i = 0; i < str.length; i++) {
5
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
6
- }
7
-
8
- const c = (hash & 0x00ffffff).toString(16).toUpperCase();
9
-
10
- return `00000${c}`.slice(-6);
11
- }