@wordpress/edit-site 6.33.4 → 6.33.6
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.
- package/build/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +2 -2
- package/build/components/add-new-template/index.js +6 -4
- package/build/components/add-new-template/index.js.map +2 -2
- package/build/components/add-new-template/utils.js +84 -9
- package/build/components/add-new-template/utils.js.map +2 -2
- package/build/components/dataviews-actions/index.js +2 -55
- package/build/components/dataviews-actions/index.js.map +3 -3
- package/build/components/editor/index.js +0 -1
- package/build/components/editor/index.js.map +2 -2
- package/build/components/editor/use-resolve-edited-entity.js +5 -11
- package/build/components/editor/use-resolve-edited-entity.js.map +2 -2
- package/build/components/page-templates/fields.js +5 -80
- package/build/components/page-templates/fields.js.map +3 -3
- package/build/components/page-templates/hooks.js +1 -1
- package/build/components/page-templates/hooks.js.map +2 -2
- package/build/components/page-templates/index.js +46 -217
- package/build/components/page-templates/index.js.map +3 -3
- package/build/components/page-templates/view-utils.js +1 -5
- package/build/components/page-templates/view-utils.js.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +6 -21
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build/components/site-editor-routes/template-item.js +14 -15
- package/build/components/site-editor-routes/template-item.js.map +2 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +2 -2
- package/build-module/components/add-new-template/index.js +7 -4
- package/build-module/components/add-new-template/index.js.map +2 -2
- package/build-module/components/add-new-template/utils.js +84 -9
- package/build-module/components/add-new-template/utils.js.map +2 -2
- package/build-module/components/dataviews-actions/index.js +1 -53
- package/build-module/components/dataviews-actions/index.js.map +2 -2
- package/build-module/components/editor/index.js +0 -1
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/editor/use-resolve-edited-entity.js +5 -11
- package/build-module/components/editor/use-resolve-edited-entity.js.map +2 -2
- package/build-module/components/page-templates/fields.js +6 -85
- package/build-module/components/page-templates/fields.js.map +3 -3
- package/build-module/components/page-templates/hooks.js +1 -1
- package/build-module/components/page-templates/hooks.js.map +2 -2
- package/build-module/components/page-templates/index.js +51 -235
- package/build-module/components/page-templates/index.js.map +2 -2
- package/build-module/components/page-templates/view-utils.js +1 -5
- package/build-module/components/page-templates/view-utils.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +7 -22
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +2 -2
- package/build-module/components/site-editor-routes/template-item.js +14 -15
- package/build-module/components/site-editor-routes/template-item.js.map +2 -2
- package/package.json +17 -17
- package/src/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/src/components/add-new-template/index.js +9 -4
- package/src/components/add-new-template/utils.js +118 -9
- package/src/components/dataviews-actions/index.js +0 -61
- package/src/components/editor/index.js +0 -1
- package/src/components/editor/use-resolve-edited-entity.js +5 -20
- package/src/components/page-templates/fields.js +5 -95
- package/src/components/page-templates/hooks.js +1 -1
- package/src/components/page-templates/index.js +35 -244
- package/src/components/page-templates/view-utils.js +1 -8
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +7 -22
- package/src/components/site-editor-routes/template-item.js +26 -28
|
@@ -34,32 +34,28 @@ module.exports = __toCommonJS(page_templates_exports);
|
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_admin_ui = require("@wordpress/admin-ui");
|
|
36
36
|
var import_i18n = require("@wordpress/i18n");
|
|
37
|
-
var import_html_entities = require("@wordpress/html-entities");
|
|
38
37
|
var import_element = require("@wordpress/element");
|
|
39
38
|
var import_core_data = require("@wordpress/core-data");
|
|
40
39
|
var import_dataviews = require("@wordpress/dataviews");
|
|
41
40
|
var import_router = require("@wordpress/router");
|
|
42
41
|
var import_editor = require("@wordpress/editor");
|
|
43
42
|
var import_url = require("@wordpress/url");
|
|
44
|
-
var import_data = require("@wordpress/data");
|
|
45
43
|
var import_compose = require("@wordpress/compose");
|
|
46
44
|
var import_views = require("@wordpress/views");
|
|
47
45
|
var import_components = require("@wordpress/components");
|
|
48
|
-
var import_notices = require("@wordpress/notices");
|
|
49
46
|
var import_add_new_template = __toESM(require("../add-new-template"));
|
|
50
47
|
var import_constants = require("../../utils/constants");
|
|
51
48
|
var import_lock_unlock = require("../../lock-unlock");
|
|
52
49
|
var import_dataviews_actions = require("../dataviews-actions");
|
|
53
50
|
var import_fields = require("./fields");
|
|
54
51
|
var import_view_utils = require("./view-utils");
|
|
55
|
-
const { usePostActions,
|
|
52
|
+
const { usePostActions, templateTitleField } = (0, import_lock_unlock.unlock)(import_editor.privateApis);
|
|
56
53
|
const { useHistory, useLocation } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
57
54
|
const { useEntityRecordsWithPermissions } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
|
|
58
55
|
function PageTemplates() {
|
|
59
56
|
const { path, query } = useLocation();
|
|
60
57
|
const { activeView = "active", postId } = query;
|
|
61
58
|
const [selection, setSelection] = (0, import_element.useState)([postId]);
|
|
62
|
-
const [selectedRegisteredTemplate, setSelectedRegisteredTemplate] = (0, import_element.useState)(false);
|
|
63
59
|
const defaultView = (0, import_element.useMemo)(() => {
|
|
64
60
|
return (0, import_view_utils.getDefaultView)(activeView);
|
|
65
61
|
}, [activeView]);
|
|
@@ -82,105 +78,9 @@ function PageTemplates() {
|
|
|
82
78
|
);
|
|
83
79
|
}
|
|
84
80
|
});
|
|
85
|
-
const {
|
|
86
|
-
const { getEntityRecord, getCurrentTheme } = select(import_core_data.store);
|
|
87
|
-
return {
|
|
88
|
-
activeTemplatesOption: getEntityRecord("root", "site")?.active_templates,
|
|
89
|
-
activeTheme: getCurrentTheme(),
|
|
90
|
-
defaultTemplateTypes: select(import_core_data.store).getCurrentTheme()?.default_template_types
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
const { records: userRecords, isResolving: isLoadingUserRecords } = useEntityRecordsWithPermissions("postType", import_constants.TEMPLATE_POST_TYPE, {
|
|
94
|
-
per_page: -1,
|
|
95
|
-
combinedTemplates: false
|
|
96
|
-
});
|
|
97
|
-
const { records: staticRecords, isResolving: isLoadingStaticData } = 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.
|
|
81
|
+
const { records, isResolving: isLoadingData } = useEntityRecordsWithPermissions("postType", import_constants.TEMPLATE_POST_TYPE, {
|
|
101
82
|
per_page: -1
|
|
102
83
|
});
|
|
103
|
-
const activeTemplates = (0, import_element.useMemo)(() => {
|
|
104
|
-
const _active = [...staticRecords];
|
|
105
|
-
if (activeTemplatesOption) {
|
|
106
|
-
for (const activeSlug in activeTemplatesOption) {
|
|
107
|
-
const activeId = activeTemplatesOption[activeSlug];
|
|
108
|
-
const template = userRecords.find(
|
|
109
|
-
(userRecord) => userRecord.id === activeId && userRecord.theme === activeTheme.stylesheet
|
|
110
|
-
);
|
|
111
|
-
if (template) {
|
|
112
|
-
const index = _active.findIndex(
|
|
113
|
-
({ slug }) => slug === template.slug
|
|
114
|
-
);
|
|
115
|
-
if (index !== -1) {
|
|
116
|
-
_active[index] = template;
|
|
117
|
-
} else {
|
|
118
|
-
_active.push(template);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return _active;
|
|
124
|
-
}, [userRecords, staticRecords, activeTemplatesOption, activeTheme]);
|
|
125
|
-
let isLoadingData;
|
|
126
|
-
if (activeView === "active") {
|
|
127
|
-
isLoadingData = isLoadingUserRecords || isLoadingStaticData;
|
|
128
|
-
} else if (activeView === "user") {
|
|
129
|
-
isLoadingData = isLoadingUserRecords;
|
|
130
|
-
} else {
|
|
131
|
-
isLoadingData = isLoadingStaticData;
|
|
132
|
-
}
|
|
133
|
-
const records = (0, import_element.useMemo)(() => {
|
|
134
|
-
function isCustom(record) {
|
|
135
|
-
return record.is_custom ?? // For user templates it's custom if the is_wp_suggestion meta
|
|
136
|
-
// field is not set and the slug is not found in the default
|
|
137
|
-
// template types.
|
|
138
|
-
(!record.meta?.is_wp_suggestion && !defaultTemplateTypes.some(
|
|
139
|
-
(type) => type.slug === record.slug
|
|
140
|
-
));
|
|
141
|
-
}
|
|
142
|
-
let _records;
|
|
143
|
-
if (activeView === "active") {
|
|
144
|
-
_records = activeTemplates.filter(
|
|
145
|
-
(record) => !isCustom(record)
|
|
146
|
-
);
|
|
147
|
-
} else if (activeView === "user") {
|
|
148
|
-
_records = userRecords;
|
|
149
|
-
} else {
|
|
150
|
-
_records = staticRecords;
|
|
151
|
-
}
|
|
152
|
-
return _records.map((record) => ({
|
|
153
|
-
...record,
|
|
154
|
-
_isActive: activeTemplates.some(
|
|
155
|
-
(template) => template.id === record.id
|
|
156
|
-
),
|
|
157
|
-
_isCustom: isCustom(record)
|
|
158
|
-
}));
|
|
159
|
-
}, [
|
|
160
|
-
activeTemplates,
|
|
161
|
-
defaultTemplateTypes,
|
|
162
|
-
userRecords,
|
|
163
|
-
staticRecords,
|
|
164
|
-
activeView
|
|
165
|
-
]);
|
|
166
|
-
const users = (0, import_data.useSelect)(
|
|
167
|
-
(select) => {
|
|
168
|
-
const { getUser } = select(import_core_data.store);
|
|
169
|
-
return records.reduce((acc, record) => {
|
|
170
|
-
if (record.author_text) {
|
|
171
|
-
if (!acc[record.author_text]) {
|
|
172
|
-
acc[record.author_text] = record.author_text;
|
|
173
|
-
}
|
|
174
|
-
} else if (record.author) {
|
|
175
|
-
if (!acc[record.author]) {
|
|
176
|
-
acc[record.author] = getUser(record.author);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return acc;
|
|
180
|
-
}, {});
|
|
181
|
-
},
|
|
182
|
-
[records]
|
|
183
|
-
);
|
|
184
84
|
const history = useHistory();
|
|
185
85
|
const onChangeSelection = (0, import_element.useCallback)(
|
|
186
86
|
(items) => {
|
|
@@ -195,87 +95,42 @@ function PageTemplates() {
|
|
|
195
95
|
},
|
|
196
96
|
[history, path, view?.type]
|
|
197
97
|
);
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
98
|
+
const authors = (0, import_element.useMemo)(() => {
|
|
99
|
+
if (!records) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const authorsSet = /* @__PURE__ */ new Set();
|
|
103
|
+
records.forEach((template) => {
|
|
104
|
+
authorsSet.add(template.author_text);
|
|
105
|
+
});
|
|
106
|
+
return Array.from(authorsSet).map((author) => ({
|
|
107
|
+
value: author,
|
|
108
|
+
label: author
|
|
109
|
+
}));
|
|
110
|
+
}, [records]);
|
|
111
|
+
const fields = (0, import_element.useMemo)(
|
|
112
|
+
() => [
|
|
205
113
|
import_fields.previewField,
|
|
206
114
|
templateTitleField,
|
|
207
115
|
import_fields.descriptionField,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (activeView === "user") {
|
|
212
|
-
_fields.push(themeField);
|
|
213
|
-
if (dateField) {
|
|
214
|
-
_fields.push(dateField);
|
|
116
|
+
{
|
|
117
|
+
...import_fields.authorField,
|
|
118
|
+
elements: authors
|
|
215
119
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
elements.push({
|
|
220
|
-
value: users[author]?.id ?? author,
|
|
221
|
-
label: users[author]?.name ?? author
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
_fields.push({
|
|
225
|
-
...import_fields.authorField,
|
|
226
|
-
elements
|
|
227
|
-
});
|
|
228
|
-
return _fields;
|
|
229
|
-
}, [users, activeView, themeField, dateField]);
|
|
120
|
+
],
|
|
121
|
+
[authors]
|
|
122
|
+
);
|
|
230
123
|
const { data, paginationInfo } = (0, import_element.useMemo)(() => {
|
|
231
124
|
return (0, import_dataviews.filterSortAndPaginate)(records, view, fields);
|
|
232
125
|
}, [records, view, fields]);
|
|
233
|
-
const { createSuccessNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
234
|
-
const onActionPerformed = (0, import_element.useCallback)(
|
|
235
|
-
(actionId, items) => {
|
|
236
|
-
switch (actionId) {
|
|
237
|
-
case "duplicate-post":
|
|
238
|
-
{
|
|
239
|
-
const newItem = items[0];
|
|
240
|
-
const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
|
|
241
|
-
history.navigate(`/template?activeView=user`);
|
|
242
|
-
createSuccessNotice(
|
|
243
|
-
(0, import_i18n.sprintf)(
|
|
244
|
-
// translators: %s: Title of the created post or template, e.g: "Hello world".
|
|
245
|
-
(0, import_i18n.__)('"%s" successfully created.'),
|
|
246
|
-
(0, import_html_entities.decodeEntities)(_title) || (0, import_i18n.__)("(no title)")
|
|
247
|
-
),
|
|
248
|
-
{
|
|
249
|
-
type: "snackbar",
|
|
250
|
-
id: "duplicate-post-action",
|
|
251
|
-
actions: [
|
|
252
|
-
{
|
|
253
|
-
label: (0, import_i18n.__)("Edit"),
|
|
254
|
-
onClick: () => {
|
|
255
|
-
history.navigate(
|
|
256
|
-
`/${newItem.type}/${newItem.id}?canvas=edit`
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
}
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
[history, createSuccessNotice]
|
|
268
|
-
);
|
|
269
126
|
const postTypeActions = usePostActions({
|
|
270
127
|
postType: import_constants.TEMPLATE_POST_TYPE,
|
|
271
|
-
context: "list"
|
|
272
|
-
onActionPerformed
|
|
128
|
+
context: "list"
|
|
273
129
|
});
|
|
274
130
|
const editAction = (0, import_dataviews_actions.useEditPostAction)();
|
|
275
|
-
const setActiveTemplateAction = (0, import_dataviews_actions.useSetActiveTemplateAction)();
|
|
276
131
|
const actions = (0, import_element.useMemo)(
|
|
277
|
-
() =>
|
|
278
|
-
[postTypeActions,
|
|
132
|
+
() => [editAction, ...postTypeActions],
|
|
133
|
+
[postTypeActions, editAction]
|
|
279
134
|
);
|
|
280
135
|
const onChangeView = (0, import_compose.useEvent)((newView) => {
|
|
281
136
|
if (newView.type !== view.type) {
|
|
@@ -283,10 +138,7 @@ function PageTemplates() {
|
|
|
283
138
|
}
|
|
284
139
|
updateView(newView);
|
|
285
140
|
});
|
|
286
|
-
|
|
287
|
-
(action) => action.id === "duplicate-post"
|
|
288
|
-
);
|
|
289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
290
142
|
import_admin_ui.Page,
|
|
291
143
|
{
|
|
292
144
|
className: "edit-site-page-templates",
|
|
@@ -305,49 +157,26 @@ function PageTemplates() {
|
|
|
305
157
|
),
|
|
306
158
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_add_new_template.default, {})
|
|
307
159
|
] }),
|
|
308
|
-
children:
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (typeof item.id === "string") {
|
|
323
|
-
setSelectedRegisteredTemplate(item);
|
|
324
|
-
} else {
|
|
325
|
-
history.navigate(
|
|
326
|
-
`/${item.type}/${item.id}?canvas=edit`
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
selection,
|
|
331
|
-
defaultLayouts: import_view_utils.defaultLayouts
|
|
160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
+
import_dataviews.DataViews,
|
|
162
|
+
{
|
|
163
|
+
paginationInfo,
|
|
164
|
+
fields,
|
|
165
|
+
actions,
|
|
166
|
+
data,
|
|
167
|
+
isLoading: isLoadingData,
|
|
168
|
+
view,
|
|
169
|
+
onChangeView,
|
|
170
|
+
onChangeSelection,
|
|
171
|
+
isItemClickable: () => true,
|
|
172
|
+
onClickItem: ({ id }) => {
|
|
173
|
+
history.navigate(`/wp_template/${id}?canvas=edit`);
|
|
332
174
|
},
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
title: (0, import_i18n.__)("Duplicate"),
|
|
339
|
-
onRequestClose: () => setSelectedRegisteredTemplate(),
|
|
340
|
-
size: "small",
|
|
341
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
342
|
-
duplicateAction.RenderModal,
|
|
343
|
-
{
|
|
344
|
-
items: [selectedRegisteredTemplate],
|
|
345
|
-
closeModal: () => setSelectedRegisteredTemplate()
|
|
346
|
-
}
|
|
347
|
-
)
|
|
348
|
-
}
|
|
349
|
-
)
|
|
350
|
-
]
|
|
175
|
+
selection,
|
|
176
|
+
defaultLayouts: import_view_utils.defaultLayouts
|
|
177
|
+
},
|
|
178
|
+
activeView
|
|
179
|
+
)
|
|
351
180
|
}
|
|
352
181
|
);
|
|
353
182
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Page } from '@wordpress/admin-ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState, useMemo, useCallback } from '@wordpress/element';\nimport {\n\tprivateApis as corePrivateApis,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEvent } from '@wordpress/compose';\nimport { useView } from '@wordpress/views';\nimport { Button, Modal } from '@wordpress/components';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddNewTemplate from '../add-new-template';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tuseEditPostAction,\n\tuseSetActiveTemplateAction,\n} from '../dataviews-actions';\nimport {\n\tauthorField,\n\tdescriptionField,\n\tpreviewField,\n\tactiveField,\n\tslugField,\n\tuseThemeField,\n} from './fields';\nimport { defaultLayouts, getDefaultView } from './view-utils';\n\nconst { usePostActions, usePostFields, templateTitleField } =\n\tunlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'active', postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\tconst [ selectedRegisteredTemplate, setSelectedRegisteredTemplate ] =\n\t\tuseState( false );\n\tconst defaultView = useMemo( () => {\n\t\treturn getDefaultView( activeView );\n\t}, [ activeView ] );\n\tconst { view, updateView, isModified, resetToDefault } = useView( {\n\t\tkind: 'postType',\n\t\tname: TEMPLATE_POST_TYPE,\n\t\tslug: activeView,\n\t\tdefaultView,\n\t\tqueryParams: {\n\t\t\tpage: query.pageNumber,\n\t\t\tsearch: query.search,\n\t\t},\n\t\tonChangeQueryParams: ( newQueryParams ) => {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t...query,\n\t\t\t\t\tpageNumber: newQueryParams.page,\n\t\t\t\t\tsearch: newQueryParams.search || undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t} );\n\n\tconst { activeTemplatesOption, activeTheme, defaultTemplateTypes } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, getCurrentTheme } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tactiveTemplatesOption: getEntityRecord( 'root', 'site' )\n\t\t\t\t\t?.active_templates,\n\t\t\t\tactiveTheme: getCurrentTheme(),\n\t\t\t\tdefaultTemplateTypes:\n\t\t\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t\t\t?.default_template_types,\n\t\t\t};\n\t\t} );\n\t// Todo: this will have to be better so that we're not fetching all the\n\t// records all the time. Active templates query will need to move server\n\t// side.\n\tconst { records: userRecords, isResolving: isLoadingUserRecords } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t\tcombinedTemplates: false,\n\t\t} );\n\tconst { records: staticRecords, isResolving: isLoadingStaticData } =\n\t\tuseEntityRecordsWithPermissions( 'root', 'registeredTemplate', {\n\t\t\t// This should not be needed, the endpoint returns all registered\n\t\t\t// templates, but it's not possible right now to turn off pagination\n\t\t\t// for entity configs.\n\t\t\tper_page: -1,\n\t\t} );\n\n\tconst activeTemplates = useMemo( () => {\n\t\tconst _active = [ ...staticRecords ];\n\t\tif ( activeTemplatesOption ) {\n\t\t\tfor ( const activeSlug in activeTemplatesOption ) {\n\t\t\t\tconst activeId = activeTemplatesOption[ activeSlug ];\n\t\t\t\t// Replace the template in the array.\n\t\t\t\tconst template = userRecords.find(\n\t\t\t\t\t( userRecord ) =>\n\t\t\t\t\t\tuserRecord.id === activeId &&\n\t\t\t\t\t\tuserRecord.theme === activeTheme.stylesheet\n\t\t\t\t);\n\t\t\t\tif ( template ) {\n\t\t\t\t\tconst index = _active.findIndex(\n\t\t\t\t\t\t( { slug } ) => slug === template.slug\n\t\t\t\t\t);\n\t\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\t\t_active[ index ] = template;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_active.push( template );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn _active;\n\t}, [ userRecords, staticRecords, activeTemplatesOption, activeTheme ] );\n\n\tlet isLoadingData;\n\tif ( activeView === 'active' ) {\n\t\tisLoadingData = isLoadingUserRecords || isLoadingStaticData;\n\t} else if ( activeView === 'user' ) {\n\t\tisLoadingData = isLoadingUserRecords;\n\t} else {\n\t\tisLoadingData = isLoadingStaticData;\n\t}\n\n\tconst records = useMemo( () => {\n\t\tfunction isCustom( record ) {\n\t\t\t// For registered templates, the is_custom field is defined.\n\t\t\treturn (\n\t\t\t\trecord.is_custom ??\n\t\t\t\t// For user templates it's custom if the is_wp_suggestion meta\n\t\t\t\t// field is not set and the slug is not found in the default\n\t\t\t\t// template types.\n\t\t\t\t( ! record.meta?.is_wp_suggestion &&\n\t\t\t\t\t! defaultTemplateTypes.some(\n\t\t\t\t\t\t( type ) => type.slug === record.slug\n\t\t\t\t\t) )\n\t\t\t);\n\t\t}\n\n\t\tlet _records;\n\t\tif ( activeView === 'active' ) {\n\t\t\t// Don't show active custom templates in the active view.\n\t\t\t_records = activeTemplates.filter(\n\t\t\t\t( record ) => ! isCustom( record )\n\t\t\t);\n\t\t} else if ( activeView === 'user' ) {\n\t\t\t_records = userRecords;\n\t\t} else {\n\t\t\t_records = staticRecords;\n\t\t}\n\t\treturn _records.map( ( record ) => ( {\n\t\t\t...record,\n\t\t\t_isActive: activeTemplates.some(\n\t\t\t\t( template ) => template.id === record.id\n\t\t\t),\n\t\t\t_isCustom: isCustom( record ),\n\t\t} ) );\n\t}, [\n\t\tactiveTemplates,\n\t\tdefaultTemplateTypes,\n\t\tuserRecords,\n\t\tstaticRecords,\n\t\tactiveView,\n\t] );\n\n\tconst users = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\treturn records.reduce( ( acc, record ) => {\n\t\t\t\tif ( record.author_text ) {\n\t\t\t\t\tif ( ! acc[ record.author_text ] ) {\n\t\t\t\t\t\tacc[ record.author_text ] = record.author_text;\n\t\t\t\t\t}\n\t\t\t\t} else if ( record.author ) {\n\t\t\t\t\tif ( ! acc[ record.author ] ) {\n\t\t\t\t\t\tacc[ record.author ] = getUser( record.author );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t}, {} );\n\t\t},\n\t\t[ records ]\n\t);\n\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === 'list' ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst postTypeFields = usePostFields( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t} );\n\tconst dateField = postTypeFields.find( ( field ) => field.id === 'date' );\n\tconst themeField = useThemeField();\n\tconst fields = useMemo( () => {\n\t\tconst _fields = [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\tactiveField,\n\t\t\tslugField,\n\t\t];\n\t\tif ( activeView === 'user' ) {\n\t\t\t_fields.push( themeField );\n\t\t\tif ( dateField ) {\n\t\t\t\t_fields.push( dateField );\n\t\t\t}\n\t\t}\n\t\tconst elements = [];\n\t\tfor ( const author in users ) {\n\t\t\telements.push( {\n\t\t\t\tvalue: users[ author ]?.id ?? author,\n\t\t\t\tlabel: users[ author ]?.name ?? author,\n\t\t\t} );\n\t\t}\n\t\t_fields.push( {\n\t\t\t...authorField,\n\t\t\telements,\n\t\t} );\n\t\treturn _fields;\n\t}, [ users, activeView, themeField, dateField ] );\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst _title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\thistory.navigate( `/template?activeView=user` );\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( _title ) || __( '(no title)' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t`/${ newItem.type }/${ newItem.id }?canvas=edit`\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ history, createSuccessNotice ]\n\t);\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t\tonActionPerformed,\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst setActiveTemplateAction = useSetActiveTemplateAction();\n\tconst actions = useMemo(\n\t\t() =>\n\t\t\tactiveView === 'user'\n\t\t\t\t? [ setActiveTemplateAction, editAction, ...postTypeActions ]\n\t\t\t\t: [ setActiveTemplateAction, ...postTypeActions ],\n\t\t[ postTypeActions, setActiveTemplateAction, editAction, activeView ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tif ( newView.type !== view.type ) {\n\t\t\t// Retrigger the routing areas resolution.\n\t\t\thistory.invalidate();\n\t\t}\n\t\tupdateView( newView );\n\t} );\n\n\tconst duplicateAction = actions.find(\n\t\t( action ) => action.id === 'duplicate-post'\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t{ isModified && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tresetToDefault();\n\t\t\t\t\t\t\t\thistory.invalidate();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset view' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t<AddNewTemplate />\n\t\t\t\t</>\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( item ) => {\n\t\t\t\t\tif ( typeof item.id === 'string' ) {\n\t\t\t\t\t\tsetSelectedRegisteredTemplate( item );\n\t\t\t\t\t} else {\n\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t`/${ item.type }/${ item.id }?canvas=edit`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t\t{ selectedRegisteredTemplate && duplicateAction && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Duplicate' ) }\n\t\t\t\t\tonRequestClose={ () => setSelectedRegisteredTemplate() }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t>\n\t\t\t\t\t<duplicateAction.RenderModal\n\t\t\t\t\t\titems={ [ selectedRegisteredTemplate ] }\n\t\t\t\t\t\tcloseModal={ () => setSelectedRegisteredTemplate() }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</Page>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["editorPrivateApis", "routerPrivateApis", "corePrivateApis", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Page } from '@wordpress/admin-ui';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback } from '@wordpress/element';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEvent } from '@wordpress/compose';\nimport { useView } from '@wordpress/views';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport AddNewTemplate from '../add-new-template';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { authorField, descriptionField, previewField } from './fields';\nimport { defaultLayouts, getDefaultView } from './view-utils';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'active', postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\treturn getDefaultView( activeView );\n\t}, [ activeView ] );\n\tconst { view, updateView, isModified, resetToDefault } = useView( {\n\t\tkind: 'postType',\n\t\tname: TEMPLATE_POST_TYPE,\n\t\tslug: activeView,\n\t\tdefaultView,\n\t\tqueryParams: {\n\t\t\tpage: query.pageNumber,\n\t\t\tsearch: query.search,\n\t\t},\n\t\tonChangeQueryParams: ( newQueryParams ) => {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t...query,\n\t\t\t\t\tpageNumber: newQueryParams.page,\n\t\t\t\t\tsearch: newQueryParams.search || undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t} );\n\n\tconst { records, isResolving: isLoadingData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === 'list' ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\t{\n\t\t\t\t...authorField,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tif ( newView.type !== view.type ) {\n\t\t\t// Retrigger the routing areas resolution.\n\t\t\thistory.invalidate();\n\t\t}\n\t\tupdateView( newView );\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t{ isModified && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tresetToDefault();\n\t\t\t\t\t\t\t\thistory.invalidate();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset view' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t<AddNewTemplate />\n\t\t\t\t</>\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/wp_template/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["editorPrivateApis", "routerPrivateApis", "corePrivateApis", "AddNewTemplate"]
|
|
7
7
|
}
|
|
@@ -43,17 +43,13 @@ const DEFAULT_VIEW = {
|
|
|
43
43
|
titleField: "title",
|
|
44
44
|
descriptionField: "description",
|
|
45
45
|
mediaField: "preview",
|
|
46
|
-
fields: ["author", "active", "slug"
|
|
46
|
+
fields: ["author", "active", "slug"],
|
|
47
47
|
filters: [],
|
|
48
48
|
...defaultLayouts.grid
|
|
49
49
|
};
|
|
50
50
|
function getDefaultView(activeView) {
|
|
51
51
|
return {
|
|
52
52
|
...DEFAULT_VIEW,
|
|
53
|
-
sort: activeView === "user" ? {
|
|
54
|
-
field: "date",
|
|
55
|
-
direction: "desc"
|
|
56
|
-
} : DEFAULT_VIEW.sort,
|
|
57
53
|
filters: !["active", "user"].includes(activeView) ? [
|
|
58
54
|
{
|
|
59
55
|
field: "author",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/view-utils.js"],
|
|
4
|
-
"sourcesContent": ["export const defaultLayouts = {\n\ttable: {\n\t\tshowMedia: false,\n\t},\n\tgrid: {\n\t\tshowMedia: true,\n\t},\n\tlist: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: 'grid',\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author', 'active', 'slug'
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB;AAAA,EAC7B,OAAO;AAAA,IACN,WAAW;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACL,WAAW;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACL,WAAW;AAAA,EACZ;AACD;AAEA,MAAM,eAAe;AAAA,EACpB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,IACL,OAAO;AAAA,IACP,WAAW;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,QAAQ,CAAE,UAAU,UAAU,
|
|
4
|
+
"sourcesContent": ["export const defaultLayouts = {\n\ttable: {\n\t\tshowMedia: false,\n\t},\n\tgrid: {\n\t\tshowMedia: true,\n\t},\n\tlist: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: 'grid',\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author', 'active', 'slug' ],\n\tfilters: [],\n\t...defaultLayouts.grid,\n};\n\nexport function getDefaultView( activeView ) {\n\treturn {\n\t\t...DEFAULT_VIEW,\n\t\tfilters: ! [ 'active', 'user' ].includes( activeView )\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [],\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB;AAAA,EAC7B,OAAO;AAAA,IACN,WAAW;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACL,WAAW;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACL,WAAW;AAAA,EACZ;AACD;AAEA,MAAM,eAAe;AAAA,EACpB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,IACL,OAAO;AAAA,IACP,WAAW;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,QAAQ,CAAE,UAAU,UAAU,MAAO;AAAA,EACrC,SAAS,CAAC;AAAA,EACV,GAAG,eAAe;AACnB;AAEO,SAAS,eAAgB,YAAa;AAC5C,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAE,CAAE,UAAU,MAAO,EAAE,SAAU,UAAW,IAClD;AAAA,MACA;AAAA,QACC,OAAO;AAAA,QACP,UAAU;AAAA,QACV,OAAO,CAAE,UAAW;AAAA,MACrB;AAAA,IACA,IACA,CAAC;AAAA,EACL;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -41,6 +41,7 @@ var import_url = require("@wordpress/url");
|
|
|
41
41
|
var import_sidebar_navigation_item = __toESM(require("../sidebar-navigation-item"));
|
|
42
42
|
var import_hooks = require("../page-templates/hooks");
|
|
43
43
|
var import_icons = require("@wordpress/icons");
|
|
44
|
+
var import_constants = require("../../utils/constants");
|
|
44
45
|
var import_lock_unlock = require("../../lock-unlock");
|
|
45
46
|
const { useLocation } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
46
47
|
const EMPTY_ARRAY = [];
|
|
@@ -58,12 +59,9 @@ function TemplateDataviewItem({ template, isActive }) {
|
|
|
58
59
|
}
|
|
59
60
|
function DataviewsTemplatesSidebarContent() {
|
|
60
61
|
const {
|
|
61
|
-
query: { activeView = "
|
|
62
|
+
query: { activeView = "all" }
|
|
62
63
|
} = useLocation();
|
|
63
|
-
const { records } = (0, import_core_data.useEntityRecords)("
|
|
64
|
-
// This should not be needed, the endpoint returns all registered
|
|
65
|
-
// templates, but it's not possible right now to turn off pagination for
|
|
66
|
-
// entity configs.
|
|
64
|
+
const { records } = (0, import_core_data.useEntityRecords)("postType", import_constants.TEMPLATE_POST_TYPE, {
|
|
67
65
|
per_page: -1
|
|
68
66
|
});
|
|
69
67
|
const firstItemPerAuthorText = (0, import_element.useMemo)(() => {
|
|
@@ -81,22 +79,9 @@ function DataviewsTemplatesSidebarContent() {
|
|
|
81
79
|
import_sidebar_navigation_item.default,
|
|
82
80
|
{
|
|
83
81
|
to: "/template",
|
|
84
|
-
icon: import_icons.
|
|
85
|
-
"aria-current": activeView === "
|
|
86
|
-
children: (0, import_i18n.__)("
|
|
87
|
-
}
|
|
88
|
-
),
|
|
89
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
|
-
import_sidebar_navigation_item.default,
|
|
91
|
-
{
|
|
92
|
-
to: (0, import_url.addQueryArgs)("/template", { activeView: "user" }),
|
|
93
|
-
icon: import_icons.commentAuthorAvatar,
|
|
94
|
-
"aria-current": activeView === "user",
|
|
95
|
-
// Let's avoid calling them "custom templates" to avoid
|
|
96
|
-
// confusion. "Created" is closest to meaning database
|
|
97
|
-
// templates, created by users.
|
|
98
|
-
// https://developer.wordpress.org/themes/classic-themes/templates/page-template-files/#creating-custom-page-templates-for-global-use
|
|
99
|
-
children: (0, import_i18n.__)("Created templates")
|
|
82
|
+
icon: import_icons.layout,
|
|
83
|
+
"aria-current": activeView === "all",
|
|
84
|
+
children: (0, import_i18n.__)("All templates")
|
|
100
85
|
}
|
|
101
86
|
),
|
|
102
87
|
firstItemPerAuthorText.map((template) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar-navigation-screen-templates-browse/content.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useAddedBy } from '../page-templates/hooks';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useAddedBy } from '../page-templates/hooks';\nimport { layout } from '@wordpress/icons';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\tto={ addQueryArgs( '/template', { activeView: text } ) }\n\t\t\ticon={ icon }\n\t\t\taria-current={ isActive }\n\t\t>\n\t\t\t{ text }\n\t\t</SidebarNavigationItem>\n\t);\n}\n\nexport default function DataviewsTemplatesSidebarContent() {\n\tconst {\n\t\tquery: { activeView = 'all' },\n\t} = useLocation();\n\tconst { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\tper_page: -1,\n\t} );\n\tconst firstItemPerAuthorText = useMemo( () => {\n\t\tconst firstItemPerAuthor = records?.reduce( ( acc, template ) => {\n\t\t\tconst author = template.author_text;\n\t\t\tif ( author && ! acc[ author ] ) {\n\t\t\t\tacc[ author ] = template;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn (\n\t\t\t( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??\n\t\t\tEMPTY_ARRAY\n\t\t);\n\t}, [ records ] );\n\n\treturn (\n\t\t<ItemGroup className=\"edit-site-sidebar-navigation-screen-templates-browse\">\n\t\t\t<SidebarNavigationItem\n\t\t\t\tto=\"/template\"\n\t\t\t\ticon={ layout }\n\t\t\t\taria-current={ activeView === 'all' }\n\t\t\t>\n\t\t\t\t{ __( 'All templates' ) }\n\t\t\t</SidebarNavigationItem>\n\t\t\t{ firstItemPerAuthorText.map( ( template ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<TemplateDataviewItem\n\t\t\t\t\t\tkey={ template.author_text }\n\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\tisActive={ activeView === template.author_text }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ItemGroup>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BE;AAxBF,uBAAiC;AACjC,qBAAwB;AACxB,wBAAqD;AACrD,kBAAmB;AACnB,oBAAiD;AACjD,iBAA6B;AAK7B,qCAAkC;AAClC,mBAA2B;AAC3B,mBAAuB;AACvB,uBAAmC;AACnC,yBAAuB;AAEvB,MAAM,EAAE,YAAY,QAAI,2BAAQ,cAAAA,WAAkB;AAElD,MAAM,cAAc,CAAC;AAErB,SAAS,qBAAsB,EAAE,UAAU,SAAS,GAAI;AACvD,QAAM,EAAE,MAAM,KAAK,QAAI,yBAAY,SAAS,MAAM,SAAS,EAAG;AAE9D,SACC;AAAA,IAAC,+BAAAC;AAAA,IAAA;AAAA,MACA,QAAK,yBAAc,aAAa,EAAE,YAAY,KAAK,CAAE;AAAA,MACrD;AAAA,MACA,gBAAe;AAAA,MAEb;AAAA;AAAA,EACH;AAEF;AAEe,SAAR,mCAAoD;AAC1D,QAAM;AAAA,IACL,OAAO,EAAE,aAAa,MAAM;AAAA,EAC7B,IAAI,YAAY;AAChB,QAAM,EAAE,QAAQ,QAAI,mCAAkB,YAAY,qCAAoB;AAAA,IACrE,UAAU;AAAA,EACX,CAAE;AACF,QAAM,6BAAyB,wBAAS,MAAM;AAC7C,UAAM,qBAAqB,SAAS,OAAQ,CAAE,KAAK,aAAc;AAChE,YAAM,SAAS,SAAS;AACxB,UAAK,UAAU,CAAE,IAAK,MAAO,GAAI;AAChC,YAAK,MAAO,IAAI;AAAA,MACjB;AACA,aAAO;AAAA,IACR,GAAG,CAAC,CAAE;AACN,YACG,sBAAsB,OAAO,OAAQ,kBAAmB,MAC1D;AAAA,EAEF,GAAG,CAAE,OAAQ,CAAE;AAEf,SACC,6CAAC,kBAAAC,yBAAA,EAAU,WAAU,wDACpB;AAAA;AAAA,MAAC,+BAAAD;AAAA,MAAA;AAAA,QACA,IAAG;AAAA,QACH,MAAO;AAAA,QACP,gBAAe,eAAe;AAAA,QAE5B,8BAAI,eAAgB;AAAA;AAAA,IACvB;AAAA,IACE,uBAAuB,IAAK,CAAE,aAAc;AAC7C,aACC;AAAA,QAAC;AAAA;AAAA,UAEA;AAAA,UACA,UAAW,eAAe,SAAS;AAAA;AAAA,QAF7B,SAAS;AAAA,MAGhB;AAAA,IAEF,CAAE;AAAA,KACH;AAEF;",
|
|
6
6
|
"names": ["routerPrivateApis", "SidebarNavigationItem", "ItemGroup"]
|
|
7
7
|
}
|
|
@@ -35,24 +35,23 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
35
35
|
var import_editor = __toESM(require("../editor"));
|
|
36
36
|
var import_sidebar_navigation_screen_templates_browse = __toESM(require("../sidebar-navigation-screen-templates-browse"));
|
|
37
37
|
var import_sidebar_navigation_screen_unsupported = __toESM(require("../sidebar-navigation-screen-unsupported"));
|
|
38
|
-
const areas = {
|
|
39
|
-
sidebar({ siteData }) {
|
|
40
|
-
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
41
|
-
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_templates_browse.default, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
42
|
-
},
|
|
43
|
-
mobile({ siteData }) {
|
|
44
|
-
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
45
|
-
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
46
|
-
},
|
|
47
|
-
preview({ siteData }) {
|
|
48
|
-
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
49
|
-
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
38
|
const templateItemRoute = {
|
|
53
39
|
name: "template-item",
|
|
54
40
|
path: "/wp_template/*postId",
|
|
55
|
-
areas
|
|
41
|
+
areas: {
|
|
42
|
+
sidebar({ siteData }) {
|
|
43
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
44
|
+
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_templates_browse.default, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
45
|
+
},
|
|
46
|
+
mobile({ siteData }) {
|
|
47
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
48
|
+
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
49
|
+
},
|
|
50
|
+
preview({ siteData }) {
|
|
51
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
52
|
+
return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_editor.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sidebar_navigation_screen_unsupported.default, {});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
56
55
|
};
|
|
57
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
57
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/site-editor-routes/template-item.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport Editor from '../editor';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport Editor from '../editor';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';\n\nexport const templateItemRoute = {\n\tname: 'template-item',\n\tpath: '/wp_template/*postId',\n\tareas: {\n\t\tsidebar( { siteData } ) {\n\t\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\t\treturn isBlockTheme ? (\n\t\t\t\t<SidebarNavigationScreenTemplatesBrowse backPath=\"/\" />\n\t\t\t) : (\n\t\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t\t);\n\t\t},\n\t\tmobile( { siteData } ) {\n\t\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\t\treturn isBlockTheme ? (\n\t\t\t\t<Editor />\n\t\t\t) : (\n\t\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t\t);\n\t\t},\n\t\tpreview( { siteData } ) {\n\t\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\t\treturn isBlockTheme ? (\n\t\t\t\t<Editor />\n\t\t\t) : (\n\t\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t\t);\n\t\t},\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcI;AAXJ,oBAAmB;AACnB,wDAAmD;AACnD,mDAA+C;AAExC,MAAM,oBAAoB;AAAA,EAChC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,IACN,QAAS,EAAE,SAAS,GAAI;AACvB,YAAM,eAAe,SAAS,cAAc;AAC5C,aAAO,eACN,4CAAC,kDAAAA,SAAA,EAAuC,UAAS,KAAI,IAErD,4CAAC,6CAAAC,SAAA,EAAmC;AAAA,IAEtC;AAAA,IACA,OAAQ,EAAE,SAAS,GAAI;AACtB,YAAM,eAAe,SAAS,cAAc;AAC5C,aAAO,eACN,4CAAC,cAAAC,SAAA,EAAO,IAER,4CAAC,6CAAAD,SAAA,EAAmC;AAAA,IAEtC;AAAA,IACA,QAAS,EAAE,SAAS,GAAI;AACvB,YAAM,eAAe,SAAS,cAAc;AAC5C,aAAO,eACN,4CAAC,cAAAC,SAAA,EAAO,IAER,4CAAC,6CAAAD,SAAA,EAAmC;AAAA,IAEtC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["SidebarNavigationScreenTemplatesBrowse", "SidebarNavigationScreenUnsupported", "Editor"]
|
|
7
7
|
}
|
|
@@ -164,7 +164,9 @@ function AddCustomTemplateModalContent({
|
|
|
164
164
|
onBack,
|
|
165
165
|
containerRef
|
|
166
166
|
}) {
|
|
167
|
-
const [showSearchEntities, setShowSearchEntities] = useState(
|
|
167
|
+
const [showSearchEntities, setShowSearchEntities] = useState(
|
|
168
|
+
entityForSuggestions.hasGeneralTemplate
|
|
169
|
+
);
|
|
168
170
|
useEffect(() => {
|
|
169
171
|
if (containerRef.current) {
|
|
170
172
|
const [firstFocusable] = focus.focusable.find(
|