@wordpress/edit-site 5.31.0 → 5.32.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 (280) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/editor-canvas.js +8 -1
  3. package/build/components/block-editor/editor-canvas.js.map +1 -1
  4. package/build/components/block-editor/site-editor-canvas.js +15 -4
  5. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  6. package/build/components/editor/index.js +12 -3
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor-canvas-container/index.js +1 -2
  9. package/build/components/editor-canvas-container/index.js.map +1 -1
  10. package/build/components/global-styles/background-panel.js +38 -0
  11. package/build/components/global-styles/background-panel.js.map +1 -0
  12. package/build/components/global-styles/font-families.js +1 -1
  13. package/build/components/global-styles/font-families.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/context.js +38 -9
  15. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/utils/index.js +20 -2
  17. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  18. package/build/components/global-styles/palette.js +3 -1
  19. package/build/components/global-styles/palette.js.map +1 -1
  20. package/build/components/global-styles/preview-colors.js +2 -2
  21. package/build/components/global-styles/preview-colors.js.map +1 -1
  22. package/build/components/global-styles/root-menu.js +8 -2
  23. package/build/components/global-styles/root-menu.js.map +1 -1
  24. package/build/components/global-styles/screen-background.js +34 -0
  25. package/build/components/global-styles/screen-background.js.map +1 -0
  26. package/build/components/global-styles/screen-color-palette.js +2 -2
  27. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  28. package/build/components/global-styles/screen-colors.js +6 -4
  29. package/build/components/global-styles/screen-colors.js.map +1 -1
  30. package/build/components/global-styles/screen-style-variations.js +3 -37
  31. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  32. package/build/components/global-styles/screen-typography.js +6 -6
  33. package/build/components/global-styles/screen-typography.js.map +1 -1
  34. package/build/components/global-styles/style-variations-container.js +5 -2
  35. package/build/components/global-styles/style-variations-container.js.map +1 -1
  36. package/build/components/global-styles/ui.js +4 -1
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/global-styles/variations/variations-color.js +10 -3
  39. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  40. package/build/components/global-styles/variations/variations-typography.js +9 -2
  41. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  42. package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
  43. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  44. package/build/components/layout/animation.js +129 -0
  45. package/build/components/layout/animation.js.map +1 -0
  46. package/build/components/layout/index.js +9 -17
  47. package/build/components/layout/index.js.map +1 -1
  48. package/build/components/layout/router.js +21 -18
  49. package/build/components/layout/router.js.map +1 -1
  50. package/build/components/page-pages/index.js +19 -17
  51. package/build/components/page-pages/index.js.map +1 -1
  52. package/build/components/page-patterns/index.js +18 -28
  53. package/build/components/page-patterns/index.js.map +1 -1
  54. package/build/components/page-patterns/search-items.js +16 -58
  55. package/build/components/page-patterns/search-items.js.map +1 -1
  56. package/build/components/page-templates-template-parts/actions.js +54 -41
  57. package/build/components/page-templates-template-parts/actions.js.map +1 -1
  58. package/build/components/page-templates-template-parts/index.js +26 -59
  59. package/build/components/page-templates-template-parts/index.js.map +1 -1
  60. package/build/components/plugin-template-setting-panel/index.js +12 -1
  61. package/build/components/plugin-template-setting-panel/index.js.map +1 -1
  62. package/build/components/save-button/index.js +45 -16
  63. package/build/components/save-button/index.js.map +1 -1
  64. package/build/components/save-hub/index.js +8 -112
  65. package/build/components/save-hub/index.js.map +1 -1
  66. package/build/components/sidebar/index.js +1 -5
  67. package/build/components/sidebar/index.js.map +1 -1
  68. package/build/components/sidebar-dataviews/default-views.js +1 -1
  69. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  70. package/build/components/sidebar-dataviews/index.js +1 -1
  71. package/build/components/sidebar-dataviews/index.js.map +1 -1
  72. package/build/components/sidebar-edit-mode/index.js +1 -2
  73. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  74. package/build/components/sidebar-edit-mode/page-panels/index.js +5 -15
  75. package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  76. package/build/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  77. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/template-panel/index.js +10 -16
  79. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  81. package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  83. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -5
  85. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  86. package/build/components/style-book/index.js +1 -1
  87. package/build/components/style-book/index.js.map +1 -1
  88. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  89. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  90. package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  91. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  92. package/build/hooks/index.js +0 -1
  93. package/build/hooks/index.js.map +1 -1
  94. package/build/store/selectors.js +1 -9
  95. package/build/store/selectors.js.map +1 -1
  96. package/build-module/components/block-editor/editor-canvas.js +8 -1
  97. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  98. package/build-module/components/block-editor/site-editor-canvas.js +15 -4
  99. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  100. package/build-module/components/editor/index.js +13 -4
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/editor-canvas-container/index.js +1 -2
  103. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  104. package/build-module/components/global-styles/background-panel.js +31 -0
  105. package/build-module/components/global-styles/background-panel.js.map +1 -0
  106. package/build-module/components/global-styles/font-families.js +1 -1
  107. package/build-module/components/global-styles/font-families.js.map +1 -1
  108. package/build-module/components/global-styles/font-library-modal/context.js +38 -9
  109. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  110. package/build-module/components/global-styles/font-library-modal/utils/index.js +20 -2
  111. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  112. package/build-module/components/global-styles/palette.js +3 -1
  113. package/build-module/components/global-styles/palette.js.map +1 -1
  114. package/build-module/components/global-styles/preview-colors.js +2 -2
  115. package/build-module/components/global-styles/preview-colors.js.map +1 -1
  116. package/build-module/components/global-styles/root-menu.js +9 -3
  117. package/build-module/components/global-styles/root-menu.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background.js +26 -0
  119. package/build-module/components/global-styles/screen-background.js.map +1 -0
  120. package/build-module/components/global-styles/screen-color-palette.js +2 -2
  121. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  122. package/build-module/components/global-styles/screen-colors.js +6 -4
  123. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  124. package/build-module/components/global-styles/screen-style-variations.js +4 -38
  125. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  126. package/build-module/components/global-styles/screen-typography.js +6 -6
  127. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  128. package/build-module/components/global-styles/style-variations-container.js +5 -2
  129. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  130. package/build-module/components/global-styles/ui.js +4 -1
  131. package/build-module/components/global-styles/ui.js.map +1 -1
  132. package/build-module/components/global-styles/variations/variations-color.js +10 -3
  133. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  134. package/build-module/components/global-styles/variations/variations-typography.js +9 -2
  135. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  136. package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
  137. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  138. package/build-module/components/layout/animation.js +122 -0
  139. package/build-module/components/layout/animation.js.map +1 -0
  140. package/build-module/components/layout/index.js +9 -17
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/layout/router.js +21 -18
  143. package/build-module/components/layout/router.js.map +1 -1
  144. package/build-module/components/page-pages/index.js +19 -17
  145. package/build-module/components/page-pages/index.js.map +1 -1
  146. package/build-module/components/page-patterns/index.js +20 -30
  147. package/build-module/components/page-patterns/index.js.map +1 -1
  148. package/build-module/components/page-patterns/search-items.js +14 -55
  149. package/build-module/components/page-patterns/search-items.js.map +1 -1
  150. package/build-module/components/page-templates-template-parts/actions.js +54 -40
  151. package/build-module/components/page-templates-template-parts/actions.js.map +1 -1
  152. package/build-module/components/page-templates-template-parts/index.js +29 -62
  153. package/build-module/components/page-templates-template-parts/index.js.map +1 -1
  154. package/build-module/components/plugin-template-setting-panel/index.js +12 -1
  155. package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
  156. package/build-module/components/save-button/index.js +46 -17
  157. package/build-module/components/save-button/index.js.map +1 -1
  158. package/build-module/components/save-hub/index.js +10 -114
  159. package/build-module/components/save-hub/index.js.map +1 -1
  160. package/build-module/components/sidebar/index.js +1 -5
  161. package/build-module/components/sidebar/index.js.map +1 -1
  162. package/build-module/components/sidebar-dataviews/default-views.js +1 -1
  163. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  164. package/build-module/components/sidebar-dataviews/index.js +1 -1
  165. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  166. package/build-module/components/sidebar-edit-mode/index.js +1 -2
  167. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  168. package/build-module/components/sidebar-edit-mode/page-panels/index.js +8 -18
  169. package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  170. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  171. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  172. package/build-module/components/sidebar-edit-mode/template-panel/index.js +11 -17
  173. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  175. package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  176. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  177. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  178. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -5
  179. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  180. package/build-module/components/style-book/index.js +1 -1
  181. package/build-module/components/style-book/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  183. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/hooks/index.js +0 -1
  187. package/build-module/hooks/index.js.map +1 -1
  188. package/build-module/store/selectors.js +1 -9
  189. package/build-module/store/selectors.js.map +1 -1
  190. package/build-style/style-rtl.css +116 -104
  191. package/build-style/style.css +116 -104
  192. package/package.json +44 -44
  193. package/src/components/block-editor/editor-canvas.js +14 -2
  194. package/src/components/block-editor/site-editor-canvas.js +10 -7
  195. package/src/components/editor/index.js +11 -4
  196. package/src/components/editor-canvas-container/index.js +0 -1
  197. package/src/components/global-styles/background-panel.js +34 -0
  198. package/src/components/global-styles/font-families.js +1 -1
  199. package/src/components/global-styles/font-library-modal/context.js +43 -14
  200. package/src/components/global-styles/font-library-modal/style.scss +1 -1
  201. package/src/components/global-styles/font-library-modal/utils/index.js +17 -4
  202. package/src/components/global-styles/palette.js +3 -1
  203. package/src/components/global-styles/preview-colors.js +2 -2
  204. package/src/components/global-styles/root-menu.js +12 -1
  205. package/src/components/global-styles/screen-background.js +29 -0
  206. package/src/components/global-styles/screen-color-palette.js +2 -2
  207. package/src/components/global-styles/screen-colors.js +4 -4
  208. package/src/components/global-styles/screen-style-variations.js +4 -36
  209. package/src/components/global-styles/screen-typography.js +6 -9
  210. package/src/components/global-styles/style-variations-container.js +2 -1
  211. package/src/components/global-styles/style.scss +14 -12
  212. package/src/components/global-styles/ui.js +5 -0
  213. package/src/components/global-styles/variations/style.scss +32 -17
  214. package/src/components/global-styles/variations/variations-color.js +4 -2
  215. package/src/components/global-styles/variations/variations-typography.js +4 -1
  216. package/src/components/header-edit-mode/style.scss +28 -17
  217. package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
  218. package/src/components/layout/animation.js +122 -0
  219. package/src/components/layout/index.js +12 -27
  220. package/src/components/layout/router.js +25 -19
  221. package/src/components/layout/style.scss +2 -0
  222. package/src/components/page-pages/index.js +27 -43
  223. package/src/components/page-patterns/index.js +20 -28
  224. package/src/components/page-patterns/search-items.js +13 -58
  225. package/src/components/page-templates-template-parts/actions.js +106 -91
  226. package/src/components/page-templates-template-parts/index.js +34 -78
  227. package/src/components/page-templates-template-parts/style.scss +5 -0
  228. package/src/components/plugin-template-setting-panel/index.js +14 -1
  229. package/src/components/save-button/index.js +55 -26
  230. package/src/components/save-hub/index.js +20 -164
  231. package/src/components/sidebar/index.js +0 -5
  232. package/src/components/sidebar-dataviews/default-views.js +1 -1
  233. package/src/components/sidebar-dataviews/index.js +1 -1
  234. package/src/components/sidebar-edit-mode/index.js +0 -2
  235. package/src/components/sidebar-edit-mode/page-panels/index.js +29 -60
  236. package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
  237. package/src/components/sidebar-edit-mode/template-panel/index.js +23 -33
  238. package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
  239. package/src/components/sidebar-navigation-screen/style.scss +12 -9
  240. package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
  241. package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -13
  242. package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
  243. package/src/components/style-book/index.js +1 -3
  244. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  245. package/src/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  246. package/src/hooks/index.js +0 -1
  247. package/src/store/selectors.js +3 -15
  248. package/src/style.scss +0 -1
  249. package/build/components/actions/index.js +0 -319
  250. package/build/components/actions/index.js.map +0 -1
  251. package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -48
  252. package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  253. package/build/components/sidebar-edit-mode/template-panel/template-areas.js +0 -70
  254. package/build/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  255. package/build/components/sidebar-navigation-screen-pages/index.js +0 -175
  256. package/build/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  257. package/build/hooks/template-part-edit.js +0 -82
  258. package/build/hooks/template-part-edit.js.map +0 -1
  259. package/build/store/utils.js +0 -71
  260. package/build/store/utils.js.map +0 -1
  261. package/build-module/components/actions/index.js +0 -308
  262. package/build-module/components/actions/index.js.map +0 -1
  263. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -40
  264. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  265. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js +0 -63
  266. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  267. package/build-module/components/sidebar-navigation-screen-pages/index.js +0 -167
  268. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  269. package/build-module/hooks/template-part-edit.js +0 -75
  270. package/build-module/hooks/template-part-edit.js.map +0 -1
  271. package/build-module/store/utils.js +0 -64
  272. package/build-module/store/utils.js.map +0 -1
  273. package/src/components/actions/index.js +0 -409
  274. package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -53
  275. package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -36
  276. package/src/components/sidebar-edit-mode/template-panel/template-areas.js +0 -86
  277. package/src/components/sidebar-navigation-screen-pages/index.js +0 -238
  278. package/src/hooks/template-part-edit.js +0 -89
  279. package/src/store/test/utils.js +0 -191
  280. package/src/store/utils.js +0 -69
@@ -3,9 +3,14 @@
3
3
  */
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import { Button } from '@wordpress/components';
6
- import { __, sprintf } from '@wordpress/i18n';
6
+ import { __, _n, sprintf } from '@wordpress/i18n';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
8
  import { displayShortcut } from '@wordpress/keycodes';
9
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
10
+ import {
11
+ useEntitiesSavedStatesIsDirty,
12
+ store as editorStore,
13
+ } from '@wordpress/editor';
9
14
 
10
15
  /**
11
16
  * Internal dependencies
@@ -15,30 +20,30 @@ import {
15
20
  currentlyPreviewingTheme,
16
21
  isPreviewingTheme,
17
22
  } from '../../utils/is-previewing-theme';
23
+ import { unlock } from '../../lock-unlock';
24
+
25
+ const { useLocation } = unlock( routerPrivateApis );
18
26
 
19
27
  export default function SaveButton( {
20
28
  className = 'edit-site-save-button__button',
21
29
  variant = 'primary',
22
30
  showTooltip = true,
23
- defaultLabel,
31
+ showReviewMessage,
24
32
  icon,
25
33
  size,
26
34
  __next40pxDefaultSize = false,
27
35
  } ) {
28
- const { isDirty, isSaving, isSaveViewOpen, previewingThemeName } =
29
- useSelect( ( select ) => {
30
- const {
31
- __experimentalGetDirtyEntityRecords,
32
- isSavingEntityRecord,
33
- isResolving,
34
- } = select( coreStore );
35
- const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
36
+ const { params } = useLocation();
37
+ const { setIsSaveViewOpened } = useDispatch( editSiteStore );
38
+ const { saveDirtyEntities } = unlock( useDispatch( editorStore ) );
39
+ const { dirtyEntityRecords } = useEntitiesSavedStatesIsDirty();
40
+ const { isSaving, isSaveViewOpen, previewingThemeName } = useSelect(
41
+ ( select ) => {
42
+ const { isSavingEntityRecord, isResolving } = select( coreStore );
36
43
  const { isSaveViewOpened } = select( editSiteStore );
37
44
  const isActivatingTheme = isResolving( 'activateTheme' );
38
45
  const currentlyPreviewingThemeId = currentlyPreviewingTheme();
39
-
40
46
  return {
41
- isDirty: dirtyEntityRecords.length > 0,
42
47
  isSaving:
43
48
  dirtyEntityRecords.some( ( record ) =>
44
49
  isSavingEntityRecord(
@@ -55,12 +60,26 @@ export default function SaveButton( {
55
60
  ?.name?.rendered
56
61
  : undefined,
57
62
  };
58
- }, [] );
59
- const { setIsSaveViewOpened } = useDispatch( editSiteStore );
60
-
61
- const activateSaveEnabled = isPreviewingTheme() || isDirty;
62
- const disabled = isSaving || ! activateSaveEnabled;
63
-
63
+ },
64
+ [ dirtyEntityRecords ]
65
+ );
66
+ const hasDirtyEntities = !! dirtyEntityRecords.length;
67
+ let isOnlyCurrentEntityDirty;
68
+ // Check if the current entity is the only entity with changes.
69
+ // We have some extra logic for `wp_global_styles` for now, that
70
+ // is used in navigation sidebar.
71
+ if ( dirtyEntityRecords.length === 1 ) {
72
+ if ( params.postId ) {
73
+ isOnlyCurrentEntityDirty =
74
+ `${ dirtyEntityRecords[ 0 ].key }` === params.postId &&
75
+ dirtyEntityRecords[ 0 ].name === params.postType;
76
+ } else if ( params.path?.includes( 'wp_global_styles' ) ) {
77
+ isOnlyCurrentEntityDirty =
78
+ dirtyEntityRecords[ 0 ].name === 'globalStyles';
79
+ }
80
+ }
81
+ const disabled =
82
+ isSaving || ( ! hasDirtyEntities && ! isPreviewingTheme() );
64
83
  const getLabel = () => {
65
84
  if ( isPreviewingTheme() ) {
66
85
  if ( isSaving ) {
@@ -71,32 +90,42 @@ export default function SaveButton( {
71
90
  );
72
91
  } else if ( disabled ) {
73
92
  return __( 'Saved' );
74
- } else if ( isDirty ) {
93
+ } else if ( hasDirtyEntities ) {
75
94
  return sprintf(
76
95
  /* translators: %s: The name of theme to be activated. */
77
96
  __( 'Activate %s & Save' ),
78
97
  previewingThemeName
79
98
  );
80
99
  }
81
-
82
100
  return sprintf(
83
101
  /* translators: %s: The name of theme to be activated. */
84
102
  __( 'Activate %s' ),
85
103
  previewingThemeName
86
104
  );
87
105
  }
88
-
89
106
  if ( isSaving ) {
90
107
  return __( 'Saving' );
91
- } else if ( disabled ) {
108
+ }
109
+ if ( disabled ) {
92
110
  return __( 'Saved' );
93
- } else if ( defaultLabel ) {
94
- return defaultLabel;
111
+ }
112
+ if ( ! isOnlyCurrentEntityDirty && showReviewMessage ) {
113
+ return sprintf(
114
+ // translators: %d: number of unsaved changes (number).
115
+ _n(
116
+ 'Review %d change…',
117
+ 'Review %d changes…',
118
+ dirtyEntityRecords.length
119
+ ),
120
+ dirtyEntityRecords.length
121
+ );
95
122
  }
96
123
  return __( 'Save' );
97
124
  };
98
125
  const label = getLabel();
99
-
126
+ const onClick = isOnlyCurrentEntityDirty
127
+ ? () => saveDirtyEntities( { dirtyEntityRecords } )
128
+ : () => setIsSaveViewOpened( true );
100
129
  return (
101
130
  <Button
102
131
  variant={ variant }
@@ -104,7 +133,7 @@ export default function SaveButton( {
104
133
  aria-disabled={ disabled }
105
134
  aria-expanded={ isSaveViewOpen }
106
135
  isBusy={ isSaving }
107
- onClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }
136
+ onClick={ disabled ? undefined : onClick }
108
137
  label={ label }
109
138
  /*
110
139
  * We want the tooltip to show the keyboard shortcut only when the
@@ -1,186 +1,42 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useSelect, useDispatch } from '@wordpress/data';
5
- import { Button, __experimentalHStack as HStack } from '@wordpress/components';
6
- import { __, sprintf, _n } from '@wordpress/i18n';
4
+ import { useSelect } from '@wordpress/data';
5
+ import { __experimentalHStack as HStack } from '@wordpress/components';
7
6
  import { store as coreStore } from '@wordpress/core-data';
8
- import { store as blockEditorStore } from '@wordpress/block-editor';
9
7
  import { check } from '@wordpress/icons';
10
- import { privateApis as routerPrivateApis } from '@wordpress/router';
11
- import { store as noticesStore } from '@wordpress/notices';
12
8
 
13
9
  /**
14
10
  * Internal dependencies
15
11
  */
16
12
  import SaveButton from '../save-button';
17
13
  import { isPreviewingTheme } from '../../utils/is-previewing-theme';
18
- import { unlock } from '../../lock-unlock';
19
- import { NAVIGATION_POST_TYPE } from '../../utils/constants';
20
-
21
- const { useLocation } = unlock( routerPrivateApis );
22
-
23
- const PUBLISH_ON_SAVE_ENTITIES = [
24
- {
25
- kind: 'postType',
26
- name: NAVIGATION_POST_TYPE,
27
- },
28
- ];
29
14
 
30
15
  export default function SaveHub() {
31
- const saveNoticeId = 'site-edit-save-notice';
32
- const { params } = useLocation();
33
-
34
- const { __unstableMarkLastChangeAsPersistent } =
35
- useDispatch( blockEditorStore );
36
-
37
- const { createSuccessNotice, createErrorNotice, removeNotice } =
38
- useDispatch( noticesStore );
39
-
40
- const { dirtyCurrentEntity, countUnsavedChanges, isDirty, isSaving } =
41
- useSelect(
42
- ( select ) => {
43
- const {
44
- __experimentalGetDirtyEntityRecords,
45
- isSavingEntityRecord,
46
- } = select( coreStore );
47
- const dirtyEntityRecords =
48
- __experimentalGetDirtyEntityRecords();
49
- let calcDirtyCurrentEntity = null;
50
-
51
- if ( dirtyEntityRecords.length === 1 ) {
52
- // if we are on global styles
53
- if ( params.path?.includes( 'wp_global_styles' ) ) {
54
- calcDirtyCurrentEntity = dirtyEntityRecords.find(
55
- ( record ) => record.name === 'globalStyles'
56
- );
57
- }
58
- // if we are on pages
59
- else if ( params.postId ) {
60
- calcDirtyCurrentEntity = dirtyEntityRecords.find(
61
- ( record ) =>
62
- record.name === params.postType &&
63
- String( record.key ) === params.postId
64
- );
65
- }
66
- }
67
-
68
- return {
69
- dirtyCurrentEntity: calcDirtyCurrentEntity,
70
- isDirty: dirtyEntityRecords.length > 0,
71
- isSaving: dirtyEntityRecords.some( ( record ) =>
72
- isSavingEntityRecord(
73
- record.kind,
74
- record.name,
75
- record.key
76
- )
77
- ),
78
- countUnsavedChanges: dirtyEntityRecords.length,
79
- };
80
- },
81
- [ params.path, params.postType, params.postId ]
16
+ const { isDisabled, isSaving } = useSelect( ( select ) => {
17
+ const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
18
+ select( coreStore );
19
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
20
+ const _isSaving = dirtyEntityRecords.some( ( record ) =>
21
+ isSavingEntityRecord( record.kind, record.name, record.key )
82
22
  );
83
-
84
- const {
85
- editEntityRecord,
86
- saveEditedEntityRecord,
87
- __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,
88
- } = useDispatch( coreStore );
89
-
90
- const disabled = isSaving || ( ! isDirty && ! isPreviewingTheme() );
91
-
92
- // if we have only one unsaved change and it matches current context, we can show a more specific label
93
- let label = dirtyCurrentEntity
94
- ? __( 'Save' )
95
- : sprintf(
96
- // translators: %d: number of unsaved changes (number).
97
- _n(
98
- 'Review %d change…',
99
- 'Review %d changes…',
100
- countUnsavedChanges
101
- ),
102
- countUnsavedChanges
103
- );
104
-
105
- if ( isSaving ) {
106
- label = __( 'Saving' );
107
- }
108
-
109
- const { homeUrl } = useSelect( ( select ) => {
110
- const {
111
- getUnstableBase, // Site index.
112
- } = select( coreStore );
113
23
  return {
114
- homeUrl: getUnstableBase()?.home,
24
+ isSaving: _isSaving,
25
+ isDisabled:
26
+ _isSaving ||
27
+ ( ! dirtyEntityRecords.length && ! isPreviewingTheme() ),
115
28
  };
116
29
  }, [] );
117
-
118
- const saveCurrentEntity = async () => {
119
- if ( ! dirtyCurrentEntity ) return;
120
-
121
- removeNotice( saveNoticeId );
122
- const { kind, name, key, property } = dirtyCurrentEntity;
123
-
124
- try {
125
- if ( 'root' === dirtyCurrentEntity.kind && 'site' === name ) {
126
- await saveSpecifiedEntityEdits( 'root', 'site', undefined, [
127
- property,
128
- ] );
129
- } else {
130
- if (
131
- PUBLISH_ON_SAVE_ENTITIES.some(
132
- ( typeToPublish ) =>
133
- typeToPublish.kind === kind &&
134
- typeToPublish.name === name
135
- )
136
- ) {
137
- editEntityRecord( kind, name, key, { status: 'publish' } );
138
- }
139
-
140
- await saveEditedEntityRecord( kind, name, key );
141
- }
142
-
143
- __unstableMarkLastChangeAsPersistent();
144
-
145
- createSuccessNotice( __( 'Site updated.' ), {
146
- type: 'snackbar',
147
- actions: [
148
- {
149
- label: __( 'View site' ),
150
- url: homeUrl,
151
- },
152
- ],
153
- id: saveNoticeId,
154
- } );
155
- } catch ( error ) {
156
- createErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` );
157
- }
158
- };
159
-
160
30
  return (
161
31
  <HStack className="edit-site-save-hub" alignment="right" spacing={ 4 }>
162
- { dirtyCurrentEntity ? (
163
- <Button
164
- variant="primary"
165
- onClick={ saveCurrentEntity }
166
- isBusy={ isSaving }
167
- disabled={ isSaving }
168
- aria-disabled={ isSaving }
169
- className="edit-site-save-hub__button"
170
- __next40pxDefaultSize
171
- >
172
- { label }
173
- </Button>
174
- ) : (
175
- <SaveButton
176
- className="edit-site-save-hub__button"
177
- variant={ disabled ? null : 'primary' }
178
- showTooltip={ false }
179
- icon={ disabled && ! isSaving ? check : null }
180
- defaultLabel={ label }
181
- __next40pxDefaultSize
182
- />
183
- ) }
32
+ <SaveButton
33
+ className="edit-site-save-hub__button"
34
+ variant={ isDisabled ? null : 'primary' }
35
+ showTooltip={ false }
36
+ icon={ isDisabled && ! isSaving ? check : null }
37
+ showReviewMessage
38
+ __next40pxDefaultSize
39
+ />
184
40
  </HStack>
185
41
  );
186
42
  }
@@ -31,7 +31,6 @@ import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-gl
31
31
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
32
32
  import SaveHub from '../save-hub';
33
33
  import { unlock } from '../../lock-unlock';
34
- import SidebarNavigationScreenPages from '../sidebar-navigation-screen-pages';
35
34
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
36
35
  import DataViewsSidebarContent from '../sidebar-dataviews';
37
36
  import SidebarNavigationScreenPage from '../sidebar-navigation-screen-page';
@@ -69,13 +68,9 @@ function SidebarScreens() {
69
68
  <SidebarNavigationScreenGlobalStyles />
70
69
  </SidebarScreenWrapper>
71
70
  <SidebarScreenWrapper path="/page">
72
- <SidebarNavigationScreenPages />
73
- </SidebarScreenWrapper>
74
- <SidebarScreenWrapper path="/pages">
75
71
  <SidebarNavigationScreen
76
72
  title={ __( 'Manage pages' ) }
77
73
  content={ <DataViewsSidebarContent /> }
78
- backPath="/page"
79
74
  />
80
75
  </SidebarScreenWrapper>
81
76
  <SidebarScreenWrapper path="/page/:postId">
@@ -29,7 +29,7 @@ export const DEFAULT_CONFIG_PER_VIEW_TYPE = {
29
29
  };
30
30
 
31
31
  const DEFAULT_PAGE_BASE = {
32
- type: LAYOUT_TABLE,
32
+ type: LAYOUT_LIST,
33
33
  search: '',
34
34
  filters: [],
35
35
  page: 1,
@@ -15,7 +15,7 @@ import DataViewItem from './dataview-item';
15
15
  import CustomDataViewsList from './custom-dataviews-list';
16
16
 
17
17
  const PATH_TO_TYPE = {
18
- '/pages': 'page',
18
+ '/page': 'page',
19
19
  };
20
20
 
21
21
  export default function DataViewsSidebarContent() {
@@ -22,7 +22,6 @@ import { STORE_NAME } from '../../store/constants';
22
22
  import SettingsHeader from './settings-header';
23
23
  import PagePanels from './page-panels';
24
24
  import TemplatePanel from './template-panel';
25
- import PluginTemplateSettingPanel from '../plugin-template-setting-panel';
26
25
  import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';
27
26
  import { store as editSiteStore } from '../../store';
28
27
  import { unlock } from '../../lock-unlock';
@@ -96,7 +95,6 @@ const FillContents = ( {
96
95
  focusable={ false }
97
96
  >
98
97
  { isEditingPage ? <PagePanels /> : <TemplatePanel /> }
99
- <PluginTemplateSettingPanel.Slot />
100
98
  </Tabs.TabPanel>
101
99
  <Tabs.TabPanel tabId={ SIDEBAR_BLOCK } focusable={ false }>
102
100
  <InspectorSlot bubblesVirtually />
@@ -1,17 +1,10 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import {
5
- PanelBody,
6
- __experimentalText as Text,
7
- __experimentalVStack as VStack,
8
- } from '@wordpress/components';
9
- import { page as pageIcon } from '@wordpress/icons';
10
- import { __, sprintf } from '@wordpress/i18n';
11
- import { humanTimeDiff } from '@wordpress/date';
4
+ import { PanelBody } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
12
6
  import { useSelect } from '@wordpress/data';
13
7
  import { store as coreStore } from '@wordpress/core-data';
14
- import { decodeEntities } from '@wordpress/html-entities';
15
8
  import {
16
9
  PageAttributesPanel,
17
10
  PluginDocumentSettingPanel,
@@ -20,50 +13,42 @@ import {
20
13
  PostLastRevisionPanel,
21
14
  PostTaxonomiesPanel,
22
15
  store as editorStore,
16
+ privateApis as editorPrivateApis,
23
17
  } from '@wordpress/editor';
24
18
 
25
19
  /**
26
20
  * Internal dependencies
27
21
  */
28
22
  import { store as editSiteStore } from '../../../store';
29
- import SidebarCard from '../sidebar-card';
30
23
  import PageContent from './page-content';
31
24
  import PageSummary from './page-summary';
25
+ import { unlock } from '../../../lock-unlock';
26
+
27
+ const { PostCardPanel } = unlock( editorPrivateApis );
32
28
 
33
29
  export default function PagePanels() {
34
- const {
35
- id,
36
- type,
37
- hasResolved,
38
- status,
39
- date,
40
- password,
41
- title,
42
- modified,
43
- renderingMode,
44
- } = useSelect( ( select ) => {
45
- const { getEditedPostContext } = select( editSiteStore );
46
- const { getEditedEntityRecord, hasFinishedResolution } =
47
- select( coreStore );
48
- const { getRenderingMode } = select( editorStore );
49
- const context = getEditedPostContext();
50
- const queryArgs = [ 'postType', context.postType, context.postId ];
51
- const page = getEditedEntityRecord( ...queryArgs );
52
- return {
53
- hasResolved: hasFinishedResolution(
54
- 'getEditedEntityRecord',
55
- queryArgs
56
- ),
57
- title: page?.title,
58
- id: page?.id,
59
- type: page?.type,
60
- status: page?.status,
61
- date: page?.date,
62
- password: page?.password,
63
- modified: page?.modified,
64
- renderingMode: getRenderingMode(),
65
- };
66
- }, [] );
30
+ const { id, type, hasResolved, status, date, password, renderingMode } =
31
+ useSelect( ( select ) => {
32
+ const { getEditedPostContext } = select( editSiteStore );
33
+ const { getEditedEntityRecord, hasFinishedResolution } =
34
+ select( coreStore );
35
+ const { getRenderingMode } = select( editorStore );
36
+ const context = getEditedPostContext();
37
+ const queryArgs = [ 'postType', context.postType, context.postId ];
38
+ const page = getEditedEntityRecord( ...queryArgs );
39
+ return {
40
+ hasResolved: hasFinishedResolution(
41
+ 'getEditedEntityRecord',
42
+ queryArgs
43
+ ),
44
+ id: page?.id,
45
+ type: page?.type,
46
+ status: page?.status,
47
+ date: page?.date,
48
+ password: page?.password,
49
+ renderingMode: getRenderingMode(),
50
+ };
51
+ }, [] );
67
52
 
68
53
  if ( ! hasResolved ) {
69
54
  return null;
@@ -71,23 +56,7 @@ export default function PagePanels() {
71
56
 
72
57
  return (
73
58
  <>
74
- <PanelBody>
75
- <SidebarCard
76
- title={ decodeEntities( title ) }
77
- icon={ pageIcon }
78
- description={
79
- <VStack>
80
- <Text>
81
- { sprintf(
82
- // translators: %s: Human-readable time difference, e.g. "2 days ago".
83
- __( 'Last edited %s' ),
84
- humanTimeDiff( modified )
85
- ) }
86
- </Text>
87
- </VStack>
88
- }
89
- />
90
- </PanelBody>
59
+ <PostCardPanel />
91
60
  <PanelBody title={ __( 'Summary' ) }>
92
61
  <PageSummary
93
62
  status={ status }
@@ -6,7 +6,6 @@ import {
6
6
  store as blockEditorStore,
7
7
  privateApis as blockEditorPrivateApis,
8
8
  } from '@wordpress/block-editor';
9
- import { useMemo } from '@wordpress/element';
10
9
 
11
10
  /**
12
11
  * Internal dependencies
@@ -15,15 +14,16 @@ import { unlock } from '../../../lock-unlock';
15
14
 
16
15
  const { BlockQuickNavigation } = unlock( blockEditorPrivateApis );
17
16
 
17
+ const PAGE_CONTENT_BLOCKS = [
18
+ 'core/post-content',
19
+ 'core/post-featured-image',
20
+ 'core/post-title',
21
+ ];
22
+
18
23
  export default function PageContent() {
19
- const clientIdsTree = useSelect(
20
- ( select ) =>
21
- unlock( select( blockEditorStore ) ).getEnabledClientIdsTree(),
22
- []
23
- );
24
- const clientIds = useMemo(
25
- () => clientIdsTree.map( ( { clientId } ) => clientId ),
26
- [ clientIdsTree ]
27
- );
24
+ const clientIds = useSelect( ( select ) => {
25
+ const { getBlocksByName } = select( blockEditorStore );
26
+ return getBlocksByName( PAGE_CONTENT_BLOCKS );
27
+ }, [] );
28
28
  return <BlockQuickNavigation clientIds={ clientIds } />;
29
29
  }
@@ -9,11 +9,10 @@ import {
9
9
  PostExcerptPanel,
10
10
  PostLastRevisionPanel,
11
11
  PostTaxonomiesPanel,
12
+ privateApis as editorPrivateApis,
12
13
  store as editorStore,
13
14
  } from '@wordpress/editor';
14
15
  import { store as coreStore } from '@wordpress/core-data';
15
- import { decodeEntities } from '@wordpress/html-entities';
16
- import { navigation, symbol } from '@wordpress/icons';
17
16
  import { __ } from '@wordpress/i18n';
18
17
  import { useAsyncList } from '@wordpress/compose';
19
18
  import { serialize } from '@wordpress/blocks';
@@ -25,19 +24,15 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
25
24
  */
26
25
  import { store as editSiteStore } from '../../../store';
27
26
  import TemplateActions from '../../template-actions';
28
- import TemplateAreas from './template-areas';
29
- import SidebarCard from '../sidebar-card';
27
+ import PluginTemplateSettingPanel from '../../plugin-template-setting-panel';
30
28
  import { useAvailablePatterns } from './hooks';
31
29
  import { TEMPLATE_PART_POST_TYPE } from '../../../utils/constants';
32
30
  import { unlock } from '../../../lock-unlock';
33
31
 
32
+ const { PostCardPanel } = unlock( editorPrivateApis );
33
+ const { PatternOverridesPanel } = unlock( editorPrivateApis );
34
34
  const { useHistory } = unlock( routerPrivateApis );
35
35
 
36
- const CARD_ICONS = {
37
- wp_block: symbol,
38
- wp_navigation: navigation,
39
- };
40
-
41
36
  function TemplatesList( { availableTemplates, onSelect } ) {
42
37
  const shownTemplates = useAsyncList( availableTemplates );
43
38
  if ( ! availableTemplates || availableTemplates?.length === 0 ) {
@@ -61,7 +56,7 @@ const POST_TYPE_PATH = {
61
56
  };
62
57
 
63
58
  export default function TemplatePanel() {
64
- const { title, description, icon, record, postType, postId } = useSelect(
59
+ const { title, description, record, postType, postId } = useSelect(
65
60
  ( select ) => {
66
61
  const { getEditedPostType, getEditedPostId } =
67
62
  select( editSiteStore );
@@ -102,29 +97,23 @@ export default function TemplatePanel() {
102
97
 
103
98
  return (
104
99
  <>
105
- <PanelBody>
106
- <SidebarCard
107
- className="edit-site-template-card"
108
- title={ decodeEntities( title ) }
109
- icon={ CARD_ICONS[ record?.type ] ?? icon }
110
- description={ decodeEntities( description ) }
111
- actions={
112
- <TemplateActions
113
- postType={ postType }
114
- postId={ postId }
115
- className="edit-site-template-card__actions"
116
- toggleProps={ { size: 'small' } }
117
- onRemove={ () => {
118
- history.push( {
119
- path: POST_TYPE_PATH[ postType ],
120
- } );
121
- } }
122
- />
123
- }
124
- >
125
- <TemplateAreas />
126
- </SidebarCard>
127
- </PanelBody>
100
+ <PostCardPanel
101
+ className="edit-site-template-card"
102
+ actions={
103
+ <TemplateActions
104
+ postType={ postType }
105
+ postId={ postId }
106
+ className="edit-site-template-card__actions"
107
+ toggleProps={ { size: 'small' } }
108
+ onRemove={ () => {
109
+ history.push( {
110
+ path: POST_TYPE_PATH[ postType ],
111
+ } );
112
+ } }
113
+ />
114
+ }
115
+ />
116
+ <PluginTemplateSettingPanel.Slot />
128
117
  { availablePatterns?.length > 0 && (
129
118
  <PanelBody
130
119
  title={ __( 'Transform into:' ) }
@@ -149,6 +138,7 @@ export default function TemplatePanel() {
149
138
  <PostExcerptPanel />
150
139
  <PostDiscussionPanel />
151
140
  <PageAttributesPanel />
141
+ <PatternOverridesPanel />
152
142
  </>
153
143
  );
154
144
  }