@wordpress/edit-site 6.30.1-next.836ecdcae.0 → 6.31.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-template-modal-content.js +1 -1
  3. package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
  4. package/build/components/add-new-template/index.js +1 -5
  5. package/build/components/add-new-template/index.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +8 -84
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/dataviews-actions/index.js +51 -1
  9. package/build/components/dataviews-actions/index.js.map +1 -1
  10. package/build/components/editor/index.js +1 -1
  11. package/build/components/editor/index.js.map +1 -1
  12. package/build/components/editor/use-resolve-edited-entity.js +42 -14
  13. package/build/components/editor/use-resolve-edited-entity.js.map +1 -1
  14. package/build/components/global-styles/screen-root.js +1 -7
  15. package/build/components/global-styles/screen-root.js.map +1 -1
  16. package/build/components/page-templates/fields.js +65 -5
  17. package/build/components/page-templates/fields.js.map +1 -1
  18. package/build/components/page-templates/hooks.js +1 -1
  19. package/build/components/page-templates/hooks.js.map +1 -1
  20. package/build/components/page-templates/index.js +103 -29
  21. package/build/components/page-templates/index.js.map +1 -1
  22. package/build/components/post-list/index.js +1 -4
  23. package/build/components/post-list/index.js.map +1 -1
  24. package/build/components/sidebar-navigation-screen-templates-browse/content.js +11 -5
  25. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  26. package/build/components/site-editor-routes/index.js +1 -1
  27. package/build/components/site-editor-routes/index.js.map +1 -1
  28. package/build/components/site-editor-routes/template-item.js +29 -23
  29. package/build/components/site-editor-routes/template-item.js.map +1 -1
  30. package/build/hooks/commands/use-common-commands.js +3 -118
  31. package/build/hooks/commands/use-common-commands.js.map +1 -1
  32. package/build-module/components/add-new-template/add-custom-template-modal-content.js +1 -1
  33. package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
  34. package/build-module/components/add-new-template/index.js +2 -6
  35. package/build-module/components/add-new-template/index.js.map +1 -1
  36. package/build-module/components/add-new-template/utils.js +8 -84
  37. package/build-module/components/add-new-template/utils.js.map +1 -1
  38. package/build-module/components/dataviews-actions/index.js +49 -0
  39. package/build-module/components/dataviews-actions/index.js.map +1 -1
  40. package/build-module/components/editor/index.js +1 -1
  41. package/build-module/components/editor/index.js.map +1 -1
  42. package/build-module/components/editor/use-resolve-edited-entity.js +42 -14
  43. package/build-module/components/editor/use-resolve-edited-entity.js.map +1 -1
  44. package/build-module/components/global-styles/screen-root.js +1 -7
  45. package/build-module/components/global-styles/screen-root.js.map +1 -1
  46. package/build-module/components/page-templates/fields.js +65 -5
  47. package/build-module/components/page-templates/fields.js.map +1 -1
  48. package/build-module/components/page-templates/hooks.js +1 -1
  49. package/build-module/components/page-templates/hooks.js.map +1 -1
  50. package/build-module/components/page-templates/index.js +105 -31
  51. package/build-module/components/page-templates/index.js.map +1 -1
  52. package/build-module/components/post-list/index.js +1 -4
  53. package/build-module/components/post-list/index.js.map +1 -1
  54. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +11 -5
  55. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  56. package/build-module/components/site-editor-routes/index.js +2 -2
  57. package/build-module/components/site-editor-routes/index.js.map +1 -1
  58. package/build-module/components/site-editor-routes/template-item.js +28 -22
  59. package/build-module/components/site-editor-routes/template-item.js.map +1 -1
  60. package/build-module/hooks/commands/use-common-commands.js +5 -120
  61. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  62. package/build-style/posts-rtl.css +17 -10
  63. package/build-style/posts.css +17 -10
  64. package/build-style/style-rtl.css +17 -10
  65. package/build-style/style.css +17 -10
  66. package/package.json +41 -41
  67. package/src/components/add-new-template/add-custom-template-modal-content.js +1 -3
  68. package/src/components/add-new-template/index.js +1 -8
  69. package/src/components/add-new-template/utils.js +9 -118
  70. package/src/components/dataviews-actions/index.js +51 -0
  71. package/src/components/editor/index.js +1 -0
  72. package/src/components/editor/use-resolve-edited-entity.js +54 -7
  73. package/src/components/global-styles/screen-root.js +1 -7
  74. package/src/components/page-templates/fields.js +70 -4
  75. package/src/components/page-templates/hooks.js +1 -1
  76. package/src/components/page-templates/index.js +160 -57
  77. package/src/components/post-list/index.js +1 -2
  78. package/src/components/sidebar-navigation-screen-templates-browse/content.js +17 -7
  79. package/src/components/site-editor-routes/index.js +2 -1
  80. package/src/components/site-editor-routes/template-item.js +34 -26
  81. package/src/hooks/commands/use-common-commands.js +6 -135
@@ -10,12 +10,10 @@ var _i18n = require("@wordpress/i18n");
10
10
  var _icons = require("@wordpress/icons");
11
11
  var _data = require("@wordpress/data");
12
12
  var _coreData = require("@wordpress/core-data");
13
- var _blockEditor = require("@wordpress/block-editor");
14
13
  var _iconWithCurrentColor = require("./icon-with-current-color");
15
14
  var _navigationButton = require("./navigation-button");
16
15
  var _rootMenu = _interopRequireDefault(require("./root-menu"));
17
16
  var _previewStyles = _interopRequireDefault(require("./preview-styles"));
18
- var _lockUnlock = require("../../lock-unlock");
19
17
  var _jsxRuntime = require("react/jsx-runtime");
20
18
  /**
21
19
  * WordPress dependencies
@@ -25,11 +23,7 @@ var _jsxRuntime = require("react/jsx-runtime");
25
23
  * Internal dependencies
26
24
  */
27
25
 
28
- const {
29
- useGlobalStyle
30
- } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
31
26
  function ScreenRoot() {
32
- const [customCSS] = useGlobalStyle('css');
33
27
  const {
34
28
  hasVariations,
35
29
  canEditCSS
@@ -99,7 +93,7 @@ function ScreenRoot() {
99
93
  })
100
94
  })
101
95
  })]
102
- }), canEditCSS && !!customCSS && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
96
+ }), canEditCSS && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
103
97
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CardDivider, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.CardBody, {
104
98
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalSpacer, {
105
99
  as: "p",
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_icons","_data","_coreData","_blockEditor","_iconWithCurrentColor","_navigationButton","_rootMenu","_interopRequireDefault","_previewStyles","_lockUnlock","_jsxRuntime","useGlobalStyle","unlock","blockEditorPrivateApis","ScreenRoot","customCSS","hasVariations","canEditCSS","useSelect","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","__experimentalGetCurrentThemeGlobalStylesVariations","coreStore","globalStylesId","globalStyles","undefined","length","_links","jsxs","Card","size","isBorderless","className","isRounded","children","jsx","CardBody","__experimentalVStack","spacing","CardMedia","default","__experimentalItemGroup","NavigationButtonAsItem","path","__experimentalHStack","justify","FlexItem","__","IconWithCurrentColor","icon","isRTL","chevronLeft","chevronRight","CardDivider","__experimentalSpacer","as","paddingTop","paddingX","marginBottom","Fragment","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-root.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalVStack as VStack,\n\tFlexItem,\n\tCardBody,\n\tCard,\n\tCardDivider,\n\tCardMedia,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport RootMenu from './root-menu';\nimport PreviewStyles from './preview-styles';\nimport { unlock } from '../../lock-unlock';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction ScreenRoot() {\n\tconst [ customCSS ] = useGlobalStyle( 'css' );\n\n\tconst { hasVariations, canEditCSS } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEntityRecord,\n\t\t\t__experimentalGetCurrentGlobalStylesId,\n\t\t\t__experimentalGetCurrentThemeGlobalStylesVariations,\n\t\t} = select( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thasVariations:\n\t\t\t\t!! __experimentalGetCurrentThemeGlobalStylesVariations()\n\t\t\t\t\t?.length,\n\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Card\n\t\t\tsize=\"small\"\n\t\t\tisBorderless\n\t\t\tclassName=\"edit-site-global-styles-screen-root\"\n\t\t\tisRounded={ false }\n\t\t>\n\t\t\t<CardBody>\n\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t<Card className=\"edit-site-global-styles-screen-root__active-style-tile\">\n\t\t\t\t\t\t<CardMedia className=\"edit-site-global-styles-screen-root__active-style-tile-preview\">\n\t\t\t\t\t\t\t<PreviewStyles />\n\t\t\t\t\t\t</CardMedia>\n\t\t\t\t\t</Card>\n\t\t\t\t\t{ hasVariations && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t<NavigationButtonAsItem path=\"/variations\">\n\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Browse styles' ) }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t<RootMenu />\n\t\t\t\t</VStack>\n\t\t\t</CardBody>\n\n\t\t\t<CardDivider />\n\n\t\t\t<CardBody>\n\t\t\t\t<Spacer\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tpaddingTop={ 2 }\n\t\t\t\t\t/*\n\t\t\t\t\t * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).\n\t\t\t\t\t * This is an ad hoc override for this instance and the Additional CSS option below. Other options for matching the\n\t\t\t\t\t * the nav button inset should be looked at before reusing further.\n\t\t\t\t\t */\n\t\t\t\t\tpaddingX=\"13px\"\n\t\t\t\t\tmarginBottom={ 4 }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the appearance of specific blocks for the whole site.'\n\t\t\t\t\t) }\n\t\t\t\t</Spacer>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<NavigationButtonAsItem path=\"/blocks\">\n\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t<FlexItem>{ __( 'Blocks' ) }</FlexItem>\n\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t</ItemGroup>\n\t\t\t</CardBody>\n\n\t\t\t{ canEditCSS && !! customCSS && (\n\t\t\t\t<>\n\t\t\t\t\t<CardDivider />\n\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t<Spacer\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tpaddingTop={ 2 }\n\t\t\t\t\t\t\tpaddingX=\"13px\"\n\t\t\t\t\t\t\tmarginBottom={ 4 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Add your own CSS to customize the appearance and layout of your site.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t<NavigationButtonAsItem path=\"/css\">\n\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Additional CSS' ) }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</CardBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Card>\n\t);\n}\n\nexport default ScreenRoot;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAWA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAKA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,cAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AAA2C,IAAAY,WAAA,GAAAZ,OAAA;AA3B3C;AACA;AACA;;AAkBA;AACA;AACA;;AAOA,MAAM;EAAEa;AAAe,CAAC,GA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AAT,QAAA,eAClC,IAAAzB,WAAA,CAAAmB,IAAA,EAAChC,WAAA,CAAAgD,oBAAM;cAACC,OAAO,EAAC,eAAe;cAAAX,QAAA,gBAC9B,IAAAzB,WAAA,CAAA0B,GAAA,EAACvC,WAAA,CAAAkD,QAAQ;gBAAAZ,QAAA,EACN,IAAAa,QAAE,EAAE,gBAAiB;cAAC,CACf,CAAC,eACX,IAAAtC,WAAA,CAAA0B,GAAA,EAAChC,qBAAA,CAAA6C,oBAAoB;gBACpBC,IAAI,EACH,IAAAC,WAAK,EAAC,CAAC,GAAGC,kBAAW,GAAGC;cACxB,CACD,CAAC;YAAA,CACK;UAAC,CACc;QAAC,CACf,CAAC;MAAA,CACH,CAAC;IAAA,CACV,CACF;EAAA,CACI,CAAC;AAET;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEc3B,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_icons","_data","_coreData","_iconWithCurrentColor","_navigationButton","_rootMenu","_interopRequireDefault","_previewStyles","_jsxRuntime","ScreenRoot","hasVariations","canEditCSS","useSelect","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","__experimentalGetCurrentThemeGlobalStylesVariations","coreStore","globalStylesId","globalStyles","undefined","length","_links","jsxs","Card","size","isBorderless","className","isRounded","children","jsx","CardBody","__experimentalVStack","spacing","CardMedia","default","__experimentalItemGroup","NavigationButtonAsItem","path","__experimentalHStack","justify","FlexItem","__","IconWithCurrentColor","icon","isRTL","chevronLeft","chevronRight","CardDivider","__experimentalSpacer","as","paddingTop","paddingX","marginBottom","Fragment","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-root.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalVStack as VStack,\n\tFlexItem,\n\tCardBody,\n\tCard,\n\tCardDivider,\n\tCardMedia,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport RootMenu from './root-menu';\nimport PreviewStyles from './preview-styles';\n\nfunction ScreenRoot() {\n\tconst { hasVariations, canEditCSS } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEntityRecord,\n\t\t\t__experimentalGetCurrentGlobalStylesId,\n\t\t\t__experimentalGetCurrentThemeGlobalStylesVariations,\n\t\t} = select( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\thasVariations:\n\t\t\t\t!! __experimentalGetCurrentThemeGlobalStylesVariations()\n\t\t\t\t\t?.length,\n\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Card\n\t\t\tsize=\"small\"\n\t\t\tisBorderless\n\t\t\tclassName=\"edit-site-global-styles-screen-root\"\n\t\t\tisRounded={ false }\n\t\t>\n\t\t\t<CardBody>\n\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t<Card className=\"edit-site-global-styles-screen-root__active-style-tile\">\n\t\t\t\t\t\t<CardMedia className=\"edit-site-global-styles-screen-root__active-style-tile-preview\">\n\t\t\t\t\t\t\t<PreviewStyles />\n\t\t\t\t\t\t</CardMedia>\n\t\t\t\t\t</Card>\n\t\t\t\t\t{ hasVariations && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t<NavigationButtonAsItem path=\"/variations\">\n\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Browse styles' ) }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t<RootMenu />\n\t\t\t\t</VStack>\n\t\t\t</CardBody>\n\n\t\t\t<CardDivider />\n\n\t\t\t<CardBody>\n\t\t\t\t<Spacer\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tpaddingTop={ 2 }\n\t\t\t\t\t/*\n\t\t\t\t\t * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).\n\t\t\t\t\t * This is an ad hoc override for this instance and the Additional CSS option below. Other options for matching the\n\t\t\t\t\t * the nav button inset should be looked at before reusing further.\n\t\t\t\t\t */\n\t\t\t\t\tpaddingX=\"13px\"\n\t\t\t\t\tmarginBottom={ 4 }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the appearance of specific blocks for the whole site.'\n\t\t\t\t\t) }\n\t\t\t\t</Spacer>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<NavigationButtonAsItem path=\"/blocks\">\n\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t<FlexItem>{ __( 'Blocks' ) }</FlexItem>\n\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t</ItemGroup>\n\t\t\t</CardBody>\n\n\t\t\t{ canEditCSS && (\n\t\t\t\t<>\n\t\t\t\t\t<CardDivider />\n\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t<Spacer\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tpaddingTop={ 2 }\n\t\t\t\t\t\t\tpaddingX=\"13px\"\n\t\t\t\t\t\t\tmarginBottom={ 4 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Add your own CSS to customize the appearance and layout of your site.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t<NavigationButtonAsItem path=\"/css\">\n\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Additional CSS' ) }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</CardBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Card>\n\t);\n}\n\nexport default ScreenRoot;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAWA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAC,sBAAA,CAAAR,OAAA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IAAA,EAAC1B,WAAA,CAAA0C,oBAAM;cAACC,OAAO,EAAC,eAAe;cAAAX,QAAA,gBAC9B,IAAArB,WAAA,CAAAsB,GAAA,EAACjC,WAAA,CAAA4C,QAAQ;gBAAAZ,QAAA,EACN,IAAAa,QAAE,EAAE,gBAAiB;cAAC,CACf,CAAC,eACX,IAAAlC,WAAA,CAAAsB,GAAA,EAAC3B,qBAAA,CAAAwC,oBAAoB;gBACpBC,IAAI,EACH,IAAAC,WAAK,EAAC,CAAC,GAAGC,kBAAW,GAAGC;cACxB,CACD,CAAC;YAAA,CACK;UAAC,CACc;QAAC,CACf,CAAC;MAAA,CACH,CAAC;IAAA,CACV,CACF;EAAA,CACI,CAAC;AAET;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEc1B,UAAU","ignoreList":[]}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.previewField = exports.descriptionField = exports.authorField = void 0;
7
+ exports.slugField = exports.previewField = exports.descriptionField = exports.authorField = exports.activeField = void 0;
8
8
  var _clsx = _interopRequireDefault(require("clsx"));
9
9
  var _components = require("@wordpress/components");
10
10
  var _i18n = require("@wordpress/i18n");
@@ -13,7 +13,9 @@ var _htmlEntities = require("@wordpress/html-entities");
13
13
  var _blocks = require("@wordpress/blocks");
14
14
  var _blockEditor = require("@wordpress/block-editor");
15
15
  var _editor = require("@wordpress/editor");
16
+ var _coreData = require("@wordpress/core-data");
16
17
  var _hooks = require("./hooks");
18
+ var _utils = require("../add-new-template/utils");
17
19
  var _usePatternSettings = _interopRequireDefault(require("../page-patterns/use-pattern-settings"));
18
20
  var _lockUnlock = require("../../lock-unlock");
19
21
  var _jsxRuntime = require("react/jsx-runtime");
@@ -32,6 +34,27 @@ var _jsxRuntime = require("react/jsx-runtime");
32
34
  const {
33
35
  useGlobalStyle
34
36
  } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
37
+ const {
38
+ Badge
39
+ } = (0, _lockUnlock.unlock)(_components.privateApis);
40
+ const {
41
+ useEntityRecordsWithPermissions
42
+ } = (0, _lockUnlock.unlock)(_coreData.privateApis);
43
+ function useAllDefaultTemplateTypes() {
44
+ const defaultTemplateTypes = (0, _utils.useDefaultTemplateTypes)();
45
+ const {
46
+ records: staticRecords
47
+ } = useEntityRecordsWithPermissions('postType', 'wp_registered_template', {
48
+ per_page: -1
49
+ });
50
+ return [...defaultTemplateTypes, ...staticRecords?.filter(record => !record.is_custom).map(record => {
51
+ return {
52
+ slug: record.slug,
53
+ title: record.title.rendered,
54
+ description: record.description
55
+ };
56
+ })];
57
+ }
35
58
  function PreviewField({
36
59
  item
37
60
  }) {
@@ -73,10 +96,12 @@ const previewField = exports.previewField = {
73
96
  const descriptionField = exports.descriptionField = {
74
97
  label: (0, _i18n.__)('Description'),
75
98
  id: 'description',
76
- render: ({
99
+ render: function RenderDescription({
77
100
  item
78
- }) => {
79
- return item.description && (0, _htmlEntities.decodeEntities)(item.description);
101
+ }) {
102
+ const defaultTemplateTypes = useAllDefaultTemplateTypes();
103
+ const defaultTemplateType = defaultTemplateTypes.find(type => type.slug === item.slug);
104
+ return item.description ? (0, _htmlEntities.decodeEntities)(item.description) : defaultTemplateType?.description;
80
105
  },
81
106
  enableSorting: false,
82
107
  enableGlobalSearch: true
@@ -118,7 +143,42 @@ const authorField = exports.authorField = {
118
143
  id: 'author',
119
144
  getValue: ({
120
145
  item
121
- }) => item.author_text,
146
+ }) => {
147
+ var _item$author_text;
148
+ return (_item$author_text = item.author_text) !== null && _item$author_text !== void 0 ? _item$author_text : item.author;
149
+ },
122
150
  render: AuthorField
123
151
  };
152
+ const activeField = exports.activeField = {
153
+ label: (0, _i18n.__)('Status'),
154
+ id: 'active',
155
+ getValue: ({
156
+ item
157
+ }) => item._isActive,
158
+ render: function Render({
159
+ item
160
+ }) {
161
+ const isActive = item._isActive;
162
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Badge, {
163
+ intent: isActive ? 'success' : 'default',
164
+ children: isActive ? (0, _i18n.__)('Active') : (0, _i18n.__)('Inactive')
165
+ });
166
+ }
167
+ };
168
+ const slugField = exports.slugField = {
169
+ label: (0, _i18n.__)('Template Type'),
170
+ id: 'slug',
171
+ getValue: ({
172
+ item
173
+ }) => item.slug,
174
+ render: function Render({
175
+ item
176
+ }) {
177
+ const defaultTemplateTypes = useAllDefaultTemplateTypes();
178
+ const defaultTemplateType = defaultTemplateTypes.find(type => type.slug === item.slug);
179
+ return defaultTemplateType?.title ||
180
+ // translators: %s is the slug of a custom template.
181
+ (0, _i18n.__)('Custom');
182
+ }
183
+ };
124
184
  //# sourceMappingURL=fields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_htmlEntities","_blocks","_blockEditor","_editor","_hooks","_usePatternSettings","_lockUnlock","_jsxRuntime","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewField","item","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","isEmpty","length","jsx","EditorProvider","post","children","jsxs","className","style","__","BlockPreview","Async","previewField","exports","label","id","render","enableSorting","descriptionField","description","decodeEntities","enableGlobalSearch","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","type","__experimentalHStack","alignment","spacing","clsx","onLoad","alt","src","Icon","authorField","getValue","author_text"],"sources":["@wordpress/edit-site/src/components/page-templates/fields.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { EditorProvider } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from './hooks';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: ( { item } ) => {\n\t\treturn item.description && decodeEntities( item.description );\n\t},\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text,\n\trender: AuthorField,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,mBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAA2C,IAAAW,WAAA,GAAAX,OAAA;AAxB3C;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAKA,MAAM;EAAEY;AAAe,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE3D,SAASC,YAAYA,CAAE;EAAEC;AAAK,CAAC,EAAG;EACjC,MAAMC,QAAQ,GAAG,I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mCAAmC;MAAAF,QAAA,EAAGqB;IAAI,CAAQ,CAAC;EAAA,CAC5D,CAAC;AAEX;AAEO,MAAMa,WAAW,GAAA1B,OAAA,CAAA0B,WAAA,GAAG;EAC1BzB,KAAK,EAAE,IAAAL,QAAE,EAAE,QAAS,CAAC;EACrBM,EAAE,EAAE,QAAQ;EACZyB,QAAQ,EAAEA,CAAE;IAAEjD;EAAK,CAAC,KAAMA,IAAI,CAACkD,WAAW;EAC1CzB,MAAM,EAAEM;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_htmlEntities","_blocks","_blockEditor","_editor","_coreData","_hooks","_utils","_usePatternSettings","_lockUnlock","_jsxRuntime","useGlobalStyle","unlock","blockEditorPrivateApis","Badge","componentsPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","useAllDefaultTemplateTypes","defaultTemplateTypes","useDefaultTemplateTypes","records","staticRecords","per_page","filter","record","is_custom","map","slug","title","rendered","description","PreviewField","item","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","isEmpty","length","jsx","EditorProvider","post","children","jsxs","className","style","__","BlockPreview","Async","previewField","exports","label","id","render","enableSorting","descriptionField","RenderDescription","defaultTemplateType","find","type","decodeEntities","enableGlobalSearch","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","__experimentalHStack","alignment","spacing","clsx","onLoad","alt","src","Icon","authorField","getValue","_item$author_text","author_text","author","activeField","_isActive","Render","isActive","intent","slugField"],"sources":["@wordpress/edit-site/src/components/page-templates/fields.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { EditorProvider } from '@wordpress/editor';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from './hooks';\nimport { useDefaultTemplateTypes } from '../add-new-template/utils';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\nconst { Badge } = unlock( componentsPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nfunction useAllDefaultTemplateTypes() {\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst { records: staticRecords } = useEntityRecordsWithPermissions(\n\t\t'postType',\n\t\t'wp_registered_template',\n\t\t{ per_page: -1 }\n\t);\n\treturn [\n\t\t...defaultTemplateTypes,\n\t\t...staticRecords\n\t\t\t?.filter( ( record ) => ! record.is_custom )\n\t\t\t.map( ( record ) => {\n\t\t\t\treturn {\n\t\t\t\t\tslug: record.slug,\n\t\t\t\t\ttitle: record.title.rendered,\n\t\t\t\t\tdescription: record.description,\n\t\t\t\t};\n\t\t\t} ),\n\t];\n}\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: function RenderDescription( { item } ) {\n\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t( type ) => type.slug === item.slug\n\t\t);\n\t\treturn item.description\n\t\t\t? decodeEntities( item.description )\n\t\t\t: defaultTemplateType?.description;\n\t},\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text ?? item.author,\n\trender: AuthorField,\n};\n\nexport const activeField = {\n\tlabel: __( 'Status' ),\n\tid: 'active',\n\tgetValue: ( { item } ) => item._isActive,\n\trender: function Render( { item } ) {\n\t\tconst isActive = item._isActive;\n\t\treturn (\n\t\t\t<Badge intent={ isActive ? 'success' : 'default' }>\n\t\t\t\t{ isActive ? __( 'Active' ) : __( 'Inactive' ) }\n\t\t\t</Badge>\n\t\t);\n\t},\n};\n\nexport const slugField = {\n\tlabel: __( 'Template Type' ),\n\tid: 'slug',\n\tgetValue: ( { item } ) => item.slug,\n\trender: function Render( { item } ) {\n\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t( type ) => type.slug === item.slug\n\t\t);\n\t\treturn (\n\t\t\tdefaultTemplateType?.title ||\n\t\t\t// translators: %s is the slug of a custom template.\n\t\t\t__( 'Custom' )\n\t\t);\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAA2C,IAAAa,WAAA,GAAAb,OAAA;AA9B3C;AACA;AACA;;AAGA;AACA;AACA;;A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I,IAAMA,IAAI,CAACpC,IAAI,KAAKK,IAAI,CAACL,IAChC,CAAC;IACD,OACCkC,mBAAmB,EAAEjC,KAAK;IAC1B;IACA,IAAAsB,QAAE,EAAE,QAAS,CAAC;EAEhB;AACD,CAAC","ignoreList":[]}
@@ -80,7 +80,7 @@ function useAddedBy(postType, postId) {
80
80
  type: 'user',
81
81
  icon: _icons.commentAuthorAvatar,
82
82
  imageUrl: user?.avatar_urls?.[48],
83
- text: authorText,
83
+ text: authorText !== null && authorText !== void 0 ? authorText : user?.name,
84
84
  isCustomized: false
85
85
  };
86
86
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_data","_icons","_constants","useAddedBy","postType","postId","useSelect","select","getEntityRecord","getUser","getEditedEntityRecord","coreStore","template","originalSource","original_source","authorText","author_text","type","icon","themeIcon","text","isCustomized","source","TEMPLATE_ORIGINS","custom","pluginIcon","siteData","globeIcon","imageUrl","site_logo","source_url","undefined","user","author","authorIcon","avatar_urls"],"sources":["@wordpress/edit-site/src/components/page-templates/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from '../../utils/constants';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getUser, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst originalSource = template?.original_source;\n\t\t\tconst authorText = template?.author_text;\n\n\t\t\tswitch ( originalSource ) {\n\t\t\t\tcase 'theme': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'plugin': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'site': {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\t\tsiteData.site_logo\n\t\t\t\t\t\t\t )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst user = getUser( template.author );\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'user',\n\t\t\t\t\t\ticon: authorIcon,\n\t\t\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAUA,IAAAG,UAAA,GAAAH,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EAC9C,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC,OAAO;MAAEC;IAAsB,CAAC,GACxDH,MAAM,CAAEI,eAAU,CAAC;IACpB,MAAMC,QAAQ,GAAGF,qBAAqB,CACrC,UAAU,EACVN,QAAQ,EACRC,MACD,CAAC;IACD,MAAMQ,cAAc,GAAGD,QAAQ,EAAEE,eAAe;IAChD,MAAMC,UAAU,GAAGH,QAAQ,EAAEI,WAAW;IAExC,QAASH,cAAc;MACtB,KAAK,OAAO;QAAE;UACb,OAAO;YACNI,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAEC,aAAS;YACfC,IAAI,EAAEL,UAAU;YAChBM,YAAY,EACXT,QAAQ,CAACU,MAAM,KAAKC,2BAAgB,CAACC;UACvC,CAAC;QACF;MACA,KAAK,QAAQ;QAAE;UACd,OAAO;YACNP,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAEO,cAAU;YAChBL,IAAI,EAAEL,UAAU;YAChBM,YAAY,EACXT,QAAQ,CAACU,MAAM,KAAKC,2BAAgB,CAACC;UACvC,CAAC;QACF;MACA,KAAK,MAAM;QAAE;UACZ,MAAME,QAAQ,GAAGlB,eAAe,CAC/B,MAAM,EACN,gBACD,CAAC;UACD,OAAO;YACNS,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAES,YAAS;YACfC,QAAQ,EAAEF,QAAQ,EAAEG,SAAS,GAC1BrB,eAAe,CACf,UAAU,EACV,YAAY,EACZkB,QAAQ,CAACG,SACT,CAAC,EAAEC,UAAU,GACbC,SAAS;YACZX,IAAI,EAAEL,UAAU;YAChBM,YAAY,EAAE;UACf,CAAC;QACF;MACA;QAAS;UACR,MAAMW,IAAI,GAAGvB,OAAO,CAAEG,QAAQ,CAACqB,MAAO,CAAC;UACvC,OAAO;YACNhB,IAAI,EAAE,MAAM;YACZC,IAAI,EAAEgB,0BAAU;YAChBN,QAAQ,EAAEI,IAAI,EAAEG,WAAW,GAAI,EAAE,CAAE;YACnCf,IAAI,EAAEL,UAAU;YAChBM,YAAY,EAAE;UACf,CAAC;QACF;IACD;EACD,CAAC,EACD,CAAEjB,QAAQ,EAAEC,MAAM,CACnB,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_data","_icons","_constants","useAddedBy","postType","postId","useSelect","select","getEntityRecord","getUser","getEditedEntityRecord","coreStore","template","originalSource","original_source","authorText","author_text","type","icon","themeIcon","text","isCustomized","source","TEMPLATE_ORIGINS","custom","pluginIcon","siteData","globeIcon","imageUrl","site_logo","source_url","undefined","user","author","authorIcon","avatar_urls","name"],"sources":["@wordpress/edit-site/src/components/page-templates/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from '../../utils/constants';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getUser, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst originalSource = template?.original_source;\n\t\t\tconst authorText = template?.author_text;\n\n\t\t\tswitch ( originalSource ) {\n\t\t\t\tcase 'theme': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'plugin': {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized:\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'site': {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: originalSource,\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\t\tsiteData.site_logo\n\t\t\t\t\t\t\t )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: authorText,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst user = getUser( template.author );\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'user',\n\t\t\t\t\t\ticon: authorIcon,\n\t\t\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\t\t\ttext: authorText ?? user?.name,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAUA,IAAAG,UAAA,GAAAH,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EAC9C,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC,OAAO;MAAEC;IAAsB,CAAC,GACxDH,MAAM,CAAEI,eAAU,CAAC;IACpB,MAAMC,QAAQ,GAAGF,qBAAqB,CACrC,UAAU,EACVN,QAAQ,EACRC,MACD,CAAC;IACD,MAAMQ,cAAc,GAAGD,QAAQ,EAAEE,eAAe;IAChD,MAAMC,UAAU,GAAGH,QAAQ,EAAEI,WAAW;IAExC,QAASH,cAAc;MACtB,KAAK,OAAO;QAAE;UACb,OAAO;YACNI,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAEC,aAAS;YACfC,IAAI,EAAEL,UAAU;YAChBM,YAAY,EACXT,QAAQ,CAACU,MAAM,KAAKC,2BAAgB,CAACC;UACvC,CAAC;QACF;MACA,KAAK,QAAQ;QAAE;UACd,OAAO;YACNP,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAEO,cAAU;YAChBL,IAAI,EAAEL,UAAU;YAChBM,YAAY,EACXT,QAAQ,CAACU,MAAM,KAAKC,2BAAgB,CAACC;UACvC,CAAC;QACF;MACA,KAAK,MAAM;QAAE;UACZ,MAAME,QAAQ,GAAGlB,eAAe,CAC/B,MAAM,EACN,gBACD,CAAC;UACD,OAAO;YACNS,IAAI,EAAEJ,cAAc;YACpBK,IAAI,EAAES,YAAS;YACfC,QAAQ,EAAEF,QAAQ,EAAEG,SAAS,GAC1BrB,eAAe,CACf,UAAU,EACV,YAAY,EACZkB,QAAQ,CAACG,SACT,CAAC,EAAEC,UAAU,GACbC,SAAS;YACZX,IAAI,EAAEL,UAAU;YAChBM,YAAY,EAAE;UACf,CAAC;QACF;MACA;QAAS;UACR,MAAMW,IAAI,GAAGvB,OAAO,CAAEG,QAAQ,CAACqB,MAAO,CAAC;UACvC,OAAO;YACNhB,IAAI,EAAE,MAAM;YACZC,IAAI,EAAEgB,0BAAU;YAChBN,QAAQ,EAAEI,IAAI,EAAEG,WAAW,GAAI,EAAE,CAAE;YACnCf,IAAI,EAAEL,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIiB,IAAI,EAAEI,IAAI;YAC9Bf,YAAY,EAAE;UACf,CAAC;QACF;IACD;EACD,CAAC,EACD,CAAEjB,QAAQ,EAAEC,MAAM,CACnB,CAAC;AACF","ignoreList":[]}
@@ -12,13 +12,14 @@ var _dataviews = require("@wordpress/dataviews");
12
12
  var _router = require("@wordpress/router");
13
13
  var _editor = require("@wordpress/editor");
14
14
  var _url = require("@wordpress/url");
15
+ var _data = require("@wordpress/data");
16
+ var _compose = require("@wordpress/compose");
15
17
  var _page = _interopRequireDefault(require("../page"));
16
18
  var _addNewTemplate = _interopRequireDefault(require("../add-new-template"));
17
19
  var _constants = require("../../utils/constants");
18
20
  var _lockUnlock = require("../../lock-unlock");
19
21
  var _dataviewsActions = require("../dataviews-actions");
20
- var _fields = require("./fields");
21
- var _compose = require("@wordpress/compose");
22
+ var _fields2 = require("./fields");
22
23
  var _jsxRuntime = require("react/jsx-runtime");
23
24
  /**
24
25
  * WordPress dependencies
@@ -39,7 +40,6 @@ const {
39
40
  const {
40
41
  useEntityRecordsWithPermissions
41
42
  } = (0, _lockUnlock.unlock)(_coreData.privateApis);
42
- const EMPTY_ARRAY = [];
43
43
  const defaultLayouts = {
44
44
  [_constants.LAYOUT_TABLE]: {
45
45
  showMedia: false
@@ -63,7 +63,7 @@ const DEFAULT_VIEW = {
63
63
  titleField: 'title',
64
64
  descriptionField: 'description',
65
65
  mediaField: 'preview',
66
- fields: ['author'],
66
+ fields: ['author', 'active', 'slug'],
67
67
  filters: [],
68
68
  ...defaultLayouts[_constants.LAYOUT_GRID]
69
69
  };
@@ -73,7 +73,7 @@ function PageTemplates() {
73
73
  query
74
74
  } = useLocation();
75
75
  const {
76
- activeView = 'all',
76
+ activeView = 'active',
77
77
  layout,
78
78
  postId
79
79
  } = query;
@@ -83,7 +83,7 @@ function PageTemplates() {
83
83
  return {
84
84
  ...DEFAULT_VIEW,
85
85
  type: usedType,
86
- filters: activeView !== 'all' ? [{
86
+ filters: !['active', 'user'].includes(activeView) ? [{
87
87
  field: 'author',
88
88
  operator: 'isAny',
89
89
  value: [activeView]
@@ -105,19 +105,95 @@ function PageTemplates() {
105
105
  (0, _element.useEffect)(() => {
106
106
  setView(currentView => ({
107
107
  ...currentView,
108
- filters: activeView !== 'all' ? [{
108
+ filters: !['active', 'user'].includes(activeView) ? [{
109
109
  field: 'author',
110
110
  operator: _constants.OPERATOR_IS_ANY,
111
111
  value: [activeView]
112
112
  }] : []
113
113
  }));
114
114
  }, [setView, activeView]);
115
+ const activeTemplatesOption = (0, _data.useSelect)(select => select(_coreData.store).getEntityRecord('root', 'site')?.active_templates);
116
+ // Todo: this will have to be better so that we're not fetching all the
117
+ // records all the time. Active templates query will need to move server
118
+ // side.
115
119
  const {
116
- records,
117
- isResolving: isLoadingData
120
+ records: userRecords,
121
+ isResolving: isLoadingUserRecords
118
122
  } = useEntityRecordsWithPermissions('postType', _constants.TEMPLATE_POST_TYPE, {
119
123
  per_page: -1
120
124
  });
125
+ const {
126
+ records: staticRecords,
127
+ isResolving: isLoadingStaticData
128
+ } = useEntityRecordsWithPermissions('postType', 'wp_registered_template', {
129
+ per_page: -1
130
+ });
131
+ const activeTemplates = (0, _element.useMemo)(() => {
132
+ const _active = [...staticRecords].filter(record => !record.is_custom);
133
+ if (activeTemplatesOption) {
134
+ for (const activeSlug in activeTemplatesOption) {
135
+ const activeId = activeTemplatesOption[activeSlug];
136
+ if (activeId === false) {
137
+ // Remove the template from the array.
138
+ const index = _active.findIndex(template => template.slug === activeSlug);
139
+ if (index !== -1) {
140
+ _active.splice(index, 1);
141
+ }
142
+ } else {
143
+ // Replace the template in the array.
144
+ const template = userRecords.find(({
145
+ id
146
+ }) => id === activeId);
147
+ if (template) {
148
+ const index = _active.findIndex(({
149
+ slug
150
+ }) => slug === template.slug);
151
+ if (index !== -1) {
152
+ _active[index] = template;
153
+ } else {
154
+ _active.push(template);
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return _active;
161
+ }, [userRecords, staticRecords, activeTemplatesOption]);
162
+ let _records;
163
+ let isLoadingData;
164
+ if (activeView === 'active') {
165
+ _records = activeTemplates;
166
+ isLoadingData = isLoadingUserRecords || isLoadingStaticData;
167
+ } else if (activeView === 'user') {
168
+ _records = userRecords;
169
+ isLoadingData = isLoadingUserRecords;
170
+ } else {
171
+ _records = staticRecords;
172
+ isLoadingData = isLoadingStaticData;
173
+ }
174
+ const records = (0, _element.useMemo)(() => {
175
+ return _records.map(record => ({
176
+ ...record,
177
+ _isActive: typeof record.id === 'string' ? activeTemplatesOption[record.slug] === record.id || activeTemplatesOption[record.slug] === undefined : Object.values(activeTemplatesOption).includes(record.id)
178
+ }));
179
+ }, [_records, activeTemplatesOption]);
180
+ const users = (0, _data.useSelect)(select => {
181
+ const {
182
+ getUser
183
+ } = select(_coreData.store);
184
+ return records.reduce((acc, record) => {
185
+ if (record.author_text) {
186
+ if (!acc[record.author_text]) {
187
+ acc[record.author_text] = record.author_text;
188
+ }
189
+ } else if (record.author) {
190
+ if (!acc[record.author]) {
191
+ acc[record.author] = getUser(record.author);
192
+ }
193
+ }
194
+ return acc;
195
+ }, {});
196
+ }, [records]);
121
197
  const history = useHistory();
122
198
  const onChangeSelection = (0, _element.useCallback)(items => {
123
199
  setSelection(items);
@@ -127,23 +203,22 @@ function PageTemplates() {
127
203
  }));
128
204
  }
129
205
  }, [history, path, view?.type]);
130
- const authors = (0, _element.useMemo)(() => {
131
- if (!records) {
132
- return EMPTY_ARRAY;
206
+ const fields = (0, _element.useMemo)(() => {
207
+ const _fields = [_fields2.previewField, templateTitleField, _fields2.descriptionField, _fields2.activeField, _fields2.slugField];
208
+ const elements = [];
209
+ for (const author in users) {
210
+ var _users$author$id, _users$author$name;
211
+ elements.push({
212
+ value: (_users$author$id = users[author]?.id) !== null && _users$author$id !== void 0 ? _users$author$id : author,
213
+ label: (_users$author$name = users[author]?.name) !== null && _users$author$name !== void 0 ? _users$author$name : author
214
+ });
133
215
  }
134
- const authorsSet = new Set();
135
- records.forEach(template => {
136
- authorsSet.add(template.author_text);
216
+ _fields.push({
217
+ ..._fields2.authorField,
218
+ elements
137
219
  });
138
- return Array.from(authorsSet).map(author => ({
139
- value: author,
140
- label: author
141
- }));
142
- }, [records]);
143
- const fields = (0, _element.useMemo)(() => [_fields.previewField, templateTitleField, _fields.descriptionField, {
144
- ..._fields.authorField,
145
- elements: authors
146
- }], [authors]);
220
+ return _fields;
221
+ }, [users]);
147
222
  const {
148
223
  data,
149
224
  paginationInfo
@@ -155,7 +230,8 @@ function PageTemplates() {
155
230
  context: 'list'
156
231
  });
157
232
  const editAction = (0, _dataviewsActions.useEditPostAction)();
158
- const actions = (0, _element.useMemo)(() => [editAction, ...postTypeActions], [postTypeActions, editAction]);
233
+ const setActiveTemplateAction = (0, _dataviewsActions.useSetActiveTemplateAction)();
234
+ const actions = (0, _element.useMemo)(() => activeView === 'user' ? [setActiveTemplateAction, editAction, ...postTypeActions] : [setActiveTemplateAction, ...postTypeActions], [postTypeActions, setActiveTemplateAction, editAction, activeView]);
159
235
  const onChangeView = (0, _compose.useEvent)(newView => {
160
236
  setView(newView);
161
237
  if (newView.type !== layout) {
@@ -178,10 +254,8 @@ function PageTemplates() {
178
254
  onChangeView: onChangeView,
179
255
  onChangeSelection: onChangeSelection,
180
256
  isItemClickable: () => true,
181
- onClickItem: ({
182
- id
183
- }) => {
184
- history.navigate(`/wp_template/${id}?canvas=edit`);
257
+ onClickItem: item => {
258
+ history.navigate(`/${item.type}/${item.id}?canvas=edit`);
185
259
  },
186
260
  selection: selection,
187
261
  defaultLayouts: defaultLayouts
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_coreData","_dataviews","_router","_editor","_url","_page","_interopRequireDefault","_addNewTemplate","_constants","_lockUnlock","_dataviewsActions","_fields","_compose","_jsxRuntime","usePostActions","templateTitleField","unlock","editorPrivateApis","useHistory","useLocation","routerPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","EMPTY_ARRAY","defaultLayouts","LAYOUT_TABLE","showMedia","LAYOUT_GRID","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","titleField","descriptionField","mediaField","fields","filters","PageTemplates","path","query","activeView","layout","postId","selection","setSelection","useState","defaultView","useMemo","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","TEMPLATE_POST_TYPE","per_page","history","onChangeSelection","useCallback","items","navigate","addQueryArgs","length","undefined","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","label","previewField","authorField","elements","data","paginationInfo","filterSortAndPaginate","postTypeActions","postType","context","editAction","useEditPostAction","actions","onChangeView","useEvent","newView","jsx","default","className","title","__","children","DataViews","isLoading","isItemClickable","onClickItem","id"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport AddNewTemplate from '../add-new-template';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { authorField, descriptionField, previewField } from './fields';\nimport { useEvent } from '@wordpress/compose';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tshowMedia: false,\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tshowMedia: true,\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author' ],\n\tfilters: [],\n\t...defaultLayouts[ LAYOUT_GRID ],\n};\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'all', layout, postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t\t...defaultLayouts[ usedType ],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\n\t// Sync the layout from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\ttype: layout ?? DEFAULT_VIEW.type,\n\t\t} ) );\n\t}, [ setView, layout ] );\n\n\t// Sync the active view from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ setView, activeView ] );\n\n\tconst { records, isResolving: isLoadingData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\t{\n\t\t\t\t...authorField,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tsetView( newView );\n\t\tif ( newView.type !== layout ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/wp_template/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAKA,IAAAO,KAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,eAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAOA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,iBAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AAA8C,IAAAe,WAAA,GAAAf,OAAA;AA1B9C;AACA;AACA;;AASA;AACA;AACA;;AAeA,MAAM;EAAEgB,cAAc;EAAEC;AAAmB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAC1E,MAAM;EAAEC,UAAU;EAAEC;AAAY,CAAC,GAAG,IAAAH,kBAAM,EAAEI,mBAAkB,CAAC;AAC/D,MAA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SAAS,EAAGA,SAAW;MACvBxB,cAAc,EAAGA;IAAgB,GAd3BqB,UAeN;EAAC,CACG,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_coreData","_dataviews","_router","_editor","_url","_data","_compose","_page","_interopRequireDefault","_addNewTemplate","_constants","_lockUnlock","_dataviewsActions","_fields2","_jsxRuntime","usePostActions","templateTitleField","unlock","editorPrivateApis","useHistory","useLocation","routerPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","defaultLayouts","LAYOUT_TABLE","showMedia","LAYOUT_GRID","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","titleField","descriptionField","mediaField","fields","filters","PageTemplates","path","query","activeView","layout","postId","selection","setSelection","useState","defaultView","useMemo","usedType","includes","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","activeTemplatesOption","useSelect","select","coreStore","getEntityRecord","active_templates","records","userRecords","isResolving","isLoadingUserRecords","TEMPLATE_POST_TYPE","per_page","staticRecords","isLoadingStaticData","activeTemplates","_active","filter","record","is_custom","activeSlug","activeId","index","findIndex","template","slug","splice","find","id","push","_records","isLoadingData","map","_isActive","undefined","Object","values","users","getUser","reduce","acc","author_text","author","history","onChangeSelection","useCallback","items","navigate","addQueryArgs","length","_fields","previewField","activeField","slugField","elements","_users$author$id","_users$author$name","label","name","authorField","data","paginationInfo","filterSortAndPaginate","postTypeActions","postType","context","editAction","useEditPostAction","setActiveTemplateAction","useSetActiveTemplateAction","actions","onChangeView","useEvent","newView","jsx","default","className","title","__","children","DataViews","isLoading","isItemClickable","onClickItem","item"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport {\n\tprivateApis as corePrivateApis,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useSelect } from '@wordpress/data';\nimport { useEvent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport AddNewTemplate from '../add-new-template';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tuseEditPostAction,\n\tuseSetActiveTemplateAction,\n} from '../dataviews-actions';\nimport {\n\tauthorField,\n\tdescriptionField,\n\tpreviewField,\n\tactiveField,\n\tslugField,\n} from './fields';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tshowMedia: false,\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tshowMedia: true,\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author', 'active', 'slug' ],\n\tfilters: [],\n\t...defaultLayouts[ LAYOUT_GRID ],\n};\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'active', layout, postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tfilters: ! [ 'active', 'user' ].includes( activeView )\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t},\n\t\t\t\t ]\n\t\t\t\t: [],\n\t\t\t...defaultLayouts[ usedType ],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\n\t// Sync the layout from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\ttype: layout ?? DEFAULT_VIEW.type,\n\t\t} ) );\n\t}, [ setView, layout ] );\n\n\t// Sync the active view from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters: ! [ 'active', 'user' ].includes( activeView )\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t},\n\t\t\t\t ]\n\t\t\t\t: [],\n\t\t} ) );\n\t}, [ setView, activeView ] );\n\n\tconst activeTemplatesOption = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )\n\t\t\t\t?.active_templates\n\t);\n\t// Todo: this will have to be better so that we're not fetching all the\n\t// records all the time. Active templates query will need to move server\n\t// side.\n\tconst { records: userRecords, isResolving: isLoadingUserRecords } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst { records: staticRecords, isResolving: isLoadingStaticData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', 'wp_registered_template', {\n\t\t\tper_page: -1,\n\t\t} );\n\n\tconst activeTemplates = useMemo( () => {\n\t\tconst _active = [ ...staticRecords ].filter(\n\t\t\t( record ) => ! record.is_custom\n\t\t);\n\t\tif ( activeTemplatesOption ) {\n\t\t\tfor ( const activeSlug in activeTemplatesOption ) {\n\t\t\t\tconst activeId = activeTemplatesOption[ activeSlug ];\n\t\t\t\tif ( activeId === false ) {\n\t\t\t\t\t// Remove the template from the array.\n\t\t\t\t\tconst index = _active.findIndex(\n\t\t\t\t\t\t( template ) => template.slug === activeSlug\n\t\t\t\t\t);\n\t\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\t\t_active.splice( index, 1 );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Replace the template in the array.\n\t\t\t\t\tconst template = userRecords.find(\n\t\t\t\t\t\t( { id } ) => id === activeId\n\t\t\t\t\t);\n\t\t\t\t\tif ( template ) {\n\t\t\t\t\t\tconst index = _active.findIndex(\n\t\t\t\t\t\t\t( { slug } ) => slug === template.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\t\t\t_active[ index ] = template;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t_active.push( template );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn _active;\n\t}, [ userRecords, staticRecords, activeTemplatesOption ] );\n\n\tlet _records;\n\tlet isLoadingData;\n\tif ( activeView === 'active' ) {\n\t\t_records = activeTemplates;\n\t\tisLoadingData = isLoadingUserRecords || isLoadingStaticData;\n\t} else if ( activeView === 'user' ) {\n\t\t_records = userRecords;\n\t\tisLoadingData = isLoadingUserRecords;\n\t} else {\n\t\t_records = staticRecords;\n\t\tisLoadingData = isLoadingStaticData;\n\t}\n\n\tconst records = useMemo( () => {\n\t\treturn _records.map( ( record ) => ( {\n\t\t\t...record,\n\t\t\t_isActive:\n\t\t\t\ttypeof record.id === 'string'\n\t\t\t\t\t? activeTemplatesOption[ record.slug ] === record.id ||\n\t\t\t\t\t activeTemplatesOption[ record.slug ] === undefined\n\t\t\t\t\t: Object.values( activeTemplatesOption ).includes(\n\t\t\t\t\t\t\trecord.id\n\t\t\t\t\t ),\n\t\t} ) );\n\t}, [ _records, activeTemplatesOption ] );\n\n\tconst users = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\treturn records.reduce( ( acc, record ) => {\n\t\t\t\tif ( record.author_text ) {\n\t\t\t\t\tif ( ! acc[ record.author_text ] ) {\n\t\t\t\t\t\tacc[ record.author_text ] = record.author_text;\n\t\t\t\t\t}\n\t\t\t\t} else if ( record.author ) {\n\t\t\t\t\tif ( ! acc[ record.author ] ) {\n\t\t\t\t\t\tacc[ record.author ] = getUser( record.author );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t}, {} );\n\t\t},\n\t\t[ records ]\n\t);\n\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst fields = useMemo( () => {\n\t\tconst _fields = [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\tactiveField,\n\t\t\tslugField,\n\t\t];\n\t\tconst elements = [];\n\t\tfor ( const author in users ) {\n\t\t\telements.push( {\n\t\t\t\tvalue: users[ author ]?.id ?? author,\n\t\t\t\tlabel: users[ author ]?.name ?? author,\n\t\t\t} );\n\t\t}\n\t\t_fields.push( {\n\t\t\t...authorField,\n\t\t\telements,\n\t\t} );\n\t\treturn _fields;\n\t}, [ users ] );\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst setActiveTemplateAction = useSetActiveTemplateAction();\n\tconst actions = useMemo(\n\t\t() =>\n\t\t\tactiveView === 'user'\n\t\t\t\t? [ setActiveTemplateAction, editAction, ...postTypeActions ]\n\t\t\t\t: [ setActiveTemplateAction, ...postTypeActions ],\n\t\t[ postTypeActions, setActiveTemplateAction, editAction, activeView ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tsetView( newView );\n\t\tif ( newView.type !== layout ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( item ) => {\n\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t`/${ item.type }/${ item.id }?canvas=edit`\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAIA,IAAAG,UA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,EAAGA,IAAM;MACb2E,YAAY,EAAGA,YAAc;MAC7B3B,iBAAiB,EAAGA,iBAAmB;MACvCsC,eAAe,EAAGA,CAAA,KAAM,IAAM;MAC9BC,WAAW,EAAKC,IAAI,IAAM;QACzBzC,OAAO,CAACI,QAAQ,CACf,IAAKqC,IAAI,CAACnH,IAAI,IAAMmH,IAAI,CAACxD,EAAE,cAC5B,CAAC;MACF,CAAG;MACHzC,SAAS,EAAGA,SAAW;MACvBxB,cAAc,EAAGA;IAAgB,GAhB3BqB,UAiBN;EAAC,CACG,CAAC;AAET","ignoreList":[]}
@@ -186,9 +186,6 @@ function PostList({
186
186
  }) {
187
187
  var _postId$split, _data$map, _usePrevious;
188
188
  const [view, setView] = useView(postType);
189
- const defaultViews = (0, _defaultViews.useDefaultViews)({
190
- postType
191
- });
192
189
  const history = useHistory();
193
190
  const location = useLocation();
194
191
  const {
@@ -241,7 +238,7 @@ function PostList({
241
238
  search: view.search,
242
239
  ...filters
243
240
  };
244
- }, [view, activeView, defaultViews]);
241
+ }, [view]);
245
242
  const {
246
243
  records,
247
244
  isResolving: isLoadingData,