@wordpress/edit-site 6.35.2-next.dc3f6d3c1.0 → 6.36.1-next.6deb34194.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 (80) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +109 -0
  3. package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
  4. package/build/components/add-new-template-legacy/add-custom-template-modal-content.js +328 -0
  5. package/build/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
  6. package/build/components/add-new-template-legacy/index.js +389 -0
  7. package/build/components/add-new-template-legacy/index.js.map +7 -0
  8. package/build/components/add-new-template-legacy/utils.js +620 -0
  9. package/build/components/add-new-template-legacy/utils.js.map +7 -0
  10. package/build/components/block-editor/use-site-editor-settings.js +3 -3
  11. package/build/components/block-editor/use-site-editor-settings.js.map +2 -2
  12. package/build/components/page-templates/fields.js +3 -1
  13. package/build/components/page-templates/fields.js.map +2 -2
  14. package/build/components/page-templates/index-legacy.js +185 -0
  15. package/build/components/page-templates/index-legacy.js.map +7 -0
  16. package/build/components/post-list/index.js +27 -4
  17. package/build/components/post-list/index.js.map +3 -3
  18. package/build/components/post-list/use-notes-count.js +56 -0
  19. package/build/components/post-list/use-notes-count.js.map +7 -0
  20. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +2 -1
  21. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +2 -2
  22. package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js +101 -0
  23. package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
  24. package/build/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
  25. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +3 -3
  26. package/build/components/site-editor-routes/templates.js +10 -2
  27. package/build/components/site-editor-routes/templates.js.map +3 -3
  28. package/build/components/site-hub/index.js +1 -1
  29. package/build/components/site-hub/index.js.map +2 -2
  30. package/build/utils/constants.js +6 -0
  31. package/build/utils/constants.js.map +2 -2
  32. package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +93 -0
  33. package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
  34. package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js +316 -0
  35. package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
  36. package/build-module/components/add-new-template-legacy/index.js +390 -0
  37. package/build-module/components/add-new-template-legacy/index.js.map +7 -0
  38. package/build-module/components/add-new-template-legacy/utils.js +589 -0
  39. package/build-module/components/add-new-template-legacy/utils.js.map +7 -0
  40. package/build-module/components/block-editor/use-site-editor-settings.js +3 -3
  41. package/build-module/components/block-editor/use-site-editor-settings.js.map +2 -2
  42. package/build-module/components/page-templates/fields.js +3 -1
  43. package/build-module/components/page-templates/fields.js.map +2 -2
  44. package/build-module/components/page-templates/index-legacy.js +154 -0
  45. package/build-module/components/page-templates/index-legacy.js.map +7 -0
  46. package/build-module/components/post-list/index.js +29 -4
  47. package/build-module/components/post-list/index.js.map +2 -2
  48. package/build-module/components/post-list/use-notes-count.js +35 -0
  49. package/build-module/components/post-list/use-notes-count.js.map +7 -0
  50. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +2 -1
  51. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +2 -2
  52. package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js +70 -0
  53. package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
  54. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
  55. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +2 -2
  56. package/build-module/components/site-editor-routes/templates.js +10 -2
  57. package/build-module/components/site-editor-routes/templates.js.map +2 -2
  58. package/build-module/components/site-hub/index.js +1 -1
  59. package/build-module/components/site-hub/index.js.map +2 -2
  60. package/build-module/utils/constants.js +4 -0
  61. package/build-module/utils/constants.js.map +2 -2
  62. package/build-style/style-rtl.css +294 -147
  63. package/build-style/style.css +294 -147
  64. package/package.json +46 -46
  65. package/src/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +94 -0
  66. package/src/components/add-new-template-legacy/add-custom-template-modal-content.js +314 -0
  67. package/src/components/add-new-template-legacy/index.js +454 -0
  68. package/src/components/add-new-template-legacy/utils.js +760 -0
  69. package/src/components/block-editor/use-site-editor-settings.js +3 -7
  70. package/src/components/page-templates/fields.js +13 -9
  71. package/src/components/page-templates/index-legacy.js +166 -0
  72. package/src/components/post-list/index.js +34 -4
  73. package/src/components/post-list/use-notes-count.js +48 -0
  74. package/src/components/sidebar-global-styles/style.scss +0 -8
  75. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -0
  76. package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js +79 -0
  77. package/src/components/sidebar-navigation-screen-templates-browse/index.js +8 -1
  78. package/src/components/site-editor-routes/templates.js +22 -3
  79. package/src/components/site-hub/index.js +1 -1
  80. package/src/utils/constants.js +2 -0
@@ -19,21 +19,17 @@ const { useLocation, useHistory } = unlock( routerPrivateApis );
19
19
 
20
20
  function useNavigateToPreviousEntityRecord() {
21
21
  const location = useLocation();
22
- const previousLocation = usePrevious( location );
22
+ const previousCanvas = usePrevious( location.query.canvas );
23
23
  const history = useHistory();
24
24
  const goBack = useMemo( () => {
25
25
  const isFocusMode =
26
26
  location.query.focusMode ||
27
27
  ( location?.params?.postId &&
28
28
  FOCUSABLE_ENTITIES.includes( location?.params?.postType ) );
29
- const didComeFromEditorCanvas =
30
- previousLocation?.query.canvas === 'edit';
29
+ const didComeFromEditorCanvas = previousCanvas === 'edit';
31
30
  const showBackButton = isFocusMode && didComeFromEditorCanvas;
32
31
  return showBackButton ? () => history.back() : undefined;
33
- // `previousLocation` changes when the component updates for any reason, not
34
- // just when location changes. Until this is fixed we can't add it to deps. See
35
- // https://github.com/WordPress/gutenberg/pull/58710#discussion_r1479219465.
36
- }, [ location, history ] );
32
+ }, [ location, history, previousCanvas ] );
37
33
  return goBack;
38
34
  }
39
35
 
@@ -100,15 +100,19 @@ export const previewField = {
100
100
  export const descriptionField = {
101
101
  label: __( 'Description' ),
102
102
  id: 'description',
103
- render: function RenderDescription( { item } ) {
104
- const defaultTemplateTypes = useAllDefaultTemplateTypes();
105
- const defaultTemplateType = defaultTemplateTypes.find(
106
- ( type ) => type.slug === item.slug
107
- );
108
- return item.description
109
- ? decodeEntities( item.description )
110
- : defaultTemplateType?.description;
111
- },
103
+ render: window?.__experimentalTemplateActivate
104
+ ? function RenderDescription( { item } ) {
105
+ const defaultTemplateTypes = useAllDefaultTemplateTypes();
106
+ const defaultTemplateType = defaultTemplateTypes.find(
107
+ ( type ) => type.slug === item.slug
108
+ );
109
+ return item.description
110
+ ? decodeEntities( item.description )
111
+ : defaultTemplateType?.description;
112
+ }
113
+ : ( { item } ) => {
114
+ return item.description && decodeEntities( item.description );
115
+ },
112
116
  enableSorting: false,
113
117
  enableGlobalSearch: true,
114
118
  };
@@ -0,0 +1,166 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Page } from '@wordpress/admin-ui';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { useState, useMemo, useCallback } from '@wordpress/element';
7
+ import { privateApis as corePrivateApis } from '@wordpress/core-data';
8
+ import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
9
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
10
+ import { privateApis as editorPrivateApis } from '@wordpress/editor';
11
+ import { addQueryArgs } from '@wordpress/url';
12
+ import { useEvent } from '@wordpress/compose';
13
+ import { useView } from '@wordpress/views';
14
+ import { Button } from '@wordpress/components';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import AddNewTemplate from '../add-new-template-legacy';
20
+ import { TEMPLATE_POST_TYPE } from '../../utils/constants';
21
+ import { unlock } from '../../lock-unlock';
22
+ import { useEditPostAction } from '../dataviews-actions';
23
+ import { authorField, descriptionField, previewField } from './fields';
24
+ import { defaultLayouts, getDefaultView } from './view-utils';
25
+
26
+ const { usePostActions, templateTitleField } = unlock( editorPrivateApis );
27
+ const { useHistory, useLocation } = unlock( routerPrivateApis );
28
+ const { useEntityRecordsWithPermissions } = unlock( corePrivateApis );
29
+
30
+ export default function PageTemplates() {
31
+ const { path, query } = useLocation();
32
+ const { activeView = 'active', postId } = query;
33
+ const [ selection, setSelection ] = useState( [ postId ] );
34
+
35
+ const defaultView = useMemo( () => {
36
+ return getDefaultView( activeView );
37
+ }, [ activeView ] );
38
+ const { view, updateView, isModified, resetToDefault } = useView( {
39
+ kind: 'postType',
40
+ name: TEMPLATE_POST_TYPE,
41
+ slug: activeView,
42
+ defaultView,
43
+ queryParams: {
44
+ page: query.pageNumber,
45
+ search: query.search,
46
+ },
47
+ onChangeQueryParams: ( newQueryParams ) => {
48
+ history.navigate(
49
+ addQueryArgs( path, {
50
+ ...query,
51
+ pageNumber: newQueryParams.page,
52
+ search: newQueryParams.search || undefined,
53
+ } )
54
+ );
55
+ },
56
+ } );
57
+
58
+ const { records, isResolving: isLoadingData } =
59
+ useEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {
60
+ per_page: -1,
61
+ } );
62
+ const history = useHistory();
63
+ const onChangeSelection = useCallback(
64
+ ( items ) => {
65
+ setSelection( items );
66
+ if ( view?.type === 'list' ) {
67
+ history.navigate(
68
+ addQueryArgs( path, {
69
+ postId: items.length === 1 ? items[ 0 ] : undefined,
70
+ } )
71
+ );
72
+ }
73
+ },
74
+ [ history, path, view?.type ]
75
+ );
76
+
77
+ const authors = useMemo( () => {
78
+ if ( ! records ) {
79
+ return [];
80
+ }
81
+ const authorsSet = new Set();
82
+ records.forEach( ( template ) => {
83
+ authorsSet.add( template.author_text );
84
+ } );
85
+ return Array.from( authorsSet ).map( ( author ) => ( {
86
+ value: author,
87
+ label: author,
88
+ } ) );
89
+ }, [ records ] );
90
+
91
+ const fields = useMemo(
92
+ () => [
93
+ previewField,
94
+ templateTitleField,
95
+ descriptionField,
96
+ {
97
+ ...authorField,
98
+ elements: authors,
99
+ },
100
+ ],
101
+ [ authors ]
102
+ );
103
+
104
+ const { data, paginationInfo } = useMemo( () => {
105
+ return filterSortAndPaginate( records, view, fields );
106
+ }, [ records, view, fields ] );
107
+
108
+ const postTypeActions = usePostActions( {
109
+ postType: TEMPLATE_POST_TYPE,
110
+ context: 'list',
111
+ } );
112
+ const editAction = useEditPostAction();
113
+ const actions = useMemo(
114
+ () => [ editAction, ...postTypeActions ],
115
+ [ postTypeActions, editAction ]
116
+ );
117
+
118
+ const onChangeView = useEvent( ( newView ) => {
119
+ if ( newView.type !== view.type ) {
120
+ // Retrigger the routing areas resolution.
121
+ history.invalidate();
122
+ }
123
+ updateView( newView );
124
+ } );
125
+
126
+ return (
127
+ <Page
128
+ className="edit-site-page-templates"
129
+ title={ __( 'Templates' ) }
130
+ actions={
131
+ <>
132
+ { isModified && (
133
+ <Button
134
+ __next40pxDefaultSize
135
+ onClick={ () => {
136
+ resetToDefault();
137
+ history.invalidate();
138
+ } }
139
+ >
140
+ { __( 'Reset view' ) }
141
+ </Button>
142
+ ) }
143
+ <AddNewTemplate />
144
+ </>
145
+ }
146
+ >
147
+ <DataViews
148
+ key={ activeView }
149
+ paginationInfo={ paginationInfo }
150
+ fields={ fields }
151
+ actions={ actions }
152
+ data={ data }
153
+ isLoading={ isLoadingData }
154
+ view={ view }
155
+ onChangeView={ onChangeView }
156
+ onChangeSelection={ onChangeSelection }
157
+ isItemClickable={ () => true }
158
+ onClickItem={ ( { id } ) => {
159
+ history.navigate( `/wp_template/${ id }?canvas=edit` );
160
+ } }
161
+ selection={ selection }
162
+ defaultLayouts={ defaultLayouts }
163
+ />
164
+ </Page>
165
+ );
166
+ }
@@ -24,6 +24,8 @@ import { useView } from '@wordpress/views';
24
24
  import {
25
25
  OPERATOR_IS_ANY,
26
26
  OPERATOR_IS_NONE,
27
+ OPERATOR_BEFORE,
28
+ OPERATOR_AFTER,
27
29
  LAYOUT_LIST,
28
30
  } from '../../utils/constants';
29
31
 
@@ -31,6 +33,7 @@ import AddNewPostModal from '../add-new-post';
31
33
  import { unlock } from '../../lock-unlock';
32
34
  import { useEditPostAction } from '../dataviews-actions';
33
35
  import { defaultLayouts, getDefaultView } from './view-utils';
36
+ import useNotesCount from './use-notes-count';
34
37
 
35
38
  const { usePostActions, usePostFields } = unlock( editorPrivateApis );
36
39
  const { useLocation, useHistory } = unlock( routerPrivateApis );
@@ -123,6 +126,17 @@ export default function PostList( { postType } ) {
123
126
  ) {
124
127
  filters.author_exclude = filter.value;
125
128
  }
129
+ if ( filter.field === 'date' ) {
130
+ // Skip if no value is set yet
131
+ if ( ! filter.value ) {
132
+ return;
133
+ }
134
+ if ( filter.operator === OPERATOR_BEFORE ) {
135
+ filters.before = filter.value;
136
+ } else if ( filter.operator === OPERATOR_AFTER ) {
137
+ filters.after = filter.value;
138
+ }
139
+ }
126
140
  } );
127
141
 
128
142
  // We want to provide a different default item for the status filter
@@ -149,18 +163,34 @@ export default function PostList( { postType } ) {
149
163
  totalPages,
150
164
  } = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );
151
165
 
166
+ const postIds = useMemo(
167
+ () => records?.map( ( record ) => record.id ) ?? [],
168
+ [ records ]
169
+ );
170
+ const { notesCount, isLoading: isLoadingNotesCount } =
171
+ useNotesCount( postIds );
172
+
152
173
  // The REST API sort the authors by ID, but we want to sort them by name.
153
174
  const data = useMemo( () => {
175
+ let processedRecords = records;
176
+
154
177
  if ( view?.sort?.field === 'author' ) {
155
- return filterSortAndPaginate(
178
+ processedRecords = filterSortAndPaginate(
156
179
  records,
157
180
  { sort: { ...view.sort } },
158
181
  fields
159
182
  ).data;
160
183
  }
161
184
 
162
- return records;
163
- }, [ records, fields, view?.sort ] );
185
+ if ( processedRecords ) {
186
+ return processedRecords.map( ( record ) => ( {
187
+ ...record,
188
+ notesCount: notesCount[ record.id ] ?? 0,
189
+ } ) );
190
+ }
191
+
192
+ return processedRecords;
193
+ }, [ records, fields, view?.sort, notesCount ] );
164
194
 
165
195
  const ids = data?.map( ( record ) => getItemId( record ) ) ?? [];
166
196
  const prevIds = usePrevious( ids ) ?? [];
@@ -261,7 +291,7 @@ export default function PostList( { postType } ) {
261
291
  fields={ fields }
262
292
  actions={ actions }
263
293
  data={ data || EMPTY_ARRAY }
264
- isLoading={ isLoadingData }
294
+ isLoading={ isLoadingData || isLoadingNotesCount }
265
295
  view={ view }
266
296
  onChangeView={ onChangeView }
267
297
  selection={ selection }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo } from '@wordpress/element';
5
+ import { useEntityRecords } from '@wordpress/core-data';
6
+
7
+ /**
8
+ * Hook to fetch notes counts for a list of post IDs.
9
+ *
10
+ * Notes are stored as comments with type 'note'.
11
+ * This hook fetches all notes for the given posts and returns
12
+ * a map of post ID to notes count.
13
+ *
14
+ * @param {number[]} postIds - Array of post IDs to fetch notes for.
15
+ * @return {{ notesCount: Object, isResolving: boolean }} Object with notesCount map and loading state.
16
+ */
17
+ export default function useNotesCount( postIds ) {
18
+ const { records: notes, isResolving } = useEntityRecords(
19
+ 'root',
20
+ 'comment',
21
+ {
22
+ post: postIds,
23
+ type: 'note',
24
+ status: 'all',
25
+ per_page: -1,
26
+ _fields: 'id,post',
27
+ },
28
+ {
29
+ enabled: postIds?.length > 0,
30
+ }
31
+ );
32
+
33
+ const notesCount = useMemo( () => {
34
+ if ( ! notes || notes.length === 0 ) {
35
+ return {};
36
+ }
37
+
38
+ const counts = {};
39
+ notes.forEach( ( note ) => {
40
+ const postId = note.post;
41
+ counts[ postId ] = ( counts[ postId ] || 0 ) + 1;
42
+ } );
43
+
44
+ return counts;
45
+ }, [ notes ] );
46
+
47
+ return { notesCount, isResolving };
48
+ }
@@ -15,14 +15,6 @@
15
15
  overflow-y: auto;
16
16
  padding-left: 0;
17
17
  padding-right: 0;
18
-
19
- .global-styles-ui-sidebar__navigator-screen {
20
- padding-top: $grid-unit-15;
21
- padding-left: $grid-unit-15;
22
- padding-right: $grid-unit-15;
23
- padding-bottom: $grid-unit-15;
24
- outline: none;
25
- }
26
18
  }
27
19
  .edit-site-sidebar-button {
28
20
  color: $gray-900;
@@ -29,6 +29,7 @@ const useTemplatePartsGroupedByArea = ( items ) => {
29
29
  footer: {},
30
30
  sidebar: {},
31
31
  uncategorized: {},
32
+ overlay: {},
32
33
  };
33
34
 
34
35
  templatePartAreas.forEach(
@@ -0,0 +1,79 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEntityRecords } from '@wordpress/core-data';
5
+ import { useMemo } from '@wordpress/element';
6
+ import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
9
+ import { addQueryArgs } from '@wordpress/url';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import SidebarNavigationItem from '../sidebar-navigation-item';
15
+ import { useAddedBy } from '../page-templates/hooks';
16
+ import { layout } from '@wordpress/icons';
17
+ import { TEMPLATE_POST_TYPE } from '../../utils/constants';
18
+ import { unlock } from '../../lock-unlock';
19
+
20
+ const { useLocation } = unlock( routerPrivateApis );
21
+
22
+ const EMPTY_ARRAY = [];
23
+
24
+ function TemplateDataviewItem( { template, isActive } ) {
25
+ const { text, icon } = useAddedBy( template.type, template.id );
26
+
27
+ return (
28
+ <SidebarNavigationItem
29
+ to={ addQueryArgs( '/template', { activeView: text } ) }
30
+ icon={ icon }
31
+ aria-current={ isActive }
32
+ >
33
+ { text }
34
+ </SidebarNavigationItem>
35
+ );
36
+ }
37
+
38
+ export default function DataviewsTemplatesSidebarContent() {
39
+ const {
40
+ query: { activeView = 'all' },
41
+ } = useLocation();
42
+ const { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, {
43
+ per_page: -1,
44
+ } );
45
+ const firstItemPerAuthorText = useMemo( () => {
46
+ const firstItemPerAuthor = records?.reduce( ( acc, template ) => {
47
+ const author = template.author_text;
48
+ if ( author && ! acc[ author ] ) {
49
+ acc[ author ] = template;
50
+ }
51
+ return acc;
52
+ }, {} );
53
+ return (
54
+ ( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??
55
+ EMPTY_ARRAY
56
+ );
57
+ }, [ records ] );
58
+
59
+ return (
60
+ <ItemGroup className="edit-site-sidebar-navigation-screen-templates-browse">
61
+ <SidebarNavigationItem
62
+ to="/template"
63
+ icon={ layout }
64
+ aria-current={ activeView === 'all' }
65
+ >
66
+ { __( 'All templates' ) }
67
+ </SidebarNavigationItem>
68
+ { firstItemPerAuthorText.map( ( template ) => {
69
+ return (
70
+ <TemplateDataviewItem
71
+ key={ template.author_text }
72
+ template={ template }
73
+ isActive={ activeView === template.author_text }
74
+ />
75
+ );
76
+ } ) }
77
+ </ItemGroup>
78
+ );
79
+ }
@@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n';
8
8
  */
9
9
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
10
10
  import DataviewsTemplatesSidebarContent from './content';
11
+ import DataviewsTemplatesSidebarContentLegacy from './content-legacy';
11
12
 
12
13
  export default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {
13
14
  return (
@@ -17,7 +18,13 @@ export default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {
17
18
  'Create new templates, or reset any customizations made to the templates supplied by your theme.'
18
19
  ) }
19
20
  backPath={ backPath }
20
- content={ <DataviewsTemplatesSidebarContent /> }
21
+ content={
22
+ window?.__experimentalTemplateActivate ? (
23
+ <DataviewsTemplatesSidebarContent />
24
+ ) : (
25
+ <DataviewsTemplatesSidebarContentLegacy />
26
+ )
27
+ }
21
28
  />
22
29
  );
23
30
  }
@@ -10,6 +10,7 @@ import Editor from '../editor';
10
10
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
11
11
  import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
12
12
  import PageTemplates from '../page-templates';
13
+ import PageTemplatesLegacy from '../page-templates/index-legacy';
13
14
  import { getDefaultView } from '../page-templates/view-utils';
14
15
 
15
16
  async function isTemplateListView( query ) {
@@ -37,7 +38,16 @@ export const templatesRoute = {
37
38
  },
38
39
  content( { siteData } ) {
39
40
  const isBlockTheme = siteData.currentTheme?.is_block_theme;
40
- return isBlockTheme ? <PageTemplates /> : undefined;
41
+ if ( ! isBlockTheme ) {
42
+ return undefined;
43
+ }
44
+ // Use the new template activation system if experiment is enabled,
45
+ // otherwise use the legacy simple template list.
46
+ return window?.__experimentalTemplateActivate ? (
47
+ <PageTemplates />
48
+ ) : (
49
+ <PageTemplatesLegacy />
50
+ );
41
51
  },
42
52
  async preview( { query, siteData } ) {
43
53
  const isBlockTheme = siteData.currentTheme?.is_block_theme;
@@ -49,10 +59,19 @@ export const templatesRoute = {
49
59
  },
50
60
  mobile( { siteData } ) {
51
61
  const isBlockTheme = siteData.currentTheme?.is_block_theme;
52
- return isBlockTheme ? (
62
+ if ( ! isBlockTheme ) {
63
+ return <SidebarNavigationScreenUnsupported />;
64
+ }
65
+ // Check if the template activation experiment is enabled.
66
+ const isTemplateActivateEnabled =
67
+ typeof window !== 'undefined' &&
68
+ window.__experimentalTemplateActivate;
69
+ // Use the new template activation system if experiment is enabled,
70
+ // otherwise use the legacy simple template list.
71
+ return isTemplateActivateEnabled ? (
53
72
  <PageTemplates />
54
73
  ) : (
55
- <SidebarNavigationScreenUnsupported />
74
+ <PageTemplatesLegacy />
56
75
  );
57
76
  },
58
77
  },
@@ -134,7 +134,7 @@ export const SiteHubMobile = memo(
134
134
  const currentTheme = getCurrentTheme();
135
135
  const settings = getSettings();
136
136
  const supportsEditorStyles =
137
- currentTheme.theme_supports[ 'editor-styles' ];
137
+ currentTheme?.theme_supports[ 'editor-styles' ];
138
138
  // This is a temp solution until the has_theme_json value is available for the current theme.
139
139
  const hasThemeJson = settings.supportsLayout;
140
140
 
@@ -55,3 +55,5 @@ export const OPERATOR_IS = 'is';
55
55
  export const OPERATOR_IS_NOT = 'isNot';
56
56
  export const OPERATOR_IS_ANY = 'isAny';
57
57
  export const OPERATOR_IS_NONE = 'isNone';
58
+ export const OPERATOR_BEFORE = 'before';
59
+ export const OPERATOR_AFTER = 'after';