@wordpress/core-commands 0.26.0 → 1.0.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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.0 (2024-05-31)
6
+
7
+ ### Breaking Changes
8
+
9
+ - Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
10
+
11
+ ## 0.27.0 (2024-05-16)
12
+
5
13
  ## 0.26.0 (2024-05-02)
6
14
 
7
15
  ## 0.25.0 (2024-04-19)
@@ -52,4 +60,4 @@
52
60
 
53
61
  ## 0.2.0 (2023-05-10)
54
62
 
55
- Initial release.
63
+ Initial release.
@@ -7,25 +7,11 @@ exports.useAdminNavigationCommands = useAdminNavigationCommands;
7
7
  var _commands = require("@wordpress/commands");
8
8
  var _i18n = require("@wordpress/i18n");
9
9
  var _icons = require("@wordpress/icons");
10
- var _url = require("@wordpress/url");
11
- var _router = require("@wordpress/router");
12
- var _hooks = require("./hooks");
13
- var _lockUnlock = require("./lock-unlock");
14
10
  /**
15
11
  * WordPress dependencies
16
12
  */
17
13
 
18
- /**
19
- * Internal dependencies
20
- */
21
-
22
- const {
23
- useHistory
24
- } = (0, _lockUnlock.unlock)(_router.privateApis);
25
14
  function useAdminNavigationCommands() {
26
- const history = useHistory();
27
- const isTemplatesAccessible = (0, _hooks.useIsTemplatesAccessible)();
28
- const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
29
15
  (0, _commands.useCommand)({
30
16
  name: 'core/add-new-post',
31
17
  label: (0, _i18n.__)('Add new post'),
@@ -42,31 +28,5 @@ function useAdminNavigationCommands() {
42
28
  document.location.href = 'post-new.php?post_type=page';
43
29
  }
44
30
  });
45
- (0, _commands.useCommand)({
46
- name: 'core/manage-reusable-blocks',
47
- label: (0, _i18n.__)('Patterns'),
48
- icon: _icons.symbol,
49
- callback: ({
50
- close
51
- }) => {
52
- // The site editor and templates both check whether the user
53
- // can read templates. We can leverage that here and this
54
- // command links to the classic dashboard manage patterns page
55
- // if the user can't access it.
56
- if (isTemplatesAccessible) {
57
- const args = {
58
- path: '/patterns'
59
- };
60
- if (isSiteEditor) {
61
- history.push(args);
62
- } else {
63
- document.location = (0, _url.addQueryArgs)('site-editor.php', args);
64
- }
65
- close();
66
- } else {
67
- document.location.href = 'edit.php?post_type=wp_block';
68
- }
69
- }
70
- });
71
31
  }
72
32
  //# sourceMappingURL=admin-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_commands","require","_i18n","_icons","_url","_router","_hooks","_lockUnlock","useHistory","unlock","routerPrivateApis","useAdminNavigationCommands","history","isTemplatesAccessible","useIsTemplatesAccessible","isSiteEditor","getPath","window","location","href","includes","useCommand","name","label","__","icon","plus","callback","document","symbol","close","args","path","push","addQueryArgs"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus, symbol } from '@wordpress/icons';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useAdminNavigationCommands() {\n\tconst history = useHistory();\n\tconst isTemplatesAccessible = useIsTemplatesAccessible();\n\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\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: __( 'Patterns' ),\n\t\ticon: symbol,\n\t\tcallback: ( { close } ) => {\n\t\t\t// The site editor and templates both check whether the user\n\t\t\t// can read templates. We can leverage that here and this\n\t\t\t// command links to the classic dashboard manage patterns page\n\t\t\t// if the user can't access it.\n\t\t\tif ( isTemplatesAccessible ) {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\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 = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t}\n\t\t},\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEO;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE3C,SAASC,0BAA0BA,CAAA,EAAG;EAC5C,MAAMC,OAAO,GAAGJ,UAAU,CAAC,CAAC;EAC5B,MAAMK,qBAAqB,GAAG,IAAAC,+BAAwB,EAAC,CAAC;EAExD,MAAMC,YAAY,GAAG,IAAAC,YAAO,EAAEC,MAAM,CAACC,QAAQ,CAACC,IAAK,CAAC,EAAEC,QAAQ,CAC7D,iBACD,CAAC;EAED,IAAAC,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,cAAc;IACxC;EACD,CAAE,CAAC;EACH,IAAAE,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,6BAA6B;IACvD;EACD,CAAE,CAAC;EACH,IAAAE,oBAAU,EAAE;IACXC,IAAI,EAAE,6BAA6B;IACnCC,KAAK,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;IACvBC,IAAI,EAAEI,aAAM;IACZF,QAAQ,EAAEA,CAAE;MAAEG;IAAM,CAAC,KAAM;MAC1B;MACA;MACA;MACA;MACA,IAAKjB,qBAAqB,EAAG;QAC5B,MAAMkB,IAAI,GAAG;UACZC,IAAI,EAAE;QACP,CAAC;QACD,IAAKjB,YAAY,EAAG;UACnBH,OAAO,CAACqB,IAAI,CAAEF,IAAK,CAAC;QACrB,CAAC,MAAM;UACNH,QAAQ,CAACV,QAAQ,GAAG,IAAAgB,iBAAY,EAAE,iBAAiB,EAAEH,IAAK,CAAC;QAC5D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACNF,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_commands","require","_i18n","_icons","useAdminNavigationCommands","useCommand","name","label","__","icon","plus","callback","document","location","href"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { 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}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKO,SAASG,0BAA0BA,CAAA,EAAG;EAC5C,IAAAC,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAG,cAAc;IACxC;EACD,CAAE,CAAC;EACH,IAAAT,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAG,6BAA6B;IACvD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
package/build/hooks.js CHANGED
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useIsBlockBasedTheme = useIsBlockBasedTheme;
7
- exports.useIsTemplatesAccessible = useIsTemplatesAccessible;
8
7
  var _coreData = require("@wordpress/core-data");
9
8
  var _data = require("@wordpress/data");
10
9
  /**
11
10
  * WordPress dependencies
12
11
  */
13
12
 
14
- function useIsTemplatesAccessible() {
15
- return (0, _data.useSelect)(select => select(_coreData.store).canUser('read', 'templates'), []);
16
- }
17
13
  function useIsBlockBasedTheme() {
18
14
  return (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme()?.is_block_theme, []);
19
15
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_data","useIsTemplatesAccessible","useSelect","select","coreStore","canUser","useIsBlockBasedTheme","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsTemplatesAccessible() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).canUser( 'read', 'templates' ),\n\t\t[]\n\t);\n}\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIO,SAASE,wBAAwBA,CAAA,EAAG;EAC1C,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACC,OAAO,CAAE,MAAM,EAAE,WAAY,CAAC,EAChE,EACD,CAAC;AACF;AAEO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAJ,eAAS,EACbC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACG,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_data","useIsBlockBasedTheme","useSelect","select","coreStore","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIO,SAASE,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACC,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF","ignoreList":[]}
@@ -25,8 +25,7 @@ var _orderEntityRecordsBySearch = require("./utils/order-entity-records-by-searc
25
25
  */
26
26
 
27
27
  const {
28
- useHistory,
29
- useLocation
28
+ useHistory
30
29
  } = (0, _lockUnlock.unlock)(_router.privateApis);
31
30
  const icons = {
32
31
  post: _icons.post,
@@ -94,9 +93,6 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
94
93
  };
95
94
  }
96
95
  const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
97
- const extraArgs = isSiteEditor ? {
98
- canvas: (0, _url.getQueryArg)(window.location.href, 'canvas')
99
- } : {};
100
96
  return {
101
97
  ...command,
102
98
  callback: ({
@@ -105,7 +101,7 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
105
101
  const args = {
106
102
  postType,
107
103
  postId: record.id,
108
- ...extraArgs
104
+ canvas: 'edit'
109
105
  };
110
106
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
111
107
  if (isSiteEditor) {
@@ -127,9 +123,6 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
127
123
  search
128
124
  }) {
129
125
  const history = useHistory();
130
- const location = useLocation();
131
- const isPatternsPage = location?.params?.path === '/patterns' || location?.params?.postType === 'wp_block';
132
- const didAccessPatternsPage = !!location?.params?.didAccessPatternsPage;
133
126
  const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
134
127
  const {
135
128
  records,
@@ -159,11 +152,9 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
159
152
  if (!isBlockBasedTheme && !templateType === 'wp_template_part') {
160
153
  return [];
161
154
  }
162
- return orderedRecords.map(record => {
163
- const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
164
- const extraArgs = isSiteEditor ? {
165
- canvas: (0, _url.getQueryArg)(window.location.href, 'canvas')
166
- } : {};
155
+ const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
156
+ const result = [];
157
+ result.push(...orderedRecords.map(record => {
167
158
  return {
168
159
  name: templateType + '-' + record.id,
169
160
  searchLabel: record.title?.rendered + ' ' + record.id,
@@ -175,8 +166,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
175
166
  const args = {
176
167
  postType: templateType,
177
168
  postId: record.id,
178
- didAccessPatternsPage: !isBlockBasedTheme && (isPatternsPage || didAccessPatternsPage) ? 1 : undefined,
179
- ...extraArgs
169
+ canvas: 'edit'
180
170
  };
181
171
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
182
172
  if (isSiteEditor) {
@@ -187,7 +177,30 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
187
177
  close();
188
178
  }
189
179
  };
190
- });
180
+ }));
181
+ if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
182
+ result.push({
183
+ name: 'core/edit-site/open-template-parts',
184
+ label: (0, _i18n.__)('Template parts'),
185
+ icon: _icons.symbolFilled,
186
+ callback: ({
187
+ close
188
+ }) => {
189
+ const args = {
190
+ postType: 'wp_template_part',
191
+ categoryId: 'all-parts'
192
+ };
193
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
194
+ if (isSiteEditor) {
195
+ history.push(args);
196
+ } else {
197
+ document.location = targetUrl;
198
+ }
199
+ close();
200
+ }
201
+ });
202
+ }
203
+ return result;
191
204
  }, [isBlockBasedTheme, orderedRecords, history]);
192
205
  return {
193
206
  commands,
@@ -201,91 +214,116 @@ const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemp
201
214
  function useSiteEditorBasicNavigationCommands() {
202
215
  const history = useHistory();
203
216
  const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
204
- const isTemplatesAccessible = (0, _hooks.useIsTemplatesAccessible)();
217
+ const canCreateTemplate = (0, _data.useSelect)(select => {
218
+ return select(_coreData.store).canUser('create', 'templates');
219
+ }, []);
205
220
  const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
206
221
  const commands = (0, _element.useMemo)(() => {
207
222
  const result = [];
208
- if (!isTemplatesAccessible || !isBlockBasedTheme) {
209
- return result;
210
- }
211
- result.push({
212
- name: 'core/edit-site/open-navigation',
213
- label: (0, _i18n.__)('Navigation'),
214
- icon: _icons.navigation,
215
- callback: ({
216
- close
217
- }) => {
218
- const args = {
219
- path: '/navigation'
220
- };
221
- const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
222
- if (isSiteEditor) {
223
- history.push(args);
224
- } else {
225
- document.location = targetUrl;
223
+ if (canCreateTemplate && isBlockBasedTheme) {
224
+ result.push({
225
+ name: 'core/edit-site/open-navigation',
226
+ label: (0, _i18n.__)('Navigation'),
227
+ icon: _icons.navigation,
228
+ callback: ({
229
+ close
230
+ }) => {
231
+ const args = {
232
+ postType: 'wp_navigation'
233
+ };
234
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
235
+ if (isSiteEditor) {
236
+ history.push(args);
237
+ } else {
238
+ document.location = targetUrl;
239
+ }
240
+ close();
226
241
  }
227
- close();
228
- }
229
- });
230
- result.push({
231
- name: 'core/edit-site/open-styles',
232
- label: (0, _i18n.__)('Styles'),
233
- icon: _icons.styles,
234
- callback: ({
235
- close
236
- }) => {
237
- const args = {
238
- path: '/wp_global_styles'
239
- };
240
- const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
241
- if (isSiteEditor) {
242
- history.push(args);
243
- } else {
244
- document.location = targetUrl;
242
+ });
243
+ result.push({
244
+ name: 'core/edit-site/open-styles',
245
+ label: (0, _i18n.__)('Styles'),
246
+ icon: _icons.styles,
247
+ callback: ({
248
+ close
249
+ }) => {
250
+ const args = {
251
+ path: '/wp_global_styles'
252
+ };
253
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
254
+ if (isSiteEditor) {
255
+ history.push(args);
256
+ } else {
257
+ document.location = targetUrl;
258
+ }
259
+ close();
245
260
  }
246
- close();
247
- }
248
- });
249
- result.push({
250
- name: 'core/edit-site/open-pages',
251
- label: (0, _i18n.__)('Pages'),
252
- icon: _icons.page,
253
- callback: ({
254
- close
255
- }) => {
256
- const args = {
257
- path: '/page'
258
- };
259
- const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
260
- if (isSiteEditor) {
261
- history.push(args);
262
- } else {
263
- document.location = targetUrl;
261
+ });
262
+ result.push({
263
+ name: 'core/edit-site/open-pages',
264
+ label: (0, _i18n.__)('Pages'),
265
+ icon: _icons.page,
266
+ callback: ({
267
+ close
268
+ }) => {
269
+ const args = {
270
+ post_type: 'page'
271
+ };
272
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
273
+ if (isSiteEditor) {
274
+ history.push(args);
275
+ } else {
276
+ document.location = targetUrl;
277
+ }
278
+ close();
264
279
  }
265
- close();
266
- }
267
- });
280
+ });
281
+ result.push({
282
+ name: 'core/edit-site/open-templates',
283
+ label: (0, _i18n.__)('Templates'),
284
+ icon: _icons.layout,
285
+ callback: ({
286
+ close
287
+ }) => {
288
+ const args = {
289
+ postType: 'wp_template'
290
+ };
291
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
292
+ if (isSiteEditor) {
293
+ history.push(args);
294
+ } else {
295
+ document.location = targetUrl;
296
+ }
297
+ close();
298
+ }
299
+ });
300
+ }
268
301
  result.push({
269
- name: 'core/edit-site/open-templates',
270
- label: (0, _i18n.__)('Templates'),
271
- icon: _icons.layout,
302
+ name: 'core/edit-site/open-patterns',
303
+ label: (0, _i18n.__)('Patterns'),
304
+ icon: _icons.symbol,
272
305
  callback: ({
273
306
  close
274
307
  }) => {
275
- const args = {
276
- path: '/wp_template'
277
- };
278
- const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
279
- if (isSiteEditor) {
280
- history.push(args);
308
+ if (canCreateTemplate) {
309
+ const args = {
310
+ postType: 'wp_block'
311
+ };
312
+ const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
313
+ if (isSiteEditor) {
314
+ history.push(args);
315
+ } else {
316
+ document.location = targetUrl;
317
+ }
318
+ close();
281
319
  } else {
282
- document.location = targetUrl;
320
+ // If a user cannot access the site editor
321
+ document.location.href = 'edit.php?post_type=wp_block';
283
322
  }
284
- close();
285
323
  }
286
324
  });
287
325
  return result;
288
- }, [history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme]);
326
+ }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]);
289
327
  return {
290
328
  commands,
291
329
  isLoading: false
@@ -1 +1 @@
1
- {"version":3,"names":["_commands","require","_i18n","_element","_data","_coreData","_icons","_router","_url","_compose","_hooks","_lockUnlock","_orderEntityRecordsBySearch","useHistory","useLocation","unlock","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","useDebouncedValue","value","debouncedValue","setDebouncedValue","useState","debounced","useDebounce","useEffect","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","useIsBlockBasedTheme","delayedSearch","records","isLoading","useSelect","select","query","per_page","orderby","status","coreStore","getEntityRecords","hasFinishedResolution","commands","useMemo","map","record","command","name","id","searchLabel","title","rendered","label","__","icon","callback","close","args","action","targetUrl","addQueryArgs","document","location","isSiteEditor","getPath","window","href","includes","extraArgs","canvas","getQueryArg","postId","push","getNavigationCommandLoaderPerTemplate","templateType","isPatternsPage","params","path","didAccessPatternsPage","orderedRecords","orderEntityRecordsBySearch","slice","undefined","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","isTemplatesAccessible","useIsTemplatesAccessible","result","navigation","styles","useSiteEditorNavigationCommands","useCommandLoader","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } 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';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\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[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\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};\n\n\t\t\t\tif (\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\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? {\n\t\t\t\t\t\t\tcanvas: getQueryArg(\n\t\t\t\t\t\t\t\twindow.location.href,\n\t\t\t\t\t\t\t\t'canvas'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\t\t\t\t: {};\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\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, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst location = useLocation();\n\n\t\tconst isPatternsPage =\n\t\t\tlocation?.params?.path === '/patterns' ||\n\t\t\tlocation?.params?.postType === 'wp_block';\n\t\tconst didAccessPatternsPage =\n\t\t\t!! location?.params?.didAccessPatternsPage;\n\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t! templateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn orderedRecords.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\n\t\t\t\treturn {\n\t\t\t\t\tname: templateType + '-' + 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[ templateType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\tdidAccessPatternsPage:\n\t\t\t\t\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t\t\t\t\t( isPatternsPage || didAccessPatternsPage )\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: undefined,\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}, [ isBlockBasedTheme, orderedRecords, 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\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( '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 isTemplatesAccessible = useIsTemplatesAccessible();\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( ! isTemplatesAccessible || ! isBlockBasedTheme ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( '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-styles',\n\t\t\tlabel: __( 'Styles' ),\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-pages',\n\t\t\tlabel: __( '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-templates',\n\t\t\tlabel: __( '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\treturn result;\n\t}, [ history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme ] );\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"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAQA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,2BAAA,GAAAX,OAAA;AAzBA;AACA;AACA;;AAkBA;AACA;AACA;;AAKA,MAAM;EAAEY,UAAU;EAAEC;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE/D,MAAMC,KAAK,GAAG;EACbC,IAAI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CAAE/D,OAAO,EAAEoC,YAAY,EAAEyB,qBAAqB,EAAE5D,iBAAiB,CAAG,CAAC;EAExE,OAAO;IACNc,QAAQ;IACRV,SAAS,EAAE;EACZ,CAAC;AACF;AAEO,SAAS6D,+BAA+BA,CAAA,EAAG;EACjD,IAAAC,0BAAgB,EAAE;IACjB/C,IAAI,EAAE,+BAA+B;IACrCgD,IAAI,EAAEZ;EACP,CAAE,CAAC;EACH,IAAAW,0BAAgB,EAAE;IACjB/C,IAAI,EAAE,+BAA+B;IACrCgD,IAAI,EAAEX;EACP,CAAE,CAAC;EACH,IAAAU,0BAAgB,EAAE;IACjB/C,IAAI,EAAE,mCAAmC;IACzCgD,IAAI,EAAEV;EACP,CAAE,CAAC;EACH,IAAAS,0BAAgB,EAAE;IACjB/C,IAAI,EAAE,wCAAwC;IAC9CgD,IAAI,EAAET;EACP,CAAE,CAAC;EACH,IAAAQ,0BAAgB,EAAE;IACjB/C,IAAI,EAAE,iCAAiC;IACvCgD,IAAI,EAAER,oCAAoC;IAC1CS,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_commands","require","_i18n","_element","_data","_coreData","_icons","_router","_url","_compose","_hooks","_lockUnlock","_orderEntityRecordsBySearch","useHistory","unlock","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","useDebouncedValue","value","debouncedValue","setDebouncedValue","useState","debounced","useDebounce","useEffect","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","useIsBlockBasedTheme","delayedSearch","records","isLoading","useSelect","select","query","per_page","orderby","status","coreStore","getEntityRecords","hasFinishedResolution","commands","useMemo","map","record","command","name","id","searchLabel","title","rendered","label","__","icon","callback","close","args","action","targetUrl","addQueryArgs","document","location","isSiteEditor","getPath","window","href","includes","postId","canvas","push","getNavigationCommandLoaderPerTemplate","templateType","orderedRecords","orderEntityRecordsBySearch","slice","result","length","categoryId","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","canCreateTemplate","canUser","navigation","styles","path","post_type","symbol","useSiteEditorNavigationCommands","useCommandLoader","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\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[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\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};\n\n\t\t\t\tif (\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\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\n\t\t\t\treturn {\n\t\t\t\t\t...command,\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\tcanvas: 'edit',\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, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t! templateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\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\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\tcategoryId: 'all-parts',\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\treturn result;\n\t\t}, [ isBlockBasedTheme, orderedRecords, 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\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( '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 canCreateTemplate = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'create', 'templates' );\n\t}, [] );\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\tlabel: __( 'Navigation' ),\n\t\t\t\ticon: navigation,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_navigation',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\tlabel: __( 'Styles' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-pages',\n\t\t\t\tlabel: __( 'Pages' ),\n\t\t\t\ticon: page,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpost_type: 'page',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\tlabel: __( 'Templates' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_block',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t} else {\n\t\t\t\t\t// If a user cannot access the site editor\n\t\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );\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"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AASA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,2BAAA,GAAAX,OAAA;AA1BA;AACA;AACA;;AAmBA;AACA;AACA;;AAKA,MAAM;EAAEY;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAElD,MAAMC,KAAK,GAAG;EACbC,IAAI,EAAJA,WAAI;EACJC,IAAI,EAAJA,WAAI;EACJC,WAAW,EAAEC,aAAM;EACnBC,gBAAgB,EAAEC;AACnB,CAAC;AAED,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAM,CAAEC,cAAc,EAAEC,iBAAiB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EAC5D,MAAMC,SAAS,GAAG,IAAAC,oBAAW,EAAEH,iBAAiB,EAAE,GAAI,CAAC;EAEvD,IAAAI,kBAAS,EAAE,MAAM;IAChBF,SAAS,CAAEJ,KAAM,CAAC;IAClB,OAAO,MAAMI,SAAS,CAACG,MAAM,CAAC,CAAC;EAChC,CAAC,EAAE,CAAEH,SAAS,EAAEJ,KAAK,CAAG,CAAC;EAEzB,OAAOC,cAAc;AACt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AAC2C,IAAI,CAAEb,IAAK,CAAC;UACrB,CAAC,MAAM;YACNI,QAAQ,CAACC,QAAQ,GAAGH,SAAS;UAC9B;UACAH,KAAK,CAAC,CAAC;QACR,CAAC,MAAM;UACN;UACAK,QAAQ,CAACC,QAAQ,CAACI,IAAI,GAAG,6BAA6B;QACvD;MACD;IACD,CAAE,CAAC;IAEH,OAAOU,MAAM;EACd,CAAC,EAAE,CAAEjD,OAAO,EAAEoC,YAAY,EAAEqB,iBAAiB,EAAExD,iBAAiB,CAAG,CAAC;EAEpE,OAAO;IACNc,QAAQ;IACRV,SAAS,EAAE;EACZ,CAAC;AACF;AAEO,SAAS2D,+BAA+BA,CAAA,EAAG;EACjD,IAAAC,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,+BAA+B;IACrC8C,IAAI,EAAEd;EACP,CAAE,CAAC;EACH,IAAAa,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,+BAA+B;IACrC8C,IAAI,EAAEb;EACP,CAAE,CAAC;EACH,IAAAY,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,mCAAmC;IACzC8C,IAAI,EAAEZ;EACP,CAAE,CAAC;EACH,IAAAW,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,wCAAwC;IAC9C8C,IAAI,EAAEX;EACP,CAAE,CAAC;EACH,IAAAU,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,iCAAiC;IACvC8C,IAAI,EAAEV,oCAAoC;IAC1CW,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -3,22 +3,8 @@
3
3
  */
4
4
  import { useCommand } from '@wordpress/commands';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { plus, symbol } from '@wordpress/icons';
7
- import { addQueryArgs, getPath } from '@wordpress/url';
8
- import { privateApis as routerPrivateApis } from '@wordpress/router';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import { useIsTemplatesAccessible } from './hooks';
14
- import { unlock } from './lock-unlock';
15
- const {
16
- useHistory
17
- } = unlock(routerPrivateApis);
6
+ import { plus } from '@wordpress/icons';
18
7
  export function useAdminNavigationCommands() {
19
- const history = useHistory();
20
- const isTemplatesAccessible = useIsTemplatesAccessible();
21
- const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
22
8
  useCommand({
23
9
  name: 'core/add-new-post',
24
10
  label: __('Add new post'),
@@ -35,31 +21,5 @@ export function useAdminNavigationCommands() {
35
21
  document.location.href = 'post-new.php?post_type=page';
36
22
  }
37
23
  });
38
- useCommand({
39
- name: 'core/manage-reusable-blocks',
40
- label: __('Patterns'),
41
- icon: symbol,
42
- callback: ({
43
- close
44
- }) => {
45
- // The site editor and templates both check whether the user
46
- // can read templates. We can leverage that here and this
47
- // command links to the classic dashboard manage patterns page
48
- // if the user can't access it.
49
- if (isTemplatesAccessible) {
50
- const args = {
51
- path: '/patterns'
52
- };
53
- if (isSiteEditor) {
54
- history.push(args);
55
- } else {
56
- document.location = addQueryArgs('site-editor.php', args);
57
- }
58
- close();
59
- } else {
60
- document.location.href = 'edit.php?post_type=wp_block';
61
- }
62
- }
63
- });
64
24
  }
65
25
  //# sourceMappingURL=admin-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCommand","__","plus","symbol","addQueryArgs","getPath","privateApis","routerPrivateApis","useIsTemplatesAccessible","unlock","useHistory","useAdminNavigationCommands","history","isTemplatesAccessible","isSiteEditor","window","location","href","includes","name","label","icon","callback","document","close","args","path","push"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus, symbol } from '@wordpress/icons';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useAdminNavigationCommands() {\n\tconst history = useHistory();\n\tconst isTemplatesAccessible = useIsTemplatesAccessible();\n\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\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: __( 'Patterns' ),\n\t\ticon: symbol,\n\t\tcallback: ( { close } ) => {\n\t\t\t// The site editor and templates both check whether the user\n\t\t\t// can read templates. We can leverage that here and this\n\t\t\t// command links to the classic dashboard manage patterns page\n\t\t\t// if the user can't access it.\n\t\t\tif ( isTemplatesAccessible ) {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\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 = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t}\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,qBAAqB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,MAAM,QAAQ,kBAAkB;AAC/C,SAASC,YAAY,EAAEC,OAAO,QAAQ,gBAAgB;AACtD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,SAAS;AAClD,SAASC,MAAM,QAA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D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACND,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["useCommand","__","plus","useAdminNavigationCommands","name","label","icon","callback","document","location","href"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { 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}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,qBAAqB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,kBAAkB;AAEvC,OAAO,SAASC,0BAA0BA,CAAA,EAAG;EAC5CH,UAAU,CAAE;IACXI,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAEJ,EAAE,CAAE,cAAe,CAAC;IAC3BK,IAAI,EAAEJ,IAAI;IACVK,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAG,cAAc;IACxC;EACD,CAAE,CAAC;EACHV,UAAU,CAAE;IACXI,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAEJ,EAAE,CAAE,cAAe,CAAC;IAC3BK,IAAI,EAAEJ,IAAI;IACVK,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAG,6BAA6B;IACvD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -3,9 +3,6 @@
3
3
  */
4
4
  import { store as coreStore } from '@wordpress/core-data';
5
5
  import { useSelect } from '@wordpress/data';
6
- export function useIsTemplatesAccessible() {
7
- return useSelect(select => select(coreStore).canUser('read', 'templates'), []);
8
- }
9
6
  export function useIsBlockBasedTheme() {
10
7
  return useSelect(select => select(coreStore).getCurrentTheme()?.is_block_theme, []);
11
8
  }
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreStore","useSelect","useIsTemplatesAccessible","select","canUser","useIsBlockBasedTheme","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsTemplatesAccessible() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).canUser( 'read', 'templates' ),\n\t\t[]\n\t);\n}\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,OAAO,SAASC,wBAAwBA,CAAA,EAAG;EAC1C,OAAOD,SAAS,CACbE,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACI,OAAO,CAAE,MAAM,EAAE,WAAY,CAAC,EAChE,EACD,CAAC;AACF;AAEA,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOJ,SAAS,CACbE,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACM,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["store","coreStore","useSelect","useIsBlockBasedTheme","select","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOD,SAAS,CACbE,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACI,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF","ignoreList":[]}