@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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.
- package/build/actions.js +375 -632
- package/build/actions.js.map +7 -1
- package/build/batch/create-batch.js +49 -62
- package/build/batch/create-batch.js.map +7 -1
- package/build/batch/default-processor.js +43 -39
- package/build/batch/default-processor.js.map +7 -1
- package/build/batch/index.js +38 -17
- package/build/batch/index.js.map +7 -1
- package/build/dynamic-entities.js +30 -32
- package/build/dynamic-entities.js.map +7 -1
- package/build/entities.js +298 -410
- package/build/entities.js.map +7 -1
- package/build/entity-context.js +29 -12
- package/build/entity-context.js.map +7 -1
- package/build/entity-provider.js +38 -46
- package/build/entity-provider.js.map +7 -1
- package/build/entity-types/attachment.js +16 -5
- package/build/entity-types/attachment.js.map +7 -1
- package/build/entity-types/base-entity-records.js +16 -42
- package/build/entity-types/base-entity-records.js.map +7 -1
- package/build/entity-types/base.js +16 -5
- package/build/entity-types/base.js.map +7 -1
- package/build/entity-types/comment.js +16 -5
- package/build/entity-types/comment.js.map +7 -1
- package/build/entity-types/global-styles-revision.js +16 -5
- package/build/entity-types/global-styles-revision.js.map +7 -1
- package/build/entity-types/helpers.js +16 -5
- package/build/entity-types/helpers.js.map +7 -1
- package/build/entity-types/index.js +16 -5
- package/build/entity-types/index.js.map +7 -1
- package/build/entity-types/menu-location.js +16 -5
- package/build/entity-types/menu-location.js.map +7 -1
- package/build/entity-types/nav-menu-item.js +16 -5
- package/build/entity-types/nav-menu-item.js.map +7 -1
- package/build/entity-types/nav-menu.js +16 -5
- package/build/entity-types/nav-menu.js.map +7 -1
- package/build/entity-types/page.js +16 -5
- package/build/entity-types/page.js.map +7 -1
- package/build/entity-types/plugin.js +16 -5
- package/build/entity-types/plugin.js.map +7 -1
- package/build/entity-types/post-revision.js +16 -5
- package/build/entity-types/post-revision.js.map +7 -1
- package/build/entity-types/post-status.js +16 -5
- package/build/entity-types/post-status.js.map +7 -1
- package/build/entity-types/post.js +16 -5
- package/build/entity-types/post.js.map +7 -1
- package/build/entity-types/settings.js +16 -5
- package/build/entity-types/settings.js.map +7 -1
- package/build/entity-types/sidebar.js +16 -5
- package/build/entity-types/sidebar.js.map +7 -1
- package/build/entity-types/taxonomy.js +16 -5
- package/build/entity-types/taxonomy.js.map +7 -1
- package/build/entity-types/term.js +16 -5
- package/build/entity-types/term.js.map +7 -1
- package/build/entity-types/theme.js +16 -5
- package/build/entity-types/theme.js.map +7 -1
- package/build/entity-types/type.js +16 -5
- package/build/entity-types/type.js.map +7 -1
- package/build/entity-types/user.js +16 -5
- package/build/entity-types/user.js.map +7 -1
- package/build/entity-types/widget-type.js +16 -5
- package/build/entity-types/widget-type.js.map +7 -1
- package/build/entity-types/widget.js +16 -5
- package/build/entity-types/widget.js.map +7 -1
- package/build/entity-types/wp-template-part.js +16 -5
- package/build/entity-types/wp-template-part.js.map +7 -1
- package/build/entity-types/wp-template.js +16 -5
- package/build/entity-types/wp-template.js.map +7 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build/fetch/__experimental-fetch-url-data.js +47 -59
- package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build/fetch/index.js +53 -32
- package/build/fetch/index.js.map +7 -1
- package/build/footnotes/get-footnotes-order.js +38 -25
- package/build/footnotes/get-footnotes-order.js.map +7 -1
- package/build/footnotes/get-rich-text-values-cached.js +26 -27
- package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build/footnotes/index.js +68 -55
- package/build/footnotes/index.js.map +7 -1
- package/build/hooks/constants.js +33 -12
- package/build/hooks/constants.js.map +7 -1
- package/build/hooks/index.js +59 -68
- package/build/hooks/index.js.map +7 -1
- package/build/hooks/memoize.js +34 -12
- package/build/hooks/memoize.js.map +7 -1
- package/build/hooks/use-entity-block-editor.js +111 -119
- package/build/hooks/use-entity-block-editor.js.map +7 -1
- package/build/hooks/use-entity-id.js +25 -23
- package/build/hooks/use-entity-id.js.map +7 -1
- package/build/hooks/use-entity-prop.js +59 -60
- package/build/hooks/use-entity-prop.js.map +7 -1
- package/build/hooks/use-entity-record.js +95 -155
- package/build/hooks/use-entity-record.js.map +7 -1
- package/build/hooks/use-entity-records.js +131 -139
- package/build/hooks/use-entity-records.js.map +7 -1
- package/build/hooks/use-query-select.js +65 -84
- package/build/hooks/use-query-select.js.map +7 -1
- package/build/hooks/use-resource-permissions.js +92 -145
- package/build/hooks/use-resource-permissions.js.map +7 -1
- package/build/index.js +96 -153
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/locks/actions.js +36 -19
- package/build/locks/actions.js.map +7 -1
- package/build/locks/engine.js +48 -47
- package/build/locks/engine.js.map +7 -1
- package/build/locks/reducer.js +54 -63
- package/build/locks/reducer.js.map +7 -1
- package/build/locks/selectors.js +35 -30
- package/build/locks/selectors.js.map +7 -1
- package/build/locks/utils.js +37 -16
- package/build/locks/utils.js.map +7 -1
- package/build/name.js +27 -12
- package/build/name.js.map +7 -1
- package/build/private-actions.js +67 -75
- package/build/private-actions.js.map +7 -1
- package/build/private-apis.js +33 -16
- package/build/private-apis.js.map +7 -1
- package/build/private-selectors.js +204 -184
- package/build/private-selectors.js.map +7 -1
- package/build/queried-data/actions.js +32 -41
- package/build/queried-data/actions.js.map +7 -1
- package/build/queried-data/get-query-parts.js +41 -79
- package/build/queried-data/get-query-parts.js.map +7 -1
- package/build/queried-data/index.js +39 -36
- package/build/queried-data/index.js.map +7 -1
- package/build/queried-data/reducer.js +162 -193
- package/build/queried-data/reducer.js.map +7 -1
- package/build/queried-data/selectors.js +57 -85
- package/build/queried-data/selectors.js.map +7 -1
- package/build/reducer.js +279 -404
- package/build/reducer.js.map +7 -1
- package/build/resolvers.js +553 -600
- package/build/resolvers.js.map +7 -1
- package/build/selectors.js +456 -981
- package/build/selectors.js.map +7 -1
- package/build/sync.js +34 -22
- package/build/sync.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/conservative-map-item.js +34 -27
- package/build/utils/conservative-map-item.js.map +7 -1
- package/build/utils/crdt-blocks.js +289 -0
- package/build/utils/crdt-blocks.js.map +7 -0
- package/build/utils/crdt.js +202 -0
- package/build/utils/crdt.js.map +7 -0
- package/build/utils/forward-resolver.js +24 -16
- package/build/utils/forward-resolver.js.map +7 -1
- package/build/utils/get-nested-value.js +26 -21
- package/build/utils/get-nested-value.js.map +7 -1
- package/build/utils/get-normalized-comma-separable.js +25 -17
- package/build/utils/get-normalized-comma-separable.js.map +7 -1
- package/build/utils/if-matching-action.js +25 -19
- package/build/utils/if-matching-action.js.map +7 -1
- package/build/utils/index.js +77 -108
- package/build/utils/index.js.map +7 -1
- package/build/utils/is-numeric-id.js +22 -12
- package/build/utils/is-numeric-id.js.map +7 -1
- package/build/utils/is-raw-attribute.js +22 -13
- package/build/utils/is-raw-attribute.js.map +7 -1
- package/build/utils/log-entity-deprecation.js +37 -38
- package/build/utils/log-entity-deprecation.js.map +7 -1
- package/build/utils/on-sub-key.js +30 -24
- package/build/utils/on-sub-key.js.map +7 -1
- package/build/utils/receive-intermediate-results.js +29 -6
- package/build/utils/receive-intermediate-results.js.map +7 -1
- package/build/utils/replace-action.js +24 -17
- package/build/utils/replace-action.js.map +7 -1
- package/build/utils/set-nested-value.js +25 -30
- package/build/utils/set-nested-value.js.map +7 -1
- package/build/utils/user-permissions.js +41 -13
- package/build/utils/user-permissions.js.map +7 -1
- package/build/utils/with-weak-map-cache.js +26 -22
- package/build/utils/with-weak-map-cache.js.map +7 -1
- package/build-module/actions.js +322 -601
- package/build-module/actions.js.map +7 -1
- package/build-module/batch/create-batch.js +21 -57
- package/build-module/batch/create-batch.js.map +7 -1
- package/build-module/batch/default-processor.js +14 -33
- package/build-module/batch/default-processor.js.map +7 -1
- package/build-module/batch/index.js +7 -3
- package/build-module/batch/index.js.map +7 -1
- package/build-module/dynamic-entities.js +7 -28
- package/build-module/dynamic-entities.js.map +7 -1
- package/build-module/entities.js +263 -399
- package/build-module/entities.js.map +7 -1
- package/build-module/entity-context.js +7 -7
- package/build-module/entity-context.js.map +7 -1
- package/build-module/entity-provider.js +19 -42
- package/build-module/entity-provider.js.map +7 -1
- package/build-module/entity-types/attachment.js +1 -2
- package/build-module/entity-types/attachment.js.map +7 -1
- package/build-module/entity-types/base-entity-records.js +1 -37
- package/build-module/entity-types/base-entity-records.js.map +7 -1
- package/build-module/entity-types/base.js +1 -2
- package/build-module/entity-types/base.js.map +7 -1
- package/build-module/entity-types/comment.js +1 -2
- package/build-module/entity-types/comment.js.map +7 -1
- package/build-module/entity-types/global-styles-revision.js +1 -2
- package/build-module/entity-types/global-styles-revision.js.map +7 -1
- package/build-module/entity-types/helpers.js +1 -2
- package/build-module/entity-types/helpers.js.map +7 -1
- package/build-module/entity-types/index.js +1 -2
- package/build-module/entity-types/index.js.map +7 -1
- package/build-module/entity-types/menu-location.js +1 -2
- package/build-module/entity-types/menu-location.js.map +7 -1
- package/build-module/entity-types/nav-menu-item.js +1 -2
- package/build-module/entity-types/nav-menu-item.js.map +7 -1
- package/build-module/entity-types/nav-menu.js +1 -2
- package/build-module/entity-types/nav-menu.js.map +7 -1
- package/build-module/entity-types/page.js +1 -2
- package/build-module/entity-types/page.js.map +7 -1
- package/build-module/entity-types/plugin.js +1 -2
- package/build-module/entity-types/plugin.js.map +7 -1
- package/build-module/entity-types/post-revision.js +1 -2
- package/build-module/entity-types/post-revision.js.map +7 -1
- package/build-module/entity-types/post-status.js +1 -2
- package/build-module/entity-types/post-status.js.map +7 -1
- package/build-module/entity-types/post.js +1 -2
- package/build-module/entity-types/post.js.map +7 -1
- package/build-module/entity-types/settings.js +1 -2
- package/build-module/entity-types/settings.js.map +7 -1
- package/build-module/entity-types/sidebar.js +1 -2
- package/build-module/entity-types/sidebar.js.map +7 -1
- package/build-module/entity-types/taxonomy.js +1 -2
- package/build-module/entity-types/taxonomy.js.map +7 -1
- package/build-module/entity-types/term.js +1 -2
- package/build-module/entity-types/term.js.map +7 -1
- package/build-module/entity-types/theme.js +1 -2
- package/build-module/entity-types/theme.js.map +7 -1
- package/build-module/entity-types/type.js +1 -2
- package/build-module/entity-types/type.js.map +7 -1
- package/build-module/entity-types/user.js +1 -2
- package/build-module/entity-types/user.js.map +7 -1
- package/build-module/entity-types/widget-type.js +1 -2
- package/build-module/entity-types/widget-type.js.map +7 -1
- package/build-module/entity-types/widget.js +1 -2
- package/build-module/entity-types/widget.js.map +7 -1
- package/build-module/entity-types/wp-template-part.js +1 -2
- package/build-module/entity-types/wp-template-part.js.map +7 -1
- package/build-module/entity-types/wp-template.js +1 -2
- package/build-module/entity-types/wp-template.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
- package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build-module/fetch/index.js +20 -15
- package/build-module/fetch/index.js.map +7 -1
- package/build-module/footnotes/get-footnotes-order.js +10 -19
- package/build-module/footnotes/get-footnotes-order.js.map +7 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
- package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build-module/footnotes/index.js +34 -47
- package/build-module/footnotes/index.js.map +7 -1
- package/build-module/hooks/constants.js +11 -8
- package/build-module/hooks/constants.js.map +7 -1
- package/build-module/hooks/index.js +27 -15
- package/build-module/hooks/index.js.map +7 -1
- package/build-module/hooks/memoize.js +6 -8
- package/build-module/hooks/memoize.js.map +7 -1
- package/build-module/hooks/use-entity-block-editor.js +80 -110
- package/build-module/hooks/use-entity-block-editor.js.map +7 -1
- package/build-module/hooks/use-entity-id.js +7 -19
- package/build-module/hooks/use-entity-id.js.map +7 -1
- package/build-module/hooks/use-entity-prop.js +31 -55
- package/build-module/hooks/use-entity-prop.js.map +7 -1
- package/build-module/hooks/use-entity-record.js +63 -148
- package/build-module/hooks/use-entity-record.js.map +7 -1
- package/build-module/hooks/use-entity-records.js +98 -131
- package/build-module/hooks/use-entity-records.js.map +7 -1
- package/build-module/hooks/use-query-select.js +27 -71
- package/build-module/hooks/use-query-select.js.map +7 -1
- package/build-module/hooks/use-resource-permissions.js +57 -136
- package/build-module/hooks/use-resource-permissions.js.map +7 -1
- package/build-module/index.js +49 -71
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/locks/actions.js +8 -13
- package/build-module/locks/actions.js.map +7 -1
- package/build-module/locks/engine.js +17 -38
- package/build-module/locks/engine.js.map +7 -1
- package/build-module/locks/reducer.js +37 -59
- package/build-module/locks/reducer.js.map +7 -1
- package/build-module/locks/selectors.js +16 -23
- package/build-module/locks/selectors.js.map +7 -1
- package/build-module/locks/utils.js +15 -12
- package/build-module/locks/utils.js.map +7 -1
- package/build-module/name.js +5 -8
- package/build-module/name.js.map +7 -1
- package/build-module/private-actions.js +35 -69
- package/build-module/private-actions.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-selectors.js +167 -174
- package/build-module/private-selectors.js.map +7 -1
- package/build-module/queried-data/actions.js +11 -38
- package/build-module/queried-data/actions.js.map +7 -1
- package/build-module/queried-data/get-query-parts.js +20 -75
- package/build-module/queried-data/get-query-parts.js.map +7 -1
- package/build-module/queried-data/index.js +7 -4
- package/build-module/queried-data/index.js.map +7 -1
- package/build-module/queried-data/reducer.js +134 -185
- package/build-module/queried-data/reducer.js.map +7 -1
- package/build-module/queried-data/selectors.js +23 -78
- package/build-module/queried-data/selectors.js.map +7 -1
- package/build-module/reducer.js +243 -393
- package/build-module/reducer.js.map +7 -1
- package/build-module/resolvers.js +478 -549
- package/build-module/resolvers.js.map +7 -1
- package/build-module/selectors.js +410 -953
- package/build-module/selectors.js.map +7 -1
- package/build-module/sync.js +14 -17
- package/build-module/sync.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/conservative-map-item.js +6 -22
- package/build-module/utils/conservative-map-item.js.map +7 -1
- package/build-module/utils/crdt-blocks.js +255 -0
- package/build-module/utils/crdt-blocks.js.map +7 -0
- package/build-module/utils/crdt.js +167 -0
- package/build-module/utils/crdt.js.map +7 -0
- package/build-module/utils/forward-resolver.js +6 -12
- package/build-module/utils/forward-resolver.js.map +7 -1
- package/build-module/utils/get-nested-value.js +9 -18
- package/build-module/utils/get-nested-value.js.map +7 -1
- package/build-module/utils/get-normalized-comma-separable.js +7 -13
- package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
- package/build-module/utils/if-matching-action.js +7 -15
- package/build-module/utils/if-matching-action.js.map +7 -1
- package/build-module/utils/index.js +35 -14
- package/build-module/utils/index.js.map +7 -1
- package/build-module/utils/is-numeric-id.js +5 -9
- package/build-module/utils/is-numeric-id.js.map +7 -1
- package/build-module/utils/is-raw-attribute.js +5 -10
- package/build-module/utils/is-raw-attribute.js.map +7 -1
- package/build-module/utils/log-entity-deprecation.js +8 -31
- package/build-module/utils/log-entity-deprecation.js.map +7 -1
- package/build-module/utils/on-sub-key.js +8 -19
- package/build-module/utils/on-sub-key.js.map +7 -1
- package/build-module/utils/receive-intermediate-results.js +7 -2
- package/build-module/utils/receive-intermediate-results.js.map +7 -1
- package/build-module/utils/replace-action.js +6 -13
- package/build-module/utils/replace-action.js.map +7 -1
- package/build-module/utils/set-nested-value.js +8 -27
- package/build-module/utils/set-nested-value.js.map +7 -1
- package/build-module/utils/user-permissions.js +19 -9
- package/build-module/utils/user-permissions.js.map +7 -1
- package/build-module/utils/with-weak-map-cache.js +8 -18
- package/build-module/utils/with-weak-map-cache.js.map +7 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +0 -56
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +6 -1
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +30 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +49 -0
- package/build-types/utils/crdt.d.ts.map +1 -0
- package/package.json +26 -19
- package/src/actions.js +56 -74
- package/src/entities.js +59 -113
- package/src/private-selectors.ts +32 -7
- package/src/resolvers.js +173 -120
- package/src/selectors.ts +0 -13
- package/src/sync.ts +12 -0
- package/src/test/resolvers.js +183 -0
- package/src/types.ts +12 -0
- package/src/utils/crdt-blocks.ts +503 -0
- package/src/utils/crdt.ts +310 -0
- package/src/utils/test/crdt-blocks.ts +375 -0
- package/src/utils/test/crdt.ts +254 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/sync.js +0 -27
package/build-module/reducer.js
CHANGED
|
@@ -1,115 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { compose } from '@wordpress/compose';
|
|
10
|
-
import { combineReducers } from '@wordpress/data';
|
|
11
|
-
import { createUndoManager } from '@wordpress/undo-manager';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { ifMatchingAction, replaceAction } from './utils';
|
|
17
|
-
import { reducer as queriedDataReducer } from './queried-data';
|
|
18
|
-
import { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
|
|
19
|
-
|
|
20
|
-
/** @typedef {import('./types').AnyFunction} AnyFunction */
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Reducer managing authors state. Keyed by id.
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} state Current state.
|
|
26
|
-
* @param {Object} action Dispatched action.
|
|
27
|
-
*
|
|
28
|
-
* @return {Object} Updated state.
|
|
29
|
-
*/
|
|
30
|
-
export function users(state = {
|
|
31
|
-
byId: {},
|
|
32
|
-
queries: {}
|
|
33
|
-
}, action) {
|
|
1
|
+
import fastDeepEqual from "fast-deep-equal/es6";
|
|
2
|
+
import { compose } from "@wordpress/compose";
|
|
3
|
+
import { combineReducers } from "@wordpress/data";
|
|
4
|
+
import { createUndoManager } from "@wordpress/undo-manager";
|
|
5
|
+
import { ifMatchingAction, replaceAction } from "./utils";
|
|
6
|
+
import { reducer as queriedDataReducer } from "./queried-data";
|
|
7
|
+
import { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from "./entities";
|
|
8
|
+
function users(state = { byId: {}, queries: {} }, action) {
|
|
34
9
|
switch (action.type) {
|
|
35
|
-
case
|
|
10
|
+
case "RECEIVE_USER_QUERY":
|
|
36
11
|
return {
|
|
37
12
|
byId: {
|
|
38
13
|
...state.byId,
|
|
39
14
|
// Key users by their ID.
|
|
40
|
-
...action.users.reduce(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
...action.users.reduce(
|
|
16
|
+
(newUsers, user) => ({
|
|
17
|
+
...newUsers,
|
|
18
|
+
[user.id]: user
|
|
19
|
+
}),
|
|
20
|
+
{}
|
|
21
|
+
)
|
|
44
22
|
},
|
|
45
23
|
queries: {
|
|
46
24
|
...state.queries,
|
|
47
|
-
[action.queryID]: action.users.map(user => user.id)
|
|
25
|
+
[action.queryID]: action.users.map((user) => user.id)
|
|
48
26
|
}
|
|
49
27
|
};
|
|
50
28
|
}
|
|
51
29
|
return state;
|
|
52
30
|
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Reducer managing current user state.
|
|
56
|
-
*
|
|
57
|
-
* @param {Object} state Current state.
|
|
58
|
-
* @param {Object} action Dispatched action.
|
|
59
|
-
*
|
|
60
|
-
* @return {Object} Updated state.
|
|
61
|
-
*/
|
|
62
|
-
export function currentUser(state = {}, action) {
|
|
31
|
+
function currentUser(state = {}, action) {
|
|
63
32
|
switch (action.type) {
|
|
64
|
-
case
|
|
33
|
+
case "RECEIVE_CURRENT_USER":
|
|
65
34
|
return action.currentUser;
|
|
66
35
|
}
|
|
67
36
|
return state;
|
|
68
37
|
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Reducer managing the current theme.
|
|
72
|
-
*
|
|
73
|
-
* @param {string|undefined} state Current state.
|
|
74
|
-
* @param {Object} action Dispatched action.
|
|
75
|
-
*
|
|
76
|
-
* @return {string|undefined} Updated state.
|
|
77
|
-
*/
|
|
78
|
-
export function currentTheme(state = undefined, action) {
|
|
38
|
+
function currentTheme(state = void 0, action) {
|
|
79
39
|
switch (action.type) {
|
|
80
|
-
case
|
|
40
|
+
case "RECEIVE_CURRENT_THEME":
|
|
81
41
|
return action.currentTheme.stylesheet;
|
|
82
42
|
}
|
|
83
43
|
return state;
|
|
84
44
|
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Reducer managing the current global styles id.
|
|
88
|
-
*
|
|
89
|
-
* @param {string|undefined} state Current state.
|
|
90
|
-
* @param {Object} action Dispatched action.
|
|
91
|
-
*
|
|
92
|
-
* @return {string|undefined} Updated state.
|
|
93
|
-
*/
|
|
94
|
-
export function currentGlobalStylesId(state = undefined, action) {
|
|
45
|
+
function currentGlobalStylesId(state = void 0, action) {
|
|
95
46
|
switch (action.type) {
|
|
96
|
-
case
|
|
47
|
+
case "RECEIVE_CURRENT_GLOBAL_STYLES_ID":
|
|
97
48
|
return action.id;
|
|
98
49
|
}
|
|
99
50
|
return state;
|
|
100
51
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Reducer managing the theme base global styles.
|
|
104
|
-
*
|
|
105
|
-
* @param {Record<string, object>} state Current state.
|
|
106
|
-
* @param {Object} action Dispatched action.
|
|
107
|
-
*
|
|
108
|
-
* @return {Record<string, object>} Updated state.
|
|
109
|
-
*/
|
|
110
|
-
export function themeBaseGlobalStyles(state = {}, action) {
|
|
52
|
+
function themeBaseGlobalStyles(state = {}, action) {
|
|
111
53
|
switch (action.type) {
|
|
112
|
-
case
|
|
54
|
+
case "RECEIVE_THEME_GLOBAL_STYLES":
|
|
113
55
|
return {
|
|
114
56
|
...state,
|
|
115
57
|
[action.stylesheet]: action.globalStyles
|
|
@@ -117,18 +59,9 @@ export function themeBaseGlobalStyles(state = {}, action) {
|
|
|
117
59
|
}
|
|
118
60
|
return state;
|
|
119
61
|
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Reducer managing the theme global styles variations.
|
|
123
|
-
*
|
|
124
|
-
* @param {Record<string, object>} state Current state.
|
|
125
|
-
* @param {Object} action Dispatched action.
|
|
126
|
-
*
|
|
127
|
-
* @return {Record<string, object>} Updated state.
|
|
128
|
-
*/
|
|
129
|
-
export function themeGlobalStyleVariations(state = {}, action) {
|
|
62
|
+
function themeGlobalStyleVariations(state = {}, action) {
|
|
130
63
|
switch (action.type) {
|
|
131
|
-
case
|
|
64
|
+
case "RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS":
|
|
132
65
|
return {
|
|
133
66
|
...state,
|
|
134
67
|
[action.stylesheet]: action.variations
|
|
@@ -136,241 +69,202 @@ export function themeGlobalStyleVariations(state = {}, action) {
|
|
|
136
69
|
}
|
|
137
70
|
return state;
|
|
138
71
|
}
|
|
139
|
-
const withMultiEntityRecordEdits = reducer => (state, action) => {
|
|
140
|
-
if (action.type ===
|
|
141
|
-
const {
|
|
142
|
-
record
|
|
143
|
-
} = action;
|
|
72
|
+
const withMultiEntityRecordEdits = (reducer) => (state, action) => {
|
|
73
|
+
if (action.type === "UNDO" || action.type === "REDO") {
|
|
74
|
+
const { record } = action;
|
|
144
75
|
let newState = state;
|
|
145
|
-
record.forEach(({
|
|
146
|
-
id: {
|
|
147
|
-
kind,
|
|
148
|
-
name,
|
|
149
|
-
recordId
|
|
150
|
-
},
|
|
151
|
-
changes
|
|
152
|
-
}) => {
|
|
76
|
+
record.forEach(({ id: { kind, name, recordId }, changes }) => {
|
|
153
77
|
newState = reducer(newState, {
|
|
154
|
-
type:
|
|
78
|
+
type: "EDIT_ENTITY_RECORD",
|
|
155
79
|
kind,
|
|
156
80
|
name,
|
|
157
81
|
recordId,
|
|
158
|
-
edits: Object.entries(changes).reduce(
|
|
159
|
-
acc[key
|
|
160
|
-
|
|
161
|
-
|
|
82
|
+
edits: Object.entries(changes).reduce(
|
|
83
|
+
(acc, [key, value]) => {
|
|
84
|
+
acc[key] = action.type === "UNDO" ? value.from : value.to;
|
|
85
|
+
return acc;
|
|
86
|
+
},
|
|
87
|
+
{}
|
|
88
|
+
)
|
|
162
89
|
});
|
|
163
90
|
});
|
|
164
91
|
return newState;
|
|
165
92
|
}
|
|
166
93
|
return reducer(state, action);
|
|
167
94
|
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Higher Order Reducer for a given entity config. It supports:
|
|
171
|
-
*
|
|
172
|
-
* - Fetching
|
|
173
|
-
* - Editing
|
|
174
|
-
* - Saving
|
|
175
|
-
*
|
|
176
|
-
* @param {Object} entityConfig Entity config.
|
|
177
|
-
*
|
|
178
|
-
* @return {AnyFunction} Reducer.
|
|
179
|
-
*/
|
|
180
95
|
function entity(entityConfig) {
|
|
181
|
-
return compose([
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
for (const record of action.items) {
|
|
205
|
-
const recordId = record?.[action.key];
|
|
206
|
-
const edits = nextState[recordId];
|
|
207
|
-
if (!edits) {
|
|
208
|
-
continue;
|
|
96
|
+
return compose([
|
|
97
|
+
withMultiEntityRecordEdits,
|
|
98
|
+
// Limit to matching action type so we don't attempt to replace action on
|
|
99
|
+
// an unhandled action.
|
|
100
|
+
ifMatchingAction(
|
|
101
|
+
(action) => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind
|
|
102
|
+
),
|
|
103
|
+
// Inject the entity config into the action.
|
|
104
|
+
replaceAction((action) => {
|
|
105
|
+
return {
|
|
106
|
+
key: entityConfig.key || DEFAULT_ENTITY_KEY,
|
|
107
|
+
...action
|
|
108
|
+
};
|
|
109
|
+
})
|
|
110
|
+
])(
|
|
111
|
+
combineReducers({
|
|
112
|
+
queriedData: queriedDataReducer,
|
|
113
|
+
edits: (state = {}, action) => {
|
|
114
|
+
switch (action.type) {
|
|
115
|
+
case "RECEIVE_ITEMS":
|
|
116
|
+
const context = action?.query?.context ?? "default";
|
|
117
|
+
if (context !== "default") {
|
|
118
|
+
return state;
|
|
209
119
|
}
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
120
|
+
const nextState = { ...state };
|
|
121
|
+
for (const record of action.items) {
|
|
122
|
+
const recordId = record?.[action.key];
|
|
123
|
+
const edits = nextState[recordId];
|
|
124
|
+
if (!edits) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const nextEdits2 = Object.keys(edits).reduce(
|
|
128
|
+
(acc, key) => {
|
|
129
|
+
if (
|
|
130
|
+
// Edits are the "raw" attribute values, but records may have
|
|
131
|
+
// objects with more properties, so we use `get` here for the
|
|
132
|
+
// comparison.
|
|
133
|
+
!fastDeepEqual(
|
|
134
|
+
edits[key],
|
|
135
|
+
record[key]?.raw ?? record[key]
|
|
136
|
+
) && // Sometimes the server alters the sent value which means
|
|
137
|
+
// we need to also remove the edits before the api request.
|
|
138
|
+
(!action.persistedEdits || !fastDeepEqual(
|
|
139
|
+
edits[key],
|
|
140
|
+
action.persistedEdits[key]
|
|
141
|
+
))
|
|
142
|
+
) {
|
|
143
|
+
acc[key] = edits[key];
|
|
144
|
+
}
|
|
145
|
+
return acc;
|
|
146
|
+
},
|
|
147
|
+
{}
|
|
148
|
+
);
|
|
149
|
+
if (Object.keys(nextEdits2).length) {
|
|
150
|
+
nextState[recordId] = nextEdits2;
|
|
151
|
+
} else {
|
|
152
|
+
delete nextState[recordId];
|
|
223
153
|
}
|
|
224
|
-
return acc;
|
|
225
|
-
}, {});
|
|
226
|
-
if (Object.keys(nextEdits).length) {
|
|
227
|
-
nextState[recordId] = nextEdits;
|
|
228
|
-
} else {
|
|
229
|
-
delete nextState[recordId];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return nextState;
|
|
233
|
-
case 'EDIT_ENTITY_RECORD':
|
|
234
|
-
const nextEdits = {
|
|
235
|
-
...state[action.recordId],
|
|
236
|
-
...action.edits
|
|
237
|
-
};
|
|
238
|
-
Object.keys(nextEdits).forEach(key => {
|
|
239
|
-
// Delete cleared edits so that the properties
|
|
240
|
-
// are not considered dirty.
|
|
241
|
-
if (nextEdits[key] === undefined) {
|
|
242
|
-
delete nextEdits[key];
|
|
243
154
|
}
|
|
155
|
+
return nextState;
|
|
156
|
+
case "EDIT_ENTITY_RECORD":
|
|
157
|
+
const nextEdits = {
|
|
158
|
+
...state[action.recordId],
|
|
159
|
+
...action.edits
|
|
160
|
+
};
|
|
161
|
+
Object.keys(nextEdits).forEach((key) => {
|
|
162
|
+
if (nextEdits[key] === void 0) {
|
|
163
|
+
delete nextEdits[key];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
...state,
|
|
168
|
+
[action.recordId]: nextEdits
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return state;
|
|
172
|
+
},
|
|
173
|
+
saving: (state = {}, action) => {
|
|
174
|
+
switch (action.type) {
|
|
175
|
+
case "SAVE_ENTITY_RECORD_START":
|
|
176
|
+
case "SAVE_ENTITY_RECORD_FINISH":
|
|
177
|
+
return {
|
|
178
|
+
...state,
|
|
179
|
+
[action.recordId]: {
|
|
180
|
+
pending: action.type === "SAVE_ENTITY_RECORD_START",
|
|
181
|
+
error: action.error,
|
|
182
|
+
isAutosave: action.isAutosave
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return state;
|
|
187
|
+
},
|
|
188
|
+
deleting: (state = {}, action) => {
|
|
189
|
+
switch (action.type) {
|
|
190
|
+
case "DELETE_ENTITY_RECORD_START":
|
|
191
|
+
case "DELETE_ENTITY_RECORD_FINISH":
|
|
192
|
+
return {
|
|
193
|
+
...state,
|
|
194
|
+
[action.recordId]: {
|
|
195
|
+
pending: action.type === "DELETE_ENTITY_RECORD_START",
|
|
196
|
+
error: action.error
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return state;
|
|
201
|
+
},
|
|
202
|
+
revisions: (state = {}, action) => {
|
|
203
|
+
if (action.type === "RECEIVE_ITEM_REVISIONS") {
|
|
204
|
+
const recordKey = action.recordKey;
|
|
205
|
+
delete action.recordKey;
|
|
206
|
+
const newState = queriedDataReducer(state[recordKey], {
|
|
207
|
+
...action,
|
|
208
|
+
type: "RECEIVE_ITEMS"
|
|
244
209
|
});
|
|
245
210
|
return {
|
|
246
211
|
...state,
|
|
247
|
-
[
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return state;
|
|
251
|
-
},
|
|
252
|
-
saving: (state = {}, action) => {
|
|
253
|
-
switch (action.type) {
|
|
254
|
-
case 'SAVE_ENTITY_RECORD_START':
|
|
255
|
-
case 'SAVE_ENTITY_RECORD_FINISH':
|
|
256
|
-
return {
|
|
257
|
-
...state,
|
|
258
|
-
[action.recordId]: {
|
|
259
|
-
pending: action.type === 'SAVE_ENTITY_RECORD_START',
|
|
260
|
-
error: action.error,
|
|
261
|
-
isAutosave: action.isAutosave
|
|
262
|
-
}
|
|
212
|
+
[recordKey]: newState
|
|
263
213
|
};
|
|
214
|
+
}
|
|
215
|
+
if (action.type === "REMOVE_ITEMS") {
|
|
216
|
+
return Object.fromEntries(
|
|
217
|
+
Object.entries(state).filter(
|
|
218
|
+
([id]) => !action.itemIds.some((itemId) => {
|
|
219
|
+
if (Number.isInteger(itemId)) {
|
|
220
|
+
return itemId === +id;
|
|
221
|
+
}
|
|
222
|
+
return itemId === id;
|
|
223
|
+
})
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
return state;
|
|
264
228
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
deleting: (state = {}, action) => {
|
|
268
|
-
switch (action.type) {
|
|
269
|
-
case 'DELETE_ENTITY_RECORD_START':
|
|
270
|
-
case 'DELETE_ENTITY_RECORD_FINISH':
|
|
271
|
-
return {
|
|
272
|
-
...state,
|
|
273
|
-
[action.recordId]: {
|
|
274
|
-
pending: action.type === 'DELETE_ENTITY_RECORD_START',
|
|
275
|
-
error: action.error
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
return state;
|
|
280
|
-
},
|
|
281
|
-
revisions: (state = {}, action) => {
|
|
282
|
-
// Use the same queriedDataReducer shape for revisions.
|
|
283
|
-
if (action.type === 'RECEIVE_ITEM_REVISIONS') {
|
|
284
|
-
const recordKey = action.recordKey;
|
|
285
|
-
delete action.recordKey;
|
|
286
|
-
const newState = queriedDataReducer(state[recordKey], {
|
|
287
|
-
...action,
|
|
288
|
-
type: 'RECEIVE_ITEMS'
|
|
289
|
-
});
|
|
290
|
-
return {
|
|
291
|
-
...state,
|
|
292
|
-
[recordKey]: newState
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
if (action.type === 'REMOVE_ITEMS') {
|
|
296
|
-
return Object.fromEntries(Object.entries(state).filter(([id]) => !action.itemIds.some(itemId => {
|
|
297
|
-
if (Number.isInteger(itemId)) {
|
|
298
|
-
return itemId === +id;
|
|
299
|
-
}
|
|
300
|
-
return itemId === id;
|
|
301
|
-
})));
|
|
302
|
-
}
|
|
303
|
-
return state;
|
|
304
|
-
}
|
|
305
|
-
}));
|
|
229
|
+
})
|
|
230
|
+
);
|
|
306
231
|
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Reducer keeping track of the registered entities.
|
|
310
|
-
*
|
|
311
|
-
* @param {Object} state Current state.
|
|
312
|
-
* @param {Object} action Dispatched action.
|
|
313
|
-
*
|
|
314
|
-
* @return {Object} Updated state.
|
|
315
|
-
*/
|
|
316
|
-
export function entitiesConfig(state = rootEntitiesConfig, action) {
|
|
232
|
+
function entitiesConfig(state = rootEntitiesConfig, action) {
|
|
317
233
|
switch (action.type) {
|
|
318
|
-
case
|
|
234
|
+
case "ADD_ENTITIES":
|
|
319
235
|
return [...state, ...action.entities];
|
|
320
236
|
}
|
|
321
237
|
return state;
|
|
322
238
|
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Reducer keeping track of the registered entities config and data.
|
|
326
|
-
*
|
|
327
|
-
* @param {Object} state Current state.
|
|
328
|
-
* @param {Object} action Dispatched action.
|
|
329
|
-
*
|
|
330
|
-
* @return {Object} Updated state.
|
|
331
|
-
*/
|
|
332
|
-
export const entities = (state = {}, action) => {
|
|
239
|
+
const entities = (state = {}, action) => {
|
|
333
240
|
const newConfig = entitiesConfig(state.config, action);
|
|
334
|
-
|
|
335
|
-
// Generates a reducer for the entities nested by `kind` and `name`.
|
|
336
|
-
// A config array with shape:
|
|
337
|
-
// ```
|
|
338
|
-
// [
|
|
339
|
-
// { kind: 'taxonomy', name: 'category' },
|
|
340
|
-
// { kind: 'taxonomy', name: 'post_tag' },
|
|
341
|
-
// { kind: 'postType', name: 'post' },
|
|
342
|
-
// { kind: 'postType', name: 'page' },
|
|
343
|
-
// ]
|
|
344
|
-
// ```
|
|
345
|
-
// generates a reducer for state tree with shape:
|
|
346
|
-
// ```
|
|
347
|
-
// {
|
|
348
|
-
// taxonomy: {
|
|
349
|
-
// category,
|
|
350
|
-
// post_tag,
|
|
351
|
-
// },
|
|
352
|
-
// postType: {
|
|
353
|
-
// post,
|
|
354
|
-
// page,
|
|
355
|
-
// },
|
|
356
|
-
// }
|
|
357
|
-
// ```
|
|
358
241
|
let entitiesDataReducer = state.reducer;
|
|
359
242
|
if (!entitiesDataReducer || newConfig !== state.config) {
|
|
360
243
|
const entitiesByKind = newConfig.reduce((acc, record) => {
|
|
361
|
-
const {
|
|
362
|
-
kind
|
|
363
|
-
} = record;
|
|
244
|
+
const { kind } = record;
|
|
364
245
|
if (!acc[kind]) {
|
|
365
246
|
acc[kind] = [];
|
|
366
247
|
}
|
|
367
248
|
acc[kind].push(record);
|
|
368
249
|
return acc;
|
|
369
250
|
}, {});
|
|
370
|
-
entitiesDataReducer = combineReducers(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
251
|
+
entitiesDataReducer = combineReducers(
|
|
252
|
+
Object.fromEntries(
|
|
253
|
+
Object.entries(entitiesByKind).map(
|
|
254
|
+
([kind, subEntities]) => {
|
|
255
|
+
const kindReducer = combineReducers(
|
|
256
|
+
Object.fromEntries(
|
|
257
|
+
subEntities.map((entityConfig) => [
|
|
258
|
+
entityConfig.name,
|
|
259
|
+
entity(entityConfig)
|
|
260
|
+
])
|
|
261
|
+
)
|
|
262
|
+
);
|
|
263
|
+
return [kind, kindReducer];
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
);
|
|
374
268
|
}
|
|
375
269
|
const newData = entitiesDataReducer(state.records, action);
|
|
376
270
|
if (newData === state.records && newConfig === state.config && entitiesDataReducer === state.reducer) {
|
|
@@ -382,38 +276,22 @@ export const entities = (state = {}, action) => {
|
|
|
382
276
|
config: newConfig
|
|
383
277
|
};
|
|
384
278
|
};
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* @type {UndoManager}
|
|
388
|
-
*/
|
|
389
|
-
export function undoManager(state = createUndoManager()) {
|
|
279
|
+
function undoManager(state = createUndoManager()) {
|
|
390
280
|
return state;
|
|
391
281
|
}
|
|
392
|
-
|
|
282
|
+
function editsReference(state = {}, action) {
|
|
393
283
|
switch (action.type) {
|
|
394
|
-
case
|
|
395
|
-
case
|
|
396
|
-
case
|
|
284
|
+
case "EDIT_ENTITY_RECORD":
|
|
285
|
+
case "UNDO":
|
|
286
|
+
case "REDO":
|
|
397
287
|
return {};
|
|
398
288
|
}
|
|
399
289
|
return state;
|
|
400
290
|
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Reducer managing embed preview data.
|
|
404
|
-
*
|
|
405
|
-
* @param {Object} state Current state.
|
|
406
|
-
* @param {Object} action Dispatched action.
|
|
407
|
-
*
|
|
408
|
-
* @return {Object} Updated state.
|
|
409
|
-
*/
|
|
410
|
-
export function embedPreviews(state = {}, action) {
|
|
291
|
+
function embedPreviews(state = {}, action) {
|
|
411
292
|
switch (action.type) {
|
|
412
|
-
case
|
|
413
|
-
const {
|
|
414
|
-
url,
|
|
415
|
-
preview
|
|
416
|
-
} = action;
|
|
293
|
+
case "RECEIVE_EMBED_PREVIEW":
|
|
294
|
+
const { url, preview } = action;
|
|
417
295
|
return {
|
|
418
296
|
...state,
|
|
419
297
|
[url]: preview
|
|
@@ -421,24 +299,14 @@ export function embedPreviews(state = {}, action) {
|
|
|
421
299
|
}
|
|
422
300
|
return state;
|
|
423
301
|
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* State which tracks whether the user can perform an action on a REST
|
|
427
|
-
* resource.
|
|
428
|
-
*
|
|
429
|
-
* @param {Object} state Current state.
|
|
430
|
-
* @param {Object} action Dispatched action.
|
|
431
|
-
*
|
|
432
|
-
* @return {Object} Updated state.
|
|
433
|
-
*/
|
|
434
|
-
export function userPermissions(state = {}, action) {
|
|
302
|
+
function userPermissions(state = {}, action) {
|
|
435
303
|
switch (action.type) {
|
|
436
|
-
case
|
|
304
|
+
case "RECEIVE_USER_PERMISSION":
|
|
437
305
|
return {
|
|
438
306
|
...state,
|
|
439
307
|
[action.key]: action.isAllowed
|
|
440
308
|
};
|
|
441
|
-
case
|
|
309
|
+
case "RECEIVE_USER_PERMISSIONS":
|
|
442
310
|
return {
|
|
443
311
|
...state,
|
|
444
312
|
...action.permissions
|
|
@@ -446,22 +314,10 @@ export function userPermissions(state = {}, action) {
|
|
|
446
314
|
}
|
|
447
315
|
return state;
|
|
448
316
|
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Reducer returning autosaves keyed by their parent's post id.
|
|
452
|
-
*
|
|
453
|
-
* @param {Object} state Current state.
|
|
454
|
-
* @param {Object} action Dispatched action.
|
|
455
|
-
*
|
|
456
|
-
* @return {Object} Updated state.
|
|
457
|
-
*/
|
|
458
|
-
export function autosaves(state = {}, action) {
|
|
317
|
+
function autosaves(state = {}, action) {
|
|
459
318
|
switch (action.type) {
|
|
460
|
-
case
|
|
461
|
-
const {
|
|
462
|
-
postId,
|
|
463
|
-
autosaves: autosavesData
|
|
464
|
-
} = action;
|
|
319
|
+
case "RECEIVE_AUTOSAVES":
|
|
320
|
+
const { postId, autosaves: autosavesData } = action;
|
|
465
321
|
return {
|
|
466
322
|
...state,
|
|
467
323
|
[postId]: autosavesData
|
|
@@ -469,46 +325,37 @@ export function autosaves(state = {}, action) {
|
|
|
469
325
|
}
|
|
470
326
|
return state;
|
|
471
327
|
}
|
|
472
|
-
|
|
328
|
+
function blockPatterns(state = [], action) {
|
|
473
329
|
switch (action.type) {
|
|
474
|
-
case
|
|
330
|
+
case "RECEIVE_BLOCK_PATTERNS":
|
|
475
331
|
return action.patterns;
|
|
476
332
|
}
|
|
477
333
|
return state;
|
|
478
334
|
}
|
|
479
|
-
|
|
335
|
+
function blockPatternCategories(state = [], action) {
|
|
480
336
|
switch (action.type) {
|
|
481
|
-
case
|
|
337
|
+
case "RECEIVE_BLOCK_PATTERN_CATEGORIES":
|
|
482
338
|
return action.categories;
|
|
483
339
|
}
|
|
484
340
|
return state;
|
|
485
341
|
}
|
|
486
|
-
|
|
342
|
+
function userPatternCategories(state = [], action) {
|
|
487
343
|
switch (action.type) {
|
|
488
|
-
case
|
|
344
|
+
case "RECEIVE_USER_PATTERN_CATEGORIES":
|
|
489
345
|
return action.patternCategories;
|
|
490
346
|
}
|
|
491
347
|
return state;
|
|
492
348
|
}
|
|
493
|
-
|
|
349
|
+
function navigationFallbackId(state = null, action) {
|
|
494
350
|
switch (action.type) {
|
|
495
|
-
case
|
|
351
|
+
case "RECEIVE_NAVIGATION_FALLBACK_ID":
|
|
496
352
|
return action.fallbackId;
|
|
497
353
|
}
|
|
498
354
|
return state;
|
|
499
355
|
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Reducer managing the theme global styles revisions.
|
|
503
|
-
*
|
|
504
|
-
* @param {Record<string, object>} state Current state.
|
|
505
|
-
* @param {Object} action Dispatched action.
|
|
506
|
-
*
|
|
507
|
-
* @return {Record<string, object>} Updated state.
|
|
508
|
-
*/
|
|
509
|
-
export function themeGlobalStyleRevisions(state = {}, action) {
|
|
356
|
+
function themeGlobalStyleRevisions(state = {}, action) {
|
|
510
357
|
switch (action.type) {
|
|
511
|
-
case
|
|
358
|
+
case "RECEIVE_THEME_GLOBAL_STYLE_REVISIONS":
|
|
512
359
|
return {
|
|
513
360
|
...state,
|
|
514
361
|
[action.currentId]: action.revisions
|
|
@@ -516,18 +363,9 @@ export function themeGlobalStyleRevisions(state = {}, action) {
|
|
|
516
363
|
}
|
|
517
364
|
return state;
|
|
518
365
|
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Reducer managing the template lookup per query.
|
|
522
|
-
*
|
|
523
|
-
* @param {Record<string, string>} state Current state.
|
|
524
|
-
* @param {Object} action Dispatched action.
|
|
525
|
-
*
|
|
526
|
-
* @return {Record<string, string>} Updated state.
|
|
527
|
-
*/
|
|
528
|
-
export function defaultTemplates(state = {}, action) {
|
|
366
|
+
function defaultTemplates(state = {}, action) {
|
|
529
367
|
switch (action.type) {
|
|
530
|
-
case
|
|
368
|
+
case "RECEIVE_DEFAULT_TEMPLATE":
|
|
531
369
|
return {
|
|
532
370
|
...state,
|
|
533
371
|
[JSON.stringify(action.query)]: action.templateId
|
|
@@ -535,18 +373,9 @@ export function defaultTemplates(state = {}, action) {
|
|
|
535
373
|
}
|
|
536
374
|
return state;
|
|
537
375
|
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Reducer returning an object of registered post meta.
|
|
541
|
-
*
|
|
542
|
-
* @param {Object} state Current state.
|
|
543
|
-
* @param {Object} action Dispatched action.
|
|
544
|
-
*
|
|
545
|
-
* @return {Object} Updated state.
|
|
546
|
-
*/
|
|
547
|
-
export function registeredPostMeta(state = {}, action) {
|
|
376
|
+
function registeredPostMeta(state = {}, action) {
|
|
548
377
|
switch (action.type) {
|
|
549
|
-
case
|
|
378
|
+
case "RECEIVE_REGISTERED_POST_META":
|
|
550
379
|
return {
|
|
551
380
|
...state,
|
|
552
381
|
[action.postType]: action.registeredPostMeta
|
|
@@ -554,13 +383,10 @@ export function registeredPostMeta(state = {}, action) {
|
|
|
554
383
|
}
|
|
555
384
|
return state;
|
|
556
385
|
}
|
|
557
|
-
|
|
558
|
-
return action.type ===
|
|
559
|
-
...state,
|
|
560
|
-
[action.target]: action.id
|
|
561
|
-
} : state;
|
|
386
|
+
function templateAutoDraftId(state = {}, action) {
|
|
387
|
+
return action.type === "RECEIVE_TEMPLATE_AUTO_DRAFT_ID" ? { ...state, [action.target]: action.id } : state;
|
|
562
388
|
}
|
|
563
|
-
|
|
389
|
+
var reducer_default = combineReducers({
|
|
564
390
|
users,
|
|
565
391
|
currentTheme,
|
|
566
392
|
currentGlobalStylesId,
|
|
@@ -582,4 +408,28 @@ export default combineReducers({
|
|
|
582
408
|
registeredPostMeta,
|
|
583
409
|
templateAutoDraftId
|
|
584
410
|
});
|
|
585
|
-
|
|
411
|
+
export {
|
|
412
|
+
autosaves,
|
|
413
|
+
blockPatternCategories,
|
|
414
|
+
blockPatterns,
|
|
415
|
+
currentGlobalStylesId,
|
|
416
|
+
currentTheme,
|
|
417
|
+
currentUser,
|
|
418
|
+
reducer_default as default,
|
|
419
|
+
defaultTemplates,
|
|
420
|
+
editsReference,
|
|
421
|
+
embedPreviews,
|
|
422
|
+
entities,
|
|
423
|
+
entitiesConfig,
|
|
424
|
+
navigationFallbackId,
|
|
425
|
+
registeredPostMeta,
|
|
426
|
+
templateAutoDraftId,
|
|
427
|
+
themeBaseGlobalStyles,
|
|
428
|
+
themeGlobalStyleRevisions,
|
|
429
|
+
themeGlobalStyleVariations,
|
|
430
|
+
undoManager,
|
|
431
|
+
userPatternCategories,
|
|
432
|
+
userPermissions,
|
|
433
|
+
users
|
|
434
|
+
};
|
|
435
|
+
//# sourceMappingURL=reducer.js.map
|