@wordpress/core-commands 0.4.0 → 0.4.2

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useAddPostTypeCommands = useAddPostTypeCommands;
6
+ exports.useAdminNavigationCommands = useAdminNavigationCommands;
7
7
 
8
8
  var _commands = require("@wordpress/commands");
9
9
 
@@ -14,7 +14,7 @@ var _icons = require("@wordpress/icons");
14
14
  /**
15
15
  * WordPress dependencies
16
16
  */
17
- function useAddPostTypeCommands() {
17
+ function useAdminNavigationCommands() {
18
18
  (0, _commands.useCommand)({
19
19
  name: 'core/add-new-post',
20
20
  label: (0, _i18n.__)('Add new post'),
@@ -31,5 +31,13 @@ function useAddPostTypeCommands() {
31
31
  document.location.href = 'post-new.php?post_type=page';
32
32
  }
33
33
  });
34
+ (0, _commands.useCommand)({
35
+ name: 'core/manage-reusable-blocks',
36
+ label: (0, _i18n.__)('Manage all custom patterns'),
37
+ callback: () => {
38
+ document.location.href = 'edit.php?post_type=wp_block';
39
+ },
40
+ icon: _icons.external
41
+ });
34
42
  }
35
- //# sourceMappingURL=add-post-type-commands.js.map
43
+ //# sourceMappingURL=admin-navigation-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"names":["useAdminNavigationCommands","name","label","icon","plus","callback","document","location","href","external"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKO,SAASA,0BAAT,GAAsC;AAC5C,4BAAY;AACXC,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAZ;AAQA,4BAAY;AACXP,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAZ;AAQA,4BAAY;AACXP,IAAAA,IAAI,EAAE,6BADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,4BAAJ,CAFI;AAGXG,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA,KALU;AAMXL,IAAAA,IAAI,EAAEM;AANK,GAAZ;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus } from '@wordpress/icons';\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Manage all custom patterns' ),\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t},\n\t\ticon: external,\n\t} );\n}\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.privateApis = void 0;
7
7
 
8
- var _addPostTypeCommands = require("./add-post-type-commands");
8
+ var _adminNavigationCommands = require("./admin-navigation-commands");
9
9
 
10
10
  var _siteEditorNavigationCommands = require("./site-editor-navigation-commands");
11
11
 
@@ -15,7 +15,7 @@ var _lockUnlock = require("./lock-unlock");
15
15
  * Internal dependencies
16
16
  */
17
17
  function useCommands() {
18
- (0, _addPostTypeCommands.useAddPostTypeCommands)();
18
+ (0, _adminNavigationCommands.useAdminNavigationCommands)();
19
19
  (0, _siteEditorNavigationCommands.useSiteEditorNavigationCommands)();
20
20
  }
21
21
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/private-apis.js"],"names":["useCommands","privateApis"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,SAASA,WAAT,GAAuB;AACtB;AACA;AACA;;AAEM,MAAMC,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB;AAClBD,EAAAA;AADkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAddPostTypeCommands } from './add-post-type-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAddPostTypeCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/core-commands/src/private-apis.js"],"names":["useCommands","privateApis"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,SAASA,WAAT,GAAuB;AACtB;AACA;AACA;;AAEM,MAAMC,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB;AAClBD,EAAAA;AADkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"]}
@@ -55,17 +55,14 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
55
55
  const query = supportsSearch ? {
56
56
  search: !!search ? search : undefined,
57
57
  per_page: 10,
58
- orderby: search ? 'relevance' : 'date'
58
+ orderby: search ? 'relevance' : 'date',
59
+ status: ['publish', 'future', 'draft', 'pending', 'private']
59
60
  } : {
60
61
  per_page: -1
61
62
  };
62
63
  return {
63
64
  records: getEntityRecords('postType', postType, query),
64
- isLoading: !select(_coreData.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query]),
65
- // We're using the string literal to check whether we're in the site editor.
66
-
67
- /* eslint-disable-next-line @wordpress/data-no-store-string-literals */
68
- isSiteEditor: !!select('edit-site')
65
+ isLoading: !select(_coreData.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
69
66
  };
70
67
  }, [supportsSearch, search]);
71
68
  const commands = (0, _element.useMemo)(() => {
@@ -111,6 +108,124 @@ const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('po
111
108
  const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template');
112
109
  const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template_part');
113
110
 
111
+ function useSiteEditorBasicNavigationCommands() {
112
+ const history = useHistory();
113
+ const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
114
+ const commands = (0, _element.useMemo)(() => {
115
+ const result = [];
116
+ result.push({
117
+ name: 'core/edit-site/open-navigation',
118
+ label: (0, _i18n.__)('Open navigation'),
119
+ icon: _icons.navigation,
120
+ callback: ({
121
+ close
122
+ }) => {
123
+ const args = {
124
+ path: '/navigation'
125
+ };
126
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
127
+
128
+ if (isSiteEditor) {
129
+ history.push(args);
130
+ } else {
131
+ document.location = targetUrl;
132
+ }
133
+
134
+ close();
135
+ }
136
+ });
137
+ result.push({
138
+ name: 'core/edit-site/open-pages',
139
+ label: (0, _i18n.__)('Open pages'),
140
+ icon: _icons.page,
141
+ callback: ({
142
+ close
143
+ }) => {
144
+ const args = {
145
+ path: '/page'
146
+ };
147
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
148
+
149
+ if (isSiteEditor) {
150
+ history.push(args);
151
+ } else {
152
+ document.location = targetUrl;
153
+ }
154
+
155
+ close();
156
+ }
157
+ });
158
+ result.push({
159
+ name: 'core/edit-site/open-style-variations',
160
+ label: (0, _i18n.__)('Open style variations'),
161
+ icon: _icons.styles,
162
+ callback: ({
163
+ close
164
+ }) => {
165
+ const args = {
166
+ path: '/wp_global_styles'
167
+ };
168
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
169
+
170
+ if (isSiteEditor) {
171
+ history.push(args);
172
+ } else {
173
+ document.location = targetUrl;
174
+ }
175
+
176
+ close();
177
+ }
178
+ });
179
+ result.push({
180
+ name: 'core/edit-site/open-templates',
181
+ label: (0, _i18n.__)('Open templates'),
182
+ icon: _icons.layout,
183
+ callback: ({
184
+ close
185
+ }) => {
186
+ const args = {
187
+ path: '/wp_template'
188
+ };
189
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
190
+
191
+ if (isSiteEditor) {
192
+ history.push(args);
193
+ } else {
194
+ document.location = targetUrl;
195
+ }
196
+
197
+ close();
198
+ }
199
+ });
200
+ result.push({
201
+ name: 'core/edit-site/open-template-parts',
202
+ label: (0, _i18n.__)('Open library'),
203
+ icon: _icons.symbolFilled,
204
+ callback: ({
205
+ close
206
+ }) => {
207
+ const args = {
208
+ path: '/wp_template_part'
209
+ };
210
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
211
+
212
+ if (isSiteEditor) {
213
+ history.push(args);
214
+ } else {
215
+ document.location = targetUrl;
216
+ }
217
+
218
+ close();
219
+ }
220
+ });
221
+ return result;
222
+ }, [history, isSiteEditor]);
223
+ return {
224
+ commands,
225
+ isLoading: false
226
+ };
227
+ }
228
+
114
229
  function useSiteEditorNavigationCommands() {
115
230
  (0, _commands.useCommandLoader)({
116
231
  name: 'core/edit-site/navigate-pages',
@@ -128,5 +243,10 @@ function useSiteEditorNavigationCommands() {
128
243
  name: 'core/edit-site/navigate-template-parts',
129
244
  hook: useTemplatePartNavigationCommandLoader
130
245
  });
246
+ (0, _commands.useCommandLoader)({
247
+ name: 'core/edit-site/basic-navigation',
248
+ hook: useSiteEditorBasicNavigationCommands,
249
+ context: 'site-editor'
250
+ });
131
251
  }
132
252
  //# sourceMappingURL=site-editor-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"names":["useHistory","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","select","getEntityRecords","coreStore","query","undefined","per_page","orderby","hasFinishedResolution","isSiteEditor","commands","slice","map","record","window","location","href","extraArgs","canvas","name","id","searchLabel","title","rendered","label","icon","callback","close","args","postId","targetUrl","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorNavigationCommands","hook"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;AAEA,MAAMC,KAAK,GAAG;AACbC,EAAAA,IAAI,EAAJA,WADa;AAEbC,EAAAA,IAAI,EAAJA,WAFa;AAGbC,EAAAA,WAAW,EAAEC,aAHA;AAIbC,EAAAA,gBAAgB,EAAEC;AAJL,CAAd;;AAOA,MAAMC,qCAAqC,GAAKC,QAAF,IAC7C,SAASC,0BAAT,CAAqC;AAAEC,EAAAA;AAAF,CAArC,EAAkD;AACjD,QAAMC,OAAO,GAAGb,UAAU,EAA1B;AACA,QAAMc,cAAc,GAAG,CAAE,C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qC,CAAE,kBAAF,CADtC;;AAGO,SAAS6C,+BAAT,GAA2C;AACjD,kCAAkB;AACjBlB,IAAAA,IAAI,EAAE,+BADW;AAEjBmB,IAAAA,IAAI,EAAEL;AAFW,GAAlB;AAIA,kCAAkB;AACjBd,IAAAA,IAAI,EAAE,+BADW;AAEjBmB,IAAAA,IAAI,EAAEJ;AAFW,GAAlB;AAIA,kCAAkB;AACjBf,IAAAA,IAAI,EAAE,mCADW;AAEjBmB,IAAAA,IAAI,EAAEH;AAFW,GAAlB;AAIA,kCAAkB;AACjBhB,IAAAA,IAAI,EAAE,wCADW;AAEjBmB,IAAAA,IAAI,EAAEF;AAFW,GAAlB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { post, page, layout, symbolFilled } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t\t// We're using the string literal to check whether we're in the site editor.\n\t\t\t\t\t/* eslint-disable-next-line @wordpress/data-no-store-string-literals */\n\t\t\t\t\tisSiteEditor: !! select( 'edit-site' ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"names":["useHistory","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","select","getEntityRecords","coreStore","query","undefined","per_page","orderby","status","hasFinishedResolution","commands","slice","map","record","isSiteEditor","window","location","href","extraArgs","canvas","name","id","searchLabel","title","rendered","label","icon","callback","close","args","postId","targetUrl","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","result","navigation","path","styles","useSiteEditorNavigationCommands","hook","context"],"mappings":";;;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AEV;AAFW,GAAlB;AAIA,kCAAkB;AACjBd,IAAAA,IAAI,EAAE,+BADW;AAEjBwB,IAAAA,IAAI,EAAET;AAFW,GAAlB;AAIA,kCAAkB;AACjBf,IAAAA,IAAI,EAAE,mCADW;AAEjBwB,IAAAA,IAAI,EAAER;AAFW,GAAlB;AAIA,kCAAkB;AACjBhB,IAAAA,IAAI,EAAE,wCADW;AAEjBwB,IAAAA,IAAI,EAAEP;AAFW,GAAlB;AAIA,kCAAkB;AACjBjB,IAAAA,IAAI,EAAE,iCADW;AAEjBwB,IAAAA,IAAI,EAAEN,oCAFW;AAGjBO,IAAAA,OAAO,EAAE;AAHQ,GAAlB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t\t\tstatus: [\n\t\t\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t\t\t'future',\n\t\t\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t\t\t'private',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( 'Open navigation' ),\n\t\t\ticon: navigation,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/navigation',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-pages',\n\t\t\tlabel: __( 'Open pages' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/page',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-style-variations',\n\t\t\tlabel: __( 'Open style variations' ),\n\t\t\ticon: styles,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-templates',\n\t\t\tlabel: __( 'Open templates' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\tlabel: __( 'Open library' ),\n\t\t\ticon: symbolFilled,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template_part',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t\treturn result;\n\t}, [ history, isSiteEditor ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"]}
@@ -3,8 +3,8 @@
3
3
  */
4
4
  import { useCommand } from '@wordpress/commands';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { plus } from '@wordpress/icons';
7
- export function useAddPostTypeCommands() {
6
+ import { external, plus } from '@wordpress/icons';
7
+ export function useAdminNavigationCommands() {
8
8
  useCommand({
9
9
  name: 'core/add-new-post',
10
10
  label: __('Add new post'),
@@ -21,5 +21,13 @@ export function useAddPostTypeCommands() {
21
21
  document.location.href = 'post-new.php?post_type=page';
22
22
  }
23
23
  });
24
+ useCommand({
25
+ name: 'core/manage-reusable-blocks',
26
+ label: __('Manage all custom patterns'),
27
+ callback: () => {
28
+ document.location.href = 'edit.php?post_type=wp_block';
29
+ },
30
+ icon: external
31
+ });
24
32
  }
25
- //# sourceMappingURL=add-post-type-commands.js.map
33
+ //# sourceMappingURL=admin-navigation-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"names":["useCommand","__","external","plus","useAdminNavigationCommands","name","label","icon","callback","document","location","href"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AAEA,OAAO,SAASC,0BAAT,GAAsC;AAC5CJ,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,cAAF,CAFE;AAGXM,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAF,CAAV;AAQAX,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,cAAF,CAFE;AAGXM,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAF,CAAV;AAQAX,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,6BADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,4BAAF,CAFE;AAGXO,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA,KALU;AAMXJ,IAAAA,IAAI,EAAEL;AANK,GAAF,CAAV;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus } from '@wordpress/icons';\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Manage all custom patterns' ),\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t},\n\t\ticon: external,\n\t} );\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { useAddPostTypeCommands } from './add-post-type-commands';
4
+ import { useAdminNavigationCommands } from './admin-navigation-commands';
5
5
  import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';
6
6
  import { lock } from './lock-unlock';
7
7
 
8
8
  function useCommands() {
9
- useAddPostTypeCommands();
9
+ useAdminNavigationCommands();
10
10
  useSiteEditorNavigationCommands();
11
11
  }
12
12
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/private-apis.js"],"names":["useAddPostTypeCommands","useSiteEditorNavigationCommands","lock","useCommands","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,0BAAvC;AACA,SAASC,+BAAT,QAAgD,mCAAhD;AACA,SAASC,IAAT,QAAqB,eAArB;;AAEA,SAASC,WAAT,GAAuB;AACtBH,EAAAA,sBAAsB;AACtBC,EAAAA,+BAA+B;AAC/B;;AAED,OAAO,MAAMG,WAAW,GAAG,EAApB;AACPF,IAAI,CAAEE,WAAF,EAAe;AAClBD,EAAAA;AADkB,CAAf,CAAJ","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAddPostTypeCommands } from './add-post-type-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAddPostTypeCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/core-commands/src/private-apis.js"],"names":["useAdminNavigationCommands","useSiteEditorNavigationCommands","lock","useCommands","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,6BAA3C;AACA,SAASC,+BAAT,QAAgD,mCAAhD;AACA,SAASC,IAAT,QAAqB,eAArB;;AAEA,SAASC,WAAT,GAAuB;AACtBH,EAAAA,0BAA0B;AAC1BC,EAAAA,+BAA+B;AAC/B;;AAED,OAAO,MAAMG,WAAW,GAAG,EAApB;AACPF,IAAI,CAAEE,WAAF,EAAe;AAClBD,EAAAA;AADkB,CAAf,CAAJ","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"]}
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
6
6
  import { useMemo } from '@wordpress/element';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { store as coreStore } from '@wordpress/core-data';
9
- import { post, page, layout, symbolFilled } from '@wordpress/icons';
9
+ import { post, page, layout, symbolFilled, styles, navigation } from '@wordpress/icons';
10
10
  import { privateApis as routerPrivateApis } from '@wordpress/router';
11
11
  import { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';
12
12
  /**
@@ -39,17 +39,14 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
39
39
  const query = supportsSearch ? {
40
40
  search: !!search ? search : undefined,
41
41
  per_page: 10,
42
- orderby: search ? 'relevance' : 'date'
42
+ orderby: search ? 'relevance' : 'date',
43
+ status: ['publish', 'future', 'draft', 'pending', 'private']
43
44
  } : {
44
45
  per_page: -1
45
46
  };
46
47
  return {
47
48
  records: getEntityRecords('postType', postType, query),
48
- isLoading: !select(coreStore).hasFinishedResolution('getEntityRecords', ['postType', postType, query]),
49
- // We're using the string literal to check whether we're in the site editor.
50
-
51
- /* eslint-disable-next-line @wordpress/data-no-store-string-literals */
52
- isSiteEditor: !!select('edit-site')
49
+ isLoading: !select(coreStore).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
53
50
  };
54
51
  }, [supportsSearch, search]);
55
52
  const commands = useMemo(() => {
@@ -94,6 +91,125 @@ const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('pa
94
91
  const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post');
95
92
  const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template');
96
93
  const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template_part');
94
+
95
+ function useSiteEditorBasicNavigationCommands() {
96
+ const history = useHistory();
97
+ const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
98
+ const commands = useMemo(() => {
99
+ const result = [];
100
+ result.push({
101
+ name: 'core/edit-site/open-navigation',
102
+ label: __('Open navigation'),
103
+ icon: navigation,
104
+ callback: ({
105
+ close
106
+ }) => {
107
+ const args = {
108
+ path: '/navigation'
109
+ };
110
+ const targetUrl = addQueryArgs('site-editor.php', args);
111
+
112
+ if (isSiteEditor) {
113
+ history.push(args);
114
+ } else {
115
+ document.location = targetUrl;
116
+ }
117
+
118
+ close();
119
+ }
120
+ });
121
+ result.push({
122
+ name: 'core/edit-site/open-pages',
123
+ label: __('Open pages'),
124
+ icon: page,
125
+ callback: ({
126
+ close
127
+ }) => {
128
+ const args = {
129
+ path: '/page'
130
+ };
131
+ const targetUrl = addQueryArgs('site-editor.php', args);
132
+
133
+ if (isSiteEditor) {
134
+ history.push(args);
135
+ } else {
136
+ document.location = targetUrl;
137
+ }
138
+
139
+ close();
140
+ }
141
+ });
142
+ result.push({
143
+ name: 'core/edit-site/open-style-variations',
144
+ label: __('Open style variations'),
145
+ icon: styles,
146
+ callback: ({
147
+ close
148
+ }) => {
149
+ const args = {
150
+ path: '/wp_global_styles'
151
+ };
152
+ const targetUrl = addQueryArgs('site-editor.php', args);
153
+
154
+ if (isSiteEditor) {
155
+ history.push(args);
156
+ } else {
157
+ document.location = targetUrl;
158
+ }
159
+
160
+ close();
161
+ }
162
+ });
163
+ result.push({
164
+ name: 'core/edit-site/open-templates',
165
+ label: __('Open templates'),
166
+ icon: layout,
167
+ callback: ({
168
+ close
169
+ }) => {
170
+ const args = {
171
+ path: '/wp_template'
172
+ };
173
+ const targetUrl = addQueryArgs('site-editor.php', args);
174
+
175
+ if (isSiteEditor) {
176
+ history.push(args);
177
+ } else {
178
+ document.location = targetUrl;
179
+ }
180
+
181
+ close();
182
+ }
183
+ });
184
+ result.push({
185
+ name: 'core/edit-site/open-template-parts',
186
+ label: __('Open library'),
187
+ icon: symbolFilled,
188
+ callback: ({
189
+ close
190
+ }) => {
191
+ const args = {
192
+ path: '/wp_template_part'
193
+ };
194
+ const targetUrl = addQueryArgs('site-editor.php', args);
195
+
196
+ if (isSiteEditor) {
197
+ history.push(args);
198
+ } else {
199
+ document.location = targetUrl;
200
+ }
201
+
202
+ close();
203
+ }
204
+ });
205
+ return result;
206
+ }, [history, isSiteEditor]);
207
+ return {
208
+ commands,
209
+ isLoading: false
210
+ };
211
+ }
212
+
97
213
  export function useSiteEditorNavigationCommands() {
98
214
  useCommandLoader({
99
215
  name: 'core/edit-site/navigate-pages',
@@ -111,5 +227,10 @@ export function useSiteEditorNavigationCommands() {
111
227
  name: 'core/edit-site/navigate-template-parts',
112
228
  hook: useTemplatePartNavigationCommandLoader
113
229
  });
230
+ useCommandLoader({
231
+ name: 'core/edit-site/basic-navigation',
232
+ hook: useSiteEditorBasicNavigationCommands,
233
+ context: 'site-editor'
234
+ });
114
235
  }
115
236
  //# sourceMappingURL=site-editor-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"names":["useCommandLoader","__","useMemo","useSelect","store","coreStore","post","page","layout","symbolFilled","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","unlock","useHistory","icons","wp_template","wp_template_part","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","select","getEntityRecords","query","undefined","per_page","orderby","hasFinishedResolution","isSiteEditor","commands","slice","map","record","window","location","href","extraArgs","canvas","name","id","searchLabel","title","rendered","label","icon","callback","close","args","postId","targetUrl","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorNavigationCommands","hook"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,qBAAjC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,MAArB,EAA6BC,YAA7B,QAAiD,kBAAjD;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,WAAT,EAAsBC,YAAtB,EAAoCC,OAApC,QAAmD,gBAAnD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,eAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAiBD,MAAM,CAAEJ,iBAAF,CAA7B;AAEA,MAAMM,KAAK,GAAG;AACbX,EAAAA,IADa;AAEbC,EAAAA,IAFa;AAGbW,EAAAA,WAAW,EAAEV,MAHA;AAIbW,EAAAA,gBAAgB,EAAEV;AAJL,CAAd;;AAOA,MAAMW,qCAAqC,GAAKC,QAAF,IAC7C,SAASC,0BAAT,CAAqC;AAAEC,EAAAA;AAAF,CAArC,EAAkD;AACjD,QAAMC,OAAO,GAAGR,UAAU,EAA1B;AACA,QAAMS,cAAc,GAAG,CAAE,CAAE,aAAF,EAAiB,kBAAjB,E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EA,MAAM2C,sCAAsC,GAC3C3C,qCAAqC,CAAE,kBAAF,CADtC;AAGA,OAAO,SAAS4C,+BAAT,GAA2C;AACjDhE,EAAAA,gBAAgB,CAAE;AACjB8C,IAAAA,IAAI,EAAE,+BADW;AAEjBmB,IAAAA,IAAI,EAAEL;AAFW,GAAF,CAAhB;AAIA5D,EAAAA,gBAAgB,CAAE;AACjB8C,IAAAA,IAAI,EAAE,+BADW;AAEjBmB,IAAAA,IAAI,EAAEJ;AAFW,GAAF,CAAhB;AAIA7D,EAAAA,gBAAgB,CAAE;AACjB8C,IAAAA,IAAI,EAAE,mCADW;AAEjBmB,IAAAA,IAAI,EAAEH;AAFW,GAAF,CAAhB;AAIA9D,EAAAA,gBAAgB,CAAE;AACjB8C,IAAAA,IAAI,EAAE,wCADW;AAEjBmB,IAAAA,IAAI,EAAEF;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { post, page, layout, symbolFilled } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t\t// We're using the string literal to check whether we're in the site editor.\n\t\t\t\t\t/* eslint-disable-next-line @wordpress/data-no-store-string-literals */\n\t\t\t\t\tisSiteEditor: !! select( 'edit-site' ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"names":["useCommandLoader","__","useMemo","useSelect","store","coreStore","post","page","layout","symbolFilled","styles","navigation","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","unlock","useHistory","icons","wp_template","wp_template_part","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","select","getEntityRecords","query","undefined","per_page","orderby","status","hasFinishedResolution","commands","slice","map","record","isSiteEditor","window","location","href","extraArgs","canvas","name","id","searchLabel","title","rendered","label","icon","callback","close","args","postId","targetUrl","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","result","path","useSiteEditorNavigationCommands","hook","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,qBAAjC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,IADD,EAECC,IAFD,EAGCC,MAHD,EAICC,YAJD,EAKCC,MALD,EAMCC,UAND,QAOO,kBAPP;AAQA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,WAAT,EAAsBC,YAAtB,EAAoCC,OAApC,QAAmD,gBAAnD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,eAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAiBD,MAAM,CAAEJ,iBAAF,CAA7B;AAEA,MAAMM,KAAK,GAAG;AACbb,EAAAA,IADa;AAEbC,EAAAA,IAFa;AAGba,EAAAA,WAAW,EAAEZ,MAHA;AAIba,EAAAA,gBAAgB,EAAEZ;AAJL,CAAd;;AAOA,MAAMa,qCAAqC,GAAKC,QAAF,IAC7C,SAASC,0BAAT,CAAqC;AAAEC,EAAAA;AAAF,CAArC,EAAkD;AACjD,QAAMC,OAAO,GAAGR,UAAU,EAA1B;AACA,QAAMS,cAAc,GAAG,CAAE,CAAE,aAAF,EAAiB,kBAAjB,EAAsCC,QAAtC,CACxBL,QADwB,CAAzB;AAGA,QAAM;AAAEM,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAyB3B,SAAS,CACrC4B,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAE1B,SAAF,CAAnC;AACA,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encies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t\t\tstatus: [\n\t\t\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t\t\t'future',\n\t\t\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t\t\t'private',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( 'Open navigation' ),\n\t\t\ticon: navigation,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/navigation',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-pages',\n\t\t\tlabel: __( 'Open pages' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/page',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-style-variations',\n\t\t\tlabel: __( 'Open style variations' ),\n\t\t\ticon: styles,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-templates',\n\t\t\tlabel: __( 'Open templates' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\tlabel: __( 'Open library' ),\n\t\t\ticon: symbolFilled,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template_part',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t\treturn result;\n\t}, [ history, isSiteEditor ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-commands",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "WordPress core reusable commands.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,15 +27,15 @@
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/commands": "^0.6.0",
31
- "@wordpress/core-data": "^6.12.0",
32
- "@wordpress/data": "^9.5.0",
33
- "@wordpress/element": "^5.12.0",
34
- "@wordpress/i18n": "^4.35.0",
35
- "@wordpress/icons": "^9.26.0",
36
- "@wordpress/private-apis": "^0.17.0",
37
- "@wordpress/router": "^0.4.0",
38
- "@wordpress/url": "^3.36.0"
30
+ "@wordpress/commands": "^0.6.2",
31
+ "@wordpress/core-data": "^6.12.2",
32
+ "@wordpress/data": "^9.5.1",
33
+ "@wordpress/element": "^5.12.1",
34
+ "@wordpress/i18n": "^4.35.1",
35
+ "@wordpress/icons": "^9.26.2",
36
+ "@wordpress/private-apis": "^0.17.1",
37
+ "@wordpress/router": "^0.4.1",
38
+ "@wordpress/url": "^3.36.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^18.0.0"
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
46
+ "gitHead": "a00463f06c90ae6705951861eb889e67a52bf448"
47
47
  }
@@ -3,9 +3,9 @@
3
3
  */
4
4
  import { useCommand } from '@wordpress/commands';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { plus } from '@wordpress/icons';
6
+ import { external, plus } from '@wordpress/icons';
7
7
 
8
- export function useAddPostTypeCommands() {
8
+ export function useAdminNavigationCommands() {
9
9
  useCommand( {
10
10
  name: 'core/add-new-post',
11
11
  label: __( 'Add new post' ),
@@ -22,4 +22,12 @@ export function useAddPostTypeCommands() {
22
22
  document.location.href = 'post-new.php?post_type=page';
23
23
  },
24
24
  } );
25
+ useCommand( {
26
+ name: 'core/manage-reusable-blocks',
27
+ label: __( 'Manage all custom patterns' ),
28
+ callback: () => {
29
+ document.location.href = 'edit.php?post_type=wp_block';
30
+ },
31
+ icon: external,
32
+ } );
25
33
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { useAddPostTypeCommands } from './add-post-type-commands';
4
+ import { useAdminNavigationCommands } from './admin-navigation-commands';
5
5
  import { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';
6
6
  import { lock } from './lock-unlock';
7
7
 
8
8
  function useCommands() {
9
- useAddPostTypeCommands();
9
+ useAdminNavigationCommands();
10
10
  useSiteEditorNavigationCommands();
11
11
  }
12
12
 
@@ -6,7 +6,14 @@ import { __ } from '@wordpress/i18n';
6
6
  import { useMemo } from '@wordpress/element';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { store as coreStore } from '@wordpress/core-data';
9
- import { post, page, layout, symbolFilled } from '@wordpress/icons';
9
+ import {
10
+ post,
11
+ page,
12
+ layout,
13
+ symbolFilled,
14
+ styles,
15
+ navigation,
16
+ } from '@wordpress/icons';
10
17
  import { privateApis as routerPrivateApis } from '@wordpress/router';
11
18
  import { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';
12
19
 
@@ -38,6 +45,13 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
38
45
  search: !! search ? search : undefined,
39
46
  per_page: 10,
40
47
  orderby: search ? 'relevance' : 'date',
48
+ status: [
49
+ 'publish',
50
+ 'future',
51
+ 'draft',
52
+ 'pending',
53
+ 'private',
54
+ ],
41
55
  }
42
56
  : {
43
57
  per_page: -1,
@@ -48,9 +62,6 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
48
62
  'getEntityRecords',
49
63
  [ 'postType', postType, query ]
50
64
  ),
51
- // We're using the string literal to check whether we're in the site editor.
52
- /* eslint-disable-next-line @wordpress/data-no-store-string-literals */
53
- isSiteEditor: !! select( 'edit-site' ),
54
65
  };
55
66
  },
56
67
  [ supportsSearch, search ]
@@ -107,6 +118,111 @@ const useTemplateNavigationCommandLoader =
107
118
  const useTemplatePartNavigationCommandLoader =
108
119
  getNavigationCommandLoaderPerPostType( 'wp_template_part' );
109
120
 
121
+ function useSiteEditorBasicNavigationCommands() {
122
+ const history = useHistory();
123
+ const isSiteEditor = getPath( window.location.href )?.includes(
124
+ 'site-editor.php'
125
+ );
126
+ const commands = useMemo( () => {
127
+ const result = [];
128
+ result.push( {
129
+ name: 'core/edit-site/open-navigation',
130
+ label: __( 'Open navigation' ),
131
+ icon: navigation,
132
+ callback: ( { close } ) => {
133
+ const args = {
134
+ path: '/navigation',
135
+ };
136
+ const targetUrl = addQueryArgs( 'site-editor.php', args );
137
+ if ( isSiteEditor ) {
138
+ history.push( args );
139
+ } else {
140
+ document.location = targetUrl;
141
+ }
142
+ close();
143
+ },
144
+ } );
145
+
146
+ result.push( {
147
+ name: 'core/edit-site/open-pages',
148
+ label: __( 'Open pages' ),
149
+ icon: page,
150
+ callback: ( { close } ) => {
151
+ const args = {
152
+ path: '/page',
153
+ };
154
+ const targetUrl = addQueryArgs( 'site-editor.php', args );
155
+ if ( isSiteEditor ) {
156
+ history.push( args );
157
+ } else {
158
+ document.location = targetUrl;
159
+ }
160
+ close();
161
+ },
162
+ } );
163
+
164
+ result.push( {
165
+ name: 'core/edit-site/open-style-variations',
166
+ label: __( 'Open style variations' ),
167
+ icon: styles,
168
+ callback: ( { close } ) => {
169
+ const args = {
170
+ path: '/wp_global_styles',
171
+ };
172
+ const targetUrl = addQueryArgs( 'site-editor.php', args );
173
+ if ( isSiteEditor ) {
174
+ history.push( args );
175
+ } else {
176
+ document.location = targetUrl;
177
+ }
178
+ close();
179
+ },
180
+ } );
181
+
182
+ result.push( {
183
+ name: 'core/edit-site/open-templates',
184
+ label: __( 'Open templates' ),
185
+ icon: layout,
186
+ callback: ( { close } ) => {
187
+ const args = {
188
+ path: '/wp_template',
189
+ };
190
+ const targetUrl = addQueryArgs( 'site-editor.php', args );
191
+ if ( isSiteEditor ) {
192
+ history.push( args );
193
+ } else {
194
+ document.location = targetUrl;
195
+ }
196
+ close();
197
+ },
198
+ } );
199
+
200
+ result.push( {
201
+ name: 'core/edit-site/open-template-parts',
202
+ label: __( 'Open library' ),
203
+ icon: symbolFilled,
204
+ callback: ( { close } ) => {
205
+ const args = {
206
+ path: '/wp_template_part',
207
+ };
208
+ const targetUrl = addQueryArgs( 'site-editor.php', args );
209
+ if ( isSiteEditor ) {
210
+ history.push( args );
211
+ } else {
212
+ document.location = targetUrl;
213
+ }
214
+ close();
215
+ },
216
+ } );
217
+ return result;
218
+ }, [ history, isSiteEditor ] );
219
+
220
+ return {
221
+ commands,
222
+ isLoading: false,
223
+ };
224
+ }
225
+
110
226
  export function useSiteEditorNavigationCommands() {
111
227
  useCommandLoader( {
112
228
  name: 'core/edit-site/navigate-pages',
@@ -124,4 +240,9 @@ export function useSiteEditorNavigationCommands() {
124
240
  name: 'core/edit-site/navigate-template-parts',
125
241
  hook: useTemplatePartNavigationCommandLoader,
126
242
  } );
243
+ useCommandLoader( {
244
+ name: 'core/edit-site/basic-navigation',
245
+ hook: useSiteEditorBasicNavigationCommands,
246
+ context: 'site-editor',
247
+ } );
127
248
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/add-post-type-commands.js"],"names":["useAddPostTypeCommands","name","label","icon","plus","callback","document","location","href"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKO,SAASA,sBAAT,GAAkC;AACxC,4BAAY;AACXC,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAZ;AAQA,4BAAY;AACXP,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAZ;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\nexport function useAddPostTypeCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/add-post-type-commands.js"],"names":["useCommand","__","plus","useAddPostTypeCommands","name","label","icon","callback","document","location","href"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA,OAAO,SAASC,sBAAT,GAAkC;AACxCH,EAAAA,UAAU,CAAE;AACXI,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEJ,EAAE,CAAE,cAAF,CAFE;AAGXK,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAF,CAAV;AAQAV,EAAAA,UAAU,CAAE;AACXI,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEJ,EAAE,CAAE,cAAF,CAFE;AAGXK,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAF,CAAV;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\nexport function useAddPostTypeCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n}\n"]}