@wordpress/core-commands 0.24.0 → 0.26.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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.26.0 (2024-05-02)
6
+
7
+ ## 0.25.0 (2024-04-19)
8
+
5
9
  ## 0.24.0 (2024-04-03)
6
10
 
7
11
  ## 0.23.0 (2024-03-21)
@@ -25,7 +25,6 @@ const {
25
25
  function useAdminNavigationCommands() {
26
26
  const history = useHistory();
27
27
  const isTemplatesAccessible = (0, _hooks.useIsTemplatesAccessible)();
28
- const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
29
28
  const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
30
29
  (0, _commands.useCommand)({
31
30
  name: 'core/add-new-post',
@@ -50,7 +49,11 @@ function useAdminNavigationCommands() {
50
49
  callback: ({
51
50
  close
52
51
  }) => {
53
- if (isTemplatesAccessible && isBlockBasedTheme) {
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) {
54
57
  const args = {
55
58
  path: '/patterns'
56
59
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_commands","require","_i18n","_icons","_url","_router","_hooks","_lockUnlock","useHistory","unlock","routerPrivateApis","useAdminNavigationCommands","history","isTemplatesAccessible","useIsTemplatesAccessible","isBlockBasedTheme","useIsBlockBasedTheme","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, useIsBlockBasedTheme } 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\tconst isBlockBasedTheme = useIsBlockBasedTheme();\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\tif ( isTemplatesAccessible && isBlockBasedTheme ) {\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,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AKjB,YAAY,EAAG;UACnBL,OAAO,CAACuB,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"}
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 +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"}
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 +1 @@
1
- {"version":3,"names":["_privateApis","require"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA"}
1
+ {"version":3,"names":["_privateApis","require"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,iHAAiH,EACjH,0BACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,iHAAiH,EACjH,0BACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_adminNavigationCommands","require","_siteEditorNavigationCommands","_lockUnlock","useCommands","useAdminNavigationCommands","useSiteEditorNavigationCommands","privateApis","exports","lock"],"sources":["@wordpress/core-commands/src/private-apis.js"],"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"],"mappings":";;;;;;AAGA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,SAASG,WAAWA,CAAA,EAAG;EACtB,IAAAC,mDAA0B,EAAC,CAAC;EAC5B,IAAAC,6DAA+B,EAAC,CAAC;AAClC;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,CAAC,CAAC;AAC7B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBH;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["_adminNavigationCommands","require","_siteEditorNavigationCommands","_lockUnlock","useCommands","useAdminNavigationCommands","useSiteEditorNavigationCommands","privateApis","exports","lock"],"sources":["@wordpress/core-commands/src/private-apis.js"],"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"],"mappings":";;;;;;AAGA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,SAASG,WAAWA,CAAA,EAAG;EACtB,IAAAC,mDAA0B,EAAC,CAAC;EAC5B,IAAAC,6DAA+B,EAAC,CAAC;AAClC;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,CAAC,CAAC;AAC7B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBH;AACD,CAAE,CAAC","ignoreList":[]}
@@ -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,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D,CAAE,CAAC;IAEH,OAAOkC,MAAM;EACd,CAAC,EAAE,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"}
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,GA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d,CAAC,EAAE,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 +1 @@
1
- {"version":3,"names":["orderEntityRecordsBySearch","records","search","Array","isArray","length","priority","nonPriority","i","record","title","raw","toLowerCase","includes","push","concat"],"sources":["@wordpress/core-commands/src/utils/order-entity-records-by-search.js"],"sourcesContent":["export function orderEntityRecordsBySearch( records = [], search = '' ) {\n\tif ( ! Array.isArray( records ) || ! records.length ) {\n\t\treturn [];\n\t}\n\n\tif ( ! search ) {\n\t\treturn records;\n\t}\n\n\tconst priority = [];\n\tconst nonPriority = [];\n\n\tfor ( let i = 0; i < records.length; i++ ) {\n\t\tconst record = records[ i ];\n\t\tif (\n\t\t\trecord?.title?.raw?.toLowerCase()?.includes( search?.toLowerCase() )\n\t\t) {\n\t\t\tpriority.push( record );\n\t\t} else {\n\t\t\tnonPriority.push( record );\n\t\t}\n\t}\n\n\treturn priority.concat( nonPriority );\n}\n"],"mappings":";;;;;;AAAO,SAASA,0BAA0BA,CAAEC,OAAO,GAAG,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAG;EACvE,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,IAAI,CAAEA,OAAO,CAACI,MAAM,EAAG;IACrD,OAAO,EAAE;EACV;EAEA,IAAK,CAAEH,MAAM,EAAG;IACf,OAAOD,OAAO;EACf;EAEA,MAAMK,QAAQ,GAAG,EAAE;EACnB,MAAMC,WAAW,GAAG,EAAE;EAEtB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,OAAO,CAACI,MAAM,EAAEG,CAAC,EAAE,EAAG;IAC1C,MAAMC,MAAM,GAAGR,OAAO,CAAEO,CAAC,CAAE;IAC3B,IACCC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,CAAEX,MAAM,EAAEU,WAAW,CAAC,CAAE,CAAC,EACnE;MACDN,QAAQ,CAACQ,IAAI,CAAEL,MAAO,CAAC;IACxB,CAAC,MAAM;MACNF,WAAW,CAACO,IAAI,CAAEL,MAAO,CAAC;IAC3B;EACD;EAEA,OAAOH,QAAQ,CAACS,MAAM,CAAER,WAAY,CAAC;AACtC"}
1
+ {"version":3,"names":["orderEntityRecordsBySearch","records","search","Array","isArray","length","priority","nonPriority","i","record","title","raw","toLowerCase","includes","push","concat"],"sources":["@wordpress/core-commands/src/utils/order-entity-records-by-search.js"],"sourcesContent":["export function orderEntityRecordsBySearch( records = [], search = '' ) {\n\tif ( ! Array.isArray( records ) || ! records.length ) {\n\t\treturn [];\n\t}\n\n\tif ( ! search ) {\n\t\treturn records;\n\t}\n\n\tconst priority = [];\n\tconst nonPriority = [];\n\n\tfor ( let i = 0; i < records.length; i++ ) {\n\t\tconst record = records[ i ];\n\t\tif (\n\t\t\trecord?.title?.raw?.toLowerCase()?.includes( search?.toLowerCase() )\n\t\t) {\n\t\t\tpriority.push( record );\n\t\t} else {\n\t\t\tnonPriority.push( record );\n\t\t}\n\t}\n\n\treturn priority.concat( nonPriority );\n}\n"],"mappings":";;;;;;AAAO,SAASA,0BAA0BA,CAAEC,OAAO,GAAG,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAG;EACvE,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,IAAI,CAAEA,OAAO,CAACI,MAAM,EAAG;IACrD,OAAO,EAAE;EACV;EAEA,IAAK,CAAEH,MAAM,EAAG;IACf,OAAOD,OAAO;EACf;EAEA,MAAMK,QAAQ,GAAG,EAAE;EACnB,MAAMC,WAAW,GAAG,EAAE;EAEtB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,OAAO,CAACI,MAAM,EAAEG,CAAC,EAAE,EAAG;IAC1C,MAAMC,MAAM,GAAGR,OAAO,CAAEO,CAAC,CAAE;IAC3B,IACCC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,CAAEX,MAAM,EAAEU,WAAW,CAAC,CAAE,CAAC,EACnE;MACDN,QAAQ,CAACQ,IAAI,CAAEL,MAAO,CAAC;IACxB,CAAC,MAAM;MACNF,WAAW,CAACO,IAAI,CAAEL,MAAO,CAAC;IAC3B;EACD;EAEA,OAAOH,QAAQ,CAACS,MAAM,CAAER,WAAY,CAAC;AACtC","ignoreList":[]}
@@ -10,7 +10,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
- import { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';
13
+ import { useIsTemplatesAccessible } from './hooks';
14
14
  import { unlock } from './lock-unlock';
15
15
  const {
16
16
  useHistory
@@ -18,7 +18,6 @@ const {
18
18
  export function useAdminNavigationCommands() {
19
19
  const history = useHistory();
20
20
  const isTemplatesAccessible = useIsTemplatesAccessible();
21
- const isBlockBasedTheme = useIsBlockBasedTheme();
22
21
  const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
23
22
  useCommand({
24
23
  name: 'core/add-new-post',
@@ -43,7 +42,11 @@ export function useAdminNavigationCommands() {
43
42
  callback: ({
44
43
  close
45
44
  }) => {
46
- if (isTemplatesAccessible && isBlockBasedTheme) {
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) {
47
50
  const args = {
48
51
  path: '/patterns'
49
52
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useCommand","__","plus","symbol","addQueryArgs","getPath","privateApis","routerPrivateApis","useIsTemplatesAccessible","useIsBlockBasedTheme","unlock","useHistory","useAdminNavigationCommands","history","isTemplatesAccessible","isBlockBasedTheme","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, useIsBlockBasedTheme } 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\tconst isBlockBasedTheme = useIsBlockBasedTheme();\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\tif ( isTemplatesAccessible && isBlockBasedTheme ) {\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,EAAEC,oBAAoB,QAAQ,SAAS;AACxE,SAASC,MAAM,QAAQ,eAAe;AAEtC,MAAM;EAAEC;AAAW,CAAC,GAAGD,MAAM,CAAEH,iBAAkB,CAAC;AAElD,OAAO,SAASK,0BAA0BA,CAAA,EAAG;EAC5C,MAAMC,OAAO,GAAGF,UAAU,CAAC,CAAC;EAC5B,MAAMG,qBAAqB,GAAGN,wBAAwB,CAAC,CAAC;EACxD,MAAMO,iBAAiB,GAAGN,oBAAoB,CAAC,CAAC;EAEhD,MAAMO,YAAY,GAAGX,OAAO,CAAEY,MAAM,CAACC,QAAQ,CAACC,IAAK,CAAC,EAAEC,QAAQ,CAC7D,iBACD,CAAC;EAEDpB,UAAU,CAAE;IACXqB,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAErB,EAAE,CAAE,cAAe,CAAC;IAC3BsB,IAAI,EAAErB,IAAI;IACVsB,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,cAAc;IACxC;EACD,CAAE,CAAC;EACHnB,UAAU,CAAE;IACXqB,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAErB,EAAE,CAAE,cAAe,CAAC;IAC3BsB,IAAI,EAAErB,IAAI;IACVsB,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,6BAA6B;IACvD;EACD,CAAE,CAAC;EACHnB,UAAU,CAAE;IACXqB,IAAI,EAAE,6BAA6B;IACnCC,KAAK,EAAErB,EAAE,CAAE,UAAW,CAAC;IACvBsB,IAAI,EAAEpB,MAAM;IACZqB,QAAQ,EAAEA,CAAE;MAAEE;IAAM,CAAC,KAAM;MAC1B,IAAKZ,qBAAqB,IAAIC,iBAAiB,EAAG;QACjD,MAAMY,IAAI,GAAG;UACZC,IAAI,EAAE;QACP,CAAC;QACD,IAAKZ,YAAY,EAAG;UACnBH,OAAO,CAACgB,IAAI,CAAEF,IAAK,CAAC;QACrB,CAAC,MAAM;UACNF,QAAQ,CAACP,QAAQ,GAAGd,YAAY,CAAE,iBAAiB,EAAEuB,IAAK,CAAC;QAC5D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACND,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD;EACD,CAAE,CAAC;AACJ"}
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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EE;IAAM,CAAC,KAAM;MAC1B;MACA;MACA;MACA;MACA,IAAKX,qBAAqB,EAAG;QAC5B,MAAMY,IAAI,GAAG;UACZC,IAAI,EAAE;QACP,CAAC;QACD,IAAKZ,YAAY,EAAG;UACnBF,OAAO,CAACe,IAAI,CAAEF,IAAK,CAAC;QACrB,CAAC,MAAM;UACNF,QAAQ,CAACP,QAAQ,GAAGZ,YAAY,CAAE,iBAAiB,EAAEqB,IAAK,CAAC;QAC5D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACND,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -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"}
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 +1 @@
1
- {"version":3,"names":["privateApis"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB"}
1
+ {"version":3,"names":["privateApis"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,0BACD,CAAC"}
1
+ {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,0BACD,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["useAdminNavigationCommands","useSiteEditorNavigationCommands","lock","useCommands","privateApis"],"sources":["@wordpress/core-commands/src/private-apis.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,6BAA6B;AACxE,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,IAAI,QAAQ,eAAe;AAEpC,SAASC,WAAWA,CAAA,EAAG;EACtBH,0BAA0B,CAAC,CAAC;EAC5BC,+BAA+B,CAAC,CAAC;AAClC;AAEA,OAAO,MAAMG,WAAW,GAAG,CAAC,CAAC;AAC7BF,IAAI,CAAEE,WAAW,EAAE;EAClBD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["useAdminNavigationCommands","useSiteEditorNavigationCommands","lock","useCommands","privateApis"],"sources":["@wordpress/core-commands/src/private-apis.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,6BAA6B;AACxE,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,IAAI,QAAQ,eAAe;AAEpC,SAASC,WAAWA,CAAA,EAAG;EACtBH,0BAA0B,CAAC,CAAC;EAC5BC,+BAA+B,CAAC,CAAC;AAClC;AAEA,OAAO,MAAMG,WAAW,GAAG,CAAC,CAAC;AAC7BF,IAAI,CAAEE,WAAW,EAAE;EAClBD;AACD,CAAE,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["useCommandLoader","__","useMemo","useEffect","useState","useSelect","store","coreStore","post","page","layout","symbolFilled","styles","navigation","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","useDebounce","useIsTemplatesAccessible","useIsBlockBasedTheme","unlock","orderEntityRecordsBySearch","useHistory","useLocation","icons","wp_template","wp_template_part","useDebouncedValue","value","debouncedValue","setDebouncedValue","debounced","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","delayedSearch","records","isLoading","select","query","per_page","orderby","status","getEntityRecords","hasFinishedResolution","commands","map","record","command","name","id","searchLabel","title","rendered","label","icon","callback","close","args","action","targetUrl","document","location","isSiteEditor","window","href","includes","extraArgs","canvas","postId","push","getNavigationCommandLoaderPerTemplate","templateType","isPatternsPage","params","path","didAccessPatternsPage","orderedRecords","slice","undefined","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","isTemplatesAccessible","result","useSiteEditorNavigationCommands","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":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,IAAI,EACJC,IAAI,EACJ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,MAAMf,SAAS,GAAGjD,YAAY,CAAE,iBAAiB,EAAE+C,IAAK,CAAC;QACzD,IAAKK,YAAY,EAAG;UACnB9B,OAAO,CAACqC,IAAI,CAAEZ,IAAK,CAAC;QACrB,CAAC,MAAM;UACNG,QAAQ,CAACC,QAAQ,GAAGF,SAAS;QAC9B;QACAH,KAAK,CAAC,CAAC;MACR;IACD,CAAE,CAAC;IAEH,OAAO6B,MAAM;EACd,CAAC,EAAE,CAAErD,OAAO,EAAE8B,YAAY,EAAEsB,qBAAqB,EAAEnD,iBAAiB,CAAG,CAAC;EAExE,OAAO;IACNW,QAAQ;IACRR,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,OAAO,SAASkD,+BAA+BA,CAAA,EAAG;EACjD7F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAER;EACP,CAAE,CAAC;EACHtF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAEP;EACP,CAAE,CAAC;EACHvF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,mCAAmC;IACzCuC,IAAI,EAAEN;EACP,CAAE,CAAC;EACHxF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,wCAAwC;IAC9CuC,IAAI,EAAEL;EACP,CAAE,CAAC;EACHzF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,iCAAiC;IACvCuC,IAAI,EAAEJ,oCAAoC;IAC1CK,OAAO,EAAE;EACV,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["useCommandLoader","__","useMemo","useEffect","useState","useSelect","store","coreStore","post","page","layout","symbolFilled","styles","navigation","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","useDebounce","useIsTemplatesAccessible","useIsBlockBasedTheme","unlock","orderEntityRecordsBySearch","useHistory","useLocation","icons","wp_template","wp_template_part","useDebouncedValue","value","debouncedValue","setDebouncedValue","debounced","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","delayedSearch","records","isLoading","select","query","per_page","orderby","status","getEntityRecords","hasFinishedResolution","commands","map","record","command","name","id","searchLabel","title","rendered","label","icon","callback","close","args","action","targetUrl","document","location","isSiteEditor","window","href","includes","extraArgs","canvas","postId","push","getNavigationCommandLoaderPerTemplate","templateType","isPatternsPage","params","path","didAccessPatternsPage","orderedRecords","slice","undefined","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","isTemplatesAccessible","result","useSiteEditorNavigationCommands","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":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,IAAI,EACJC,IAAI,EACJC,MAAM,EACNC,YAAY,EACZC,MAAM,EACNC,UAAU,QACJ,kBAAkB;AACzB,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,WAAW,EA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K,CAAC;QACrB,CAAC,MAAM;UACNG,QAAQ,CAACC,QAAQ,GAAGF,SAAS;QAC9B;QACAH,KAAK,CAAC,CAAC;MACR;IACD,CAAE,CAAC;IAEH,OAAO6B,MAAM;EACd,CAAC,EAAE,CAAErD,OAAO,EAAE8B,YAAY,EAAEsB,qBAAqB,EAAEnD,iBAAiB,CAAG,CAAC;EAExE,OAAO;IACNW,QAAQ;IACRR,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,OAAO,SAASkD,+BAA+BA,CAAA,EAAG;EACjD7F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAER;EACP,CAAE,CAAC;EACHtF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAEP;EACP,CAAE,CAAC;EACHvF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,mCAAmC;IACzCuC,IAAI,EAAEN;EACP,CAAE,CAAC;EACHxF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,wCAAwC;IAC9CuC,IAAI,EAAEL;EACP,CAAE,CAAC;EACHzF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,iCAAiC;IACvCuC,IAAI,EAAEJ,oCAAoC;IAC1CK,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["orderEntityRecordsBySearch","records","search","Array","isArray","length","priority","nonPriority","i","record","title","raw","toLowerCase","includes","push","concat"],"sources":["@wordpress/core-commands/src/utils/order-entity-records-by-search.js"],"sourcesContent":["export function orderEntityRecordsBySearch( records = [], search = '' ) {\n\tif ( ! Array.isArray( records ) || ! records.length ) {\n\t\treturn [];\n\t}\n\n\tif ( ! search ) {\n\t\treturn records;\n\t}\n\n\tconst priority = [];\n\tconst nonPriority = [];\n\n\tfor ( let i = 0; i < records.length; i++ ) {\n\t\tconst record = records[ i ];\n\t\tif (\n\t\t\trecord?.title?.raw?.toLowerCase()?.includes( search?.toLowerCase() )\n\t\t) {\n\t\t\tpriority.push( record );\n\t\t} else {\n\t\t\tnonPriority.push( record );\n\t\t}\n\t}\n\n\treturn priority.concat( nonPriority );\n}\n"],"mappings":"AAAA,OAAO,SAASA,0BAA0BA,CAAEC,OAAO,GAAG,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAG;EACvE,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,IAAI,CAAEA,OAAO,CAACI,MAAM,EAAG;IACrD,OAAO,EAAE;EACV;EAEA,IAAK,CAAEH,MAAM,EAAG;IACf,OAAOD,OAAO;EACf;EAEA,MAAMK,QAAQ,GAAG,EAAE;EACnB,MAAMC,WAAW,GAAG,EAAE;EAEtB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,OAAO,CAACI,MAAM,EAAEG,CAAC,EAAE,EAAG;IAC1C,MAAMC,MAAM,GAAGR,OAAO,CAAEO,CAAC,CAAE;IAC3B,IACCC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,CAAEX,MAAM,EAAEU,WAAW,CAAC,CAAE,CAAC,EACnE;MACDN,QAAQ,CAACQ,IAAI,CAAEL,MAAO,CAAC;IACxB,CAAC,MAAM;MACNF,WAAW,CAACO,IAAI,CAAEL,MAAO,CAAC;IAC3B;EACD;EAEA,OAAOH,QAAQ,CAACS,MAAM,CAAER,WAAY,CAAC;AACtC"}
1
+ {"version":3,"names":["orderEntityRecordsBySearch","records","search","Array","isArray","length","priority","nonPriority","i","record","title","raw","toLowerCase","includes","push","concat"],"sources":["@wordpress/core-commands/src/utils/order-entity-records-by-search.js"],"sourcesContent":["export function orderEntityRecordsBySearch( records = [], search = '' ) {\n\tif ( ! Array.isArray( records ) || ! records.length ) {\n\t\treturn [];\n\t}\n\n\tif ( ! search ) {\n\t\treturn records;\n\t}\n\n\tconst priority = [];\n\tconst nonPriority = [];\n\n\tfor ( let i = 0; i < records.length; i++ ) {\n\t\tconst record = records[ i ];\n\t\tif (\n\t\t\trecord?.title?.raw?.toLowerCase()?.includes( search?.toLowerCase() )\n\t\t) {\n\t\t\tpriority.push( record );\n\t\t} else {\n\t\t\tnonPriority.push( record );\n\t\t}\n\t}\n\n\treturn priority.concat( nonPriority );\n}\n"],"mappings":"AAAA,OAAO,SAASA,0BAA0BA,CAAEC,OAAO,GAAG,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAG;EACvE,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,IAAI,CAAEA,OAAO,CAACI,MAAM,EAAG;IACrD,OAAO,EAAE;EACV;EAEA,IAAK,CAAEH,MAAM,EAAG;IACf,OAAOD,OAAO;EACf;EAEA,MAAMK,QAAQ,GAAG,EAAE;EACnB,MAAMC,WAAW,GAAG,EAAE;EAEtB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,OAAO,CAACI,MAAM,EAAEG,CAAC,EAAE,EAAG;IAC1C,MAAMC,MAAM,GAAGR,OAAO,CAAEO,CAAC,CAAE;IAC3B,IACCC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,CAAEX,MAAM,EAAEU,WAAW,CAAC,CAAE,CAAC,EACnE;MACDN,QAAQ,CAACQ,IAAI,CAAEL,MAAO,CAAC;IACxB,CAAC,MAAM;MACNF,WAAW,CAACO,IAAI,CAAEL,MAAO,CAAC;IAC3B;EACD;EAEA,OAAOH,QAAQ,CAACS,MAAM,CAAER,WAAY,CAAC;AACtC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-commands",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "WordPress core reusable commands.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,17 +27,17 @@
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/block-editor": "^12.23.0",
31
- "@wordpress/commands": "^0.26.0",
32
- "@wordpress/compose": "^6.32.0",
33
- "@wordpress/core-data": "^6.32.0",
34
- "@wordpress/data": "^9.25.0",
35
- "@wordpress/element": "^5.32.0",
36
- "@wordpress/i18n": "^4.55.0",
37
- "@wordpress/icons": "^9.46.0",
38
- "@wordpress/private-apis": "^0.37.0",
39
- "@wordpress/router": "^0.24.0",
40
- "@wordpress/url": "^3.56.0"
30
+ "@wordpress/block-editor": "^12.25.0",
31
+ "@wordpress/commands": "^0.28.0",
32
+ "@wordpress/compose": "^6.34.0",
33
+ "@wordpress/core-data": "^6.34.0",
34
+ "@wordpress/data": "^9.27.0",
35
+ "@wordpress/element": "^5.34.0",
36
+ "@wordpress/i18n": "^4.57.0",
37
+ "@wordpress/icons": "^9.48.0",
38
+ "@wordpress/private-apis": "^0.39.0",
39
+ "@wordpress/router": "^0.26.0",
40
+ "@wordpress/url": "^3.58.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "^18.0.0",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "ac2b13783c28f959770cf029a797a712f59e1958"
49
+ "gitHead": "581d8a5580dba8f600b7268d51eb554771ae482c"
50
50
  }
@@ -10,7 +10,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
- import { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';
13
+ import { useIsTemplatesAccessible } from './hooks';
14
14
  import { unlock } from './lock-unlock';
15
15
 
16
16
  const { useHistory } = unlock( routerPrivateApis );
@@ -18,7 +18,6 @@ const { useHistory } = unlock( routerPrivateApis );
18
18
  export function useAdminNavigationCommands() {
19
19
  const history = useHistory();
20
20
  const isTemplatesAccessible = useIsTemplatesAccessible();
21
- const isBlockBasedTheme = useIsBlockBasedTheme();
22
21
 
23
22
  const isSiteEditor = getPath( window.location.href )?.includes(
24
23
  'site-editor.php'
@@ -45,7 +44,11 @@ export function useAdminNavigationCommands() {
45
44
  label: __( 'Patterns' ),
46
45
  icon: symbol,
47
46
  callback: ( { close } ) => {
48
- if ( isTemplatesAccessible && isBlockBasedTheme ) {
47
+ // The site editor and templates both check whether the user
48
+ // can read templates. We can leverage that here and this
49
+ // command links to the classic dashboard manage patterns page
50
+ // if the user can't access it.
51
+ if ( isTemplatesAccessible ) {
49
52
  const args = {
50
53
  path: '/patterns',
51
54
  };