@wordpress/edit-site 3.0.15 → 3.0.18

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 (208) hide show
  1. package/build/components/add-new-template/new-template-part.js +29 -18
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +30 -23
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/app/index.js +51 -0
  6. package/build/components/app/index.js.map +1 -0
  7. package/build/components/block-editor/back-button.js +8 -20
  8. package/build/components/block-editor/back-button.js.map +1 -1
  9. package/build/components/block-editor/index.js +2 -1
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/create-template-part-modal/index.js +0 -2
  12. package/build/components/create-template-part-modal/index.js.map +1 -1
  13. package/build/components/edit-template-part-menu-button/index.js +20 -8
  14. package/build/components/edit-template-part-menu-button/index.js.map +1 -1
  15. package/build/components/editor/index.js +11 -30
  16. package/build/components/editor/index.js.map +1 -1
  17. package/build/components/global-styles/gradients-palette-panel.js +14 -10
  18. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  19. package/build/components/global-styles/screen-root.js +8 -2
  20. package/build/components/global-styles/screen-root.js.map +1 -1
  21. package/build/components/global-styles/use-global-styles-output.js +1 -2
  22. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  23. package/build/components/header/document-actions/index.js +3 -6
  24. package/build/components/header/document-actions/index.js.map +1 -1
  25. package/build/components/list/added-by.js +9 -3
  26. package/build/components/list/added-by.js.map +1 -1
  27. package/build/components/list/index.js +17 -15
  28. package/build/components/list/index.js.map +1 -1
  29. package/build/components/list/table.js +4 -4
  30. package/build/components/list/table.js.map +1 -1
  31. package/build/components/navigation-sidebar/index.js +12 -13
  32. package/build/components/navigation-sidebar/index.js.map +1 -1
  33. package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
  34. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  35. package/build/components/navigation-sidebar/navigation-toggle/index.js +11 -0
  36. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  37. package/build/components/routes/index.js +60 -0
  38. package/build/components/routes/index.js.map +1 -0
  39. package/build/components/routes/link.js +65 -0
  40. package/build/components/routes/link.js.map +1 -0
  41. package/build/components/routes/use-title.js +57 -0
  42. package/build/components/routes/use-title.js.map +1 -0
  43. package/build/components/sidebar/global-styles-sidebar.js +10 -0
  44. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  45. package/build/components/sidebar/template-card/template-areas.js +7 -4
  46. package/build/components/sidebar/template-card/template-areas.js.map +1 -1
  47. package/build/components/template-details/index.js +12 -10
  48. package/build/components/template-details/index.js.map +1 -1
  49. package/build/components/template-details/template-areas.js +27 -10
  50. package/build/components/template-details/template-areas.js.map +1 -1
  51. package/build/components/template-part-converter/convert-to-template-part.js +7 -12
  52. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  53. package/build/components/url-query-controller/index.js +41 -50
  54. package/build/components/url-query-controller/index.js.map +1 -1
  55. package/build/components/welcome-guide/editor.js +6 -0
  56. package/build/components/welcome-guide/editor.js.map +1 -1
  57. package/build/components/welcome-guide/index.js +1 -28
  58. package/build/components/welcome-guide/index.js.map +1 -1
  59. package/build/components/welcome-guide/styles.js +18 -1
  60. package/build/components/welcome-guide/styles.js.map +1 -1
  61. package/build/index.js +29 -35
  62. package/build/index.js.map +1 -1
  63. package/build/plugins/index.js +3 -23
  64. package/build/plugins/index.js.map +1 -1
  65. package/build/plugins/site-export.js +67 -0
  66. package/build/plugins/site-export.js.map +1 -0
  67. package/build/plugins/welcome-guide-menu-item.js +1 -7
  68. package/build/plugins/welcome-guide-menu-item.js.map +1 -1
  69. package/build/store/actions.js +0 -27
  70. package/build/store/actions.js.map +1 -1
  71. package/build/store/constants.js +1 -14
  72. package/build/store/constants.js.map +1 -1
  73. package/build/store/reducer.js +7 -16
  74. package/build/store/reducer.js.map +1 -1
  75. package/build/store/selectors.js +1 -31
  76. package/build/store/selectors.js.map +1 -1
  77. package/build/utils/get-is-list-page.js +23 -0
  78. package/build/utils/get-is-list-page.js.map +1 -0
  79. package/build/utils/history.js +35 -0
  80. package/build/utils/history.js.map +1 -0
  81. package/build-module/components/add-new-template/new-template-part.js +27 -16
  82. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  83. package/build-module/components/add-new-template/new-template.js +28 -18
  84. package/build-module/components/add-new-template/new-template.js.map +1 -1
  85. package/build-module/components/app/index.js +35 -0
  86. package/build-module/components/app/index.js.map +1 -0
  87. package/build-module/components/block-editor/back-button.js +8 -19
  88. package/build-module/components/block-editor/back-button.js.map +1 -1
  89. package/build-module/components/block-editor/index.js +2 -1
  90. package/build-module/components/block-editor/index.js.map +1 -1
  91. package/build-module/components/create-template-part-modal/index.js +0 -2
  92. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  93. package/build-module/components/edit-template-part-menu-button/index.js +17 -9
  94. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
  95. package/build-module/components/editor/index.js +13 -33
  96. package/build-module/components/editor/index.js.map +1 -1
  97. package/build-module/components/global-styles/gradients-palette-panel.js +12 -11
  98. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  99. package/build-module/components/global-styles/screen-root.js +9 -4
  100. package/build-module/components/global-styles/screen-root.js.map +1 -1
  101. package/build-module/components/global-styles/use-global-styles-output.js +1 -2
  102. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  103. package/build-module/components/header/document-actions/index.js +3 -6
  104. package/build-module/components/header/document-actions/index.js.map +1 -1
  105. package/build-module/components/list/added-by.js +10 -4
  106. package/build-module/components/list/added-by.js.map +1 -1
  107. package/build-module/components/list/index.js +15 -15
  108. package/build-module/components/list/index.js.map +1 -1
  109. package/build-module/components/list/table.js +4 -4
  110. package/build-module/components/list/table.js.map +1 -1
  111. package/build-module/components/navigation-sidebar/index.js +13 -13
  112. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  113. package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
  114. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  115. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -0
  116. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  117. package/build-module/components/routes/index.js +47 -0
  118. package/build-module/components/routes/index.js.map +1 -0
  119. package/build-module/components/routes/link.js +51 -0
  120. package/build-module/components/routes/link.js.map +1 -0
  121. package/build-module/components/routes/use-title.js +44 -0
  122. package/build-module/components/routes/use-title.js.map +1 -0
  123. package/build-module/components/sidebar/global-styles-sidebar.js +8 -0
  124. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  125. package/build-module/components/sidebar/template-card/template-areas.js +8 -4
  126. package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
  127. package/build-module/components/template-details/index.js +10 -9
  128. package/build-module/components/template-details/index.js.map +1 -1
  129. package/build-module/components/template-details/template-areas.js +24 -9
  130. package/build-module/components/template-details/template-areas.js.map +1 -1
  131. package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
  132. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  133. package/build-module/components/url-query-controller/index.js +40 -49
  134. package/build-module/components/url-query-controller/index.js.map +1 -1
  135. package/build-module/components/welcome-guide/editor.js +7 -1
  136. package/build-module/components/welcome-guide/editor.js.map +1 -1
  137. package/build-module/components/welcome-guide/index.js +2 -26
  138. package/build-module/components/welcome-guide/index.js.map +1 -1
  139. package/build-module/components/welcome-guide/styles.js +18 -2
  140. package/build-module/components/welcome-guide/styles.js.map +1 -1
  141. package/build-module/index.js +28 -33
  142. package/build-module/index.js.map +1 -1
  143. package/build-module/plugins/index.js +2 -18
  144. package/build-module/plugins/index.js.map +1 -1
  145. package/build-module/plugins/site-export.js +51 -0
  146. package/build-module/plugins/site-export.js.map +1 -0
  147. package/build-module/plugins/welcome-guide-menu-item.js +2 -7
  148. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
  149. package/build-module/store/actions.js +0 -23
  150. package/build-module/store/actions.js.map +1 -1
  151. package/build-module/store/constants.js +0 -11
  152. package/build-module/store/constants.js.map +1 -1
  153. package/build-module/store/reducer.js +7 -16
  154. package/build-module/store/reducer.js.map +1 -1
  155. package/build-module/store/selectors.js +1 -27
  156. package/build-module/store/selectors.js.map +1 -1
  157. package/build-module/utils/get-is-list-page.js +16 -0
  158. package/build-module/utils/get-is-list-page.js.map +1 -0
  159. package/build-module/utils/history.js +25 -0
  160. package/build-module/utils/history.js.map +1 -0
  161. package/build-style/style-rtl.css +7 -6
  162. package/build-style/style.css +7 -6
  163. package/package.json +18 -17
  164. package/src/components/add-new-template/new-template-part.js +29 -11
  165. package/src/components/add-new-template/new-template.js +26 -12
  166. package/src/components/app/index.js +47 -0
  167. package/src/components/block-editor/back-button.js +6 -14
  168. package/src/components/block-editor/index.js +1 -0
  169. package/src/components/create-template-part-modal/index.js +0 -2
  170. package/src/components/edit-template-part-menu-button/index.js +16 -5
  171. package/src/components/editor/index.js +105 -131
  172. package/src/components/global-styles/gradients-palette-panel.js +13 -13
  173. package/src/components/global-styles/screen-root.js +17 -7
  174. package/src/components/global-styles/style.scss +6 -0
  175. package/src/components/global-styles/test/use-global-styles-output.js +7 -1
  176. package/src/components/global-styles/use-global-styles-output.js +0 -1
  177. package/src/components/header/document-actions/index.js +3 -9
  178. package/src/components/list/added-by.js +25 -9
  179. package/src/components/list/index.js +11 -12
  180. package/src/components/list/style.scss +6 -11
  181. package/src/components/list/table.js +5 -5
  182. package/src/components/navigation-sidebar/index.js +18 -17
  183. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
  184. package/src/components/navigation-sidebar/navigation-toggle/index.js +14 -0
  185. package/src/components/routes/index.js +53 -0
  186. package/src/components/routes/link.js +44 -0
  187. package/src/components/routes/use-title.js +56 -0
  188. package/src/components/sidebar/global-styles-sidebar.js +8 -0
  189. package/src/components/sidebar/template-card/template-areas.js +16 -4
  190. package/src/components/template-details/index.js +8 -6
  191. package/src/components/template-details/template-areas.js +31 -8
  192. package/src/components/template-part-converter/convert-to-template-part.js +4 -2
  193. package/src/components/url-query-controller/index.js +34 -45
  194. package/src/components/welcome-guide/editor.js +10 -1
  195. package/src/components/welcome-guide/index.js +6 -25
  196. package/src/components/welcome-guide/styles.js +20 -2
  197. package/src/index.js +33 -36
  198. package/src/plugins/index.js +2 -32
  199. package/src/plugins/site-export.js +52 -0
  200. package/src/plugins/welcome-guide-menu-item.js +2 -16
  201. package/src/store/actions.js +0 -23
  202. package/src/store/constants.js +0 -12
  203. package/src/store/reducer.js +12 -26
  204. package/src/store/selectors.js +1 -27
  205. package/src/store/test/reducer.js +22 -39
  206. package/src/store/test/selectors.js +3 -34
  207. package/src/utils/get-is-list-page.js +11 -0
  208. package/src/utils/history.js +35 -0
@@ -15,10 +15,14 @@ var _i18n = require("@wordpress/i18n");
15
15
 
16
16
  var _icons = require("@wordpress/icons");
17
17
 
18
+ var _data = require("@wordpress/data");
19
+
18
20
  var _defaultSidebar = _interopRequireDefault(require("./default-sidebar"));
19
21
 
20
22
  var _globalStyles = require("../global-styles");
21
23
 
24
+ var _store = require("../../store");
25
+
22
26
  /**
23
27
  * WordPress dependencies
24
28
  */
@@ -28,6 +32,9 @@ var _globalStyles = require("../global-styles");
28
32
  */
29
33
  function GlobalStylesSidebar() {
30
34
  const [canReset, onReset] = (0, _globalStyles.useGlobalStylesReset)();
35
+ const {
36
+ toggleFeature
37
+ } = (0, _data.useDispatch)(_store.store);
31
38
  return (0, _element.createElement)(_defaultSidebar.default, {
32
39
  className: "edit-site-global-styles-sidebar",
33
40
  identifier: "edit-site/global-styles",
@@ -45,6 +52,9 @@ function GlobalStylesSidebar() {
45
52
  controls: [{
46
53
  title: (0, _i18n.__)('Reset to defaults'),
47
54
  onClick: onReset
55
+ }, {
56
+ title: (0, _i18n.__)('Welcome Guide'),
57
+ onClick: () => toggleFeature('welcomeGuideStyles')
48
58
  }]
49
59
  })))
50
60
  }, (0, _element.createElement)(_globalStyles.GlobalStylesUI, null));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["GlobalStylesSidebar","canReset","onReset","styles","moreVertical","disabled","title","onClick"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,mBAAT,GAA+B;AAC7C,QAAM,CAAEC,QAAF,EAAYC,OAAZ,IAAwB,yCAA9B;AAEA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,UAAU,EAAC,yBAFZ;AAGC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAHT;AAIC,IAAA,IAAI,EAAGC,aAJR;AAKC,IAAA,UAAU,EAAG,cAAI,6BAAJ,CALd;AAMC,IAAA,MAAM,EACL,4BAAC,gBAAD,QACC,4BAAC,qBAAD,QACC,4CAAU,cAAI,QAAJ,CAAV,CADD,EAEC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACG,cAAI,MAAJ,CADH,CAFD,CADD,EAOC,4BAAC,oBAAD,QACC,4BAAC,wBAAD;AACC,MAAA,IAAI,EAAGC,mBADR;AAEC,MAAA,KAAK,EAAG,cAAI,4BAAJ,CAFT;AAGC,MAAA,WAAW,EAAG;AAAEC,QAAAA,QAAQ,EAAE,CAAEJ;AAAd,OAHf;AAIC,MAAA,QAAQ,EAAG,CACV;AACCK,QAAAA,KAAK,EAAE,cAAI,mBAAJ,CADR;AAECC,QAAAA,OAAO,EAAEL;AAFV,OADU;AAJZ,MADD,CAPD;AAPF,KA8BC,4BAAC,4BAAD,OA9BD,CADD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';\n\nexport default function GlobalStylesSidebar() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-global-styles-sidebar\"\n\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\ticon={ styles }\n\t\t\tcloseLabel={ __( 'Close global styles sidebar' ) }\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Styles' ) }</strong>\n\t\t\t\t\t\t<span className=\"edit-site-global-styles-sidebar__beta\">\n\t\t\t\t\t\t\t{ __( 'Beta' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'More Global Styles Actions' ) }\n\t\t\t\t\t\t\ttoggleProps={ { disabled: ! canReset } }\n\t\t\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Reset to defaults' ),\n\t\t\t\t\t\t\t\t\tonClick: onReset,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<GlobalStylesUI />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["GlobalStylesSidebar","canReset","onReset","toggleFeature","editSiteStore","styles","moreVertical","disabled","title","onClick"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKe,SAASA,mBAAT,GAA+B;AAC7C,QAAM,CAAEC,QAAF,EAAYC,OAAZ,IAAwB,yCAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AAEA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,UAAU,EAAC,yBAFZ;AAGC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAHT;AAIC,IAAA,IAAI,EAAGC,aAJR;AAKC,IAAA,UAAU,EAAG,cAAI,6BAAJ,CALd;AAMC,IAAA,MAAM,EACL,4BAAC,gBAAD,QACC,4BAAC,qBAAD,QACC,4CAAU,cAAI,QAAJ,CAAV,CADD,EAEC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACG,cAAI,MAAJ,CADH,CAFD,CADD,EAOC,4BAAC,oBAAD,QACC,4BAAC,wBAAD;AACC,MAAA,IAAI,EAAGC,mBADR;AAEC,MAAA,KAAK,EAAG,cAAI,4BAAJ,CAFT;AAGC,MAAA,WAAW,EAAG;AAAEC,QAAAA,QAAQ,EAAE,CAAEN;AAAd,OAHf;AAIC,MAAA,QAAQ,EAAG,CACV;AACCO,QAAAA,KAAK,EAAE,cAAI,mBAAJ,CADR;AAECC,QAAAA,OAAO,EAAEP;AAFV,OADU,EAKV;AACCM,QAAAA,KAAK,EAAE,cAAI,eAAJ,CADR;AAECC,QAAAA,OAAO,EAAE,MACRN,aAAa,CAAE,oBAAF;AAHf,OALU;AAJZ,MADD,CAPD;AAPF,KAmCC,4BAAC,4BAAD,OAnCD,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, moreVertical } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';\nimport { store as editSiteStore } from '../../store';\n\nexport default function GlobalStylesSidebar() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-global-styles-sidebar\"\n\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\ticon={ styles }\n\t\t\tcloseLabel={ __( 'Close global styles sidebar' ) }\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Styles' ) }</strong>\n\t\t\t\t\t\t<span className=\"edit-site-global-styles-sidebar__beta\">\n\t\t\t\t\t\t\t{ __( 'Beta' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'More Global Styles Actions' ) }\n\t\t\t\t\t\t\ttoggleProps={ { disabled: ! canReset } }\n\t\t\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Reset to defaults' ),\n\t\t\t\t\t\t\t\t\tonClick: onReset,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Welcome Guide' ),\n\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\ttoggleFeature( 'welcomeGuideStyles' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<GlobalStylesUI />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
@@ -19,8 +19,6 @@ var _i18n = require("@wordpress/i18n");
19
19
 
20
20
  var _store = require("../../../store");
21
21
 
22
- var _constants = require("../../../store/constants");
23
-
24
22
  /**
25
23
  * WordPress dependencies
26
24
  */
@@ -37,6 +35,11 @@ function TemplateAreaItem(_ref) {
37
35
  selectBlock,
38
36
  toggleBlockHighlight
39
37
  } = (0, _data.useDispatch)(_blockEditor.store);
38
+ const templatePartArea = (0, _data.useSelect)(select => {
39
+ const defaultAreas = select(_editor.store).__experimentalGetDefaultTemplatePartAreas();
40
+
41
+ return defaultAreas.find(defaultArea => defaultArea.area === area);
42
+ }, [area]);
40
43
 
41
44
  const highlightBlock = () => toggleBlockHighlight(clientId, true);
42
45
 
@@ -44,7 +47,7 @@ function TemplateAreaItem(_ref) {
44
47
 
45
48
  return (0, _element.createElement)(_components.Button, {
46
49
  className: "edit-site-template-card__template-areas-item",
47
- icon: (0, _editor.getTemplatePartIcon)(area),
50
+ icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
48
51
  onMouseOver: highlightBlock,
49
52
  onMouseLeave: cancelHighlightBlock,
50
53
  onFocus: highlightBlock,
@@ -52,7 +55,7 @@ function TemplateAreaItem(_ref) {
52
55
  onClick: () => {
53
56
  selectBlock(clientId);
54
57
  }
55
- }, _constants.TEMPLATE_PART_AREA_TO_NAME[area]);
58
+ }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label);
56
59
  }
57
60
 
58
61
  function TemplateAreas() {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/template-card/template-areas.js"],"names":["TemplateAreaItem","area","clientId","selectBlock","toggleBlockHighlight","blockEditorStore","highlightBlock","cancelHighlightBlock","TEMPLATE_PART_AREA_TO_NAME","TemplateAreas","templateParts","select","editSiteStore","getCurrentTemplateTemplateParts","length","map","templatePart","block","slug"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIA,SAASA,gBAAT,OAAgD;AAAA,MAArB;AAAEC,IA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;AAEC,MAAA,QAAQ,EAAGgB,KAAK,CAACf;AAFlB,MADD,CADoB;AAAA,GAAnB,CADH,CARD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { getTemplatePartIcon } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport { TEMPLATE_PART_AREA_TO_NAME } from '../../../store/constants';\n\nfunction TemplateAreaItem( { area, clientId } ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-site-template-card__template-areas-item\"\n\t\t\ticon={ getTemplatePartIcon( area ) }\n\t\t\tonMouseOver={ highlightBlock }\n\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\tonFocus={ highlightBlock }\n\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t>\n\t\t\t{ TEMPLATE_PART_AREA_TO_NAME[ area ] }\n\t\t</Button>\n\t);\n}\n\nexport default function TemplateAreas() {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<section className=\"edit-site-template-card__template-areas\">\n\t\t\t<Heading\n\t\t\t\tlevel={ 3 }\n\t\t\t\tclassName=\"edit-site-template-card__template-areas-title\"\n\t\t\t>\n\t\t\t\t{ __( 'Areas' ) }\n\t\t\t</Heading>\n\n\t\t\t<ul className=\"edit-site-template-card__template-areas-list\">\n\t\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t\t<li key={ templatePart.slug }>\n\t\t\t\t\t\t<TemplateAreaItem\n\t\t\t\t\t\t\tarea={ templatePart.area }\n\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</section>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/template-card/template-areas.js"],"names":["TemplateAreaItem","area","clientId","selectBlock","toggleBlockHighlight","blockEditorStore","templatePartArea","select","defaultAreas","editorStore","__experimentalGetDefaultTemplatePartAreas","find","defaultArea","highlightBlock","cancelHighlightBlock","icon","label","TemplateAreas","templateParts","editSiteStore","getCurrentTemplateTemplateParts","length","map","templatePart","block","slug"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;AAGA,SAASA,gBAAT,OAAgD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAC/C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAwC,uBAC7CC,kBAD6C,CAA9C;AAGA,QAAMC,gBAAgB,GAAG,qBACtBC,MAAF,IAAc;AACb,UAAMC,YAAY,GAAGD,MAAM,CAC1BE,aAD0B,CAAN,CAEnBC,yCAFmB,EAArB;;AAIA,WAAOF,YAAY,CAACG,IAAb,CACJC,WAAF,IAAmBA,WAAW,CAACX,IAAZ,KAAqBA,IADlC,CAAP;AAGA,GATuB,EAUxB,CAAEA,IAAF,CAVwB,CAAzB;;AAaA,QAAMY,cAAc,GAAG,MAAMT,oBAAoB,CAAEF,QAAF,EAAY,IAAZ,CAAjD;;AACA,QAAMY,oBAAoB,GAAG,MAAMV,oBAAoB,CAAEF,QAAF,EAAY,KAAZ,CAAvD;;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,IAAI,EAAGI,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAES,IAF1B;AAGC,IAAA,WAAW,EAAGF,cAHf;AAIC,IAAA,YAAY,EAAGC,oBAJhB;AAKC,IAAA,OAAO,EAAGD,cALX;AAMC,IAAA,MAAM,EAAGC,oBANV;AAOC,IAAA,OAAO,EAAG,MAAM;AACfX,MAAAA,WAAW,CAAED,QAAF,CAAX;AACA;AATF,KAWGI,gBAXH,aAWGA,gBAXH,uBAWGA,gBAAgB,CAAEU,KAXrB,CADD;AAeA;;AAEc,SAASC,aAAT,GAAyB;AACvC,QAAMC,aAAa,GAAG,qBACnBX,MAAF,IAAcA,MAAM,CAAEY,YAAF,CAAN,CAAwBC,+BAAxB,EADO,EAErB,EAFqB,CAAtB;;AAKA,MAAK,CAAEF,aAAa,CAACG,MAArB,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC,4BAAC,iCAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,SAAS,EAAC;AAFX,KAIG,cAAI,OAAJ,CAJH,CADD,EAQC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGH,aAAa,CAACI,GAAd,CAAmB;AAAA,QAAE;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,KAAF;AAAA,WACpB;AAAI,MAAA,GAAG,EAAGD,YAAY,CAACE;AAAvB,OACC,4BAAC,gBAAD;AACC,MAAA,IAAI,EAAGF,YAAY,CAACtB,IADrB;AAEC,MAAA,QAAQ,EAAGuB,KAAK,CAACtB;AAFlB,MADD,CADoB;AAAA,GAAnB,CADH,CARD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nfunction TemplateAreaItem( { area, clientId } ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst templatePartArea = useSelect(\n\t\t( select ) => {\n\t\t\tconst defaultAreas = select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\treturn defaultAreas.find(\n\t\t\t\t( defaultArea ) => defaultArea.area === area\n\t\t\t);\n\t\t},\n\t\t[ area ]\n\t);\n\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-site-template-card__template-areas-item\"\n\t\t\ticon={ templatePartArea?.icon }\n\t\t\tonMouseOver={ highlightBlock }\n\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\tonFocus={ highlightBlock }\n\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t>\n\t\t\t{ templatePartArea?.label }\n\t\t</Button>\n\t);\n}\n\nexport default function TemplateAreas() {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<section className=\"edit-site-template-card__template-areas\">\n\t\t\t<Heading\n\t\t\t\tlevel={ 3 }\n\t\t\t\tclassName=\"edit-site-template-card__template-areas-title\"\n\t\t\t>\n\t\t\t\t{ __( 'Areas' ) }\n\t\t\t</Heading>\n\n\t\t\t<ul className=\"edit-site-template-card__template-areas-list\">\n\t\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t\t<li key={ templatePart.slug }>\n\t\t\t\t\t\t<TemplateAreaItem\n\t\t\t\t\t\t\tarea={ templatePart.area }\n\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</section>\n\t);\n}\n"]}
@@ -9,6 +9,8 @@ exports.default = TemplateDetails;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
12
14
  var _i18n = require("@wordpress/i18n");
13
15
 
14
16
  var _components = require("@wordpress/components");
@@ -17,8 +19,6 @@ var _data = require("@wordpress/data");
17
19
 
18
20
  var _editor = require("@wordpress/editor");
19
21
 
20
- var _url = require("@wordpress/url");
21
-
22
22
  var _isTemplateRevertable = _interopRequireDefault(require("../../utils/is-template-revertable"));
23
23
 
24
24
  var _constants = require("../navigation-sidebar/navigation-panel/constants");
@@ -29,6 +29,8 @@ var _templateAreas = _interopRequireDefault(require("./template-areas"));
29
29
 
30
30
  var _editTemplateTitle = _interopRequireDefault(require("./edit-template-title"));
31
31
 
32
+ var _link = require("../routes/link");
33
+
32
34
  /**
33
35
  * WordPress dependencies
34
36
  */
@@ -63,6 +65,11 @@ function TemplateDetails(_ref) {
63
65
  return area === (template === null || template === void 0 ? void 0 : template.area);
64
66
  });
65
67
  }, [template]);
68
+ const browseAllLinkProps = (0, _link.useLink)({
69
+ // TODO: We should update this to filter by template part's areas as well.
70
+ postType: template.type,
71
+ postId: undefined
72
+ });
66
73
 
67
74
  if (!template) {
68
75
  return null;
@@ -95,14 +102,9 @@ function TemplateDetails(_ref) {
95
102
  className: "edit-site-template-details__revert-button",
96
103
  info: (0, _i18n.__)('Restore template to default state'),
97
104
  onClick: revert
98
- }, (0, _i18n.__)('Clear customizations'))), (0, _element.createElement)(_components.Button, {
99
- className: "edit-site-template-details__show-all-button",
100
- href: (0, _url.addQueryArgs)(window.location.href, {
101
- // TODO: We should update this to filter by template part's areas as well.
102
- postId: undefined,
103
- postType: template.type
104
- })
105
- }, (0, _i18n.sprintf)(
105
+ }, (0, _i18n.__)('Clear customizations'))), (0, _element.createElement)(_components.Button, (0, _extends2.default)({
106
+ className: "edit-site-template-details__show-all-button"
107
+ }, browseAllLinkProps), (0, _i18n.sprintf)(
106
108
  /* translators: the template part's area name ("Headers", "Sidebars") or "templates". */
107
109
  (0, _i18n.__)('Browse all %s'), templateSubMenu.title)));
108
110
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["TemplateDetails","template","onClose","title","description","select","editorStore","__experimentalGetTemplateInfo","revertTemplate","editSiteStore","templateSubMenu","type","menu","MENU_TEMPLATES","TEMPLATE_PARTS_SUB_MENUS","find","area","revert","is_custom","window","location","href","postId","undefined","postType"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAcA;AACA;AACA;AAUe,SAASA,eAAT,OAAkD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAChE,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAyB,qBAC5BC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,6BAAtB,CAAqDN,QAArD,CAF6B,EAG9B,EAH8B,CAA/B;AAKA,QAAM;AAAEO,IAAAA;AAAF,MAAqB,uBAAaC,YAAb,CAA3B;AAEA,QAAMC,eAAe,GAAG,sBAAS,MAAM;AACtC,QAAK,CAAAT,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEU,IAAV,MAAmB,aAAxB,EAAwC;AACvC,aAAO;AAAER,QAAAA,KAAK,EAAE,cAAI,WAAJ,CAAT;AAA4BS,QAAAA,IAAI,EAAEC;AAAlC,OAAP;AACA;;AAED,WAAOC,oCAAyBC,IAAzB,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,EAAEC,SAFkC;AAG1CC,MAAAA,QAAQ,EAAEvB,QAAQ,CAACU;AAHuB,KAApC;AAFR,KAQG;AACD;AACA,gBAAI,eAAJ,CAFC,EAGDD,eAAe,CAACP,KAHf,CARH,CAvCD,CADD;AAwDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport {\n\tMENU_TEMPLATES,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../navigation-sidebar/navigation-panel/constants';\nimport { store as editSiteStore } from '../../store';\nimport TemplateAreas from './template-areas';\nimport EditTemplateTitle from './edit-template-title';\n\nexport default function TemplateDetails( { template, onClose } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetTemplateInfo( template ),\n\t\t[]\n\t);\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\n\tconst templateSubMenu = useMemo( () => {\n\t\tif ( template?.type === 'wp_template' ) {\n\t\t\treturn { title: __( 'templates' ), menu: MENU_TEMPLATES };\n\t\t}\n\n\t\treturn TEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t( { area } ) => area === template?.area\n\t\t);\n\t}, [ template ] );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tconst revert = () => {\n\t\trevertTemplate( template );\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<div className=\"edit-site-template-details\">\n\t\t\t<div className=\"edit-site-template-details__group\">\n\t\t\t\t{ template.is_custom ? (\n\t\t\t\t\t<EditTemplateTitle template={ template } />\n\t\t\t\t) : (\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tlevel={ 4 }\n\t\t\t\t\t\tweight={ 600 }\n\t\t\t\t\t\tclassName=\"edit-site-template-details__title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\n\t\t\t\t{ description && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\tclassName=\"edit-site-template-details__description\"\n\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t<TemplateAreas closeTemplateDetailsDropdown={ onClose } />\n\n\t\t\t{ isTemplateRevertable( template ) && (\n\t\t\t\t<MenuGroup className=\"edit-site-template-details__group edit-site-template-details__revert\">\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tclassName=\"edit-site-template-details__revert-button\"\n\t\t\t\t\t\tinfo={ __( 'Restore template to default state' ) }\n\t\t\t\t\t\tonClick={ revert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-template-details__show-all-button\"\n\t\t\t\thref={ addQueryArgs( window.location.href, {\n\t\t\t\t\t// TODO: We should update this to filter by template part's areas as well.\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tpostType: template.type,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: the template part's area name (\"Headers\", \"Sidebars\") or \"templates\". */\n\t\t\t\t\t__( 'Browse all %s' ),\n\t\t\t\t\ttemplateSubMenu.title\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["TemplateDetails","template","onClose","title","description","select","editorStore","__experimentalGetTemplateInfo","revertTemplate","editSiteStore","templateSubMenu","type","menu","MENU_TEMPLATES","TEMPLATE_PARTS_SUB_MENUS","find","area","browseAllLinkProps","postType","postId","undefined","revert","is_custom"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAaA;AACA;AACA;AAWe,SAASA,eAAT,OAAkD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAChE,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAyB,qBAC5BC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,6BAAtB,CAAqDN,QAArD,CAF6B,EAG9B,EAH8B,CAA/B;AAKA,QAAM;AAAEO,IAAAA;AAAF,MAAqB,uBAAaC,YAAb,CAA3B;AAEA,QAAMC,eAAe,GAAG,sBAAS,MAAM;AACtC,QAAK,CAAAT,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEU,IAAV,MAAmB,aAAxB,EAAwC;AACvC,aAAO;AAAER,QAAAA,KAAK,EAAE,cAAI,WAAJ,CAAT;AAA4BS,QAAAA,IAAI,EAAEC;AAAlC,OAAP;AACA;;AAED,WAAOC,oCAAyBC,IAAzB,CACN;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAgBA,IAAI,MAAKf,QAAL,aAAKA,QAAL,uBAAKA,QAAQ,CAAEe,IAAf,CAApB;AAAA,KADM,CAAP;AAGA,GARuB,EAQrB,CAAEf,QAAF,CARqB,CAAxB;AAUA,QAAMgB,kBAAkB,GAAG,mBAAS;AACnC;AACAC,IAAAA,QAAQ,EAAEjB,QAAQ,CAACU,IAFgB;AAGnCQ,IAAAA,MAAM,EAAEC;AAH2B,GAAT,CAA3B;;AAMA,MAAK,CAAEnB,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMoB,MAAM,GAAG,MAAM;AACpBb,IAAAA,cAAc,CAAEP,QAAF,CAAd;AACAC,IAAAA,OAAO;AACP,GAHD;;AAKA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGD,QAAQ,CAACqB,SAAT,GACD,4BAAC,0BAAD;AAAmB,IAAA,QAAQ,EAAGrB;AAA9B,IADC,GAGD,4BAAC,iCAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,MAAM,EAAG,GAFV;AAGC,IAAA,SAAS,EAAC;AAHX,KAKGE,KALH,CAJF,EAaGC,WAAW,IACZ,4BAAC,8BAAD;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,SAAS,EAAC,yCAFX;AAGC,IAAA,EAAE,EAAC;AAHJ,KAKGA,WALH,CAdF,CADD,EAyBC,4BAAC,sBAAD;AAAe,IAAA,4BAA4B,EAAGF;AAA9C,IAzBD,EA2BG,mCAAsBD,QAAtB,KACD,4BAAC,qBAAD;AAAW,IAAA,SAAS,EAAC;AAArB,KACC,4BAAC,oBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAG,cAAI,mCAAJ,CAFR;AAGC,IAAA,OAAO,EAAGoB;AAHX,KAKG,cAAI,sBAAJ,CALH,CADD,CA5BF,EAuCC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC;AADX,KAEMJ,kBAFN,GAIG;AACD;AACA,gBAAI,eAAJ,CAFC,EAGDP,eAAe,CAACP,KAHf,CAJH,CAvCD,CADD;AAoDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport {\n\tMENU_TEMPLATES,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../navigation-sidebar/navigation-panel/constants';\nimport { store as editSiteStore } from '../../store';\nimport TemplateAreas from './template-areas';\nimport EditTemplateTitle from './edit-template-title';\nimport { useLink } from '../routes/link';\n\nexport default function TemplateDetails( { template, onClose } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetTemplateInfo( template ),\n\t\t[]\n\t);\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\n\tconst templateSubMenu = useMemo( () => {\n\t\tif ( template?.type === 'wp_template' ) {\n\t\t\treturn { title: __( 'templates' ), menu: MENU_TEMPLATES };\n\t\t}\n\n\t\treturn TEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t( { area } ) => area === template?.area\n\t\t);\n\t}, [ template ] );\n\n\tconst browseAllLinkProps = useLink( {\n\t\t// TODO: We should update this to filter by template part's areas as well.\n\t\tpostType: template.type,\n\t\tpostId: undefined,\n\t} );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tconst revert = () => {\n\t\trevertTemplate( template );\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<div className=\"edit-site-template-details\">\n\t\t\t<div className=\"edit-site-template-details__group\">\n\t\t\t\t{ template.is_custom ? (\n\t\t\t\t\t<EditTemplateTitle template={ template } />\n\t\t\t\t) : (\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tlevel={ 4 }\n\t\t\t\t\t\tweight={ 600 }\n\t\t\t\t\t\tclassName=\"edit-site-template-details__title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\n\t\t\t\t{ description && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\tclassName=\"edit-site-template-details__description\"\n\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t<TemplateAreas closeTemplateDetailsDropdown={ onClose } />\n\n\t\t\t{ isTemplateRevertable( template ) && (\n\t\t\t\t<MenuGroup className=\"edit-site-template-details__group edit-site-template-details__revert\">\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tclassName=\"edit-site-template-details__revert-button\"\n\t\t\t\t\t\tinfo={ __( 'Restore template to default state' ) }\n\t\t\t\t\t\tonClick={ revert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-template-details__show-all-button\"\n\t\t\t\t{ ...browseAllLinkProps }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: the template part's area name (\"Headers\", \"Sidebars\") or \"templates\". */\n\t\t\t\t\t__( 'Browse all %s' ),\n\t\t\t\t\ttemplateSubMenu.title\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"]}
@@ -9,6 +9,8 @@ exports.default = TemplateAreas;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
12
14
  var _i18n = require("@wordpress/i18n");
13
15
 
14
16
  var _components = require("@wordpress/components");
@@ -23,10 +25,12 @@ var _icons = require("@wordpress/icons");
23
25
 
24
26
  var _store = require("../../store");
25
27
 
26
- var _constants = require("../../store/constants");
27
-
28
28
  var _isTemplateRevertable = _interopRequireDefault(require("../../utils/is-template-revertable"));
29
29
 
30
+ var _routes = require("../routes");
31
+
32
+ var _link = require("../routes/link");
33
+
30
34
  /**
31
35
  * WordPress dependencies
32
36
  */
@@ -43,12 +47,20 @@ function TemplatePartItemMore(_ref) {
43
47
  closeTemplateDetailsDropdown
44
48
  } = _ref;
45
49
  const {
46
- pushTemplatePart,
47
50
  revertTemplate
48
51
  } = (0, _data.useDispatch)(_store.store);
49
-
50
- function editTemplatePart() {
51
- pushTemplatePart(templatePart.id);
52
+ const {
53
+ params
54
+ } = (0, _routes.useLocation)();
55
+ const editLinkProps = (0, _link.useLink)({
56
+ postId: templatePart.id,
57
+ postType: templatePart.type
58
+ }, {
59
+ fromTemplateId: params.postId
60
+ });
61
+
62
+ function editTemplatePart(event) {
63
+ editLinkProps.onClick(event);
52
64
  onClose();
53
65
  closeTemplateDetailsDropdown();
54
66
  }
@@ -59,9 +71,9 @@ function TemplatePartItemMore(_ref) {
59
71
  closeTemplateDetailsDropdown();
60
72
  }
61
73
 
62
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
74
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, (0, _extends2.default)({}, editLinkProps, {
63
75
  onClick: editTemplatePart
64
- }, (0, _i18n.sprintf)(
76
+ }), (0, _i18n.sprintf)(
65
77
  /* translators: %s: template part title */
66
78
  (0, _i18n.__)('Edit %s'), (_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered))), (0, _isTemplateRevertable.default)(templatePart) && (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
67
79
  info: (0, _i18n.__)('Restore template to default state'),
@@ -79,6 +91,11 @@ function TemplatePartItem(_ref2) {
79
91
  selectBlock,
80
92
  toggleBlockHighlight
81
93
  } = (0, _data.useDispatch)(_blockEditor.store);
94
+ const templatePartArea = (0, _data.useSelect)(select => {
95
+ const defaultAreas = select(_editor.store).__experimentalGetDefaultTemplatePartAreas();
96
+
97
+ return defaultAreas.find(defaultArea => defaultArea.area === templatePart.area);
98
+ }, [templatePart.area]);
82
99
 
83
100
  const highlightBlock = () => toggleBlockHighlight(clientId, true);
84
101
 
@@ -89,7 +106,7 @@ function TemplatePartItem(_ref2) {
89
106
  className: "edit-site-template-details__template-areas-item"
90
107
  }, (0, _element.createElement)(_components.MenuItem, {
91
108
  role: "button",
92
- icon: (0, _editor.getTemplatePartIcon)(templatePart.area),
109
+ icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
93
110
  iconPosition: "left",
94
111
  onClick: () => {
95
112
  selectBlock(clientId);
@@ -98,7 +115,7 @@ function TemplatePartItem(_ref2) {
98
115
  onMouseLeave: cancelHighlightBlock,
99
116
  onFocus: highlightBlock,
100
117
  onBlur: cancelHighlightBlock
101
- }, _constants.TEMPLATE_PART_AREA_TO_NAME[templatePart.area]), (0, _element.createElement)(_components.DropdownMenu, {
118
+ }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label), (0, _element.createElement)(_components.DropdownMenu, {
102
119
  icon: _icons.moreVertical,
103
120
  label: (0, _i18n.__)('More options'),
104
121
  className: "edit-site-template-details__template-areas-item-more"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-details/template-areas.js"],"names":["TemplatePartItemMore","onClose","templatePart","closeTemplateDetailsDropdown","pushTemplatePart","revertTemplate","editSiteStore","editTemplatePart","id","clearCustomizations","title","rendered","TemplatePartItem","clientId","selectBlock","toggleBlockHighlight","blockEditorStore","highlightBlock","cancelHighlightBlock","area","TEMPLATE_PART_AREA_TO_NAME","moreVertical","TemplateAreas","templateParts","select","getCurrentTemplateTemplateParts","length","map","block","slug"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAfA;AACA;AACA;;AAQA;AACA;AACA;AAKA,SAASA,oBAAT,OAII;AAAA;;AAAA,MAJ2B;AAC9BC,IAAAA,OAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA;AAH8B,GAI3B;AACH,QAAM;AAAEC,IA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AnB,CAJH,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { getTemplatePartIcon } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { TEMPLATE_PART_AREA_TO_NAME } from '../../store/constants';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\n\nfunction TemplatePartItemMore( {\n\tonClose,\n\ttemplatePart,\n\tcloseTemplateDetailsDropdown,\n} ) {\n\tconst { pushTemplatePart, revertTemplate } = useDispatch( editSiteStore );\n\n\tfunction editTemplatePart() {\n\t\tpushTemplatePart( templatePart.id );\n\t\tonClose();\n\t\tcloseTemplateDetailsDropdown();\n\t}\n\n\tfunction clearCustomizations() {\n\t\trevertTemplate( templatePart );\n\t\tonClose();\n\t\tcloseTemplateDetailsDropdown();\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuGroup>\n\t\t\t\t<MenuItem onClick={ editTemplatePart }>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Edit %s' ),\n\t\t\t\t\t\ttemplatePart.title?.rendered\n\t\t\t\t\t) }\n\t\t\t\t</MenuItem>\n\t\t\t</MenuGroup>\n\t\t\t{ isTemplateRevertable( templatePart ) && (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tinfo={ __( 'Restore template to default state' ) }\n\t\t\t\t\t\tonClick={ clearCustomizations }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatePartItem( {\n\ttemplatePart,\n\tclientId,\n\tcloseTemplateDetailsDropdown,\n} ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<div\n\t\t\trole=\"menuitem\"\n\t\t\tclassName=\"edit-site-template-details__template-areas-item\"\n\t\t>\n\t\t\t<MenuItem\n\t\t\t\trole=\"button\"\n\t\t\t\ticon={ getTemplatePartIcon( templatePart.area ) }\n\t\t\t\ticonPosition=\"left\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} }\n\t\t\t\tonMouseOver={ highlightBlock }\n\t\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\t\tonFocus={ highlightBlock }\n\t\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\t>\n\t\t\t\t{ TEMPLATE_PART_AREA_TO_NAME[ templatePart.area ] }\n\t\t\t</MenuItem>\n\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\tclassName=\"edit-site-template-details__template-areas-item-more\"\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<TemplatePartItemMore\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\t\tcloseTemplateDetailsDropdown={\n\t\t\t\t\t\t\tcloseTemplateDetailsDropdown\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</div>\n\t);\n}\n\nexport default function TemplateAreas( { closeTemplateDetailsDropdown } ) {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup\n\t\t\tlabel={ __( 'Areas' ) }\n\t\t\tclassName=\"edit-site-template-details__group edit-site-template-details__template-areas\"\n\t\t>\n\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t<TemplatePartItem\n\t\t\t\t\tkey={ templatePart.slug }\n\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\tcloseTemplateDetailsDropdown={\n\t\t\t\t\t\tcloseTemplateDetailsDropdown\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-details/template-areas.js"],"names":["TemplatePartItemMore","onClose","templatePart","closeTemplateDetailsDropdown","revertTemplate","editSiteStore","params","editLinkProps","postId","id","postType","type","fromTemplateId","editTemplatePart","event","onClick","clearCustomizations","title","rendered","TemplatePartItem","clientId","selectBlock","toggleBlockHighlight","blockEditorStore","templatePartArea","select","defaultAreas","editorStore","__experimentalGetDefaultTemplatePartAreas","find","defaultArea","area","highlightBlock","cancelHighlightBlock","icon","label","moreVertical","TemplateAreas","templateParts","getCurrentTemplateTemplateParts","length","map","block","slug"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAQA;AACA;AACA;AAMA,SAASA,oBAAT,OAII;AAAA;;AAAA,MAJ2B;AAC9BC,IAAAA,OAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA;AAH8B,GAI3B;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAqB,uBAAaC,YAAb,CAA3B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,aAAa,GAAG,mBACrB;AACCC,IAAAA,MAAM,EAAEN,YAAY,CAACO,EADtB;AAECC,IAAAA,QAAQ,EAAER,YAAY,CAACS;AAFxB,G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AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGF,aAAa,CAACG,GAAd,CAAmB;AAAA,QAAE;AAAEvC,MAAAA,YAAF;AAAgBwC,MAAAA;AAAhB,KAAF;AAAA,WACpB,4BAAC,gBAAD;AACC,MAAA,GAAG,EAAGxC,YAAY,CAACyC,IADpB;AAEC,MAAA,QAAQ,EAAGD,KAAK,CAACtB,QAFlB;AAGC,MAAA,YAAY,EAAGlB,YAHhB;AAIC,MAAA,4BAA4B,EAC3BC;AALF,MADoB;AAAA,GAAnB,CAJH,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { useLocation } from '../routes';\nimport { useLink } from '../routes/link';\n\nfunction TemplatePartItemMore( {\n\tonClose,\n\ttemplatePart,\n\tcloseTemplateDetailsDropdown,\n} ) {\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { params } = useLocation();\n\tconst editLinkProps = useLink(\n\t\t{\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: templatePart.type,\n\t\t},\n\t\t{\n\t\t\tfromTemplateId: params.postId,\n\t\t}\n\t);\n\n\tfunction editTemplatePart( event ) {\n\t\teditLinkProps.onClick( event );\n\t\tonClose();\n\t\tcloseTemplateDetailsDropdown();\n\t}\n\n\tfunction clearCustomizations() {\n\t\trevertTemplate( templatePart );\n\t\tonClose();\n\t\tcloseTemplateDetailsDropdown();\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuGroup>\n\t\t\t\t<MenuItem { ...editLinkProps } onClick={ editTemplatePart }>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Edit %s' ),\n\t\t\t\t\t\ttemplatePart.title?.rendered\n\t\t\t\t\t) }\n\t\t\t\t</MenuItem>\n\t\t\t</MenuGroup>\n\t\t\t{ isTemplateRevertable( templatePart ) && (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tinfo={ __( 'Restore template to default state' ) }\n\t\t\t\t\t\tonClick={ clearCustomizations }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatePartItem( {\n\ttemplatePart,\n\tclientId,\n\tcloseTemplateDetailsDropdown,\n} ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst templatePartArea = useSelect(\n\t\t( select ) => {\n\t\t\tconst defaultAreas = select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\treturn defaultAreas.find(\n\t\t\t\t( defaultArea ) => defaultArea.area === templatePart.area\n\t\t\t);\n\t\t},\n\t\t[ templatePart.area ]\n\t);\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<div\n\t\t\trole=\"menuitem\"\n\t\t\tclassName=\"edit-site-template-details__template-areas-item\"\n\t\t>\n\t\t\t<MenuItem\n\t\t\t\trole=\"button\"\n\t\t\t\ticon={ templatePartArea?.icon }\n\t\t\t\ticonPosition=\"left\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} }\n\t\t\t\tonMouseOver={ highlightBlock }\n\t\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\t\tonFocus={ highlightBlock }\n\t\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\t>\n\t\t\t\t{ templatePartArea?.label }\n\t\t\t</MenuItem>\n\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\tclassName=\"edit-site-template-details__template-areas-item-more\"\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<TemplatePartItemMore\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\t\tcloseTemplateDetailsDropdown={\n\t\t\t\t\t\t\tcloseTemplateDetailsDropdown\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</div>\n\t);\n}\n\nexport default function TemplateAreas( { closeTemplateDetailsDropdown } ) {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup\n\t\t\tlabel={ __( 'Areas' ) }\n\t\t\tclassName=\"edit-site-template-details__group edit-site-template-details__template-areas\"\n\t\t>\n\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t<TemplatePartItem\n\t\t\t\t\tkey={ templatePart.slug }\n\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\tcloseTemplateDetailsDropdown={\n\t\t\t\t\t\tcloseTemplateDetailsDropdown\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n"]}
@@ -71,20 +71,15 @@ function ConvertToTemplatePart(_ref) {
71
71
  }));
72
72
  createSuccessNotice((0, _i18n.__)('Template part created.'), {
73
73
  type: 'snackbar'
74
- });
74
+ }); // The modal and this component will be unmounted because of `replaceBlocks` above,
75
+ // so no need to call `closeModal` or `onClose`.
75
76
  };
76
77
 
77
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockSettingsMenuControls, null, _ref3 => {
78
- let {
79
- onClose
80
- } = _ref3;
81
- return (0, _element.createElement)(_components.MenuItem, {
82
- onClick: () => {
83
- setIsModalOpen(true);
84
- onClose();
85
- }
86
- }, (0, _i18n.__)('Make template part'));
87
- }), isModalOpen && (0, _element.createElement)(_createTemplatePartModal.default, {
78
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockSettingsMenuControls, null, () => (0, _element.createElement)(_components.MenuItem, {
79
+ onClick: () => {
80
+ setIsModalOpen(true);
81
+ }
82
+ }, (0, _i18n.__)('Make template part'))), isModalOpen && (0, _element.createElement)(_createTemplatePartModal.default, {
88
83
  closeModal: () => {
89
84
  setIsModalOpen(false);
90
85
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","blockEditorStore","saveEntityRecord","coreStore","createSuccessNotice","noticesStore","onConvert","title","area","templatePart","slug","content","theme","type","onClose"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGe,SAASA,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAwB;AACtE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,kBAAb,CAA1B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;;AAEA,QAAMC,SAAS,GAAG,eAA6B;AAAA,QAArB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAqB;AAC9C,UAAMC,YAAY,GAAG,MAAMP,gBAAgB,CAC1C,UAD0C,EAE1C,kBAF0C,EAG1C;AACCQ,MAAAA,IAAI,EAAE,uBAAWH,KAAX,CADP;AAECA,MAAAA,KAFD;AAGCI,MAAAA,OAAO,EAAE,uBAAWd,MAAX,CAHV;AAICW,MAAAA;AAJD,KAH0C,CAA3C;AAUAR,IAAAA,aAAa,CACZJ,SADY,EAEZ,yBAAa,oBAAb,EAAmC;AAClCc,MAAAA,IAAI,EAAED,YAAY,CAACC,IADe;AAElCE,MAAAA,KAAK,EAAEH,YAAY,CAACG;AAFc,KAAnC,CAFY,CAAb;AAOAR,IAAAA,mBAAmB,CAAE,cAAI,wBAAJ,CAAF,EAAkC;AACpDS,MAAAA,IAAI,EAAE;AAD8C,KAAlC,CAAnB;AAGA,GArBD;;AAuBA,SACC,qDACC,4BAAC,sCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACff,QAAAA,cAAc,CAAE,IAAF,CAAd;AACAe,QAAAA,OAAO;AACP;AAJF,OAMG,cAAI,oBAAJ,CANH,CADC;AAAA,GADH,CADD,EAaGhB,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAM;AAClBC,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGO;AAJZ,IAdF,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock, serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onConvert = async ( { title, area } ) => {\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\ttitle,\n\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\tarea,\n\t\t\t}\n\t\t);\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Make template part' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t) }\n\t\t\t</BlockSettingsMenuControls>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-template-part.js"],"names":["ConvertToTemplatePart","clientIds","blocks","isModalOpen","setIsModalOpen","replaceBlocks","blockEditorStore","saveEntityRecord","coreStore","createSuccessNotice","noticesStore","onConvert","title","area","templatePart","slug","content","theme","type"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGe,SAASA,qBAAT,OAAwD;AAAA,MAAxB;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAwB;AACtE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,kBAAb,CAA1B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;;AAEA,QAAMC,SAAS,GAAG,eAA6B;AAAA,QAArB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAqB;AAC9C,UAAMC,YAAY,GAAG,MAAMP,gBAAgB,CAC1C,UAD0C,EAE1C,kBAF0C,EAG1C;AACCQ,MAAAA,IAAI,EAAE,uBAAWH,KAAX,CADP;AAECA,MAAAA,KAFD;AAGCI,MAAAA,OAAO,EAAE,uBAAWd,MAAX,CAHV;AAICW,MAAAA;AAJD,KAH0C,CAA3C;AAUAR,IAAAA,aAAa,CACZJ,SADY,EAEZ,yBAAa,oBAAb,EAAmC;AAClCc,MAAAA,IAAI,EAAED,YAAY,CAACC,IADe;AAElCE,MAAAA,KAAK,EAAEH,YAAY,CAACG;AAFc,KAAnC,CAFY,CAAb;AAOAR,IAAAA,mBAAmB,CAAE,cAAI,wBAAJ,CAAF,EAAkC;AACpDS,MAAAA,IAAI,EAAE;AAD8C,KAAlC,CAAnB,CAlB8C,CAsB9C;AACA;AACA,GAxBD;;AA0BA,SACC,qDACC,4BAAC,sCAAD,QACG,MACD,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfd,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAHF,KAKG,cAAI,oBAAJ,CALH,CAFF,CADD,EAYGD,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAM;AAClBC,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA,KAHF;AAIC,IAAA,QAAQ,EAAGO;AAJZ,IAbF,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { createBlock, serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function ConvertToTemplatePart( { clientIds, blocks } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onConvert = async ( { title, area } ) => {\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\ttitle,\n\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\tarea,\n\t\t\t}\n\t\t);\n\t\treplaceBlocks(\n\t\t\tclientIds,\n\t\t\tcreateBlock( 'core/template-part', {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t} )\n\t\t);\n\t\tcreateSuccessNotice( __( 'Template part created.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\n\t\t// The modal and this component will be unmounted because of `replaceBlocks` above,\n\t\t// so no need to call `closeModal` or `onClose`.\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ () => (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Make template part' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t) }\n\t\t\t</BlockSettingsMenuControls>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCreate={ onConvert }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -9,7 +9,7 @@ var _element = require("@wordpress/element");
9
9
 
10
10
  var _data = require("@wordpress/data");
11
11
 
12
- var _url = require("@wordpress/url");
12
+ var _routes = require("../routes");
13
13
 
14
14
  var _store = require("../../store");
15
15
 
@@ -26,18 +26,22 @@ function URLQueryController() {
26
26
  setTemplatePart,
27
27
  showHomepage,
28
28
  setPage
29
- } = (0, _data.useDispatch)(_store.store); // Set correct entity on load.
30
-
31
- (0, _element.useEffect)(() => {
32
- const url = window.location.href;
33
- const postId = (0, _url.getQueryArg)(url, 'postId');
34
-
35
- if (!postId) {
36
- showHomepage();
37
- return;
29
+ } = (0, _data.useDispatch)(_store.store);
30
+ const history = (0, _routes.useHistory)();
31
+ const {
32
+ params: {
33
+ postId,
34
+ postType
38
35
  }
36
+ } = (0, _routes.useLocation)();
37
+ const {
38
+ getPage,
39
+ getEditedPostId,
40
+ getEditedPostType
41
+ } = (0, _data.useSelect)(_store.store); // Set correct entity on page navigation.
39
42
 
40
- const postType = (0, _url.getQueryArg)(url, 'postType');
43
+ (0, _element.useEffect)(() => {
44
+ let isMounted = true;
41
45
 
42
46
  if ('page' === postType || 'post' === postType) {
43
47
  setPage({
@@ -51,48 +55,35 @@ function URLQueryController() {
51
55
  } else if ('wp_template_part' === postType) {
52
56
  setTemplatePart(postId);
53
57
  } else {
54
- showHomepage();
55
- }
56
- }, []); // Update page URL when context changes.
58
+ showHomepage().then(() => {
59
+ var _page$context, _page$context2;
57
60
 
58
- const pageContext = useCurrentPageContext();
59
- (0, _element.useEffect)(() => {
60
- const newUrl = pageContext ? (0, _url.addQueryArgs)(window.location.href, pageContext) : (0, _url.removeQueryArgs)(window.location.href, 'postType', 'postId');
61
- window.history.replaceState({}, '', newUrl);
62
- }, [pageContext]);
63
- return null;
64
- }
65
-
66
- function useCurrentPageContext() {
67
- return (0, _data.useSelect)(select => {
68
- var _page$context, _page$context2;
69
-
70
- const {
71
- getEditedPostType,
72
- getEditedPostId,
73
- getPage
74
- } = select(_store.store);
75
- const page = getPage();
76
-
77
- let _postId = getEditedPostId(),
78
- _postType = getEditedPostType(); // This doesn't seem right to me,
79
- // we shouldn't be using the "page" and the "template" in the same way.
80
- // This need to be investigated.
81
-
82
-
83
- if (page !== null && page !== void 0 && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId && page !== null && page !== void 0 && (_page$context2 = page.context) !== null && _page$context2 !== void 0 && _page$context2.postType) {
84
- _postId = page.context.postId;
85
- _postType = page.context.postType;
86
- }
61
+ if (!isMounted) {
62
+ return;
63
+ }
87
64
 
88
- if (_postId && _postType) {
89
- return {
90
- postId: _postId,
91
- postType: _postType
92
- };
65
+ const page = getPage();
66
+ const editedPostId = getEditedPostId();
67
+ const editedPostType = getEditedPostType();
68
+
69
+ if (page !== null && page !== void 0 && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId && page !== null && page !== void 0 && (_page$context2 = page.context) !== null && _page$context2 !== void 0 && _page$context2.postType) {
70
+ history.replace({
71
+ postId: page.context.postId,
72
+ postType: page.context.postType
73
+ });
74
+ } else if (editedPostId && editedPostType) {
75
+ history.replace({
76
+ postId: editedPostId,
77
+ postType: editedPostType
78
+ });
79
+ }
80
+ });
93
81
  }
94
82
 
95
- return null;
96
- }, []);
83
+ return () => {
84
+ isMounted = false;
85
+ };
86
+ }, [postId, postType]);
87
+ return null;
97
88
  }
98
89
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","editSiteStore","url","window","location","href","postId","postType","context","pageContext","useCurrentPageContext","newUrl","history","replaceState","select","getEditedPostType","getEditedPostId","getPage","page","_postId","_postType"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0D,uBAC/DC,YAD+D,CAAhE,CAD4C,CAK5C;;AACA,0BAAW,MAAM;AAChB,UAAMC,GAAG,GAAGC,MAAM,CAACC,QAAP,CAAgBC,IAA5B;AACA,UAAMC,MAAM,GAAG,sBAAaJ,GAAb,EAAkB,QAAlB,CAAf;;AAEA,QAAK,CAAEI,MAAP,EAAgB;AACfP,MAAAA,YAAY;AACZ;AACA;;AAED,UAAMQ,QAAQ,GAAG,sBAAaL,GAAb,EAAkB,UAAlB,CAAjB;;AACA,QAAK,WAAWK,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDP,MAAAA,OAAO,CAAE;AAAEQ,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAA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AI,CAACV,OAAL,CAAaF,MAAvB;AACAc,MAAAA,SAAS,GAAGF,IAAI,CAACV,OAAL,CAAaD,QAAzB;AACA;;AAED,QAAKY,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,aAAO;AAAEd,QAAAA,MAAM,EAAEa,OAAV;AAAmBZ,QAAAA,QAAQ,EAAEa;AAA7B,OAAP;AACA;;AAED,WAAO,IAAP;AACA,GArBM,EAqBJ,EArBI,CAAP;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getQueryArg, addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\t// Set correct entity on load.\n\tuseEffect( () => {\n\t\tconst url = window.location.href;\n\t\tconst postId = getQueryArg( url, 'postId' );\n\n\t\tif ( ! postId ) {\n\t\t\tshowHomepage();\n\t\t\treturn;\n\t\t}\n\n\t\tconst postType = getQueryArg( url, 'postType' );\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t} else {\n\t\t\tshowHomepage();\n\t\t}\n\t}, [] );\n\n\t// Update page URL when context changes.\n\tconst pageContext = useCurrentPageContext();\n\tuseEffect( () => {\n\t\tconst newUrl = pageContext\n\t\t\t? addQueryArgs( window.location.href, pageContext )\n\t\t\t: removeQueryArgs( window.location.href, 'postType', 'postId' );\n\n\t\twindow.history.replaceState( {}, '', newUrl );\n\t}, [ pageContext ] );\n\n\treturn null;\n}\n\nfunction useCurrentPageContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId, getPage } = select(\n\t\t\teditSiteStore\n\t\t);\n\n\t\tconst page = getPage();\n\t\tlet _postId = getEditedPostId(),\n\t\t\t_postType = getEditedPostType();\n\t\t// This doesn't seem right to me,\n\t\t// we shouldn't be using the \"page\" and the \"template\" in the same way.\n\t\t// This need to be investigated.\n\t\tif ( page?.context?.postId && page?.context?.postType ) {\n\t\t\t_postId = page.context.postId;\n\t\t\t_postType = page.context.postType;\n\t\t}\n\n\t\tif ( _postId && _postType ) {\n\t\t\treturn { postId: _postId, postType: _postType };\n\t\t}\n\n\t\treturn null;\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","editSiteStore","history","params","postId","postType","getPage","getEditedPostId","getEditedPostType","isMounted","context","then","page","editedPostId","editedPostType","replace"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0D,uBAC/DC,YAD+D,CAAhE;AAGA,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEF,0BAFJ;AAGA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,eAAX;AAA4BC,IAAAA;AAA5B,MAAkD,qBACvDP,YADuD,CAAxD,CAR4C,CAY5C;;AACA,0BAAW,MAAM;AAChB,QAAIQ,SAAS,GAAG,IAAhB;;AAEA,QAAK,WAAWJ,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDL,MAAAA,OAAO,CAAE;AAAEU,QAAAA,OAAO,EAAE;AAAEL,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCR,MAAAA,WAAW,CAAEO,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CP,MAAAA,eAAe,CAAEM,MAAF,CAAf;AACA,KAFM,MAEA;AACNL,MAAAA,YAAY,GAAGY,IAAf,CAAqB,MAAM;AAAA;;AAC1B,YAAK,CAAEF,SAAP,EAAmB;AAClB;AACA;;AAED,cAAMG,IAAI,GAAGN,OAAO,EAApB;AACA,cAAMO,YAAY,GAAGN,eAAe,EAApC;AACA,cAAMO,cAAc,GAAGN,iBAAiB,EAAxC;;AAEA,YAAKI,IAAI,SAAJ,IAAAA,IAAI,WAAJ,qBAAAA,IAAI,CAAEF,OAAN,wDAAeN,MAAf,IAAyBQ,IAAzB,aAAyBA,IAAzB,iCAAyBA,IAAI,CAAEF,OAA/B,2CAAyB,eAAeL,QAA7C,EAAwD;AACvDH,UAAAA,OAAO,CAACa,OAAR,CAAiB;AAChBX,YAAAA,MAAM,EAAEQ,IAAI,CAACF,OAAL,CAAaN,MADL;AAEhBC,YAAAA,QAAQ,EAAEO,IAAI,CAACF,OAAL,CAAaL;AAFP,WAAjB;AAIA,SALD,MAKO,IAAKQ,YAAY,IAAIC,cAArB,EAAsC;AAC5CZ,UAAAA,OAAO,CAACa,OAAR,CAAiB;AAChBX,YAAAA,MAAM,EAAES,YADQ;AAEhBR,YAAAA,QAAQ,EAAES;AAFM,WAAjB;AAIA;AACD,OApBD;AAqBA;;AAED,WAAO,MAAM;AACZL,MAAAA,SAAS,GAAG,KAAZ;AACA,KAFD;AAGA,GApCD,EAoCG,CAAEL,MAAF,EAAUC,QAAV,CApCH;AAsCA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function URLQueryController() {\n\tconst { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(\n\t\teditSiteStore\n\t);\n\tconst history = useHistory();\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\tconst { getPage, getEditedPostId, getEditedPostType } = useSelect(\n\t\teditSiteStore\n\t);\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\tlet isMounted = true;\n\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t} else {\n\t\t\tshowHomepage().then( () => {\n\t\t\t\tif ( ! isMounted ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst page = getPage();\n\t\t\t\tconst editedPostId = getEditedPostId();\n\t\t\t\tconst editedPostType = getEditedPostType();\n\n\t\t\t\tif ( page?.context?.postId && page?.context?.postType ) {\n\t\t\t\t\thistory.replace( {\n\t\t\t\t\t\tpostId: page.context.postId,\n\t\t\t\t\t\tpostType: page.context.postType,\n\t\t\t\t\t} );\n\t\t\t\t} else if ( editedPostId && editedPostType ) {\n\t\t\t\t\thistory.replace( {\n\t\t\t\t\t\tpostId: editedPostId,\n\t\t\t\t\t\tpostType: editedPostType,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tisMounted = false;\n\t\t};\n\t}, [ postId, postType ] );\n\n\treturn null;\n}\n"]}
@@ -30,6 +30,12 @@ function WelcomeGuideEditor() {
30
30
  const {
31
31
  toggleFeature
32
32
  } = (0, _data.useDispatch)(_store.store);
33
+ const isActive = (0, _data.useSelect)(select => select(_store.store).isFeatureActive('welcomeGuide'), []);
34
+
35
+ if (!isActive) {
36
+ return null;
37
+ }
38
+
33
39
  return (0, _element.createElement)(_components.Guide, {
34
40
  className: "edit-site-welcome-guide",
35
41
  contentLabel: (0, _i18n.__)('Welcome to the site editor'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/editor.js"],"names":["WelcomeGuideEditor","toggleFeature","editSiteStore","image","content","StylesIconImage"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AAEA,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,yBADX;AAEC,IAAA,YAAY,EAAG,cAAI,4BAAJ,CAFhB;AAGC,IAAA,gBAAgB,EAAG,cAAI,aAAJ,CAHpB;AAIC,IAAA,QAAQ,EAAG,MAAMD,aAAa,CAAE,cAAF,CAJ/B;AAKC,IAAA,KAAK,EAAG,CACP;AACCE,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,0DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,gBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,2FADC,CADH,CAJD,EASC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,uCACD,cACC,2GADD,CADC,EAID;AACCC,QAAAA,eAAe,EACd;AACC,UAAA,GAAG,EAAG,cAAI,QAAJ,CADP;AAEC,UAAA,GAAG,EAAC;AAFL;AAFF,OAJC,CADH,CATD;AARF,KADO;AALT,IADD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\nimport { store as editSiteStore } from '../../store';\n\nexport default function WelcomeGuideEditor() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to the site editor' ) }\n\t\t\tfinishButtonText={ __( 'Get Started' ) }\n\t\t\tonFinish={ () => toggleFeature( 'welcomeGuide' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Edit your site' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Design everything on your site — from the header right down to the footer — using blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStylesIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'styles' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\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);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/editor.js"],"names":["WelcomeGuideEditor","toggleFeature","editSiteStore","isActive","select","isFeatureActive","image","content","StylesIconImage"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AAEA,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IAAcA,MAAM,CAAEF,YAAF,CAAN,CAAwBG,eAAxB,CAAyC,cAAzC,CADE,EAEhB,EAFgB,CAAjB;;AAKA,MAAK,CAAEF,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,yBADX;AAEC,IAAA,YAAY,EAAG,cAAI,4BAAJ,CAFhB;AAGC,IAAA,gBAAgB,EAAG,cAAI,aAAJ,CAHpB;AAIC,IAAA,QAAQ,EAAG,MAAMF,aAAa,CAAE,cAAF,CAJ/B;AAKC,IAAA,KAAK,EAAG,CACP;AACCK,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,0DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,gBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,2FADC,CADH,CAJD,EASC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,uCACD,cACC,2GADD,CADC,EAID;AACCC,QAAAA,eAAe,EACd;AACC,UAAA,GAAG,EAAG,cAAI,QAAJ,CADP;AAEC,UAAA,GAAG,EAAC;AAFL;AAFF,OAJC,CADH,CATD;AARF,KADO;AALT,IADD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\nimport { store as editSiteStore } from '../../store';\n\nexport default function WelcomeGuideEditor() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\tconst isActive = useSelect(\n\t\t( select ) => select( editSiteStore ).isFeatureActive( 'welcomeGuide' ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to the site editor' ) }\n\t\t\tfinishButtonText={ __( 'Get Started' ) }\n\t\t\tonFinish={ () => toggleFeature( 'welcomeGuide' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Edit your site' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Design everything on your site — from the header right down to the footer — using blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStylesIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'styles' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\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);\n}\n"]}
@@ -9,41 +9,14 @@ exports.default = WelcomeGuide;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _data = require("@wordpress/data");
13
-
14
- var _interface = require("@wordpress/interface");
15
-
16
12
  var _editor = _interopRequireDefault(require("./editor"));
17
13
 
18
14
  var _styles = _interopRequireDefault(require("./styles"));
19
15
 
20
- var _store = require("../../store");
21
-
22
- /**
23
- * WordPress dependencies
24
- */
25
-
26
16
  /**
27
17
  * Internal dependencies
28
18
  */
29
19
  function WelcomeGuide() {
30
- const {
31
- isActive,
32
- isStylesOpen
33
- } = (0, _data.useSelect)(select => {
34
- const sidebar = select(_interface.store).getActiveComplementaryArea(_store.store.name);
35
- const isStylesSidebar = sidebar === 'edit-site/global-styles';
36
- const feature = isStylesSidebar ? 'welcomeGuideStyles' : 'welcomeGuide';
37
- return {
38
- isActive: select(_store.store).isFeatureActive(feature),
39
- isStylesOpen: isStylesSidebar
40
- };
41
- }, []);
42
-
43
- if (!isActive) {
44
- return null;
45
- }
46
-
47
- return isStylesOpen ? (0, _element.createElement)(_styles.default, null) : (0, _element.createElement)(_editor.default, null);
20
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_editor.default, null), (0, _element.createElement)(_styles.default, null));
48
21
  }
49
22
  //# sourceMappingURL=index.js.map