@wordpress/core-data 6.4.0 → 6.5.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/CHANGELOG.md +2 -0
- package/build/entities.js +7 -7
- package/build/entities.js.map +1 -1
- package/build/queried-data/selectors.js +4 -1
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +3 -1
- package/build/reducer.js.map +1 -1
- package/build/selectors.js +42 -19
- package/build/selectors.js.map +1 -1
- package/build-module/entities.js +7 -6
- package/build-module/entities.js.map +1 -1
- package/build-module/queried-data/selectors.js +5 -2
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/reducer.js +4 -2
- package/build-module/reducer.js.map +1 -1
- package/build-module/selectors.js +43 -20
- package/build-module/selectors.js.map +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/selectors.d.ts +15 -2
- package/build-types/selectors.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/entities.js +1 -2
- package/src/queried-data/selectors.js +5 -2
- package/src/reducer.js +2 -6
- package/src/selectors.ts +58 -102
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/reducer.js"],"names":["fastDeepEqual","groupBy","get","compose","combineReducers","isShallowEqual","ifMatchingAction","replaceAction","reducer","queriedDataReducer","rootEntitiesConfig","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","entity","entityConfig","name","kind","key","queriedData","edits","context","query","nextState","record","items","recordId","nextEdits","Object","keys","acc","persistedEdits","length","forEach","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","entries","memo","subEntities","kindReducer","kindMemo","newData","records","UNDO_INITIAL_STATE","assign","offset","lastEditAction","undo","isCreateUndoLevel","isUndoOrRedo","meta","isUndo","isRedo","some","transientEdits","flattenedUndo","slice","pop","push","comparisonUndoEdits","values","filter","edit","comparisonEdits","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,OAAT,EAAkBC,GAAlB,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,eAAT,QAAgC,iBAAhC;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,SAAhD;AACA,SAASC,OAAO,IAAIC,kBAApB,QAA8C,gBAA9C;AACA,SAASC,kBAAT,EAA6BC,kBAA7B,QAAuD,YAAvD;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,GAAqC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC3C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,QAAT,GAAqBF,MAAM,CAACF;AAFtB,OAAP;AAFF;;AAQA,SAAOC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,KAAT,GAA4D;AAAA,MAA5CJ,KAA4C,uEAApC;AAAEK,IAAAA,IAAI,EAAE,EAAR;AAAYC,IAAAA,OAAO,EAAE;AAArB,GAAoC;AAAA,MAATL,MAAS;;AAClE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,oBAAL;AACC,aAAO;AACNG,QAAAA,IAAI,EAAE,EACL,GAAGL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,EAAAA,qBAJ+B;AAK/BL,EAAAA,WAL+B;AAM/BQ,EAAAA,0BAN+B;AAO/BF,EAAAA,qBAP+B;AAQ/BL,EAAAA,UAR+B;AAS/BmC,EAAAA,QAT+B;AAU/BgB,EAAAA,IAV+B;AAW/BiB,EAAAA,aAX+B;AAY/BG,EAAAA,eAZ+B;AAa/BE,EAAAA,SAb+B;AAc/BG,EAAAA,aAd+B;AAe/BE,EAAAA;AAf+B,CAAF,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { groupBy, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: action.users.map( ( user ) => user.id ),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\tget(\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\t'raw',\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ]\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = rootEntitiesConfig, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities.\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = groupBy( newConfig, 'kind' );\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.records, action );\n\n\tif (\n\t\tnewData === state.records &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @typedef {Object} UndoStateMeta\n *\n * @property {number} offset Where in the undo stack we are.\n * @property {Object} [flattenedUndo] Flattened form of undo stack.\n */\n\n/** @typedef {Array<Object> & UndoStateMeta} UndoState */\n\n/**\n * @type {UndoState}\n *\n * @todo Given how we use this we might want to make a custom class for it.\n */\nconst UNDO_INITIAL_STATE = Object.assign( [], { offset: 0 } );\n\n/** @type {Object} */\nlet lastEditAction;\n\n/**\n * Reducer keeping track of entity edit undo history.\n *\n * @param {UndoState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {UndoState} Updated state.\n */\nexport function undo( state = UNDO_INITIAL_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'CREATE_UNDO_LEVEL':\n\t\t\tlet isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';\n\t\t\tconst isUndoOrRedo =\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t( action.meta.isUndo || action.meta.isRedo );\n\t\t\tif ( isCreateUndoLevel ) {\n\t\t\t\taction = lastEditAction;\n\t\t\t} else if ( ! isUndoOrRedo ) {\n\t\t\t\t// Don't lose the last edit cache if the new one only has transient edits.\n\t\t\t\t// Transient edits don't create new levels so updating the cache would make\n\t\t\t\t// us skip an edit later when creating levels explicitly.\n\t\t\t\tif (\n\t\t\t\t\tObject.keys( action.edits ).some(\n\t\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlastEditAction = action;\n\t\t\t\t} else {\n\t\t\t\t\tlastEditAction = {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\tedits: {\n\t\t\t\t\t\t\t...( lastEditAction && lastEditAction.edits ),\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/** @type {UndoState} */\n\t\t\tlet nextState;\n\n\t\t\tif ( isUndoOrRedo ) {\n\t\t\t\t// @ts-ignore we might consider using Object.assign({}, state)\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.offset =\n\t\t\t\t\tstate.offset + ( action.meta.isUndo ? -1 : 1 );\n\n\t\t\t\tif ( state.flattenedUndo ) {\n\t\t\t\t\t// The first undo in a sequence of undos might happen while we have\n\t\t\t\t\t// flattened undos in state. If this is the case, we want execution\n\t\t\t\t\t// to continue as if we were creating an explicit undo level. This\n\t\t\t\t\t// will result in an extra undo level being appended with the flattened\n\t\t\t\t\t// undo values.\n\t\t\t\t\t// We also have to take into account if the `lastEditAction` had opted out\n\t\t\t\t\t// of being tracked in undo history, like the action that persists the latest\n\t\t\t\t\t// content right before saving. In that case we have to update the `lastEditAction`\n\t\t\t\t\t// to avoid returning early before applying the existing flattened undos.\n\t\t\t\t\tisCreateUndoLevel = true;\n\t\t\t\t\tif ( ! lastEditAction.meta.undo ) {\n\t\t\t\t\t\tlastEditAction.meta.undo = {\n\t\t\t\t\t\t\tedits: {},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\taction = lastEditAction;\n\t\t\t\t} else {\n\t\t\t\t\treturn nextState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! action.meta.undo ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\t// Transient edits don't create an undo level, but are\n\t\t\t// reachable in the next meaningful edit to which they\n\t\t\t// are merged. They are defined in the entity's config.\n\t\t\tif (\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t! Object.keys( action.edits ).some(\n\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// @ts-ignore we might consider using Object.assign({}, state)\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.flattenedUndo = {\n\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t...action.edits,\n\t\t\t\t};\n\t\t\t\tnextState.offset = state.offset;\n\t\t\t\treturn nextState;\n\t\t\t}\n\n\t\t\t// Clear potential redos, because this only supports linear history.\n\t\t\tnextState =\n\t\t\t\t// @ts-ignore this needs additional cleanup, probably involving code-level changes\n\t\t\t\tnextState || state.slice( 0, state.offset || undefined );\n\t\t\tnextState.offset = nextState.offset || 0;\n\t\t\tnextState.pop();\n\t\t\tif ( ! isCreateUndoLevel ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.meta.undo.kind,\n\t\t\t\t\tname: action.meta.undo.name,\n\t\t\t\t\trecordId: action.meta.undo.recordId,\n\t\t\t\t\tedits: {\n\t\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t\t...action.meta.undo.edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// When an edit is a function it's an optimization to avoid running some expensive operation.\n\t\t\t// We can't rely on the function references being the same so we opt out of comparing them here.\n\t\t\tconst comparisonUndoEdits = Object.values(\n\t\t\t\taction.meta.undo.edits\n\t\t\t).filter( ( edit ) => typeof edit !== 'function' );\n\t\t\tconst comparisonEdits = Object.values( action.edits ).filter(\n\t\t\t\t( edit ) => typeof edit !== 'function'\n\t\t\t);\n\t\t\tif ( ! isShallowEqual( comparisonUndoEdits, comparisonEdits ) ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.kind,\n\t\t\t\t\tname: action.name,\n\t\t\t\t\trecordId: action.recordId,\n\t\t\t\t\tedits: isCreateUndoLevel\n\t\t\t\t\t\t? { ...state.flattenedUndo, ...action.edits }\n\t\t\t\t\t\t: action.edits,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\ttaxonomies,\n\tentities,\n\tundo,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n} );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/reducer.js"],"names":["fastDeepEqual","groupBy","compose","combineReducers","isShallowEqual","ifMatchingAction","replaceAction","reducer","queriedDataReducer","rootEntitiesConfig","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","entity","entityConfig","name","kind","key","queriedData","edits","context","query","nextState","record","items","recordId","nextEdits","Object","keys","acc","raw","persistedEdits","length","forEach","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","entries","memo","subEntities","kindReducer","kindMemo","newData","records","UNDO_INITIAL_STATE","assign","offset","lastEditAction","undo","isCreateUndoLevel","isUndoOrRedo","meta","isUndo","isRedo","some","transientEdits","flattenedUndo","slice","pop","push","comparisonUndoEdits","values","filter","edit","comparisonEdits","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,eAAT,QAAgC,iBAAhC;AACA,OAAOC,cAAP,MAA2B,6BAA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uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC/C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,mBAAL;AACC,YAAM;AAAEuF,QAAAA,MAAF;AAAUD,QAAAA,SAAS,EAAEE;AAArB,UAAuCzF,MAA7C;AAEA,aAAO,EACN,GAAGD,KADG;AAEN,SAAEyF,MAAF,GAAYC;AAFN,OAAP;AAJF;;AAUA,SAAO1F,KAAP;AACA;AAED,OAAO,SAAS2F,aAAT,GAA6C;AAAA,MAArB3F,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOD,MAAM,CAAC2F,QAAd;AAFF;;AAKA,SAAO5F,KAAP;AACA;AAED,OAAO,SAAS6F,sBAAT,GAAsD;AAAA,MAArB7F,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC5D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kCAAL;AACC,aAAOD,MAAM,CAAC6F,UAAd;AAFF;;AAKA,SAAO9F,KAAP;AACA;AAED,eAAeT,eAAe,CAAE;AAC/BQ,EAAAA,KAD+B;AAE/BK,EAAAA,KAF+B;AAG/BW,EAAAA,YAH+B;AAI/BG,EAAAA,qBAJ+B;AAK/BL,EAAAA,WAL+B;AAM/BQ,EAAAA,0BAN+B;AAO/BF,EAAAA,qBAP+B;AAQ/BL,EAAAA,UAR+B;AAS/BoC,EAAAA,QAT+B;AAU/BgB,EAAAA,IAV+B;AAW/BiB,EAAAA,aAX+B;AAY/BG,EAAAA,eAZ+B;AAa/BE,EAAAA,SAb+B;AAc/BG,EAAAA,aAd+B;AAe/BE,EAAAA;AAf+B,CAAF,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { groupBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: action.users.map( ( user ) => user.id ),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = rootEntitiesConfig, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities.\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = groupBy( newConfig, 'kind' );\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.records, action );\n\n\tif (\n\t\tnewData === state.records &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @typedef {Object} UndoStateMeta\n *\n * @property {number} offset Where in the undo stack we are.\n * @property {Object} [flattenedUndo] Flattened form of undo stack.\n */\n\n/** @typedef {Array<Object> & UndoStateMeta} UndoState */\n\n/**\n * @type {UndoState}\n *\n * @todo Given how we use this we might want to make a custom class for it.\n */\nconst UNDO_INITIAL_STATE = Object.assign( [], { offset: 0 } );\n\n/** @type {Object} */\nlet lastEditAction;\n\n/**\n * Reducer keeping track of entity edit undo history.\n *\n * @param {UndoState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {UndoState} Updated state.\n */\nexport function undo( state = UNDO_INITIAL_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'CREATE_UNDO_LEVEL':\n\t\t\tlet isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';\n\t\t\tconst isUndoOrRedo =\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t( action.meta.isUndo || action.meta.isRedo );\n\t\t\tif ( isCreateUndoLevel ) {\n\t\t\t\taction = lastEditAction;\n\t\t\t} else if ( ! isUndoOrRedo ) {\n\t\t\t\t// Don't lose the last edit cache if the new one only has transient edits.\n\t\t\t\t// Transient edits don't create new levels so updating the cache would make\n\t\t\t\t// us skip an edit later when creating levels explicitly.\n\t\t\t\tif (\n\t\t\t\t\tObject.keys( action.edits ).some(\n\t\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlastEditAction = action;\n\t\t\t\t} else {\n\t\t\t\t\tlastEditAction = {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\tedits: {\n\t\t\t\t\t\t\t...( lastEditAction && lastEditAction.edits ),\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/** @type {UndoState} */\n\t\t\tlet nextState;\n\n\t\t\tif ( isUndoOrRedo ) {\n\t\t\t\t// @ts-ignore we might consider using Object.assign({}, state)\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.offset =\n\t\t\t\t\tstate.offset + ( action.meta.isUndo ? -1 : 1 );\n\n\t\t\t\tif ( state.flattenedUndo ) {\n\t\t\t\t\t// The first undo in a sequence of undos might happen while we have\n\t\t\t\t\t// flattened undos in state. If this is the case, we want execution\n\t\t\t\t\t// to continue as if we were creating an explicit undo level. This\n\t\t\t\t\t// will result in an extra undo level being appended with the flattened\n\t\t\t\t\t// undo values.\n\t\t\t\t\t// We also have to take into account if the `lastEditAction` had opted out\n\t\t\t\t\t// of being tracked in undo history, like the action that persists the latest\n\t\t\t\t\t// content right before saving. In that case we have to update the `lastEditAction`\n\t\t\t\t\t// to avoid returning early before applying the existing flattened undos.\n\t\t\t\t\tisCreateUndoLevel = true;\n\t\t\t\t\tif ( ! lastEditAction.meta.undo ) {\n\t\t\t\t\t\tlastEditAction.meta.undo = {\n\t\t\t\t\t\t\tedits: {},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\taction = lastEditAction;\n\t\t\t\t} else {\n\t\t\t\t\treturn nextState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! action.meta.undo ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\t// Transient edits don't create an undo level, but are\n\t\t\t// reachable in the next meaningful edit to which they\n\t\t\t// are merged. They are defined in the entity's config.\n\t\t\tif (\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t! Object.keys( action.edits ).some(\n\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// @ts-ignore we might consider using Object.assign({}, state)\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.flattenedUndo = {\n\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t...action.edits,\n\t\t\t\t};\n\t\t\t\tnextState.offset = state.offset;\n\t\t\t\treturn nextState;\n\t\t\t}\n\n\t\t\t// Clear potential redos, because this only supports linear history.\n\t\t\tnextState =\n\t\t\t\t// @ts-ignore this needs additional cleanup, probably involving code-level changes\n\t\t\t\tnextState || state.slice( 0, state.offset || undefined );\n\t\t\tnextState.offset = nextState.offset || 0;\n\t\t\tnextState.pop();\n\t\t\tif ( ! isCreateUndoLevel ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.meta.undo.kind,\n\t\t\t\t\tname: action.meta.undo.name,\n\t\t\t\t\trecordId: action.meta.undo.recordId,\n\t\t\t\t\tedits: {\n\t\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t\t...action.meta.undo.edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// When an edit is a function it's an optimization to avoid running some expensive operation.\n\t\t\t// We can't rely on the function references being the same so we opt out of comparing them here.\n\t\t\tconst comparisonUndoEdits = Object.values(\n\t\t\t\taction.meta.undo.edits\n\t\t\t).filter( ( edit ) => typeof edit !== 'function' );\n\t\t\tconst comparisonEdits = Object.values( action.edits ).filter(\n\t\t\t\t( edit ) => typeof edit !== 'function'\n\t\t\t);\n\t\t\tif ( ! isShallowEqual( comparisonUndoEdits, comparisonEdits ) ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.kind,\n\t\t\t\t\tname: action.name,\n\t\t\t\t\trecordId: action.recordId,\n\t\t\t\t\tedits: isCreateUndoLevel\n\t\t\t\t\t\t? { ...state.flattenedUndo, ...action.edits }\n\t\t\t\t\t\t: action.edits,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\ttaxonomies,\n\tentities,\n\tundo,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n} );\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import createSelector from 'rememo';
|
|
5
|
-
import { set
|
|
5
|
+
import { set } from 'lodash';
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
@@ -187,9 +187,9 @@ export function getEntityConfig(state, kind, name) {
|
|
|
187
187
|
* @return Record.
|
|
188
188
|
*/
|
|
189
189
|
export const getEntityRecord = createSelector((state, kind, name, key, query) => {
|
|
190
|
-
var _query$context, _queriedState$items$c;
|
|
190
|
+
var _state$entities$recor, _state$entities$recor2, _state$entities$recor3, _query$context, _queriedState$items$c;
|
|
191
191
|
|
|
192
|
-
const queriedState =
|
|
192
|
+
const queriedState = (_state$entities$recor = state.entities.records) === null || _state$entities$recor === void 0 ? void 0 : (_state$entities$recor2 = _state$entities$recor[kind]) === null || _state$entities$recor2 === void 0 ? void 0 : (_state$entities$recor3 = _state$entities$recor2[name]) === null || _state$entities$recor3 === void 0 ? void 0 : _state$entities$recor3.queriedData;
|
|
193
193
|
|
|
194
194
|
if (!queriedState) {
|
|
195
195
|
return undefined;
|
|
@@ -218,7 +218,10 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
|
|
|
218
218
|
|
|
219
219
|
for (let f = 0; f < fields.length; f++) {
|
|
220
220
|
const field = fields[f].split('.');
|
|
221
|
-
|
|
221
|
+
let value = item;
|
|
222
|
+
field.forEach(fieldName => {
|
|
223
|
+
value = value[fieldName];
|
|
224
|
+
});
|
|
222
225
|
set(filteredItem, field, value);
|
|
223
226
|
}
|
|
224
227
|
|
|
@@ -227,10 +230,10 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
|
|
|
227
230
|
|
|
228
231
|
return item;
|
|
229
232
|
}, (state, kind, name, recordId, query) => {
|
|
230
|
-
var _query$context2;
|
|
233
|
+
var _query$context2, _state$entities$recor4, _state$entities$recor5, _state$entities$recor6, _state$entities$recor7, _state$entities$recor8, _state$entities$recor9, _state$entities$recor10, _state$entities$recor11, _state$entities$recor12, _state$entities$recor13;
|
|
231
234
|
|
|
232
235
|
const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
|
|
233
|
-
return [
|
|
236
|
+
return [(_state$entities$recor4 = state.entities.records) === null || _state$entities$recor4 === void 0 ? void 0 : (_state$entities$recor5 = _state$entities$recor4[kind]) === null || _state$entities$recor5 === void 0 ? void 0 : (_state$entities$recor6 = _state$entities$recor5[name]) === null || _state$entities$recor6 === void 0 ? void 0 : (_state$entities$recor7 = _state$entities$recor6.queriedData) === null || _state$entities$recor7 === void 0 ? void 0 : (_state$entities$recor8 = _state$entities$recor7.items[context]) === null || _state$entities$recor8 === void 0 ? void 0 : _state$entities$recor8[recordId], (_state$entities$recor9 = state.entities.records) === null || _state$entities$recor9 === void 0 ? void 0 : (_state$entities$recor10 = _state$entities$recor9[kind]) === null || _state$entities$recor10 === void 0 ? void 0 : (_state$entities$recor11 = _state$entities$recor10[name]) === null || _state$entities$recor11 === void 0 ? void 0 : (_state$entities$recor12 = _state$entities$recor11.queriedData) === null || _state$entities$recor12 === void 0 ? void 0 : (_state$entities$recor13 = _state$entities$recor12.itemIsComplete[context]) === null || _state$entities$recor13 === void 0 ? void 0 : _state$entities$recor13[recordId]];
|
|
234
237
|
});
|
|
235
238
|
/**
|
|
236
239
|
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
|
|
@@ -262,10 +265,12 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
|
262
265
|
const record = getEntityRecord(state, kind, name, key);
|
|
263
266
|
return record && Object.keys(record).reduce((accumulator, _key) => {
|
|
264
267
|
if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
|
|
268
|
+
var _record$_key$raw, _record$_key;
|
|
269
|
+
|
|
265
270
|
// Because edits are the "raw" attribute values,
|
|
266
271
|
// we return those from record selectors to make rendering,
|
|
267
272
|
// comparisons, and joins with edits easier.
|
|
268
|
-
accumulator[_key] =
|
|
273
|
+
accumulator[_key] = (_record$_key$raw = (_record$_key = record[_key]) === null || _record$_key === void 0 ? void 0 : _record$_key.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
|
|
269
274
|
} else {
|
|
270
275
|
accumulator[_key] = record[_key];
|
|
271
276
|
}
|
|
@@ -273,10 +278,10 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
|
273
278
|
return accumulator;
|
|
274
279
|
}, {});
|
|
275
280
|
}, (state, kind, name, recordId, query) => {
|
|
276
|
-
var _query$context3;
|
|
281
|
+
var _query$context3, _state$entities$recor14, _state$entities$recor15, _state$entities$recor16, _state$entities$recor17, _state$entities$recor18, _state$entities$recor19, _state$entities$recor20, _state$entities$recor21, _state$entities$recor22, _state$entities$recor23;
|
|
277
282
|
|
|
278
283
|
const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
|
|
279
|
-
return [state.entities.config,
|
|
284
|
+
return [state.entities.config, (_state$entities$recor14 = state.entities.records) === null || _state$entities$recor14 === void 0 ? void 0 : (_state$entities$recor15 = _state$entities$recor14[kind]) === null || _state$entities$recor15 === void 0 ? void 0 : (_state$entities$recor16 = _state$entities$recor15[name]) === null || _state$entities$recor16 === void 0 ? void 0 : (_state$entities$recor17 = _state$entities$recor16.queriedData) === null || _state$entities$recor17 === void 0 ? void 0 : (_state$entities$recor18 = _state$entities$recor17.items[context]) === null || _state$entities$recor18 === void 0 ? void 0 : _state$entities$recor18[recordId], (_state$entities$recor19 = state.entities.records) === null || _state$entities$recor19 === void 0 ? void 0 : (_state$entities$recor20 = _state$entities$recor19[kind]) === null || _state$entities$recor20 === void 0 ? void 0 : (_state$entities$recor21 = _state$entities$recor20[name]) === null || _state$entities$recor21 === void 0 ? void 0 : (_state$entities$recor22 = _state$entities$recor21.queriedData) === null || _state$entities$recor22 === void 0 ? void 0 : (_state$entities$recor23 = _state$entities$recor22.itemIsComplete[context]) === null || _state$entities$recor23 === void 0 ? void 0 : _state$entities$recor23[recordId]];
|
|
280
285
|
});
|
|
281
286
|
/**
|
|
282
287
|
* Returns true if records have been received for the given set of parameters,
|
|
@@ -314,9 +319,11 @@ export function hasEntityRecords(state, kind, name, query) {
|
|
|
314
319
|
* @return Records.
|
|
315
320
|
*/
|
|
316
321
|
export const getEntityRecords = (state, kind, name, query) => {
|
|
322
|
+
var _state$entities$recor24, _state$entities$recor25, _state$entities$recor26;
|
|
323
|
+
|
|
317
324
|
// Queried data state is prepopulated for all known entities. If this is not
|
|
318
325
|
// assigned for the given parameters, then it is known to not exist.
|
|
319
|
-
const queriedState =
|
|
326
|
+
const queriedState = (_state$entities$recor24 = state.entities.records) === null || _state$entities$recor24 === void 0 ? void 0 : (_state$entities$recor25 = _state$entities$recor24[kind]) === null || _state$entities$recor25 === void 0 ? void 0 : (_state$entities$recor26 = _state$entities$recor25[name]) === null || _state$entities$recor26 === void 0 ? void 0 : _state$entities$recor26.queriedData;
|
|
320
327
|
|
|
321
328
|
if (!queriedState) {
|
|
322
329
|
return null;
|
|
@@ -416,7 +423,9 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
|
416
423
|
*/
|
|
417
424
|
|
|
418
425
|
export function getEntityRecordEdits(state, kind, name, recordId) {
|
|
419
|
-
|
|
426
|
+
var _state$entities$recor27, _state$entities$recor28, _state$entities$recor29, _state$entities$recor30;
|
|
427
|
+
|
|
428
|
+
return (_state$entities$recor27 = state.entities.records) === null || _state$entities$recor27 === void 0 ? void 0 : (_state$entities$recor28 = _state$entities$recor27[kind]) === null || _state$entities$recor28 === void 0 ? void 0 : (_state$entities$recor29 = _state$entities$recor28[name]) === null || _state$entities$recor29 === void 0 ? void 0 : (_state$entities$recor30 = _state$entities$recor29.edits) === null || _state$entities$recor30 === void 0 ? void 0 : _state$entities$recor30[recordId];
|
|
420
429
|
}
|
|
421
430
|
/**
|
|
422
431
|
* Returns the specified entity record's non transient edits.
|
|
@@ -450,7 +459,11 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
|
|
|
450
459
|
|
|
451
460
|
return acc;
|
|
452
461
|
}, {});
|
|
453
|
-
}, (state, kind, name, recordId) =>
|
|
462
|
+
}, (state, kind, name, recordId) => {
|
|
463
|
+
var _state$entities$recor31, _state$entities$recor32, _state$entities$recor33, _state$entities$recor34;
|
|
464
|
+
|
|
465
|
+
return [state.entities.config, (_state$entities$recor31 = state.entities.records) === null || _state$entities$recor31 === void 0 ? void 0 : (_state$entities$recor32 = _state$entities$recor31[kind]) === null || _state$entities$recor32 === void 0 ? void 0 : (_state$entities$recor33 = _state$entities$recor32[name]) === null || _state$entities$recor33 === void 0 ? void 0 : (_state$entities$recor34 = _state$entities$recor33.edits) === null || _state$entities$recor34 === void 0 ? void 0 : _state$entities$recor34[recordId]];
|
|
466
|
+
});
|
|
454
467
|
/**
|
|
455
468
|
* Returns true if the specified entity record has edits,
|
|
456
469
|
* and false otherwise.
|
|
@@ -480,10 +493,10 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
480
493
|
export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
|
|
481
494
|
...getEntityRecordEdits(state, kind, name, recordId)
|
|
482
495
|
}), (state, kind, name, recordId, query) => {
|
|
483
|
-
var _query$context4;
|
|
496
|
+
var _query$context4, _state$entities$recor35, _state$entities$recor36, _state$entities$recor37, _state$entities$recor38, _state$entities$recor39, _state$entities$recor40, _state$entities$recor41, _state$entities$recor42, _state$entities$recor43, _state$entities$recor44, _state$entities$recor45, _state$entities$recor46;
|
|
484
497
|
|
|
485
498
|
const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
|
|
486
|
-
return [state.entities.config,
|
|
499
|
+
return [state.entities.config, (_state$entities$recor35 = state.entities.records) === null || _state$entities$recor35 === void 0 ? void 0 : (_state$entities$recor36 = _state$entities$recor35[kind]) === null || _state$entities$recor36 === void 0 ? void 0 : (_state$entities$recor37 = _state$entities$recor36[name]) === null || _state$entities$recor37 === void 0 ? void 0 : (_state$entities$recor38 = _state$entities$recor37.queriedData.items[context]) === null || _state$entities$recor38 === void 0 ? void 0 : _state$entities$recor38[recordId], (_state$entities$recor39 = state.entities.records) === null || _state$entities$recor39 === void 0 ? void 0 : (_state$entities$recor40 = _state$entities$recor39[kind]) === null || _state$entities$recor40 === void 0 ? void 0 : (_state$entities$recor41 = _state$entities$recor40[name]) === null || _state$entities$recor41 === void 0 ? void 0 : (_state$entities$recor42 = _state$entities$recor41.queriedData.itemIsComplete[context]) === null || _state$entities$recor42 === void 0 ? void 0 : _state$entities$recor42[recordId], (_state$entities$recor43 = state.entities.records) === null || _state$entities$recor43 === void 0 ? void 0 : (_state$entities$recor44 = _state$entities$recor43[kind]) === null || _state$entities$recor44 === void 0 ? void 0 : (_state$entities$recor45 = _state$entities$recor44[name]) === null || _state$entities$recor45 === void 0 ? void 0 : (_state$entities$recor46 = _state$entities$recor45.edits) === null || _state$entities$recor46 === void 0 ? void 0 : _state$entities$recor46[recordId]];
|
|
487
500
|
});
|
|
488
501
|
/**
|
|
489
502
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
@@ -497,10 +510,12 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
|
|
|
497
510
|
*/
|
|
498
511
|
|
|
499
512
|
export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
513
|
+
var _state$entities$recor47, _state$entities$recor48, _state$entities$recor49, _state$entities$recor50, _state$entities$recor51;
|
|
514
|
+
|
|
500
515
|
const {
|
|
501
516
|
pending,
|
|
502
517
|
isAutosave
|
|
503
|
-
} =
|
|
518
|
+
} = (_state$entities$recor47 = (_state$entities$recor48 = state.entities.records) === null || _state$entities$recor48 === void 0 ? void 0 : (_state$entities$recor49 = _state$entities$recor48[kind]) === null || _state$entities$recor49 === void 0 ? void 0 : (_state$entities$recor50 = _state$entities$recor49[name]) === null || _state$entities$recor50 === void 0 ? void 0 : (_state$entities$recor51 = _state$entities$recor50.saving) === null || _state$entities$recor51 === void 0 ? void 0 : _state$entities$recor51[recordId]) !== null && _state$entities$recor47 !== void 0 ? _state$entities$recor47 : {};
|
|
504
519
|
return Boolean(pending && isAutosave);
|
|
505
520
|
}
|
|
506
521
|
/**
|
|
@@ -515,7 +530,9 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
515
530
|
*/
|
|
516
531
|
|
|
517
532
|
export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
518
|
-
|
|
533
|
+
var _state$entities$recor52, _state$entities$recor53, _state$entities$recor54, _state$entities$recor55, _state$entities$recor56, _state$entities$recor57;
|
|
534
|
+
|
|
535
|
+
return (_state$entities$recor52 = (_state$entities$recor53 = state.entities.records) === null || _state$entities$recor53 === void 0 ? void 0 : (_state$entities$recor54 = _state$entities$recor53[kind]) === null || _state$entities$recor54 === void 0 ? void 0 : (_state$entities$recor55 = _state$entities$recor54[name]) === null || _state$entities$recor55 === void 0 ? void 0 : (_state$entities$recor56 = _state$entities$recor55.saving) === null || _state$entities$recor56 === void 0 ? void 0 : (_state$entities$recor57 = _state$entities$recor56[recordId]) === null || _state$entities$recor57 === void 0 ? void 0 : _state$entities$recor57.pending) !== null && _state$entities$recor52 !== void 0 ? _state$entities$recor52 : false;
|
|
519
536
|
}
|
|
520
537
|
/**
|
|
521
538
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
@@ -529,7 +546,9 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
529
546
|
*/
|
|
530
547
|
|
|
531
548
|
export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
532
|
-
|
|
549
|
+
var _state$entities$recor58, _state$entities$recor59, _state$entities$recor60, _state$entities$recor61, _state$entities$recor62, _state$entities$recor63;
|
|
550
|
+
|
|
551
|
+
return (_state$entities$recor58 = (_state$entities$recor59 = state.entities.records) === null || _state$entities$recor59 === void 0 ? void 0 : (_state$entities$recor60 = _state$entities$recor59[kind]) === null || _state$entities$recor60 === void 0 ? void 0 : (_state$entities$recor61 = _state$entities$recor60[name]) === null || _state$entities$recor61 === void 0 ? void 0 : (_state$entities$recor62 = _state$entities$recor61.deleting) === null || _state$entities$recor62 === void 0 ? void 0 : (_state$entities$recor63 = _state$entities$recor62[recordId]) === null || _state$entities$recor63 === void 0 ? void 0 : _state$entities$recor63.pending) !== null && _state$entities$recor58 !== void 0 ? _state$entities$recor58 : false;
|
|
533
552
|
}
|
|
534
553
|
/**
|
|
535
554
|
* Returns the specified entity record's last save error.
|
|
@@ -543,7 +562,9 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
543
562
|
*/
|
|
544
563
|
|
|
545
564
|
export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
546
|
-
|
|
565
|
+
var _state$entities$recor64, _state$entities$recor65, _state$entities$recor66, _state$entities$recor67, _state$entities$recor68;
|
|
566
|
+
|
|
567
|
+
return (_state$entities$recor64 = state.entities.records) === null || _state$entities$recor64 === void 0 ? void 0 : (_state$entities$recor65 = _state$entities$recor64[kind]) === null || _state$entities$recor65 === void 0 ? void 0 : (_state$entities$recor66 = _state$entities$recor65[name]) === null || _state$entities$recor66 === void 0 ? void 0 : (_state$entities$recor67 = _state$entities$recor66.saving) === null || _state$entities$recor67 === void 0 ? void 0 : (_state$entities$recor68 = _state$entities$recor67[recordId]) === null || _state$entities$recor68 === void 0 ? void 0 : _state$entities$recor68.error;
|
|
547
568
|
}
|
|
548
569
|
/**
|
|
549
570
|
* Returns the specified entity record's last delete error.
|
|
@@ -557,7 +578,9 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
557
578
|
*/
|
|
558
579
|
|
|
559
580
|
export function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
560
|
-
|
|
581
|
+
var _state$entities$recor69, _state$entities$recor70, _state$entities$recor71, _state$entities$recor72, _state$entities$recor73;
|
|
582
|
+
|
|
583
|
+
return (_state$entities$recor69 = state.entities.records) === null || _state$entities$recor69 === void 0 ? void 0 : (_state$entities$recor70 = _state$entities$recor69[kind]) === null || _state$entities$recor70 === void 0 ? void 0 : (_state$entities$recor71 = _state$entities$recor70[name]) === null || _state$entities$recor71 === void 0 ? void 0 : (_state$entities$recor72 = _state$entities$recor71.deleting) === null || _state$entities$recor72 === void 0 ? void 0 : (_state$entities$recor73 = _state$entities$recor72[recordId]) === null || _state$entities$recor73 === void 0 ? void 0 : _state$entities$recor73.error;
|
|
561
584
|
}
|
|
562
585
|
/**
|
|
563
586
|
* Returns the current undo offset for the
|
|
@@ -713,7 +736,7 @@ export function isPreviewEmbedFallback(state, url) {
|
|
|
713
736
|
|
|
714
737
|
export function canUser(state, action, resource, id) {
|
|
715
738
|
const key = [action, resource, id].filter(Boolean).join('/');
|
|
716
|
-
return
|
|
739
|
+
return state.userPermissions[key];
|
|
717
740
|
}
|
|
718
741
|
/**
|
|
719
742
|
* Returns whether the current user can edit the given entity.
|