@wordpress/edit-site 6.2.0 → 6.3.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 (245) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/{add-new-page → add-new-post}/index.js +21 -17
  3. package/build/components/add-new-post/index.js.map +1 -0
  4. package/build/components/block-editor/use-site-editor-settings.js +5 -3
  5. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  6. package/build/components/editor/index.js +21 -3
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/global-styles/background-panel.js +0 -5
  9. package/build/components/global-styles/background-panel.js.map +1 -1
  10. package/build/components/global-styles/font-library-modal/font-collection.js +13 -30
  11. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  12. package/build/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  13. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  14. package/build/components/global-styles/hooks.js +0 -40
  15. package/build/components/global-styles/hooks.js.map +1 -1
  16. package/build/components/global-styles/preview-typography.js +47 -0
  17. package/build/components/global-styles/preview-typography.js.map +1 -0
  18. package/build/components/global-styles/screen-block.js +14 -0
  19. package/build/components/global-styles/screen-block.js.map +1 -1
  20. package/build/components/global-styles/screen-layout.js +5 -1
  21. package/build/components/global-styles/screen-layout.js.map +1 -1
  22. package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  23. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  24. package/build/components/global-styles/shadows-edit-panel.js +1 -2
  25. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  26. package/build/components/global-styles/style-variations-container.js +5 -5
  27. package/build/components/global-styles/style-variations-container.js.map +1 -1
  28. package/build/components/global-styles/typography-elements.js +0 -2
  29. package/build/components/global-styles/typography-elements.js.map +1 -1
  30. package/build/components/global-styles/variations/variation.js +4 -4
  31. package/build/components/global-styles/variations/variation.js.map +1 -1
  32. package/build/components/global-styles/variations/variations-color.js +4 -3
  33. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  34. package/build/components/global-styles/variations/variations-typography.js +14 -28
  35. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  36. package/build/components/global-styles-sidebar/index.js +2 -2
  37. package/build/components/global-styles-sidebar/index.js.map +1 -1
  38. package/build/components/layout/index.js +16 -8
  39. package/build/components/layout/index.js.map +1 -1
  40. package/build/components/layout/router.js +20 -41
  41. package/build/components/layout/router.js.map +1 -1
  42. package/build/components/page-patterns/index.js +43 -39
  43. package/build/components/page-patterns/index.js.map +1 -1
  44. package/build/components/page-patterns/search-items.js +29 -4
  45. package/build/components/page-patterns/search-items.js.map +1 -1
  46. package/build/components/page-patterns/use-patterns.js +22 -55
  47. package/build/components/page-patterns/use-patterns.js.map +1 -1
  48. package/build/components/page-templates/index.js +18 -19
  49. package/build/components/page-templates/index.js.map +1 -1
  50. package/build/components/pagination/index.js +4 -4
  51. package/build/components/pagination/index.js.map +1 -1
  52. package/build/components/posts-app/index.js +11 -17
  53. package/build/components/posts-app/index.js.map +1 -1
  54. package/build/components/{page-pages/index.js → posts-app/posts-list.js} +135 -40
  55. package/build/components/posts-app/posts-list.js.map +1 -0
  56. package/build/components/posts-app/router.js +85 -0
  57. package/build/components/posts-app/router.js.map +1 -0
  58. package/build/components/revisions/index.js +10 -7
  59. package/build/components/revisions/index.js.map +1 -1
  60. package/build/components/save-panel/index.js +1 -1
  61. package/build/components/save-panel/index.js.map +1 -1
  62. package/build/components/sidebar-dataviews/add-new-view.js +4 -1
  63. package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
  64. package/build/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
  65. package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  66. package/build/components/sidebar-dataviews/default-views.js +98 -84
  67. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  68. package/build/components/sidebar-dataviews/index.js +4 -1
  69. package/build/components/sidebar-dataviews/index.js.map +1 -1
  70. package/build/components/sidebar-navigation-screen-global-styles/index.js +3 -3
  71. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -2
  73. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  74. package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
  75. package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
  76. package/build/components/site-hub/index.js +81 -1
  77. package/build/components/site-hub/index.js.map +1 -1
  78. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -1
  79. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  80. package/build/hooks/push-changes-to-global-styles/index.js +1 -1
  81. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  82. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +65 -42
  83. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  84. package/build/index.js +6 -0
  85. package/build/index.js.map +1 -1
  86. package/build/posts.js +57 -2
  87. package/build/posts.js.map +1 -1
  88. package/build/store/private-actions.js +7 -2
  89. package/build/store/private-actions.js.map +1 -1
  90. package/build-module/components/{add-new-page → add-new-post}/index.js +21 -17
  91. package/build-module/components/add-new-post/index.js.map +1 -0
  92. package/build-module/components/block-editor/use-site-editor-settings.js +5 -3
  93. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  94. package/build-module/components/editor/index.js +21 -3
  95. package/build-module/components/editor/index.js.map +1 -1
  96. package/build-module/components/global-styles/background-panel.js +0 -5
  97. package/build-module/components/global-styles/background-panel.js.map +1 -1
  98. package/build-module/components/global-styles/font-library-modal/font-collection.js +14 -31
  99. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  100. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  101. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  102. package/build-module/components/global-styles/hooks.js +0 -38
  103. package/build-module/components/global-styles/hooks.js.map +1 -1
  104. package/build-module/components/global-styles/preview-typography.js +39 -0
  105. package/build-module/components/global-styles/preview-typography.js.map +1 -0
  106. package/build-module/components/global-styles/screen-block.js +15 -0
  107. package/build-module/components/global-styles/screen-block.js.map +1 -1
  108. package/build-module/components/global-styles/screen-layout.js +5 -1
  109. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  110. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  111. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  112. package/build-module/components/global-styles/shadows-edit-panel.js +1 -2
  113. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  114. package/build-module/components/global-styles/style-variations-container.js +6 -6
  115. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  116. package/build-module/components/global-styles/typography-elements.js +0 -2
  117. package/build-module/components/global-styles/typography-elements.js.map +1 -1
  118. package/build-module/components/global-styles/variations/variation.js +5 -5
  119. package/build-module/components/global-styles/variations/variation.js.map +1 -1
  120. package/build-module/components/global-styles/variations/variations-color.js +4 -3
  121. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  122. package/build-module/components/global-styles/variations/variations-typography.js +16 -29
  123. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  124. package/build-module/components/global-styles-sidebar/index.js +2 -2
  125. package/build-module/components/global-styles-sidebar/index.js.map +1 -1
  126. package/build-module/components/layout/index.js +14 -8
  127. package/build-module/components/layout/index.js.map +1 -1
  128. package/build-module/components/layout/router.js +20 -41
  129. package/build-module/components/layout/router.js.map +1 -1
  130. package/build-module/components/page-patterns/index.js +44 -40
  131. package/build-module/components/page-patterns/index.js.map +1 -1
  132. package/build-module/components/page-patterns/search-items.js +28 -4
  133. package/build-module/components/page-patterns/search-items.js.map +1 -1
  134. package/build-module/components/page-patterns/use-patterns.js +23 -56
  135. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  136. package/build-module/components/page-templates/index.js +18 -19
  137. package/build-module/components/page-templates/index.js.map +1 -1
  138. package/build-module/components/pagination/index.js +4 -4
  139. package/build-module/components/pagination/index.js.map +1 -1
  140. package/build-module/components/posts-app/index.js +11 -17
  141. package/build-module/components/posts-app/index.js.map +1 -1
  142. package/build-module/components/{page-pages/index.js → posts-app/posts-list.js} +134 -39
  143. package/build-module/components/posts-app/posts-list.js.map +1 -0
  144. package/build-module/components/posts-app/router.js +77 -0
  145. package/build-module/components/posts-app/router.js.map +1 -0
  146. package/build-module/components/revisions/index.js +10 -7
  147. package/build-module/components/revisions/index.js.map +1 -1
  148. package/build-module/components/save-panel/index.js +1 -1
  149. package/build-module/components/save-panel/index.js.map +1 -1
  150. package/build-module/components/sidebar-dataviews/add-new-view.js +4 -1
  151. package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
  152. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
  153. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  154. package/build-module/components/sidebar-dataviews/default-views.js +96 -83
  155. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  156. package/build-module/components/sidebar-dataviews/index.js +5 -2
  157. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  158. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +3 -3
  159. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  160. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -2
  161. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  162. package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
  163. package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
  164. package/build-module/components/site-hub/index.js +81 -1
  165. package/build-module/components/site-hub/index.js.map +1 -1
  166. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -1
  167. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  168. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -1
  169. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  170. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +61 -38
  171. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  172. package/build-module/index.js +7 -2
  173. package/build-module/index.js.map +1 -1
  174. package/build-module/posts.js +57 -2
  175. package/build-module/posts.js.map +1 -1
  176. package/build-module/store/private-actions.js +7 -2
  177. package/build-module/store/private-actions.js.map +1 -1
  178. package/build-style/posts-rtl.css +108 -28
  179. package/build-style/posts.css +108 -28
  180. package/build-style/style-rtl.css +112 -144
  181. package/build-style/style.css +112 -144
  182. package/package.json +41 -41
  183. package/src/components/{add-new-page → add-new-post}/index.js +28 -22
  184. package/src/components/block-editor/use-site-editor-settings.js +33 -28
  185. package/src/components/editor/index.js +21 -5
  186. package/src/components/global-styles/background-panel.js +0 -8
  187. package/src/components/global-styles/font-library-modal/font-collection.js +17 -32
  188. package/src/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  189. package/src/components/global-styles/font-library-modal/style.scss +17 -10
  190. package/src/components/global-styles/hooks.js +0 -41
  191. package/src/components/global-styles/preview-typography.js +39 -0
  192. package/src/components/global-styles/screen-block.js +22 -0
  193. package/src/components/global-styles/screen-layout.js +5 -1
  194. package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  195. package/src/components/global-styles/shadows-edit-panel.js +1 -2
  196. package/src/components/global-styles/style-variations-container.js +10 -7
  197. package/src/components/global-styles/typography-elements.js +0 -4
  198. package/src/components/global-styles/variations/variation.js +5 -5
  199. package/src/components/global-styles/variations/variations-color.js +5 -3
  200. package/src/components/global-styles/variations/variations-typography.js +15 -32
  201. package/src/components/global-styles-sidebar/index.js +2 -2
  202. package/src/components/layout/index.js +13 -4
  203. package/src/components/layout/router.js +20 -36
  204. package/src/components/layout/style.scss +12 -0
  205. package/src/components/page-patterns/index.js +47 -56
  206. package/src/components/page-patterns/search-items.js +37 -3
  207. package/src/components/page-patterns/style.scss +1 -8
  208. package/src/components/page-patterns/use-patterns.js +43 -82
  209. package/src/components/page-templates/index.js +17 -19
  210. package/src/components/page-templates/style.scss +1 -6
  211. package/src/components/pagination/index.js +4 -4
  212. package/src/components/posts-app/index.js +9 -11
  213. package/src/components/{page-pages/index.js → posts-app/posts-list.js} +126 -39
  214. package/src/components/posts-app/router.js +69 -0
  215. package/src/components/{page-pages → posts-app}/style.scss +22 -8
  216. package/src/components/revisions/index.js +9 -1
  217. package/src/components/save-panel/index.js +1 -1
  218. package/src/components/sidebar/style.scss +6 -0
  219. package/src/components/sidebar-dataviews/add-new-view.js +2 -1
  220. package/src/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
  221. package/src/components/sidebar-dataviews/default-views.js +110 -97
  222. package/src/components/sidebar-dataviews/index.js +3 -3
  223. package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -6
  224. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -1
  225. package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -2
  226. package/src/components/site-hub/index.js +84 -1
  227. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -2
  228. package/src/hooks/push-changes-to-global-styles/index.js +1 -1
  229. package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +28 -24
  230. package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +72 -47
  231. package/src/index.js +8 -1
  232. package/src/posts.js +63 -2
  233. package/src/posts.scss +9 -0
  234. package/src/store/private-actions.js +7 -3
  235. package/src/style.scss +1 -2
  236. package/build/components/add-new-page/index.js.map +0 -1
  237. package/build/components/page-pages/index.js.map +0 -1
  238. package/build/components/table/index.js +0 -35
  239. package/build/components/table/index.js.map +0 -1
  240. package/build-module/components/add-new-page/index.js.map +0 -1
  241. package/build-module/components/page-pages/index.js.map +0 -1
  242. package/build-module/components/table/index.js +0 -30
  243. package/build-module/components/table/index.js.map +0 -1
  244. package/src/components/table/index.js +0 -33
  245. package/src/components/table/style.scss +0 -38
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+
5
6
  import {
6
7
  trash,
7
8
  pages,
@@ -11,6 +12,9 @@ import {
11
12
  pending,
12
13
  notAllowed,
13
14
  } from '@wordpress/icons';
15
+ import { useSelect } from '@wordpress/data';
16
+ import { store as coreStore } from '@wordpress/core-data';
17
+ import { useMemo } from '@wordpress/element';
14
18
 
15
19
  /**
16
20
  * Internal dependencies
@@ -36,7 +40,7 @@ export const DEFAULT_CONFIG_PER_VIEW_TYPE = {
36
40
  },
37
41
  };
38
42
 
39
- const DEFAULT_PAGE_BASE = {
43
+ const DEFAULT_POST_BASE = {
40
44
  type: LAYOUT_LIST,
41
45
  search: '',
42
46
  filters: [],
@@ -46,111 +50,120 @@ const DEFAULT_PAGE_BASE = {
46
50
  field: 'date',
47
51
  direction: 'desc',
48
52
  },
49
- // All fields are visible by default, so it's
50
- // better to keep track of the hidden ones.
51
- hiddenFields: [ 'date', 'featured-image' ],
53
+ fields: [ 'title', 'author', 'status' ],
52
54
  layout: {
53
55
  ...DEFAULT_CONFIG_PER_VIEW_TYPE[ LAYOUT_LIST ],
54
56
  },
55
57
  };
56
58
 
57
- export const DEFAULT_VIEWS = {
58
- page: [
59
- {
60
- title: __( 'All pages' ),
61
- slug: 'all',
62
- icon: pages,
63
- view: DEFAULT_PAGE_BASE,
59
+ export function useDefaultViews( { postType } ) {
60
+ const labels = useSelect(
61
+ ( select ) => {
62
+ const { getPostType } = select( coreStore );
63
+ return getPostType( postType )?.labels;
64
64
  },
65
- {
66
- title: __( 'Published' ),
67
- slug: 'published',
68
- icon: published,
69
- view: {
70
- ...DEFAULT_PAGE_BASE,
71
- filters: [
72
- {
73
- field: 'status',
74
- operator: OPERATOR_IS_ANY,
75
- value: 'publish',
65
+ [ postType ]
66
+ );
67
+ return useMemo( () => {
68
+ return {
69
+ [ postType ]: [
70
+ {
71
+ title: labels?.all_items || __( 'All items' ),
72
+ slug: 'all',
73
+ icon: pages,
74
+ view: DEFAULT_POST_BASE,
75
+ },
76
+ {
77
+ title: __( 'Published' ),
78
+ slug: 'published',
79
+ icon: published,
80
+ view: {
81
+ ...DEFAULT_POST_BASE,
82
+ filters: [
83
+ {
84
+ field: 'status',
85
+ operator: OPERATOR_IS_ANY,
86
+ value: 'publish',
87
+ },
88
+ ],
76
89
  },
77
- ],
78
- },
79
- },
80
- {
81
- title: __( 'Scheduled' ),
82
- slug: 'future',
83
- icon: scheduled,
84
- view: {
85
- ...DEFAULT_PAGE_BASE,
86
- filters: [
87
- {
88
- field: 'status',
89
- operator: OPERATOR_IS_ANY,
90
- value: 'future',
90
+ },
91
+ {
92
+ title: __( 'Scheduled' ),
93
+ slug: 'future',
94
+ icon: scheduled,
95
+ view: {
96
+ ...DEFAULT_POST_BASE,
97
+ filters: [
98
+ {
99
+ field: 'status',
100
+ operator: OPERATOR_IS_ANY,
101
+ value: 'future',
102
+ },
103
+ ],
91
104
  },
92
- ],
93
- },
94
- },
95
- {
96
- title: __( 'Drafts' ),
97
- slug: 'drafts',
98
- icon: drafts,
99
- view: {
100
- ...DEFAULT_PAGE_BASE,
101
- filters: [
102
- {
103
- field: 'status',
104
- operator: OPERATOR_IS_ANY,
105
- value: 'draft',
105
+ },
106
+ {
107
+ title: __( 'Drafts' ),
108
+ slug: 'drafts',
109
+ icon: drafts,
110
+ view: {
111
+ ...DEFAULT_POST_BASE,
112
+ filters: [
113
+ {
114
+ field: 'status',
115
+ operator: OPERATOR_IS_ANY,
116
+ value: 'draft',
117
+ },
118
+ ],
106
119
  },
107
- ],
108
- },
109
- },
110
- {
111
- title: __( 'Pending' ),
112
- slug: 'pending',
113
- icon: pending,
114
- view: {
115
- ...DEFAULT_PAGE_BASE,
116
- filters: [
117
- {
118
- field: 'status',
119
- operator: OPERATOR_IS_ANY,
120
- value: 'pending',
120
+ },
121
+ {
122
+ title: __( 'Pending' ),
123
+ slug: 'pending',
124
+ icon: pending,
125
+ view: {
126
+ ...DEFAULT_POST_BASE,
127
+ filters: [
128
+ {
129
+ field: 'status',
130
+ operator: OPERATOR_IS_ANY,
131
+ value: 'pending',
132
+ },
133
+ ],
121
134
  },
122
- ],
123
- },
124
- },
125
- {
126
- title: __( 'Private' ),
127
- slug: 'private',
128
- icon: notAllowed,
129
- view: {
130
- ...DEFAULT_PAGE_BASE,
131
- filters: [
132
- {
133
- field: 'status',
134
- operator: OPERATOR_IS_ANY,
135
- value: 'private',
135
+ },
136
+ {
137
+ title: __( 'Private' ),
138
+ slug: 'private',
139
+ icon: notAllowed,
140
+ view: {
141
+ ...DEFAULT_POST_BASE,
142
+ filters: [
143
+ {
144
+ field: 'status',
145
+ operator: OPERATOR_IS_ANY,
146
+ value: 'private',
147
+ },
148
+ ],
136
149
  },
137
- ],
138
- },
139
- },
140
- {
141
- title: __( 'Trash' ),
142
- slug: 'trash',
143
- icon: trash,
144
- view: {
145
- ...DEFAULT_PAGE_BASE,
146
- filters: [
147
- {
148
- field: 'status',
149
- operator: OPERATOR_IS_ANY,
150
- value: 'trash',
150
+ },
151
+ {
152
+ title: __( 'Trash' ),
153
+ slug: 'trash',
154
+ icon: trash,
155
+ view: {
156
+ ...DEFAULT_POST_BASE,
157
+ filters: [
158
+ {
159
+ field: 'status',
160
+ operator: OPERATOR_IS_ANY,
161
+ value: 'trash',
162
+ },
163
+ ],
151
164
  },
152
- ],
153
- },
154
- },
155
- ],
156
- };
165
+ },
166
+ ],
167
+ };
168
+ }, [ labels, postType ] );
169
+ }
@@ -2,13 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
5
-
6
5
  import { privateApis as routerPrivateApis } from '@wordpress/router';
6
+
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
-
11
- import { DEFAULT_VIEWS } from './default-views';
10
+ import { useDefaultViews } from './default-views';
12
11
  import { unlock } from '../../lock-unlock';
13
12
  const { useLocation } = unlock( routerPrivateApis );
14
13
  import DataViewItem from './dataview-item';
@@ -18,6 +17,7 @@ export default function DataViewsSidebarContent() {
18
17
  const {
19
18
  params: { postType, activeView = 'all', isCustom = 'false' },
20
19
  } = useLocation();
20
+ const DEFAULT_VIEWS = useDefaultViews( { postType } );
21
21
  if ( ! postType ) {
22
22
  return null;
23
23
  }
@@ -26,10 +26,7 @@ import useGlobalStylesRevisions from '../global-styles/screen-revisions/use-glob
26
26
  import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';
27
27
  import ColorVariations from '../global-styles/variations/variations-color';
28
28
  import TypographyVariations from '../global-styles/variations/variations-typography';
29
- import {
30
- useColorVariations,
31
- useTypographyVariations,
32
- } from '../global-styles/hooks';
29
+ import { useCurrentMergeThemeStyleVariationsWithUserConfig } from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';
33
30
 
34
31
  const noop = () => {};
35
32
 
@@ -75,8 +72,12 @@ function SidebarNavigationScreenGlobalStylesContent() {
75
72
  };
76
73
  }, [] );
77
74
 
78
- const colorVariations = useColorVariations();
79
- const typographyVariations = useTypographyVariations();
75
+ const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig( [
76
+ 'color',
77
+ ] );
78
+ const typographyVariations =
79
+ useCurrentMergeThemeStyleVariationsWithUserConfig( [ 'typography' ] );
80
+
80
81
  const gap = 3;
81
82
 
82
83
  // Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
@@ -36,6 +36,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {
36
36
  value={ editedMenuTitle }
37
37
  placeholder={ __( 'Navigation title' ) }
38
38
  onChange={ setEditedMenuTitle }
39
+ label={ __( 'Name' ) }
39
40
  />
40
41
  <HStack justify="right">
41
42
  <Button
@@ -48,7 +49,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {
48
49
 
49
50
  <Button
50
51
  __next40pxDefaultSize
51
- __experimentalIsFocusable
52
+ accessibleWhenDisabled
52
53
  disabled={ ! isEditedMenuTitleValid }
53
54
  variant="primary"
54
55
  type="submit"
@@ -58,13 +58,21 @@ export default function usePatternCategories() {
58
58
 
59
59
  // Update the category counts to reflect user registered patterns.
60
60
  userPatterns.forEach( ( pattern ) => {
61
- pattern.categories?.forEach( ( category ) => {
61
+ pattern.wp_pattern_category?.forEach( ( catId ) => {
62
+ const category = userPatternCategories.find(
63
+ ( cat ) => cat.id === catId
64
+ )?.name;
62
65
  if ( categoryMap[ category ] ) {
63
66
  categoryMap[ category ].count += 1;
64
67
  }
65
68
  } );
66
69
  // If the pattern has no categories, add it to uncategorized.
67
- if ( ! pattern.categories?.length ) {
70
+ if (
71
+ ! pattern.wp_pattern_category?.length ||
72
+ ! pattern.wp_pattern_category.some( ( catId ) =>
73
+ userPatternCategories.find( ( cat ) => cat.id === catId )
74
+ )
75
+ ) {
68
76
  categoryMap.uncategorized.count += 1;
69
77
  }
70
78
  } );
@@ -11,11 +11,12 @@ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
13
  import { decodeEntities } from '@wordpress/html-entities';
14
- import { memo, forwardRef } from '@wordpress/element';
14
+ import { memo, forwardRef, useContext } from '@wordpress/element';
15
15
  import { search } from '@wordpress/icons';
16
16
  import { store as commandsStore } from '@wordpress/commands';
17
17
  import { displayShortcut } from '@wordpress/keycodes';
18
18
  import { filterURLForDisplay } from '@wordpress/url';
19
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
19
20
 
20
21
  /**
21
22
  * Internal dependencies
@@ -23,6 +24,8 @@ import { filterURLForDisplay } from '@wordpress/url';
23
24
  import { store as editSiteStore } from '../../store';
24
25
  import SiteIcon from '../site-icon';
25
26
  import { unlock } from '../../lock-unlock';
27
+ const { useHistory } = unlock( routerPrivateApis );
28
+ import { SidebarNavigationContext } from '../sidebar';
26
29
 
27
30
  const SiteHub = memo(
28
31
  forwardRef( ( { isTransparent }, ref ) => {
@@ -103,3 +106,83 @@ const SiteHub = memo(
103
106
  );
104
107
 
105
108
  export default SiteHub;
109
+
110
+ export const SiteHubMobile = memo(
111
+ forwardRef( ( { isTransparent }, ref ) => {
112
+ const history = useHistory();
113
+ const { navigate } = useContext( SidebarNavigationContext );
114
+
115
+ const { homeUrl, siteTitle } = useSelect( ( select ) => {
116
+ const {
117
+ getSite,
118
+ getUnstableBase, // Site index.
119
+ } = select( coreStore );
120
+ const _site = getSite();
121
+ return {
122
+ homeUrl: getUnstableBase()?.home,
123
+ siteTitle:
124
+ ! _site?.title && !! _site?.url
125
+ ? filterURLForDisplay( _site?.url )
126
+ : _site?.title,
127
+ };
128
+ }, [] );
129
+ const { open: openCommandCenter } = useDispatch( commandsStore );
130
+
131
+ return (
132
+ <div className="edit-site-site-hub">
133
+ <HStack justify="flex-start" spacing="0">
134
+ <div
135
+ className={ clsx(
136
+ 'edit-site-site-hub__view-mode-toggle-container',
137
+ {
138
+ 'has-transparent-background': isTransparent,
139
+ }
140
+ ) }
141
+ >
142
+ <Button
143
+ ref={ ref }
144
+ label={ __( 'Go to Site Editor' ) }
145
+ className="edit-site-layout__view-mode-toggle"
146
+ style={ {
147
+ transform: 'scale(0.5)',
148
+ borderRadius: 4,
149
+ } }
150
+ onClick={ () => {
151
+ history.push( {} );
152
+ navigate( 'back' );
153
+ } }
154
+ >
155
+ <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
156
+ </Button>
157
+ </div>
158
+
159
+ <HStack>
160
+ <div className="edit-site-site-hub__title">
161
+ <Button
162
+ variant="link"
163
+ href={ homeUrl }
164
+ target="_blank"
165
+ label={ __( 'View site (opens in a new tab)' ) }
166
+ >
167
+ { decodeEntities( siteTitle ) }
168
+ </Button>
169
+ </div>
170
+ <HStack
171
+ spacing={ 0 }
172
+ expanded={ false }
173
+ className="edit-site-site-hub__actions"
174
+ >
175
+ <Button
176
+ className="edit-site-site-hub_toggle-command-center"
177
+ icon={ search }
178
+ onClick={ () => openCommandCenter() }
179
+ label={ __( 'Open command palette' ) }
180
+ shortcut={ displayShortcut.primary( 'k' ) }
181
+ />
182
+ </HStack>
183
+ </HStack>
184
+ </HStack>
185
+ </div>
186
+ );
187
+ } )
188
+ );
@@ -27,7 +27,7 @@ const postTypesWithoutParentTemplate = [
27
27
  PATTERN_TYPES.user,
28
28
  ];
29
29
 
30
- const authorizedPostTypes = [ 'page' ];
30
+ const authorizedPostTypes = [ 'page', 'post' ];
31
31
 
32
32
  function useResolveEditedEntityAndContext( { postId, postType } ) {
33
33
  const {
@@ -213,7 +213,8 @@ function useResolveEditedEntityAndContext( { postId, postType } ) {
213
213
  if ( postType && postId && authorizedPostTypes.includes( postType ) ) {
214
214
  return { postType, postId };
215
215
  }
216
-
216
+ // TODO: for post types lists we should probably not render the front page, but maybe a placeholder
217
+ // with a message like "Select a page" or something similar.
217
218
  if ( homepageId ) {
218
219
  return { postType: 'page', postId: homepageId };
219
220
  }
@@ -339,7 +339,7 @@ function PushChangesToGlobalStylesControl( {
339
339
  <Button
340
340
  __next40pxDefaultSize
341
341
  variant="secondary"
342
- __experimentalIsFocusable
342
+ accessibleWhenDisabled
343
343
  disabled={ changes.length === 0 }
344
344
  onClick={ pushChanges }
345
345
  >
@@ -2,11 +2,11 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import {
5
- filterObjectByProperty,
6
- removePropertyFromObject,
5
+ filterObjectByProperties,
6
+ removePropertiesFromObject,
7
7
  } from '../use-theme-style-variations-by-property';
8
8
 
9
- describe( 'filterObjectByProperty', () => {
9
+ describe( 'filterObjectByProperties', () => {
10
10
  const noop = () => {};
11
11
  test.each( [
12
12
  {
@@ -14,21 +14,21 @@ describe( 'filterObjectByProperty', () => {
14
14
  foo: 'bar',
15
15
  array: [ 1, 3, 4 ],
16
16
  },
17
- property: 'array',
17
+ properties: [ 'array' ],
18
18
  expected: { array: [ 1, 3, 4 ] },
19
19
  },
20
20
  {
21
21
  object: {
22
22
  foo: 'bar',
23
23
  },
24
- property: 'does-not-exist',
24
+ properties: [ 'does-not-exist' ],
25
25
  expected: {},
26
26
  },
27
27
  {
28
28
  object: {
29
29
  foo: 'bar',
30
30
  },
31
- property: false,
31
+ properties: false,
32
32
  expected: {},
33
33
  },
34
34
  {
@@ -39,7 +39,7 @@ describe( 'filterObjectByProperty', () => {
39
39
  },
40
40
  },
41
41
  },
42
- property: 'null',
42
+ properties: [ 'null' ],
43
43
  expected: {
44
44
  dig: {
45
45
  deeper: {
@@ -52,19 +52,19 @@ describe( 'filterObjectByProperty', () => {
52
52
  object: {
53
53
  function: noop,
54
54
  },
55
- property: 'function',
55
+ properties: [ 'function' ],
56
56
  expected: {
57
57
  function: noop,
58
58
  },
59
59
  },
60
60
  {
61
61
  object: [],
62
- property: 'something',
62
+ properties: [ 'something' ],
63
63
  expected: {},
64
64
  },
65
65
  {
66
66
  object: {},
67
- property: undefined,
67
+ properties: undefined,
68
68
  expected: {},
69
69
  },
70
70
  {
@@ -74,7 +74,7 @@ describe( 'filterObjectByProperty', () => {
74
74
  array: [ 1, 3, 4 ],
75
75
  },
76
76
  },
77
- property: 'nested-object-foo',
77
+ properties: [ 'nested-object-foo' ],
78
78
  expected: {
79
79
  'nested-object': {
80
80
  'nested-object-foo': 'bar',
@@ -82,15 +82,15 @@ describe( 'filterObjectByProperty', () => {
82
82
  },
83
83
  },
84
84
  ] )(
85
- 'should filter object by $property',
86
- ( { expected, object, property } ) => {
87
- const result = filterObjectByProperty( object, property );
85
+ 'should filter object by $properties',
86
+ ( { expected, object, properties } ) => {
87
+ const result = filterObjectByProperties( object, properties );
88
88
  expect( result ).toEqual( expected );
89
89
  }
90
90
  );
91
91
  } );
92
92
 
93
- describe( 'removePropertyFromObject', () => {
93
+ describe( 'removePropertiesFromObject', () => {
94
94
  const mockBaseVariation = {
95
95
  settings: {
96
96
  typography: {
@@ -188,34 +188,38 @@ describe( 'removePropertyFromObject', () => {
188
188
  },
189
189
  };
190
190
 
191
- it( 'should return with no property', () => {
191
+ it( 'should return with no properties', () => {
192
192
  const object = { test: 'me' };
193
- expect( removePropertyFromObject( object, undefined ) ).toEqual(
193
+ expect( removePropertiesFromObject( object, undefined ) ).toEqual(
194
194
  object
195
195
  );
196
196
  } );
197
197
 
198
- it( 'should return with non-string property', () => {
198
+ it( 'should return with non-string properties', () => {
199
199
  const object = { test: 'you' };
200
- expect( removePropertyFromObject( object, true ) ).toEqual( object );
200
+ expect( removePropertiesFromObject( object, true ) ).toEqual( object );
201
201
  } );
202
202
 
203
203
  it( 'should return with empty object', () => {
204
204
  const object = {};
205
- expect( removePropertyFromObject( object, 'color' ) ).toEqual( object );
205
+ expect( removePropertiesFromObject( object, [ 'color' ] ) ).toEqual(
206
+ object
207
+ );
206
208
  } );
207
209
 
208
210
  it( 'should return with null', () => {
209
- expect( removePropertyFromObject( null, 'color' ) ).toEqual( null );
211
+ expect( removePropertiesFromObject( null, [ 'color' ] ) ).toEqual(
212
+ null
213
+ );
210
214
  } );
211
215
 
212
- it( 'should remove the specified property from the object', () => {
216
+ it( 'should remove the specified properties from the object', () => {
213
217
  expect(
214
- removePropertyFromObject(
218
+ removePropertiesFromObject(
215
219
  {
216
220
  ...mockBaseVariation,
217
221
  },
218
- 'typography'
222
+ [ 'typography' ]
219
223
  )
220
224
  ).toEqual( {
221
225
  settings: {