@wordpress/edit-site 3.0.10 → 3.0.14
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/new-template-part.js +34 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +41 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +3 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +12 -6
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +29 -6
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +5 -43
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +71 -0
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +5 -5
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +23 -3
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +54 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +74 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +12 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +26 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/actions/index.js +104 -0
- package/build/components/list/actions/index.js.map +1 -0
- package/build/components/list/actions/rename-menu-item.js +112 -0
- package/build/components/list/actions/rename-menu-item.js.map +1 -0
- package/build/components/list/added-by.js +180 -0
- package/build/components/list/added-by.js.map +1 -0
- package/build/components/list/index.js +54 -7
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +58 -68
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +52 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +24 -9
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +35 -17
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +33 -0
- package/build/components/template-details/edit-template-title.js.map +1 -0
- package/build/components/template-details/index.js +8 -4
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/store/actions.js +47 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +30 -17
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +40 -24
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +13 -7
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +29 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +6 -39
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +60 -0
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +12 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +22 -3
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +41 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +70 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +28 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +11 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +26 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +85 -0
- package/build-module/components/list/actions/index.js.map +1 -0
- package/build-module/components/list/actions/rename-menu-item.js +101 -0
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
- package/build-module/components/list/added-by.js +166 -0
- package/build-module/components/list/added-by.js.map +1 -0
- package/build-module/components/list/index.js +49 -8
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +60 -70
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +41 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +22 -10
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +33 -18
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +23 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -0
- package/build-module/components/template-details/index.js +7 -4
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/index.js +8 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +48 -19
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +146 -21
- package/build-style/style.css +146 -21
- package/package.json +10 -8
- package/src/components/add-new-template/new-template-part.js +32 -18
- package/src/components/add-new-template/new-template.js +39 -20
- package/src/components/block-editor/index.js +2 -0
- package/src/components/editor/index.js +17 -6
- package/src/components/global-styles/color-palette-panel.js +64 -7
- package/src/components/global-styles/global-styles-provider.js +3 -33
- package/src/components/global-styles/gradients-palette-panel.js +99 -0
- package/src/components/global-styles/hooks.js +4 -4
- package/src/components/global-styles/palette.js +30 -10
- package/src/components/global-styles/screen-background-color.js +2 -0
- package/src/components/global-styles/screen-color-palette.js +30 -3
- package/src/components/global-styles/screen-link-color.js +2 -0
- package/src/components/global-styles/screen-text-color.js +2 -0
- package/src/components/global-styles/screen-typography-element.js +39 -0
- package/src/components/global-styles/screen-typography.js +84 -3
- package/src/components/global-styles/style.scss +45 -6
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/test/utils.js +1 -1
- package/src/components/global-styles/typography-panel.js +37 -7
- package/src/components/global-styles/ui.js +9 -0
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +32 -0
- package/src/components/list/actions/index.js +95 -0
- package/src/components/list/actions/rename-menu-item.js +134 -0
- package/src/components/list/added-by.js +179 -0
- package/src/components/list/index.js +63 -5
- package/src/components/list/style.scss +106 -11
- package/src/components/list/table.js +65 -76
- package/src/components/list/use-register-shortcuts.js +45 -0
- package/src/components/navigation-sidebar/index.js +21 -12
- package/src/components/navigation-sidebar/navigation-panel/index.js +32 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/template-details/edit-template-title.js +28 -0
- package/src/components/template-details/index.js +15 -10
- package/src/components/template-details/template-areas.js +1 -1
- package/src/index.js +10 -2
- package/src/store/actions.js +82 -34
- package/src/store/selectors.js +22 -4
- package/src/store/test/actions.js +0 -24
- package/src/store/test/selectors.js +24 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = RenameMenuItem;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _coreData = require("@wordpress/core-data");
|
|
17
|
+
|
|
18
|
+
var _notices = require("@wordpress/notices");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
function RenameMenuItem(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
template,
|
|
26
|
+
onClose
|
|
27
|
+
} = _ref;
|
|
28
|
+
const [title, setTitle] = (0, _element.useState)(() => template.title.rendered);
|
|
29
|
+
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
30
|
+
const {
|
|
31
|
+
getLastEntitySaveError
|
|
32
|
+
} = (0, _data.useSelect)(_coreData.store);
|
|
33
|
+
const {
|
|
34
|
+
editEntityRecord,
|
|
35
|
+
saveEditedEntityRecord
|
|
36
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
37
|
+
const {
|
|
38
|
+
createSuccessNotice,
|
|
39
|
+
createErrorNotice
|
|
40
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
41
|
+
|
|
42
|
+
if (!template.is_custom) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function onTemplateRename(event) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await editEntityRecord('postType', template.type, template.id, {
|
|
51
|
+
title
|
|
52
|
+
}); // Update state before saving rerenders the list.
|
|
53
|
+
|
|
54
|
+
setTitle('');
|
|
55
|
+
setIsModalOpen(false);
|
|
56
|
+
onClose(); // Persist edited entity.
|
|
57
|
+
|
|
58
|
+
await saveEditedEntityRecord('postType', template.type, template.id);
|
|
59
|
+
const lastError = getLastEntitySaveError('postType', template.type, template.id);
|
|
60
|
+
|
|
61
|
+
if (lastError) {
|
|
62
|
+
throw lastError;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
createSuccessNotice((0, _i18n.__)('Template has been renamed.'), {
|
|
66
|
+
type: 'snackbar'
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while renaming the template.');
|
|
70
|
+
createErrorNotice(errorMessage, {
|
|
71
|
+
type: 'snackbar'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
|
|
77
|
+
onClick: () => {
|
|
78
|
+
setIsModalOpen(true);
|
|
79
|
+
setTitle(template.title.rendered);
|
|
80
|
+
}
|
|
81
|
+
}, (0, _i18n.__)('Rename')), isModalOpen && (0, _element.createElement)(_components.Modal, {
|
|
82
|
+
title: (0, _i18n.__)('Rename template'),
|
|
83
|
+
closeLabel: (0, _i18n.__)('Close'),
|
|
84
|
+
onRequestClose: () => {
|
|
85
|
+
setIsModalOpen(false);
|
|
86
|
+
},
|
|
87
|
+
overlayClassName: "edit-site-list__rename-modal"
|
|
88
|
+
}, (0, _element.createElement)("form", {
|
|
89
|
+
onSubmit: onTemplateRename
|
|
90
|
+
}, (0, _element.createElement)(_components.Flex, {
|
|
91
|
+
align: "flex-start",
|
|
92
|
+
gap: 8
|
|
93
|
+
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.TextControl, {
|
|
94
|
+
label: (0, _i18n.__)('Name'),
|
|
95
|
+
value: title,
|
|
96
|
+
onChange: setTitle,
|
|
97
|
+
required: true
|
|
98
|
+
}))), (0, _element.createElement)(_components.Flex, {
|
|
99
|
+
className: "edit-site-list__rename-modal-actions",
|
|
100
|
+
justify: "flex-end",
|
|
101
|
+
expanded: false
|
|
102
|
+
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
103
|
+
variant: "tertiary",
|
|
104
|
+
onClick: () => {
|
|
105
|
+
setIsModalOpen(false);
|
|
106
|
+
}
|
|
107
|
+
}, (0, _i18n.__)('Cancel'))), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
108
|
+
variant: "primary",
|
|
109
|
+
type: "submit"
|
|
110
|
+
}, (0, _i18n.__)('Save')))))));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=rename-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/actions/rename-menu-item.js"],"names":["RenameMenuItem","template","onClose","title","setTitle","rendered","isModalOpen","setIsModalOpen","getLastEntitySaveError","coreStore","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","is_custom","onTemplateRename","event","preventDefault","type","id","lastError","error","errorMessage","message","code"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAQA;;AACA;;AAfA;AACA;AACA;AAee,SAASA,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAC/D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,MAAMH,QAAQ,CAACE,KAAT,CAAeE,QAA/B,CAA5B;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAA6B,qBAAWC,eAAX,CAAnC;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAA+C,uBACpDF,eADoD,CAArD;AAGA,QAAM;AAAEG,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MAA6C,uBAClDC,cADkD,CAAnD;;AAIA,MAAK,CAAEb,QAAQ,CAACc,SAAhB,EAA4B;AAC3B,WAAO,IAAP;AACA;;AAED,iBAAeC,gBAAf,CAAiCC,KAAjC,EAAyC;AACxCA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAI;AACH,YAAMR,gBAAgB,CAAE,UAAF,EAAcT,QAAQ,CAACkB,IAAvB,EAA6BlB,QAAQ,CAACmB,EAAtC,EAA0C;AAC/DjB,QAAAA;AAD+D,OAA1C,CAAtB,C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AGS;AAAjB,KACC,4BAAC,gBAAD;AAAM,IAAA,KAAK,EAAC,YAAZ;AAAyB,IAAA,GAAG,EAAG;AAA/B,KACC,4BAAC,oBAAD,QACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,MAAJ,CADT;AAEC,IAAA,KAAK,EAAGb,KAFT;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ;AAJT,IADD,CADD,CADD,EAYC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMG,cAAI,QAAJ,CANH,CADD,CALD,EAeC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,MAAJ,CADH,CADD,CAfD,CAZD,CARD,CAVF,CADD;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tMenuItem,\n\tModal,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => template.title.rendered );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = useDispatch(\n\t\tcoreStore\n\t);\n\tconst { createSuccessNotice, createErrorNotice } = useDispatch(\n\t\tnoticesStore\n\t);\n\n\tif ( ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tconst lastError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tif ( lastError ) {\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tcreateSuccessNotice( __( 'Template has been renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( template.title.rendered );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename template' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-site-list__rename-modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\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\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = AddedBy;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _coreData = require("@wordpress/core-data");
|
|
17
|
+
|
|
18
|
+
var _data = require("@wordpress/data");
|
|
19
|
+
|
|
20
|
+
var _icons = require("@wordpress/icons");
|
|
21
|
+
|
|
22
|
+
var _i18n = require("@wordpress/i18n");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* External dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* WordPress dependencies
|
|
30
|
+
*/
|
|
31
|
+
const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
|
|
32
|
+
|
|
33
|
+
function CustomizedTooltip(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
isCustomized,
|
|
36
|
+
children
|
|
37
|
+
} = _ref;
|
|
38
|
+
|
|
39
|
+
if (!isCustomized) {
|
|
40
|
+
return children;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (0, _element.createElement)(_components.Tooltip, {
|
|
44
|
+
text: (0, _i18n.__)('This template has been customized')
|
|
45
|
+
}, children);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function AddedByTheme(_ref2) {
|
|
49
|
+
var _theme$name;
|
|
50
|
+
|
|
51
|
+
let {
|
|
52
|
+
slug,
|
|
53
|
+
isCustomized
|
|
54
|
+
} = _ref2;
|
|
55
|
+
const theme = (0, _data.useSelect)(select => select(_coreData.store).getTheme(slug), [slug]);
|
|
56
|
+
return (0, _element.createElement)(_components.__experimentalHStack, {
|
|
57
|
+
alignment: "left"
|
|
58
|
+
}, (0, _element.createElement)(CustomizedTooltip, {
|
|
59
|
+
isCustomized: isCustomized
|
|
60
|
+
}, (0, _element.createElement)("div", {
|
|
61
|
+
className: (0, _classnames.default)('edit-site-list-added-by__icon', {
|
|
62
|
+
'is-customized': isCustomized
|
|
63
|
+
})
|
|
64
|
+
}, (0, _element.createElement)(_components.Icon, {
|
|
65
|
+
icon: _icons.layout
|
|
66
|
+
}))), (0, _element.createElement)("span", null, (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function AddedByPlugin(_ref3) {
|
|
70
|
+
let {
|
|
71
|
+
slug,
|
|
72
|
+
isCustomized
|
|
73
|
+
} = _ref3;
|
|
74
|
+
const plugin = (0, _data.useSelect)(select => select(_coreData.store).getPlugin(slug), [slug]);
|
|
75
|
+
return (0, _element.createElement)(_components.__experimentalHStack, {
|
|
76
|
+
alignment: "left"
|
|
77
|
+
}, (0, _element.createElement)(CustomizedTooltip, {
|
|
78
|
+
isCustomized: isCustomized
|
|
79
|
+
}, (0, _element.createElement)("div", {
|
|
80
|
+
className: "edit-site-list-added-by__icon"
|
|
81
|
+
}, (0, _element.createElement)(_components.Icon, {
|
|
82
|
+
icon: _icons.plugins
|
|
83
|
+
}))), (0, _element.createElement)("span", null, (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function AddedByAuthor(_ref4) {
|
|
87
|
+
let {
|
|
88
|
+
id
|
|
89
|
+
} = _ref4;
|
|
90
|
+
const user = (0, _data.useSelect)(select => select(_coreData.store).getUser(id), [id]);
|
|
91
|
+
const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
|
|
92
|
+
return (0, _element.createElement)(_components.__experimentalHStack, {
|
|
93
|
+
alignment: "left"
|
|
94
|
+
}, (0, _element.createElement)("div", {
|
|
95
|
+
className: (0, _classnames.default)('edit-site-list-added-by__avatar', {
|
|
96
|
+
'is-loaded': isImageLoaded
|
|
97
|
+
})
|
|
98
|
+
}, (0, _element.createElement)("img", {
|
|
99
|
+
onLoad: () => setIsImageLoaded(true),
|
|
100
|
+
alt: "",
|
|
101
|
+
src: user === null || user === void 0 ? void 0 : user.avatar_urls[48]
|
|
102
|
+
})), (0, _element.createElement)("span", null, user === null || user === void 0 ? void 0 : user.nickname));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function AddedBySite() {
|
|
106
|
+
const {
|
|
107
|
+
name,
|
|
108
|
+
logoURL
|
|
109
|
+
} = (0, _data.useSelect)(select => {
|
|
110
|
+
var _getMedia;
|
|
111
|
+
|
|
112
|
+
const {
|
|
113
|
+
getEntityRecord,
|
|
114
|
+
getMedia
|
|
115
|
+
} = select(_coreData.store);
|
|
116
|
+
const siteData = getEntityRecord('root', '__unstableBase');
|
|
117
|
+
return {
|
|
118
|
+
name: siteData.name,
|
|
119
|
+
logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
|
|
120
|
+
};
|
|
121
|
+
}, []);
|
|
122
|
+
const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
|
|
123
|
+
return (0, _element.createElement)(_components.__experimentalHStack, {
|
|
124
|
+
alignment: "left"
|
|
125
|
+
}, (0, _element.createElement)("div", {
|
|
126
|
+
className: (0, _classnames.default)('edit-site-list-added-by__avatar', {
|
|
127
|
+
'is-loaded': isImageLoaded
|
|
128
|
+
})
|
|
129
|
+
}, (0, _element.createElement)("img", {
|
|
130
|
+
onLoad: () => setIsImageLoaded(true),
|
|
131
|
+
alt: "",
|
|
132
|
+
src: logoURL
|
|
133
|
+
})), (0, _element.createElement)("span", null, name));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function AddedBy(_ref5) {
|
|
137
|
+
let {
|
|
138
|
+
templateType,
|
|
139
|
+
template
|
|
140
|
+
} = _ref5;
|
|
141
|
+
|
|
142
|
+
if (!template) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
|
|
147
|
+
// Template originally provided by a theme, but customized by a user.
|
|
148
|
+
// Templates originally didn't have the 'origin' field so identify
|
|
149
|
+
// older customized templates by checking for no origin and a 'theme'
|
|
150
|
+
// or 'custom' source.
|
|
151
|
+
if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
|
|
152
|
+
return (0, _element.createElement)(AddedByTheme, {
|
|
153
|
+
slug: template.theme,
|
|
154
|
+
isCustomized: template.source === 'custom'
|
|
155
|
+
});
|
|
156
|
+
} // Template originally provided by a plugin, but customized by a user.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (template.has_theme_file && template.origin === 'plugin') {
|
|
160
|
+
return (0, _element.createElement)(AddedByPlugin, {
|
|
161
|
+
slug: template.theme,
|
|
162
|
+
isCustomized: template.source === 'custom'
|
|
163
|
+
});
|
|
164
|
+
} // Template was created from scratch, but has no author. Author support
|
|
165
|
+
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
166
|
+
// site logo and title.
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
if (!template.has_theme_file && template.source === 'custom' && !template.author) {
|
|
170
|
+
return (0, _element.createElement)(AddedBySite, null);
|
|
171
|
+
}
|
|
172
|
+
} // Simply show the author for templates created from scratch that have an
|
|
173
|
+
// author or for any other post type.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
return (0, _element.createElement)(AddedByAuthor, {
|
|
177
|
+
id: template.author
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=added-by.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","AddedByTheme","slug","theme","select","coreStore","getTheme","themeIcon","name","rendered","AddedByPlugin","plugin","getPlugin","pluginIcon","AddedByAuthor","id","user","getUser","isImageLoaded","setIsImageLoaded","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AAKA;;AACA;;AAEA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;AAYA,MAAMA,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP;AACA;;AAED,SACC,4BAAC,mBAAD;AAAS,IAAA,IAAI,EAAG,cAAI,mCAAJ;AAAhB,KACGA,QADH,CADD;AAKA;;AAED,SAASC,YAAT,QAAgD;AAAA;;AAAA,MAAzB;AAAEC,IAAAA,IAAF;AAAQH,IAAAA;AAAR,GAAyB;AAC/C,QAAMI,KAAK,GAAG,qBACXC,MAAF,IAAcA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,QAApB,CAA8BJ,IAA9B,CADD,EAEb,CAAEA,IAAF,CAFa,CAAd;AAKA,SACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iBAAD;AAAmB,IAAA,YAAY,EAAGH;AAAlC,KACC;AACC,IAAA,SAAS,EAAG,yBAAY,+BAAZ,EAA6C;AACxD,uBAAiBA;AADuC,KAA7C;AADb,KAKC,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAGQ;AAAb,IALD,CADD,CADD,EAUC,0CAAQ,CAAAJ,KAAK,SAAL,IAAAA,KAAK,WAAL,2BAAAA,KAAK,CAAEK,IAAP,4DAAaC,QAAb,KAAyBP,IAAjC,CAVD,CADD;AAcA;;AAED,SAASQ,aAAT,QAAiD;AAAA,MAAzB;AAAER,IA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,QAAX,EAAsBF,QAAtB,CAAgCD,QAAQ,CAACI,MAAzC,CAHF,CADD,EAKE;AACD,aACC,4BAAC,YAAD;AACC,QAAA,IAAI,EAAGJ,QAAQ,CAAC7B,KADjB;AAEC,QAAA,YAAY,EAAG6B,QAAQ,CAACI,MAAT,KAAoB;AAFpC,QADD;AAMA,KAjBuD,CAmBxD;;;AACA,QAAKJ,QAAQ,CAACE,cAAT,IAA2BF,QAAQ,CAACG,MAAT,KAAoB,QAApD,EAA+D;AAC9D,aACC,4BAAC,aAAD;AACC,QAAA,IAAI,EAAGH,QAAQ,CAAC7B,KADjB;AAEC,QAAA,YAAY,EAAG6B,QAAQ,CAACI,MAAT,KAAoB;AAFpC,QADD;AAMA,KA3BuD,CA6BxD;AACA;AACA;;;AACA,QACC,CAAEJ,QAAQ,CAACE,cAAX,IACAF,QAAQ,CAACI,MAAT,KAAoB,QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,4BAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,4BAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__icon', {\n\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ themeIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ theme?.name?.rendered || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ pluginIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ plugin?.name || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ user?.avatar_urls[ 48 ] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ user?.nickname }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ logoURL }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ name }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
|
|
@@ -9,11 +9,21 @@ exports.default = List;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _coreData = require("@wordpress/core-data");
|
|
15
|
+
|
|
16
|
+
var _data = require("@wordpress/data");
|
|
17
|
+
|
|
12
18
|
var _interface = require("@wordpress/interface");
|
|
13
19
|
|
|
14
20
|
var _i18n = require("@wordpress/i18n");
|
|
15
21
|
|
|
16
|
-
var
|
|
22
|
+
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
23
|
+
|
|
24
|
+
var _editor = require("@wordpress/editor");
|
|
25
|
+
|
|
26
|
+
var _useRegisterShortcuts = _interopRequireDefault(require("./use-register-shortcuts"));
|
|
17
27
|
|
|
18
28
|
var _header = _interopRequireDefault(require("./header"));
|
|
19
29
|
|
|
@@ -21,6 +31,12 @@ var _navigationSidebar = _interopRequireDefault(require("../navigation-sidebar")
|
|
|
21
31
|
|
|
22
32
|
var _table = _interopRequireDefault(require("./table"));
|
|
23
33
|
|
|
34
|
+
var _store = require("../../store");
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* External dependencies
|
|
38
|
+
*/
|
|
39
|
+
|
|
24
40
|
/**
|
|
25
41
|
* WordPress dependencies
|
|
26
42
|
*/
|
|
@@ -29,27 +45,58 @@ var _table = _interopRequireDefault(require("./table"));
|
|
|
29
45
|
* Internal dependencies
|
|
30
46
|
*/
|
|
31
47
|
function List(_ref) {
|
|
48
|
+
var _postType$labels;
|
|
49
|
+
|
|
32
50
|
let {
|
|
33
51
|
templateType
|
|
34
52
|
} = _ref;
|
|
35
|
-
|
|
53
|
+
(0, _useRegisterShortcuts.default)();
|
|
54
|
+
const {
|
|
55
|
+
previousShortcut,
|
|
56
|
+
nextShortcut,
|
|
57
|
+
isNavigationOpen
|
|
58
|
+
} = (0, _data.useSelect)(select => {
|
|
59
|
+
return {
|
|
60
|
+
previousShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
|
|
61
|
+
nextShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
|
|
62
|
+
isNavigationOpen: select(_store.store).isNavigationOpened()
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
const postType = (0, _data.useSelect)(select => select(_coreData.store).getPostType(templateType), [templateType]); // `postType` could load in asynchronously. Only provide the detailed region labels if
|
|
66
|
+
// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
|
|
67
|
+
|
|
68
|
+
const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.items_list;
|
|
69
|
+
const detailedRegionLabels = postType ? {
|
|
70
|
+
header: (0, _i18n.sprintf)( // translators: %s - the name of the page, 'Header' as in the header area of that page.
|
|
71
|
+
(0, _i18n.__)('%s - Header'), itemsListLabel),
|
|
72
|
+
body: (0, _i18n.sprintf)( // translators: %s - the name of the page, 'Content' as in the content area of that page.
|
|
73
|
+
(0, _i18n.__)('%s - Content'), itemsListLabel)
|
|
74
|
+
} : undefined;
|
|
36
75
|
return (0, _element.createElement)(_interface.InterfaceSkeleton, {
|
|
37
|
-
className:
|
|
76
|
+
className: (0, _classnames.default)('edit-site-list', {
|
|
77
|
+
'is-navigation-open': isNavigationOpen
|
|
78
|
+
}),
|
|
38
79
|
labels: {
|
|
39
|
-
drawer: (0, _i18n.__)('Navigation Sidebar')
|
|
80
|
+
drawer: (0, _i18n.__)('Navigation Sidebar'),
|
|
81
|
+
...detailedRegionLabels
|
|
40
82
|
},
|
|
41
83
|
header: (0, _element.createElement)(_header.default, {
|
|
42
84
|
templateType: templateType
|
|
43
85
|
}),
|
|
44
86
|
drawer: (0, _element.createElement)(_navigationSidebar.default, {
|
|
45
|
-
|
|
46
|
-
|
|
87
|
+
activeTemplateType: templateType,
|
|
88
|
+
isDefaultOpen: true
|
|
47
89
|
}),
|
|
90
|
+
notices: (0, _element.createElement)(_editor.EditorSnackbars, null),
|
|
48
91
|
content: (0, _element.createElement)("main", {
|
|
49
92
|
className: "edit-site-list-main"
|
|
50
93
|
}, (0, _element.createElement)(_table.default, {
|
|
51
94
|
templateType: templateType
|
|
52
|
-
}))
|
|
95
|
+
})),
|
|
96
|
+
shortcuts: {
|
|
97
|
+
previous: previousShortcut,
|
|
98
|
+
next: nextShortcut
|
|
99
|
+
}
|
|
53
100
|
});
|
|
54
101
|
}
|
|
55
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["List","templateType","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["List","templateType","previousShortcut","nextShortcut","isNavigationOpen","select","keyboardShortcutsStore","getAllShortcutKeyCombinations","editSiteStore","isNavigationOpened","postType","coreStore","getPostType","itemsListLabel","labels","items_list","detailedRegionLabels","header","body","undefined","drawer","previous","next"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAOe,SAASA,IAAT,OAAkC;AAAA;;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,EACL,4BAAC,0BAAD;AACC,MAAA,kBAAkB,EAAGA,YADtB;AAEC,MAAA,aAAa;AAFd,MAVF;AAeC,IAAA,OAAO,EAAG,4BAAC,uBAAD,OAfX;AAgBC,IAAA,OAAO,EACN;AAAM,MAAA,SAAS,EAAC;AAAhB,OACC,4BAAC,cAAD;AAAO,MAAA,YAAY,EAAGA;AAAtB,MADD,CAjBF;AAqBC,IAAA,SAAS,EAAG;AACXoB,MAAAA,QAAQ,EAAEnB,gBADC;AAEXoB,MAAAA,IAAI,EAAEnB;AAFK;AArBb,IADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport NavigationSidebar from '../navigation-sidebar';\nimport Table from './table';\nimport { store as editSiteStore } from '../../store';\n\nexport default function List( { templateType } ) {\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut, isNavigationOpen } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tpreviousShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t\t'core/edit-site/previous-region'\n\t\t\t\t),\n\t\t\t\tnextShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName={ classnames( 'edit-site-list', {\n\t\t\t\t'is-navigation-open': isNavigationOpen,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\tdrawer: __( 'Navigation Sidebar' ),\n\t\t\t\t...detailedRegionLabels,\n\t\t\t} }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tdrawer={\n\t\t\t\t<NavigationSidebar\n\t\t\t\t\tactiveTemplateType={ templateType }\n\t\t\t\t\tisDefaultOpen\n\t\t\t\t/>\n\t\t\t}\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={\n\t\t\t\t<main className=\"edit-site-list-main\">\n\t\t\t\t\t<Table templateType={ templateType } />\n\t\t\t\t</main>\n\t\t\t}\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -17,13 +17,11 @@ var _i18n = require("@wordpress/i18n");
|
|
|
17
17
|
|
|
18
18
|
var _components = require("@wordpress/components");
|
|
19
19
|
|
|
20
|
-
var _icons = require("@wordpress/icons");
|
|
21
|
-
|
|
22
20
|
var _url = require("@wordpress/url");
|
|
23
21
|
|
|
24
|
-
var
|
|
22
|
+
var _actions = _interopRequireDefault(require("./actions"));
|
|
25
23
|
|
|
26
|
-
var
|
|
24
|
+
var _addedBy = _interopRequireDefault(require("./added-by"));
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* WordPress dependencies
|
|
@@ -32,26 +30,10 @@ var _isTemplateRemovable = _interopRequireDefault(require("../../utils/is-templa
|
|
|
32
30
|
/**
|
|
33
31
|
* Internal dependencies
|
|
34
32
|
*/
|
|
35
|
-
function
|
|
36
|
-
let {
|
|
37
|
-
template,
|
|
38
|
-
onClose
|
|
39
|
-
} = _ref;
|
|
40
|
-
const {
|
|
41
|
-
removeTemplate
|
|
42
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
43
|
-
return (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
|
|
44
|
-
onClick: () => {
|
|
45
|
-
removeTemplate(template);
|
|
46
|
-
onClose();
|
|
47
|
-
}
|
|
48
|
-
}, (0, _i18n.__)('Remove template')));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function Table(_ref2) {
|
|
33
|
+
function Table(_ref) {
|
|
52
34
|
let {
|
|
53
35
|
templateType
|
|
54
|
-
} =
|
|
36
|
+
} = _ref;
|
|
55
37
|
const {
|
|
56
38
|
templates,
|
|
57
39
|
isLoading,
|
|
@@ -63,8 +45,12 @@ function Table(_ref2) {
|
|
|
63
45
|
getPostType
|
|
64
46
|
} = select(_coreData.store);
|
|
65
47
|
return {
|
|
66
|
-
templates: getEntityRecords('postType', templateType
|
|
67
|
-
|
|
48
|
+
templates: getEntityRecords('postType', templateType, {
|
|
49
|
+
per_page: -1
|
|
50
|
+
}),
|
|
51
|
+
isLoading: !hasFinishedResolution('getEntityRecords', ['postType', templateType, {
|
|
52
|
+
per_page: -1
|
|
53
|
+
}]),
|
|
68
54
|
postType: getPostType(templateType)
|
|
69
55
|
};
|
|
70
56
|
}, [templateType]);
|
|
@@ -80,49 +66,53 @@ function Table(_ref2) {
|
|
|
80
66
|
(0, _i18n.__)('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
|
|
81
67
|
}
|
|
82
68
|
|
|
83
|
-
return (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
69
|
+
return (// These explicit aria roles are needed for Safari.
|
|
70
|
+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
|
|
71
|
+
(0, _element.createElement)("table", {
|
|
72
|
+
className: "edit-site-list-table",
|
|
73
|
+
role: "table"
|
|
74
|
+
}, (0, _element.createElement)("thead", null, (0, _element.createElement)("tr", {
|
|
75
|
+
className: "edit-site-list-table-head",
|
|
76
|
+
role: "row"
|
|
77
|
+
}, (0, _element.createElement)("th", {
|
|
78
|
+
className: "edit-site-list-table-column",
|
|
79
|
+
role: "columnheader"
|
|
80
|
+
}, (0, _i18n.__)('Template')), (0, _element.createElement)("th", {
|
|
81
|
+
className: "edit-site-list-table-column",
|
|
82
|
+
role: "columnheader"
|
|
83
|
+
}, (0, _i18n.__)('Added by')), (0, _element.createElement)("th", {
|
|
84
|
+
className: "edit-site-list-table-column",
|
|
85
|
+
role: "columnheader"
|
|
86
|
+
}, (0, _element.createElement)(_components.VisuallyHidden, null, (0, _i18n.__)('Actions'))))), (0, _element.createElement)("tbody", null, templates.map(template => {
|
|
87
|
+
var _template$title;
|
|
88
|
+
|
|
89
|
+
return (0, _element.createElement)("tr", {
|
|
90
|
+
key: template.id,
|
|
91
|
+
className: "edit-site-list-table-row",
|
|
92
|
+
role: "row"
|
|
93
|
+
}, (0, _element.createElement)("td", {
|
|
94
|
+
className: "edit-site-list-table-column",
|
|
95
|
+
role: "cell"
|
|
96
|
+
}, (0, _element.createElement)(_components.__experimentalHeading, {
|
|
97
|
+
level: 4
|
|
98
|
+
}, (0, _element.createElement)("a", {
|
|
99
|
+
href: (0, _url.addQueryArgs)(window.location.href, {
|
|
100
|
+
postId: template.id,
|
|
101
|
+
postType: template.type
|
|
102
|
+
})
|
|
103
|
+
}, ((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug)), template.description), (0, _element.createElement)("td", {
|
|
104
|
+
className: "edit-site-list-table-column",
|
|
105
|
+
role: "cell"
|
|
106
|
+
}, (0, _element.createElement)(_addedBy.default, {
|
|
107
|
+
templateType: templateType,
|
|
108
|
+
template: template
|
|
109
|
+
})), (0, _element.createElement)("td", {
|
|
110
|
+
className: "edit-site-list-table-column",
|
|
111
|
+
role: "cell"
|
|
112
|
+
}, (0, _element.createElement)(_actions.default, {
|
|
113
|
+
template: template
|
|
114
|
+
})));
|
|
115
|
+
})))
|
|
116
|
+
);
|
|
127
117
|
}
|
|
128
118
|
//# sourceMappingURL=table.js.map
|