@wordpress/edit-site 6.33.3-next.36001005c.0 → 6.33.4

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 (58) hide show
  1. package/build/components/dataviews-actions/index.js +8 -6
  2. package/build/components/dataviews-actions/index.js.map +2 -2
  3. package/build/components/global-styles-renderer/index.js +4 -2
  4. package/build/components/global-styles-renderer/index.js.map +3 -3
  5. package/build/components/page-templates/fields.js +19 -26
  6. package/build/components/page-templates/fields.js.map +2 -2
  7. package/build/components/page-templates/index.js +52 -39
  8. package/build/components/page-templates/index.js.map +2 -2
  9. package/build/components/page-templates/view-utils.js +4 -0
  10. package/build/components/page-templates/view-utils.js.map +2 -2
  11. package/build/components/revisions/index.js +2 -2
  12. package/build/components/revisions/index.js.map +2 -2
  13. package/build/components/sidebar-navigation-screen-templates-browse/content.js +8 -9
  14. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
  15. package/build/components/style-book/index.js +8 -4
  16. package/build/components/style-book/index.js.map +2 -2
  17. package/build-module/components/dataviews-actions/index.js +8 -6
  18. package/build-module/components/dataviews-actions/index.js.map +2 -2
  19. package/build-module/components/global-styles-renderer/index.js +3 -1
  20. package/build-module/components/global-styles-renderer/index.js.map +2 -2
  21. package/build-module/components/page-templates/fields.js +19 -26
  22. package/build-module/components/page-templates/fields.js.map +2 -2
  23. package/build-module/components/page-templates/index.js +52 -39
  24. package/build-module/components/page-templates/index.js.map +2 -2
  25. package/build-module/components/page-templates/view-utils.js +4 -0
  26. package/build-module/components/page-templates/view-utils.js.map +2 -2
  27. package/build-module/components/revisions/index.js +1 -1
  28. package/build-module/components/revisions/index.js.map +2 -2
  29. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +9 -10
  30. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
  31. package/build-module/components/style-book/index.js +6 -2
  32. package/build-module/components/style-book/index.js.map +2 -2
  33. package/build-style/posts-rtl.css +13 -13
  34. package/build-style/posts.css +13 -13
  35. package/build-style/style-rtl.css +23 -23
  36. package/build-style/style.css +23 -23
  37. package/package.json +44 -45
  38. package/src/components/dataviews-actions/index.js +12 -10
  39. package/src/components/global-styles/font-library-modal/style.scss +3 -3
  40. package/src/components/global-styles/style.scss +1 -1
  41. package/src/components/global-styles-renderer/index.js +4 -1
  42. package/src/components/global-styles-sidebar/style.scss +2 -2
  43. package/src/components/page-templates/fields.js +23 -29
  44. package/src/components/page-templates/index.js +62 -45
  45. package/src/components/page-templates/view-utils.js +7 -0
  46. package/src/components/revisions/index.js +1 -1
  47. package/src/components/sidebar-navigation-screen/style.scss +1 -1
  48. package/src/components/sidebar-navigation-screen-patterns/style.scss +1 -1
  49. package/src/components/sidebar-navigation-screen-templates-browse/content.js +9 -10
  50. package/src/components/site-hub/style.scss +1 -1
  51. package/src/components/style-book/index.js +6 -3
  52. package/tsconfig.json +0 -1
  53. package/tsconfig.tsbuildinfo +1 -1
  54. package/build/hooks/use-global-styles-output.js +0 -77
  55. package/build/hooks/use-global-styles-output.js.map +0 -7
  56. package/build-module/hooks/use-global-styles-output.js +0 -52
  57. package/build-module/hooks/use-global-styles-output.js.map +0 -7
  58. package/src/hooks/use-global-styles-output.js +0 -80
@@ -403,7 +403,7 @@
403
403
  }
404
404
  .dataviews-title-field {
405
405
  font-size: 13px;
406
- font-weight: 499;
406
+ font-weight: 500;
407
407
  color: #2f2f2f;
408
408
  text-overflow: ellipsis;
409
409
  white-space: nowrap;
@@ -500,7 +500,7 @@
500
500
 
501
501
  .dataviews-bulk-actions-footer__item-count {
502
502
  color: #1e1e1e;
503
- font-weight: 499;
503
+ font-weight: 500;
504
504
  font-size: 11px;
505
505
  text-transform: uppercase;
506
506
  }
@@ -616,7 +616,7 @@
616
616
  }
617
617
 
618
618
  .dataviews-filters__summary-chip-container .dataviews-filters__summary-chip .dataviews-filters-__summary-filter-text-name {
619
- font-weight: 499;
619
+ font-weight: 500;
620
620
  }
621
621
 
622
622
  .dataviews-filters__summary-chip-container .dataviews-filters__summary-chip-remove {
@@ -1135,14 +1135,14 @@
1135
1135
  }
1136
1136
  .dataviews-pagination__page-select {
1137
1137
  font-size: 11px;
1138
- font-weight: 499;
1138
+ font-weight: 500;
1139
1139
  text-transform: uppercase;
1140
1140
  }
1141
1141
 
1142
1142
  @media (min-width: 600px) {
1143
1143
  .dataviews-pagination__page-select .components-select-control__input {
1144
1144
  font-size: 11px !important;
1145
- font-weight: 499;
1145
+ font-weight: 500;
1146
1146
  }
1147
1147
  }
1148
1148
  .dataviews-action-modal {
@@ -1474,7 +1474,7 @@
1474
1474
 
1475
1475
  .dataviews-view-grid__group-header {
1476
1476
  font-size: 15px;
1477
- font-weight: 499;
1477
+ font-weight: 500;
1478
1478
  color: #1e1e1e;
1479
1479
  margin: 0 0 8px 0;
1480
1480
  padding: 0 48px;
@@ -1703,7 +1703,7 @@ div.dataviews-view-list {
1703
1703
 
1704
1704
  .dataviews-view-list__group-header {
1705
1705
  font-size: 15px;
1706
- font-weight: 499;
1706
+ font-weight: 500;
1707
1707
  color: #1e1e1e;
1708
1708
  margin: 0 0 8px 0;
1709
1709
  padding: 0 24px;
@@ -1865,7 +1865,7 @@ div.dataviews-view-list {
1865
1865
  padding-left: 12px;
1866
1866
  font-size: 11px;
1867
1867
  text-transform: uppercase;
1868
- font-weight: 499;
1868
+ font-weight: 500;
1869
1869
  }
1870
1870
 
1871
1871
  .dataviews-view-table thead th:has(.dataviews-view-table-header-button):not(:first-child) {
@@ -1898,7 +1898,7 @@ div.dataviews-view-list {
1898
1898
  padding: 4px 8px;
1899
1899
  font-size: 11px;
1900
1900
  text-transform: uppercase;
1901
- font-weight: 499;
1901
+ font-weight: 500;
1902
1902
  }
1903
1903
 
1904
1904
  .dataviews-view-table .dataviews-view-table-header-button:not(:hover) {
@@ -1998,7 +1998,7 @@ div.dataviews-view-list {
1998
1998
  }
1999
1999
 
2000
2000
  .dataviews-view-table__group-header-row .dataviews-view-table__group-header-cell {
2001
- font-weight: 499;
2001
+ font-weight: 500;
2002
2002
  padding: 12px 48px;
2003
2003
  color: #1e1e1e;
2004
2004
  }
@@ -2156,7 +2156,7 @@ div.dataviews-view-list {
2156
2156
 
2157
2157
  .dataviews-view-picker-grid-group__header {
2158
2158
  font-size: 15px;
2159
- font-weight: 499;
2159
+ font-weight: 500;
2160
2160
  color: #1e1e1e;
2161
2161
  margin: 0 0 8px 0;
2162
2162
  padding: 0 48px;
@@ -2278,7 +2278,7 @@ div.dataviews-view-list {
2278
2278
 
2279
2279
  .dataforms-layouts-card__field-header-label {
2280
2280
  font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
2281
- font-weight: 499;
2281
+ font-weight: 500;
2282
2282
  font-size: 15px;
2283
2283
  line-height: 20px;
2284
2284
  }
@@ -2956,7 +2956,7 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
2956
2956
  .edit-site-global-styles-subtitle {
2957
2957
  margin-bottom: 0 !important;
2958
2958
  text-transform: uppercase;
2959
- font-weight: 499 !important;
2959
+ font-weight: 500 !important;
2960
2960
  font-size: 11px !important;
2961
2961
  }
2962
2962
 
@@ -3302,11 +3302,11 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
3302
3302
 
3303
3303
  .edit-site-global-styles-sidebar .components-navigation__menu-title-heading {
3304
3304
  font-size: 15.6px;
3305
- font-weight: 499;
3305
+ font-weight: 500;
3306
3306
  }
3307
3307
 
3308
3308
  .edit-site-global-styles-sidebar .components-navigation__item > button span {
3309
- font-weight: 499;
3309
+ font-weight: 500;
3310
3310
  }
3311
3311
 
3312
3312
  .edit-site-global-styles-sidebar .block-editor-panel-color-gradient-settings {
@@ -4038,7 +4038,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
4038
4038
  .edit-site-sidebar-navigation-item.components-item[aria-current=true] {
4039
4039
  background: #2f2f2f;
4040
4040
  color: #fff;
4041
- font-weight: 499;
4041
+ font-weight: 500;
4042
4042
  }
4043
4043
  .edit-site-sidebar-navigation-item.components-item:focus-visible {
4044
4044
  transform: translateZ(0);
@@ -4113,7 +4113,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
4113
4113
  color: #ddd;
4114
4114
  font-size: 11px;
4115
4115
  text-transform: uppercase;
4116
- font-weight: 499;
4116
+ font-weight: 500;
4117
4117
  }
4118
4118
 
4119
4119
  .edit-site-sidebar-navigation-screen__content .edit-site-global-styles-variations_item .edit-site-global-styles-variations_item-preview {
@@ -4201,7 +4201,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
4201
4201
  }
4202
4202
  .edit-site-sidebar-navigation-screen-patterns__group-header h2 {
4203
4203
  font-size: 11px;
4204
- font-weight: 499;
4204
+ font-weight: 500;
4205
4205
  text-transform: uppercase;
4206
4206
  }
4207
4207
 
@@ -4274,7 +4274,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
4274
4274
  }
4275
4275
  .edit-site-sidebar-dataviews-dataview-item.is-selected {
4276
4276
  background: #2f2f2f;
4277
- font-weight: 499;
4277
+ font-weight: 500;
4278
4278
  color: #fff;
4279
4279
  }
4280
4280
 
@@ -4305,7 +4305,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
4305
4305
  display: block;
4306
4306
  flex-grow: 1;
4307
4307
  font-size: 15px;
4308
- font-weight: 499;
4308
+ font-weight: 500;
4309
4309
  overflow: hidden;
4310
4310
  padding-right: 16px;
4311
4311
  margin-left: -4px;
@@ -4608,7 +4608,7 @@ body:has(.edit-site-resizable-frame__inner.is-resizing) {
4608
4608
  }
4609
4609
  .font-library-modal .font-library-modal__subtitle {
4610
4610
  text-transform: uppercase;
4611
- font-weight: 499;
4611
+ font-weight: 500;
4612
4612
  font-size: 11px;
4613
4613
  }
4614
4614
  .font-library-modal .components-navigator-screen {
@@ -4643,13 +4643,13 @@ body:has(.edit-site-resizable-frame__inner.is-resizing) {
4643
4643
 
4644
4644
  .font-library-modal__page-selection {
4645
4645
  font-size: 11px;
4646
- font-weight: 499;
4646
+ font-weight: 500;
4647
4647
  text-transform: uppercase;
4648
4648
  }
4649
4649
  @media (min-width: 600px) {
4650
4650
  .font-library-modal__page-selection .components-select-control__input {
4651
4651
  font-size: 11px !important;
4652
- font-weight: 499;
4652
+ font-weight: 500;
4653
4653
  }
4654
4654
  }
4655
4655
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "6.33.3-next.36001005c.0",
3
+ "version": "6.33.4",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,49 +37,48 @@
37
37
  "wpScript": true,
38
38
  "dependencies": {
39
39
  "@react-spring/web": "^9.4.5",
40
- "@wordpress/a11y": "^4.33.1-next.36001005c.0",
41
- "@wordpress/admin-ui": "^1.1.1-next.36001005c.0",
42
- "@wordpress/api-fetch": "^7.33.1-next.36001005c.0",
43
- "@wordpress/base-styles": "^6.10.1-next.36001005c.0",
44
- "@wordpress/blob": "^4.33.1-next.36001005c.0",
45
- "@wordpress/block-editor": "^15.6.1-next.36001005c.0",
46
- "@wordpress/block-library": "^9.33.2-next.36001005c.0",
47
- "@wordpress/blocks": "^15.6.1-next.36001005c.0",
48
- "@wordpress/commands": "^1.33.1-next.36001005c.0",
49
- "@wordpress/components": "^30.7.1-next.36001005c.0",
50
- "@wordpress/compose": "^7.33.1-next.36001005c.0",
51
- "@wordpress/core-data": "^7.33.1-next.36001005c.0",
52
- "@wordpress/data": "^10.33.1-next.36001005c.0",
53
- "@wordpress/dataviews": "^10.1.1-next.36001005c.0",
54
- "@wordpress/date": "^5.33.1-next.36001005c.0",
55
- "@wordpress/deprecated": "^4.33.1-next.36001005c.0",
56
- "@wordpress/dom": "^4.33.1-next.36001005c.0",
57
- "@wordpress/editor": "^14.33.3-next.36001005c.0",
58
- "@wordpress/element": "^6.33.1-next.36001005c.0",
59
- "@wordpress/escape-html": "^3.33.1-next.36001005c.0",
60
- "@wordpress/fields": "^0.25.3-next.36001005c.0",
61
- "@wordpress/global-styles-engine": "^1.0.1-next.36001005c.0",
62
- "@wordpress/hooks": "^4.33.1-next.36001005c.0",
63
- "@wordpress/html-entities": "^4.33.1-next.36001005c.0",
64
- "@wordpress/i18n": "^6.6.1-next.36001005c.0",
65
- "@wordpress/icons": "^11.0.1-next.36001005c.0",
66
- "@wordpress/keyboard-shortcuts": "^5.33.1-next.36001005c.0",
67
- "@wordpress/keycodes": "^4.33.1-next.36001005c.0",
68
- "@wordpress/media-utils": "^5.33.1-next.36001005c.0",
69
- "@wordpress/notices": "^5.33.1-next.36001005c.0",
70
- "@wordpress/patterns": "^2.33.1-next.36001005c.0",
71
- "@wordpress/plugins": "^7.33.1-next.36001005c.0",
72
- "@wordpress/preferences": "^4.33.1-next.36001005c.0",
73
- "@wordpress/primitives": "^4.33.1-next.36001005c.0",
74
- "@wordpress/private-apis": "^1.33.1-next.36001005c.0",
75
- "@wordpress/reusable-blocks": "^5.33.1-next.36001005c.0",
76
- "@wordpress/router": "^1.33.1-next.36001005c.0",
77
- "@wordpress/style-engine": "^2.33.1-next.36001005c.0",
78
- "@wordpress/url": "^4.33.1-next.36001005c.0",
79
- "@wordpress/viewport": "^6.33.1-next.36001005c.0",
80
- "@wordpress/views": "^1.0.2-next.36001005c.0",
81
- "@wordpress/widgets": "^4.33.1-next.36001005c.0",
82
- "@wordpress/wordcount": "^4.33.1-next.36001005c.0",
40
+ "@wordpress/a11y": "^4.33.1",
41
+ "@wordpress/admin-ui": "^1.1.1",
42
+ "@wordpress/api-fetch": "^7.33.1",
43
+ "@wordpress/base-styles": "^6.9.1",
44
+ "@wordpress/blob": "^4.33.1",
45
+ "@wordpress/block-editor": "^15.6.2",
46
+ "@wordpress/block-library": "^9.33.3",
47
+ "@wordpress/blocks": "^15.6.1",
48
+ "@wordpress/commands": "^1.33.1",
49
+ "@wordpress/components": "^30.6.1",
50
+ "@wordpress/compose": "^7.33.1",
51
+ "@wordpress/core-data": "^7.33.2",
52
+ "@wordpress/data": "^10.33.1",
53
+ "@wordpress/dataviews": "^10.1.2",
54
+ "@wordpress/date": "^5.33.1",
55
+ "@wordpress/deprecated": "^4.33.1",
56
+ "@wordpress/dom": "^4.33.1",
57
+ "@wordpress/editor": "^14.33.4",
58
+ "@wordpress/element": "^6.33.1",
59
+ "@wordpress/escape-html": "^3.33.1",
60
+ "@wordpress/fields": "^0.25.4",
61
+ "@wordpress/hooks": "^4.33.1",
62
+ "@wordpress/html-entities": "^4.33.1",
63
+ "@wordpress/i18n": "^6.6.1",
64
+ "@wordpress/icons": "^11.0.1",
65
+ "@wordpress/keyboard-shortcuts": "^5.33.1",
66
+ "@wordpress/keycodes": "^4.33.1",
67
+ "@wordpress/media-utils": "^5.33.1",
68
+ "@wordpress/notices": "^5.33.1",
69
+ "@wordpress/patterns": "^2.33.2",
70
+ "@wordpress/plugins": "^7.33.1",
71
+ "@wordpress/preferences": "^4.33.1",
72
+ "@wordpress/primitives": "^4.33.1",
73
+ "@wordpress/private-apis": "^1.33.1",
74
+ "@wordpress/reusable-blocks": "^5.33.2",
75
+ "@wordpress/router": "^1.33.1",
76
+ "@wordpress/style-engine": "^2.33.1",
77
+ "@wordpress/url": "^4.33.1",
78
+ "@wordpress/viewport": "^6.33.1",
79
+ "@wordpress/views": "^1.0.3",
80
+ "@wordpress/widgets": "^4.33.2",
81
+ "@wordpress/wordcount": "^4.33.1",
83
82
  "change-case": "^4.1.2",
84
83
  "clsx": "^2.1.1",
85
84
  "colord": "^2.9.2",
@@ -94,5 +93,5 @@
94
93
  "publishConfig": {
95
94
  "access": "public"
96
95
  },
97
- "gitHead": "b73a8a22e779c59efb8f911e32b681652f237d60"
96
+ "gitHead": "45005cc254bab59182927e35a68cd22f6320634d"
98
97
  }
@@ -34,11 +34,17 @@ export const useSetActiveTemplateAction = () => {
34
34
  isPrimary: true,
35
35
  icon: pencil,
36
36
  isEligible( item ) {
37
- return (
38
- ! item._isCustom &&
39
- ! ( item.slug === 'index' && item.source === 'theme' ) &&
40
- item.theme === activeTheme.stylesheet
41
- );
37
+ if ( item.theme !== activeTheme.stylesheet ) {
38
+ return false;
39
+ }
40
+
41
+ // If it's not a created template but a registered template,
42
+ // only allow activating (so when it's inactive).
43
+ if ( typeof item.id !== 'number' ) {
44
+ return item._isActive === false;
45
+ }
46
+
47
+ return true;
42
48
  },
43
49
  async callback( items ) {
44
50
  const deactivate = items.some( ( item ) => item._isActive );
@@ -49,11 +55,7 @@ export const useSetActiveTemplateAction = () => {
49
55
  };
50
56
  for ( const item of items ) {
51
57
  if ( deactivate ) {
52
- if ( item.source === 'theme' ) {
53
- activeTemplates[ item.slug ] = false;
54
- } else {
55
- delete activeTemplates[ item.slug ];
56
- }
58
+ delete activeTemplates[ item.slug ];
57
59
  } else {
58
60
  activeTemplates[ item.slug ] = item.id;
59
61
  }
@@ -27,7 +27,7 @@ $footer-height: 70px;
27
27
 
28
28
  .font-library-modal__subtitle {
29
29
  text-transform: uppercase;
30
- font-weight: $font-weight-medium;
30
+ font-weight: 500;
31
31
  font-size: 11px;
32
32
  }
33
33
 
@@ -68,13 +68,13 @@ $footer-height: 70px;
68
68
 
69
69
  .font-library-modal__page-selection {
70
70
  font-size: 11px;
71
- font-weight: $font-weight-medium;
71
+ font-weight: 500;
72
72
  text-transform: uppercase;
73
73
 
74
74
  @include break-small() {
75
75
  .components-select-control__input {
76
76
  font-size: 11px !important;
77
- font-weight: $font-weight-medium;
77
+ font-weight: 500;
78
78
  }
79
79
  }
80
80
  }
@@ -85,7 +85,7 @@
85
85
  // Need to override the too specific styles for complementary areas.
86
86
  margin-bottom: 0 !important;
87
87
  text-transform: uppercase;
88
- font-weight: $font-weight-medium !important;
88
+ font-weight: 500 !important;
89
89
  font-size: 11px !important;
90
90
  }
91
91
 
@@ -3,12 +3,15 @@
3
3
  */
4
4
  import { useEffect } from '@wordpress/element';
5
5
  import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
11
  import { store as editSiteStore } from '../../store';
11
- import { useGlobalStylesOutput } from '../../hooks/use-global-styles-output';
12
+ import { unlock } from '../../lock-unlock';
13
+
14
+ const { useGlobalStylesOutput } = unlock( blockEditorPrivateApis );
12
15
 
13
16
  function useGlobalStylesRenderer( disableRootPadding ) {
14
17
  const [ styles, settings ] = useGlobalStylesOutput( disableRootPadding );
@@ -21,11 +21,11 @@
21
21
 
22
22
  .edit-site-global-styles-sidebar .components-navigation__menu-title-heading {
23
23
  font-size: $default-font-size * 1.2;
24
- font-weight: $font-weight-medium;
24
+ font-weight: 500;
25
25
  }
26
26
 
27
27
  .edit-site-global-styles-sidebar .components-navigation__item > button span {
28
- font-weight: $font-weight-medium;
28
+ font-weight: 500;
29
29
  }
30
30
 
31
31
  .edit-site-global-styles-sidebar .block-editor-panel-color-gradient-settings {
@@ -41,9 +41,8 @@ const { useEntityRecordsWithPermissions } = unlock( corePrivateApis );
41
41
  function useAllDefaultTemplateTypes() {
42
42
  const defaultTemplateTypes = useDefaultTemplateTypes();
43
43
  const { records: staticRecords } = useEntityRecordsWithPermissions(
44
- 'postType',
45
- 'wp_registered_template',
46
- { per_page: -1 }
44
+ 'root',
45
+ 'registeredTemplate'
47
46
  );
48
47
  return [
49
48
  ...defaultTemplateTypes,
@@ -153,25 +152,17 @@ export const authorField = {
153
152
  export const activeField = {
154
153
  label: __( 'Status' ),
155
154
  id: 'active',
155
+ type: 'boolean',
156
156
  getValue: ( { item } ) => item._isActive,
157
157
  render: function Render( { item } ) {
158
- if ( item._isCustom ) {
159
- return (
160
- <Badge
161
- intent="info"
162
- title={ __(
163
- 'Custom templates cannot be active nor inactive.'
164
- ) }
165
- >
166
- { __( 'N/A' ) }
167
- </Badge>
168
- );
169
- }
170
-
158
+ const activeLabel = item._isCustom
159
+ ? __( 'Active when used' )
160
+ : __( 'Active' );
161
+ const activeIntent = item._isCustom ? 'info' : 'success';
171
162
  const isActive = item._isActive;
172
163
  return (
173
- <Badge intent={ isActive ? 'success' : 'default' }>
174
- { isActive ? __( 'Active' ) : __( 'Inactive' ) }
164
+ <Badge intent={ isActive ? activeIntent : 'default' }>
165
+ { isActive ? activeLabel : __( 'Inactive' ) }
175
166
  </Badge>
176
167
  );
177
168
  },
@@ -181,17 +172,20 @@ export const useThemeField = () => {
181
172
  const activeTheme = useSelect( ( select ) =>
182
173
  select( coreStore ).getCurrentTheme()
183
174
  );
184
- return {
185
- label: __( 'Compatible Theme' ),
186
- id: 'theme',
187
- getValue: ( { item } ) => item.theme,
188
- render: function Render( { item } ) {
189
- if ( item.theme === activeTheme.stylesheet ) {
190
- return <Badge intent="success">{ item.theme }</Badge>;
191
- }
192
- return <Badge intent="error">{ item.theme }</Badge>;
193
- },
194
- };
175
+ return useMemo(
176
+ () => ( {
177
+ label: __( 'Compatible Theme' ),
178
+ id: 'theme',
179
+ getValue: ( { item } ) => item.theme,
180
+ render: function Render( { item } ) {
181
+ if ( item.theme === activeTheme.stylesheet ) {
182
+ return <Badge intent="success">{ item.theme }</Badge>;
183
+ }
184
+ return <Badge intent="error">{ item.theme }</Badge>;
185
+ },
186
+ } ),
187
+ [ activeTheme ]
188
+ );
195
189
  };
196
190
 
197
191
  export const slugField = {
@@ -39,7 +39,8 @@ import {
39
39
  } from './fields';
40
40
  import { defaultLayouts, getDefaultView } from './view-utils';
41
41
 
42
- const { usePostActions, templateTitleField } = unlock( editorPrivateApis );
42
+ const { usePostActions, usePostFields, templateTitleField } =
43
+ unlock( editorPrivateApis );
43
44
  const { useHistory, useLocation } = unlock( routerPrivateApis );
44
45
  const { useEntityRecordsWithPermissions } = unlock( corePrivateApis );
45
46
 
@@ -93,41 +94,32 @@ export default function PageTemplates() {
93
94
  combinedTemplates: false,
94
95
  } );
95
96
  const { records: staticRecords, isResolving: isLoadingStaticData } =
96
- useEntityRecordsWithPermissions( 'postType', 'wp_registered_template', {
97
+ useEntityRecordsWithPermissions( 'root', 'registeredTemplate', {
98
+ // This should not be needed, the endpoint returns all registered
99
+ // templates, but it's not possible right now to turn off pagination
100
+ // for entity configs.
97
101
  per_page: -1,
98
102
  } );
99
103
 
100
104
  const activeTemplates = useMemo( () => {
101
- const _active = [ ...staticRecords ].filter(
102
- ( record ) => ! record.is_custom
103
- );
105
+ const _active = [ ...staticRecords ];
104
106
  if ( activeTemplatesOption ) {
105
107
  for ( const activeSlug in activeTemplatesOption ) {
106
108
  const activeId = activeTemplatesOption[ activeSlug ];
107
- if ( activeId === false ) {
108
- // Remove the template from the array.
109
+ // Replace the template in the array.
110
+ const template = userRecords.find(
111
+ ( userRecord ) =>
112
+ userRecord.id === activeId &&
113
+ userRecord.theme === activeTheme.stylesheet
114
+ );
115
+ if ( template ) {
109
116
  const index = _active.findIndex(
110
- ( template ) => template.slug === activeSlug
117
+ ( { slug } ) => slug === template.slug
111
118
  );
112
119
  if ( index !== -1 ) {
113
- _active.splice( index, 1 );
114
- }
115
- } else {
116
- // Replace the template in the array.
117
- const template = userRecords.find(
118
- ( userRecord ) =>
119
- userRecord.id === activeId &&
120
- userRecord.theme === activeTheme.stylesheet
121
- );
122
- if ( template ) {
123
- const index = _active.findIndex(
124
- ( { slug } ) => slug === template.slug
125
- );
126
- if ( index !== -1 ) {
127
- _active[ index ] = template;
128
- } else {
129
- _active.push( template );
130
- }
120
+ _active[ index ] = template;
121
+ } else {
122
+ _active.push( template );
131
123
  }
132
124
  }
133
125
  }
@@ -135,33 +127,55 @@ export default function PageTemplates() {
135
127
  return _active;
136
128
  }, [ userRecords, staticRecords, activeTemplatesOption, activeTheme ] );
137
129
 
138
- let _records;
139
130
  let isLoadingData;
140
131
  if ( activeView === 'active' ) {
141
- _records = activeTemplates;
142
132
  isLoadingData = isLoadingUserRecords || isLoadingStaticData;
143
133
  } else if ( activeView === 'user' ) {
144
- _records = userRecords;
145
134
  isLoadingData = isLoadingUserRecords;
146
135
  } else {
147
- _records = staticRecords;
148
136
  isLoadingData = isLoadingStaticData;
149
137
  }
150
138
 
151
139
  const records = useMemo( () => {
140
+ function isCustom( record ) {
141
+ // For registered templates, the is_custom field is defined.
142
+ return (
143
+ record.is_custom ??
144
+ // For user templates it's custom if the is_wp_suggestion meta
145
+ // field is not set and the slug is not found in the default
146
+ // template types.
147
+ ( ! record.meta?.is_wp_suggestion &&
148
+ ! defaultTemplateTypes.some(
149
+ ( type ) => type.slug === record.slug
150
+ ) )
151
+ );
152
+ }
153
+
154
+ let _records;
155
+ if ( activeView === 'active' ) {
156
+ // Don't show active custom templates in the active view.
157
+ _records = activeTemplates.filter(
158
+ ( record ) => ! isCustom( record )
159
+ );
160
+ } else if ( activeView === 'user' ) {
161
+ _records = userRecords;
162
+ } else {
163
+ _records = staticRecords;
164
+ }
152
165
  return _records.map( ( record ) => ( {
153
166
  ...record,
154
- _isActive: activeTemplates.find(
167
+ _isActive: activeTemplates.some(
155
168
  ( template ) => template.id === record.id
156
169
  ),
157
- _isCustom:
158
- record.is_custom ||
159
- ( ! record.meta?.is_wp_suggestion &&
160
- ! defaultTemplateTypes.find(
161
- ( type ) => type.slug === record.slug
162
- ) ),
170
+ _isCustom: isCustom( record ),
163
171
  } ) );
164
- }, [ _records, activeTemplates, defaultTemplateTypes ] );
172
+ }, [
173
+ activeTemplates,
174
+ defaultTemplateTypes,
175
+ userRecords,
176
+ staticRecords,
177
+ activeView,
178
+ ] );
165
179
 
166
180
  const users = useSelect(
167
181
  ( select ) => {
@@ -197,6 +211,10 @@ export default function PageTemplates() {
197
211
  [ history, path, view?.type ]
198
212
  );
199
213
 
214
+ const postTypeFields = usePostFields( {
215
+ postType: TEMPLATE_POST_TYPE,
216
+ } );
217
+ const dateField = postTypeFields.find( ( field ) => field.id === 'date' );
200
218
  const themeField = useThemeField();
201
219
  const fields = useMemo( () => {
202
220
  const _fields = [
@@ -208,6 +226,9 @@ export default function PageTemplates() {
208
226
  ];
209
227
  if ( activeView === 'user' ) {
210
228
  _fields.push( themeField );
229
+ if ( dateField ) {
230
+ _fields.push( dateField );
231
+ }
211
232
  }
212
233
  const elements = [];
213
234
  for ( const author in users ) {
@@ -221,7 +242,7 @@ export default function PageTemplates() {
221
242
  elements,
222
243
  } );
223
244
  return _fields;
224
- }, [ users, activeView, themeField ] );
245
+ }, [ users, activeView, themeField, dateField ] );
225
246
 
226
247
  const { data, paginationInfo } = useMemo( () => {
227
248
  return filterSortAndPaginate( records, view, fields );
@@ -238,6 +259,7 @@ export default function PageTemplates() {
238
259
  typeof newItem.title === 'string'
239
260
  ? newItem.title
240
261
  : newItem.title?.rendered;
262
+ history.navigate( `/template?activeView=user` );
241
263
  createSuccessNotice(
242
264
  sprintf(
243
265
  // translators: %s: Title of the created post or template, e.g: "Hello world".
@@ -325,7 +347,7 @@ export default function PageTemplates() {
325
347
  onChangeSelection={ onChangeSelection }
326
348
  isItemClickable={ () => true }
327
349
  onClickItem={ ( item ) => {
328
- if ( item.type === 'wp_registered_template' ) {
350
+ if ( typeof item.id === 'string' ) {
329
351
  setSelectedRegisteredTemplate( item );
330
352
  } else {
331
353
  history.navigate(
@@ -345,11 +367,6 @@ export default function PageTemplates() {
345
367
  <duplicateAction.RenderModal
346
368
  items={ [ selectedRegisteredTemplate ] }
347
369
  closeModal={ () => setSelectedRegisteredTemplate() }
348
- onActionPerformed={ ( [ item ] ) => {
349
- history.navigate(
350
- `/${ item.type }/${ item.id }?canvas=edit`
351
- );
352
- } }
353
370
  />
354
371
  </Modal>
355
372
  ) }