@wordpress/core-data 4.0.2 → 4.0.6
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/README.md +3 -5
- package/build/actions.js +79 -34
- package/build/actions.js.map +1 -1
- package/build/entities.js +51 -9
- package/build/entities.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +1 -1
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/index.js +0 -7
- package/build/index.js.map +1 -1
- package/build/queried-data/get-query-parts.js +2 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/reducer.js +16 -18
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +48 -31
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +70 -10
- package/build/selectors.js.map +1 -1
- package/build/utils/forward-resolver.js +23 -0
- package/build/utils/forward-resolver.js.map +1 -0
- package/build/utils/index.js +3 -3
- package/build/utils/index.js.map +1 -1
- package/build-module/actions.js +74 -33
- package/build-module/actions.js.map +1 -1
- package/build-module/entities.js +51 -9
- package/build-module/entities.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/index.js +0 -5
- package/build-module/index.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +2 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/reducer.js +14 -16
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +51 -37
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +64 -8
- package/build-module/selectors.js.map +1 -1
- package/build-module/utils/forward-resolver.js +15 -0
- package/build-module/utils/forward-resolver.js.map +1 -0
- package/build-module/utils/index.js +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/package.json +10 -11
- package/src/actions.js +83 -52
- package/src/entities.js +36 -6
- package/src/fetch/__experimental-fetch-url-data.js +1 -1
- package/src/index.js +0 -3
- package/src/queried-data/get-query-parts.js +2 -0
- package/src/reducer.js +14 -17
- package/src/resolvers.js +67 -42
- package/src/selectors.js +143 -35
- package/src/test/actions.js +116 -37
- package/src/test/selectors.js +56 -1
- package/src/utils/forward-resolver.js +14 -0
- package/src/utils/index.js +1 -1
- package/build/controls.js +0 -44
- package/build/controls.js.map +0 -1
- package/build/utils/if-not-resolved.js +0 -31
- package/build/utils/if-not-resolved.js.map +0 -1
- package/build-module/controls.js +0 -31
- package/build-module/controls.js.map +0 -1
- package/build-module/utils/if-not-resolved.js +0 -23
- package/build-module/utils/if-not-resolved.js.map +0 -1
- package/src/controls.js +0 -31
- package/src/utils/if-not-resolved.js +0 -22
- package/src/utils/test/if-not-resolved.js +0 -76
package/src/actions.js
CHANGED
|
@@ -7,9 +7,9 @@ import { v4 as uuid } from 'uuid';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
11
|
-
import triggerFetch from '@wordpress/api-fetch';
|
|
10
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
12
11
|
import { addQueryArgs } from '@wordpress/url';
|
|
12
|
+
import deprecated from '@wordpress/deprecated';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -17,7 +17,6 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
17
17
|
import { receiveItems, removeItems, receiveQueriedItems } from './queried-data';
|
|
18
18
|
import { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';
|
|
19
19
|
import { createBatch } from './batch';
|
|
20
|
-
import { getDispatch } from './controls';
|
|
21
20
|
import { STORE_NAME } from './name';
|
|
22
21
|
|
|
23
22
|
/**
|
|
@@ -119,17 +118,55 @@ export function receiveCurrentTheme( currentTheme ) {
|
|
|
119
118
|
};
|
|
120
119
|
}
|
|
121
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Returns an action object used in signalling that the current global styles id has been received.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} currentGlobalStylesId The current global styles id.
|
|
125
|
+
*
|
|
126
|
+
* @return {Object} Action object.
|
|
127
|
+
*/
|
|
128
|
+
export function __experimentalReceiveCurrentGlobalStylesId(
|
|
129
|
+
currentGlobalStylesId
|
|
130
|
+
) {
|
|
131
|
+
return {
|
|
132
|
+
type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
|
|
133
|
+
id: currentGlobalStylesId,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns an action object used in signalling that the theme base global styles have been received
|
|
139
|
+
*
|
|
140
|
+
* @param {string} stylesheet The theme's identifier
|
|
141
|
+
* @param {Object} globalStyles The global styles object.
|
|
142
|
+
*
|
|
143
|
+
* @return {Object} Action object.
|
|
144
|
+
*/
|
|
145
|
+
export function __experimentalReceiveThemeBaseGlobalStyles(
|
|
146
|
+
stylesheet,
|
|
147
|
+
globalStyles
|
|
148
|
+
) {
|
|
149
|
+
return {
|
|
150
|
+
type: 'RECEIVE_THEME_GLOBAL_STYLES',
|
|
151
|
+
stylesheet,
|
|
152
|
+
globalStyles,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
122
156
|
/**
|
|
123
157
|
* Returns an action object used in signalling that the index has been received.
|
|
124
158
|
*
|
|
125
|
-
* @
|
|
159
|
+
* @deprecated since WP 5.9, this is not useful anymore, use the selector direclty.
|
|
126
160
|
*
|
|
127
161
|
* @return {Object} Action object.
|
|
128
162
|
*/
|
|
129
|
-
export function receiveThemeSupports(
|
|
163
|
+
export function receiveThemeSupports() {
|
|
164
|
+
deprecated( "wp.data.dispatch( 'core' ).receiveThemeSupports", {
|
|
165
|
+
since: '5.9',
|
|
166
|
+
} );
|
|
167
|
+
|
|
130
168
|
return {
|
|
131
|
-
type: '
|
|
132
|
-
themeSupports,
|
|
169
|
+
type: 'DO_NOTHING',
|
|
133
170
|
};
|
|
134
171
|
}
|
|
135
172
|
|
|
@@ -168,13 +205,13 @@ export const deleteEntityRecord = (
|
|
|
168
205
|
name,
|
|
169
206
|
recordId,
|
|
170
207
|
query,
|
|
171
|
-
{ __unstableFetch =
|
|
208
|
+
{ __unstableFetch = apiFetch } = {}
|
|
172
209
|
) => async ( { dispatch } ) => {
|
|
173
210
|
const entities = await dispatch( getKindEntities( kind ) );
|
|
174
211
|
const entity = find( entities, { kind, name } );
|
|
175
212
|
let error;
|
|
176
213
|
let deletedRecord = false;
|
|
177
|
-
if ( ! entity ) {
|
|
214
|
+
if ( ! entity || entity?.__experimentalNoFetch ) {
|
|
178
215
|
return;
|
|
179
216
|
}
|
|
180
217
|
|
|
@@ -242,7 +279,7 @@ export const editEntityRecord = (
|
|
|
242
279
|
recordId,
|
|
243
280
|
edits,
|
|
244
281
|
options = {}
|
|
245
|
-
) =>
|
|
282
|
+
) => ( { select, dispatch } ) => {
|
|
246
283
|
const entity = select.getEntity( kind, name );
|
|
247
284
|
if ( ! entity ) {
|
|
248
285
|
throw new Error(
|
|
@@ -270,7 +307,7 @@ export const editEntityRecord = (
|
|
|
270
307
|
}, {} ),
|
|
271
308
|
transientEdits,
|
|
272
309
|
};
|
|
273
|
-
|
|
310
|
+
dispatch( {
|
|
274
311
|
type: 'EDIT_ENTITY_RECORD',
|
|
275
312
|
...edit,
|
|
276
313
|
meta: {
|
|
@@ -347,11 +384,11 @@ export const saveEntityRecord = (
|
|
|
347
384
|
kind,
|
|
348
385
|
name,
|
|
349
386
|
record,
|
|
350
|
-
{ isAutosave = false, __unstableFetch =
|
|
387
|
+
{ isAutosave = false, __unstableFetch = apiFetch } = {}
|
|
351
388
|
) => async ( { select, resolveSelect, dispatch } ) => {
|
|
352
389
|
const entities = await dispatch( getKindEntities( kind ) );
|
|
353
390
|
const entity = find( entities, { kind, name } );
|
|
354
|
-
if ( ! entity ) {
|
|
391
|
+
if ( ! entity || entity?.__experimentalNoFetch ) {
|
|
355
392
|
return;
|
|
356
393
|
}
|
|
357
394
|
const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
|
|
@@ -371,7 +408,7 @@ export const saveEntityRecord = (
|
|
|
371
408
|
const evaluatedValue = value(
|
|
372
409
|
select.getEditedEntityRecord( kind, name, recordId )
|
|
373
410
|
);
|
|
374
|
-
|
|
411
|
+
dispatch.editEntityRecord(
|
|
375
412
|
kind,
|
|
376
413
|
name,
|
|
377
414
|
recordId,
|
|
@@ -384,7 +421,7 @@ export const saveEntityRecord = (
|
|
|
384
421
|
}
|
|
385
422
|
}
|
|
386
423
|
|
|
387
|
-
|
|
424
|
+
dispatch( {
|
|
388
425
|
type: 'SAVE_ENTITY_RECORD_START',
|
|
389
426
|
kind,
|
|
390
427
|
name,
|
|
@@ -436,12 +473,11 @@ export const saveEntityRecord = (
|
|
|
436
473
|
: data.status,
|
|
437
474
|
}
|
|
438
475
|
);
|
|
439
|
-
|
|
476
|
+
updatedRecord = await __unstableFetch( {
|
|
440
477
|
path: `${ path }/autosaves`,
|
|
441
478
|
method: 'POST',
|
|
442
479
|
data,
|
|
443
|
-
};
|
|
444
|
-
updatedRecord = await __unstableFetch( options );
|
|
480
|
+
} );
|
|
445
481
|
|
|
446
482
|
// An autosave may be processed by the server as a regular save
|
|
447
483
|
// when its update is requested by the author and the post had
|
|
@@ -477,7 +513,7 @@ export const saveEntityRecord = (
|
|
|
477
513
|
},
|
|
478
514
|
{}
|
|
479
515
|
);
|
|
480
|
-
|
|
516
|
+
dispatch.receiveEntityRecords(
|
|
481
517
|
kind,
|
|
482
518
|
name,
|
|
483
519
|
newRecord,
|
|
@@ -485,7 +521,7 @@ export const saveEntityRecord = (
|
|
|
485
521
|
true
|
|
486
522
|
);
|
|
487
523
|
} else {
|
|
488
|
-
|
|
524
|
+
dispatch.receiveAutosaves(
|
|
489
525
|
persistedRecord.id,
|
|
490
526
|
updatedRecord
|
|
491
527
|
);
|
|
@@ -501,13 +537,12 @@ export const saveEntityRecord = (
|
|
|
501
537
|
),
|
|
502
538
|
};
|
|
503
539
|
}
|
|
504
|
-
|
|
540
|
+
updatedRecord = await __unstableFetch( {
|
|
505
541
|
path,
|
|
506
542
|
method: recordId ? 'PUT' : 'POST',
|
|
507
543
|
data: edits,
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
await dispatch.receiveEntityRecords(
|
|
544
|
+
} );
|
|
545
|
+
dispatch.receiveEntityRecords(
|
|
511
546
|
kind,
|
|
512
547
|
name,
|
|
513
548
|
updatedRecord,
|
|
@@ -530,7 +565,7 @@ export const saveEntityRecord = (
|
|
|
530
565
|
|
|
531
566
|
return updatedRecord;
|
|
532
567
|
} finally {
|
|
533
|
-
|
|
568
|
+
dispatch.__unstableReleaseStoreLock( lock );
|
|
534
569
|
}
|
|
535
570
|
};
|
|
536
571
|
|
|
@@ -556,13 +591,12 @@ export const saveEntityRecord = (
|
|
|
556
591
|
* @return {Promise} A promise that resolves to an array containing the return
|
|
557
592
|
* values of each function given in `requests`.
|
|
558
593
|
*/
|
|
559
|
-
export
|
|
594
|
+
export const __experimentalBatch = ( requests ) => async ( { dispatch } ) => {
|
|
560
595
|
const batch = createBatch();
|
|
561
|
-
const dispatch = yield getDispatch();
|
|
562
596
|
const api = {
|
|
563
597
|
saveEntityRecord( kind, name, record, options ) {
|
|
564
598
|
return batch.add( ( add ) =>
|
|
565
|
-
dispatch
|
|
599
|
+
dispatch.saveEntityRecord( kind, name, record, {
|
|
566
600
|
...options,
|
|
567
601
|
__unstableFetch: add,
|
|
568
602
|
} )
|
|
@@ -570,38 +604,28 @@ export function* __experimentalBatch( requests ) {
|
|
|
570
604
|
},
|
|
571
605
|
saveEditedEntityRecord( kind, name, recordId, options ) {
|
|
572
606
|
return batch.add( ( add ) =>
|
|
573
|
-
dispatch(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
{
|
|
578
|
-
...options,
|
|
579
|
-
__unstableFetch: add,
|
|
580
|
-
}
|
|
581
|
-
)
|
|
607
|
+
dispatch.saveEditedEntityRecord( kind, name, recordId, {
|
|
608
|
+
...options,
|
|
609
|
+
__unstableFetch: add,
|
|
610
|
+
} )
|
|
582
611
|
);
|
|
583
612
|
},
|
|
584
613
|
deleteEntityRecord( kind, name, recordId, query, options ) {
|
|
585
614
|
return batch.add( ( add ) =>
|
|
586
|
-
dispatch(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
query,
|
|
591
|
-
{
|
|
592
|
-
...options,
|
|
593
|
-
__unstableFetch: add,
|
|
594
|
-
}
|
|
595
|
-
)
|
|
615
|
+
dispatch.deleteEntityRecord( kind, name, recordId, query, {
|
|
616
|
+
...options,
|
|
617
|
+
__unstableFetch: add,
|
|
618
|
+
} )
|
|
596
619
|
);
|
|
597
620
|
},
|
|
598
621
|
};
|
|
599
622
|
const resultPromises = requests.map( ( request ) => request( api ) );
|
|
600
|
-
const [ , ...results ] =
|
|
601
|
-
|
|
602
|
-
|
|
623
|
+
const [ , ...results ] = await Promise.all( [
|
|
624
|
+
batch.run(),
|
|
625
|
+
...resultPromises,
|
|
626
|
+
] );
|
|
603
627
|
return results;
|
|
604
|
-
}
|
|
628
|
+
};
|
|
605
629
|
|
|
606
630
|
/**
|
|
607
631
|
* Action triggered to save an entity record's edits.
|
|
@@ -620,12 +644,19 @@ export const saveEditedEntityRecord = (
|
|
|
620
644
|
if ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {
|
|
621
645
|
return;
|
|
622
646
|
}
|
|
647
|
+
const entities = await dispatch( getKindEntities( kind ) );
|
|
648
|
+
const entity = find( entities, { kind, name } );
|
|
649
|
+
if ( ! entity ) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
|
|
653
|
+
|
|
623
654
|
const edits = select.getEntityRecordNonTransientEdits(
|
|
624
655
|
kind,
|
|
625
656
|
name,
|
|
626
657
|
recordId
|
|
627
658
|
);
|
|
628
|
-
const record = {
|
|
659
|
+
const record = { [ entityIdKey ]: recordId, ...edits };
|
|
629
660
|
return await dispatch.saveEntityRecord( kind, name, record, options );
|
|
630
661
|
};
|
|
631
662
|
|
package/src/entities.js
CHANGED
|
@@ -23,7 +23,7 @@ export const defaultEntities = [
|
|
|
23
23
|
label: __( 'Base' ),
|
|
24
24
|
name: '__unstableBase',
|
|
25
25
|
kind: 'root',
|
|
26
|
-
baseURL: '',
|
|
26
|
+
baseURL: '/',
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
label: __( 'Site' ),
|
|
@@ -104,7 +104,7 @@ export const defaultEntities = [
|
|
|
104
104
|
{
|
|
105
105
|
name: 'menu',
|
|
106
106
|
kind: 'root',
|
|
107
|
-
baseURL: '/
|
|
107
|
+
baseURL: '/wp/v2/menus',
|
|
108
108
|
baseURLParams: { context: 'edit' },
|
|
109
109
|
plural: 'menus',
|
|
110
110
|
label: __( 'Menu' ),
|
|
@@ -112,20 +112,48 @@ export const defaultEntities = [
|
|
|
112
112
|
{
|
|
113
113
|
name: 'menuItem',
|
|
114
114
|
kind: 'root',
|
|
115
|
-
baseURL: '/
|
|
115
|
+
baseURL: '/wp/v2/menu-items',
|
|
116
116
|
baseURLParams: { context: 'edit' },
|
|
117
117
|
plural: 'menuItems',
|
|
118
118
|
label: __( 'Menu Item' ),
|
|
119
|
+
rawAttributes: [ 'title', 'content' ],
|
|
119
120
|
},
|
|
120
121
|
{
|
|
121
122
|
name: 'menuLocation',
|
|
122
123
|
kind: 'root',
|
|
123
|
-
baseURL: '/
|
|
124
|
+
baseURL: '/wp/v2/menu-locations',
|
|
124
125
|
baseURLParams: { context: 'edit' },
|
|
125
126
|
plural: 'menuLocations',
|
|
126
127
|
label: __( 'Menu Location' ),
|
|
127
128
|
key: 'name',
|
|
128
129
|
},
|
|
130
|
+
{
|
|
131
|
+
name: 'navigationArea',
|
|
132
|
+
kind: 'root',
|
|
133
|
+
baseURL: '/wp/v2/block-navigation-areas',
|
|
134
|
+
baseURLParams: { context: 'edit' },
|
|
135
|
+
plural: 'navigationAreas',
|
|
136
|
+
label: __( 'Navigation Area' ),
|
|
137
|
+
key: 'name',
|
|
138
|
+
getTitle: ( record ) => record?.description,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: __( 'Global Styles' ),
|
|
142
|
+
name: 'globalStyles',
|
|
143
|
+
kind: 'root',
|
|
144
|
+
baseURL: '/wp/v2/global-styles',
|
|
145
|
+
baseURLParams: { context: 'edit' },
|
|
146
|
+
plural: 'globalStylesVariations', // should be different than name
|
|
147
|
+
getTitle: ( record ) => record?.title?.rendered || record?.title,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
label: __( 'Themes' ),
|
|
151
|
+
name: 'theme',
|
|
152
|
+
kind: 'root',
|
|
153
|
+
baseURL: '/wp/v2/themes',
|
|
154
|
+
baseURLParams: { context: 'edit' },
|
|
155
|
+
key: 'stylesheet',
|
|
156
|
+
},
|
|
129
157
|
];
|
|
130
158
|
|
|
131
159
|
export const kinds = [
|
|
@@ -174,9 +202,10 @@ async function loadPostTypeEntities() {
|
|
|
174
202
|
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
|
|
175
203
|
name
|
|
176
204
|
);
|
|
205
|
+
const namespace = postType?.rest_namespace ?? 'wp/v2';
|
|
177
206
|
return {
|
|
178
207
|
kind: 'postType',
|
|
179
|
-
baseURL:
|
|
208
|
+
baseURL: `/${ namespace }/${ postType.rest_base }`,
|
|
180
209
|
baseURLParams: { context: 'edit' },
|
|
181
210
|
name,
|
|
182
211
|
label: postType.labels.singular_name,
|
|
@@ -206,9 +235,10 @@ async function loadTaxonomyEntities() {
|
|
|
206
235
|
path: '/wp/v2/taxonomies?context=edit',
|
|
207
236
|
} );
|
|
208
237
|
return map( taxonomies, ( taxonomy, name ) => {
|
|
238
|
+
const namespace = taxonomy?.rest_namespace ?? 'wp/v2';
|
|
209
239
|
return {
|
|
210
240
|
kind: 'taxonomy',
|
|
211
|
-
baseURL:
|
|
241
|
+
baseURL: `/${ namespace }/${ taxonomy.rest_base }`,
|
|
212
242
|
baseURLParams: { context: 'edit' },
|
|
213
243
|
name,
|
|
214
244
|
label: taxonomy.labels.singular_name,
|
|
@@ -45,7 +45,7 @@ const CACHE = new Map();
|
|
|
45
45
|
* @return {Promise< WPRemoteUrlData[] >} Remote URL data.
|
|
46
46
|
*/
|
|
47
47
|
const fetchUrlData = async ( url, options = {} ) => {
|
|
48
|
-
const endpoint = '/
|
|
48
|
+
const endpoint = '/wp-block-editor/v1/url-details';
|
|
49
49
|
|
|
50
50
|
const args = {
|
|
51
51
|
url: prependHTTP( url ),
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
-
import { controls } from '@wordpress/data-controls';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
@@ -12,7 +11,6 @@ import * as selectors from './selectors';
|
|
|
12
11
|
import * as actions from './actions';
|
|
13
12
|
import * as resolvers from './resolvers';
|
|
14
13
|
import createLocksActions from './locks/actions';
|
|
15
|
-
import customControls from './controls';
|
|
16
14
|
import { defaultEntities, getMethodName } from './entities';
|
|
17
15
|
import { STORE_NAME } from './name';
|
|
18
16
|
|
|
@@ -58,7 +56,6 @@ const entityActions = defaultEntities.reduce( ( result, entity ) => {
|
|
|
58
56
|
|
|
59
57
|
const storeConfig = () => ( {
|
|
60
58
|
reducer,
|
|
61
|
-
controls: { ...customControls, ...controls },
|
|
62
59
|
actions: { ...actions, ...entityActions, ...createLocksActions() },
|
|
63
60
|
selectors: { ...selectors, ...entitySelectors },
|
|
64
61
|
resolvers: { ...resolvers, ...entityResolvers },
|
|
@@ -20,6 +20,8 @@ import { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';
|
|
|
20
20
|
* @property {?(string[])} fields Target subset of fields to derive from
|
|
21
21
|
* item objects.
|
|
22
22
|
* @property {?(number[])} include Specific item IDs to include.
|
|
23
|
+
* @property {string} context Scope under which the request is made;
|
|
24
|
+
* determines returned fields in response.
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
27
|
/**
|
package/src/reducer.js
CHANGED
|
@@ -120,39 +120,36 @@ export function currentTheme( state = undefined, action ) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Reducer managing
|
|
123
|
+
* Reducer managing the current global styles id.
|
|
124
124
|
*
|
|
125
|
-
* @param {
|
|
125
|
+
* @param {string} state Current state.
|
|
126
126
|
* @param {Object} action Dispatched action.
|
|
127
127
|
*
|
|
128
|
-
* @return {
|
|
128
|
+
* @return {string} Updated state.
|
|
129
129
|
*/
|
|
130
|
-
export function
|
|
130
|
+
export function currentGlobalStylesId( state = undefined, action ) {
|
|
131
131
|
switch ( action.type ) {
|
|
132
|
-
case '
|
|
133
|
-
return
|
|
134
|
-
...state,
|
|
135
|
-
[ action.currentTheme.stylesheet ]: action.currentTheme,
|
|
136
|
-
};
|
|
132
|
+
case 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':
|
|
133
|
+
return action.id;
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
return state;
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
/**
|
|
143
|
-
* Reducer managing theme
|
|
140
|
+
* Reducer managing the theme base global styles.
|
|
144
141
|
*
|
|
145
|
-
* @param {
|
|
142
|
+
* @param {string} state Current state.
|
|
146
143
|
* @param {Object} action Dispatched action.
|
|
147
144
|
*
|
|
148
|
-
* @return {
|
|
145
|
+
* @return {string} Updated state.
|
|
149
146
|
*/
|
|
150
|
-
export function
|
|
147
|
+
export function themeBaseGlobalStyles( state = {}, action ) {
|
|
151
148
|
switch ( action.type ) {
|
|
152
|
-
case '
|
|
149
|
+
case 'RECEIVE_THEME_GLOBAL_STYLES':
|
|
153
150
|
return {
|
|
154
151
|
...state,
|
|
155
|
-
|
|
152
|
+
[ action.stylesheet ]: action.globalStyles,
|
|
156
153
|
};
|
|
157
154
|
}
|
|
158
155
|
|
|
@@ -570,10 +567,10 @@ export default combineReducers( {
|
|
|
570
567
|
terms,
|
|
571
568
|
users,
|
|
572
569
|
currentTheme,
|
|
570
|
+
currentGlobalStylesId,
|
|
573
571
|
currentUser,
|
|
572
|
+
themeBaseGlobalStyles,
|
|
574
573
|
taxonomies,
|
|
575
|
-
themes,
|
|
576
|
-
themeSupports,
|
|
577
574
|
entities,
|
|
578
575
|
undo,
|
|
579
576
|
embedPreviews,
|