@wordpress/edit-site 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-template/new-template.js +16 -10
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +4 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +2 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +20 -159
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +2 -3
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -26
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -3
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +13 -5
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -1
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -1
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/layout/index.js +7 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +128 -136
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +6 -5
- package/build/components/list/table.js.map +1 -1
- package/build/components/routes/link.js +4 -1
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-button/index.js +2 -5
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +82 -0
- package/build/components/save-hub/index.js.map +1 -0
- package/build/components/sidebar/index.js +2 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +5 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +13 -13
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +87 -10
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/index.js +59 -10
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +134 -19
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +0 -3
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-regular.js +8 -12
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +2 -2
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/template-part-converter/index.js +19 -14
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -6
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/utils/history.js +8 -2
- package/build/utils/history.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +18 -11
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +3 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +2 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +2 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +21 -157
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +2 -2
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +11 -2
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -1
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -1
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/layout/index.js +7 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +126 -137
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +6 -5
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-button/index.js +2 -5
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +68 -0
- package/build-module/components/save-hub/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +2 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +13 -13
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +81 -10
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js +60 -13
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +135 -22
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +0 -3
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +20 -15
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +6 -6
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/index.js +4 -1
- package/build-module/index.js.map +1 -1
- package/build-module/utils/history.js +9 -3
- package/build-module/utils/history.js.map +1 -1
- package/build-style/style-rtl.css +168 -111
- package/build-style/style.css +168 -111
- package/package.json +31 -31
- package/src/components/add-new-template/new-template.js +57 -32
- package/src/components/add-new-template/style.scss +12 -1
- package/src/components/app/index.js +9 -6
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/editor/index.js +61 -65
- package/src/components/global-styles/border-panel.js +24 -199
- package/src/components/global-styles/context-menu.js +2 -2
- package/src/components/global-styles/hooks.js +12 -36
- package/src/components/global-styles/screen-block-list.js +2 -2
- package/src/components/global-styles/screen-border.js +9 -2
- package/src/components/global-styles/screen-root.js +1 -1
- package/src/components/global-styles/screen-style-variations.js +5 -1
- package/src/components/global-styles/style.scss +10 -0
- package/src/components/layout/index.js +15 -0
- package/src/components/layout/style.scss +1 -3
- package/src/components/list/added-by.js +144 -140
- package/src/components/list/index.js +3 -1
- package/src/components/list/table.js +7 -4
- package/src/components/routes/link.js +9 -2
- package/src/components/save-button/index.js +2 -2
- package/src/components/save-hub/index.js +78 -0
- package/src/components/save-hub/style.scss +15 -0
- package/src/components/sidebar/index.js +2 -3
- package/src/components/sidebar/style.scss +4 -3
- package/src/components/sidebar-button/style.scss +2 -1
- package/src/components/sidebar-navigation-item/style.scss +1 -23
- package/src/components/sidebar-navigation-screen/index.js +6 -0
- package/src/components/sidebar-navigation-screen/style.scss +15 -0
- package/src/components/sidebar-navigation-screen-main/index.js +21 -8
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +92 -9
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
- package/src/components/sidebar-navigation-screen-template/index.js +82 -11
- package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
- package/src/components/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -1
- package/src/components/style-book/index.js +209 -54
- package/src/components/style-book/style.scss +1 -45
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
- package/src/components/template-details/index.js +0 -3
- package/src/components/template-part-converter/convert-to-regular.js +10 -17
- package/src/components/template-part-converter/convert-to-template-part.js +9 -16
- package/src/components/template-part-converter/index.js +28 -12
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +5 -1
- package/src/store/test/actions.js +0 -2
- package/src/style.scss +2 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -161
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -79
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -146
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -69
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -191
- package/src/components/navigation-inspector/navigation-menu.js +0 -84
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* External dependencies
|
|
3
4
|
*/
|
|
@@ -6,7 +7,7 @@ import classnames from 'classnames';
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
8
9
|
*/
|
|
9
|
-
import { __experimentalHStack as HStack
|
|
10
|
+
import { Icon, __experimentalHStack as HStack } from '@wordpress/components';
|
|
10
11
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
12
|
import { useSelect } from '@wordpress/data';
|
|
12
13
|
import { useState } from '@wordpress/element';
|
|
@@ -18,25 +19,154 @@ import {
|
|
|
18
19
|
} from '@wordpress/icons';
|
|
19
20
|
import { _x } from '@wordpress/i18n';
|
|
20
21
|
|
|
22
|
+
/** @typedef {'wp_template'|'wp_template_part'} TemplateType */
|
|
23
|
+
|
|
24
|
+
/** @type {TemplateType} */
|
|
21
25
|
const TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {'theme'|'plugin'|'site'|'user'} AddedByType
|
|
29
|
+
*
|
|
30
|
+
* @typedef AddedByData
|
|
31
|
+
* @type {Object}
|
|
32
|
+
* @property {AddedByType} type The type of the data.
|
|
33
|
+
* @property {JSX.Element} icon The icon to display.
|
|
34
|
+
* @property {string} [imageUrl] The optional image URL to display.
|
|
35
|
+
* @property {string} [text] The text to display.
|
|
36
|
+
* @property {boolean} isCustomized Whether the template has been customized.
|
|
37
|
+
*
|
|
38
|
+
* @param {TemplateType} postType The template post type.
|
|
39
|
+
* @param {number} postId The template post id.
|
|
40
|
+
* @return {AddedByData} The added by object or null.
|
|
41
|
+
*/
|
|
42
|
+
export function useAddedBy( postType, postId ) {
|
|
43
|
+
return useSelect(
|
|
44
|
+
( select ) => {
|
|
45
|
+
const {
|
|
46
|
+
getTheme,
|
|
47
|
+
getPlugin,
|
|
48
|
+
getEntityRecord,
|
|
49
|
+
getMedia,
|
|
50
|
+
getUser,
|
|
51
|
+
getEditedEntityRecord,
|
|
52
|
+
} = select( coreStore );
|
|
53
|
+
const template = getEditedEntityRecord(
|
|
54
|
+
'postType',
|
|
55
|
+
postType,
|
|
56
|
+
postId
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if ( TEMPLATE_POST_TYPE_NAMES.includes( template.type ) ) {
|
|
60
|
+
// Added by theme.
|
|
61
|
+
// Template originally provided by a theme, but customized by a user.
|
|
62
|
+
// Templates originally didn't have the 'origin' field so identify
|
|
63
|
+
// older customized templates by checking for no origin and a 'theme'
|
|
64
|
+
// or 'custom' source.
|
|
65
|
+
if (
|
|
66
|
+
template.has_theme_file &&
|
|
67
|
+
( template.origin === 'theme' ||
|
|
68
|
+
( ! template.origin &&
|
|
69
|
+
[ 'theme', 'custom' ].includes(
|
|
70
|
+
template.source
|
|
71
|
+
) ) )
|
|
72
|
+
) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'theme',
|
|
75
|
+
icon: themeIcon,
|
|
76
|
+
text:
|
|
77
|
+
getTheme( template.theme )?.name?.rendered ||
|
|
78
|
+
template.theme,
|
|
79
|
+
isCustomized: template.source === 'custom',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Added by plugin.
|
|
84
|
+
if ( template.has_theme_file && template.origin === 'plugin' ) {
|
|
85
|
+
return {
|
|
86
|
+
type: 'plugin',
|
|
87
|
+
icon: pluginIcon,
|
|
88
|
+
text:
|
|
89
|
+
getPlugin( template.theme )?.name || template.theme,
|
|
90
|
+
isCustomized: template.source === 'custom',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Added by site.
|
|
95
|
+
// Template was created from scratch, but has no author. Author support
|
|
96
|
+
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
97
|
+
// site logo and title.
|
|
98
|
+
if (
|
|
99
|
+
! template.has_theme_file &&
|
|
100
|
+
template.source === 'custom' &&
|
|
101
|
+
! template.author
|
|
102
|
+
) {
|
|
103
|
+
const siteData = getEntityRecord(
|
|
104
|
+
'root',
|
|
105
|
+
'__unstableBase'
|
|
106
|
+
);
|
|
107
|
+
return {
|
|
108
|
+
type: 'site',
|
|
109
|
+
icon: globeIcon,
|
|
110
|
+
imageUrl: siteData?.site_logo
|
|
111
|
+
? getMedia( siteData.site_logo )?.source_url
|
|
112
|
+
: undefined,
|
|
113
|
+
text: siteData?.name,
|
|
114
|
+
isCustomized: false,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Added by user.
|
|
120
|
+
const user = getUser( template.author );
|
|
121
|
+
return {
|
|
122
|
+
type: 'user',
|
|
123
|
+
icon: authorIcon,
|
|
124
|
+
imageUrl: user?.avatar_urls?.[ 48 ],
|
|
125
|
+
text: user?.nickname,
|
|
126
|
+
isCustomized: false,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
[ postType, postId ]
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {Object} props
|
|
135
|
+
* @param {string} props.imageUrl
|
|
136
|
+
*/
|
|
137
|
+
function AvatarImage( { imageUrl } ) {
|
|
24
138
|
const [ isImageLoaded, setIsImageLoaded ] = useState( false );
|
|
25
139
|
|
|
140
|
+
return (
|
|
141
|
+
<div
|
|
142
|
+
className={ classnames( 'edit-site-list-added-by__avatar', {
|
|
143
|
+
'is-loaded': isImageLoaded,
|
|
144
|
+
} ) }
|
|
145
|
+
>
|
|
146
|
+
<img
|
|
147
|
+
onLoad={ () => setIsImageLoaded( true ) }
|
|
148
|
+
alt=""
|
|
149
|
+
src={ imageUrl }
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @param {Object} props
|
|
157
|
+
* @param {TemplateType} props.postType The template post type.
|
|
158
|
+
* @param {number} props.postId The template post id.
|
|
159
|
+
*/
|
|
160
|
+
export default function AddedBy( { postType, postId } ) {
|
|
161
|
+
const { text, icon, imageUrl, isCustomized } = useAddedBy(
|
|
162
|
+
postType,
|
|
163
|
+
postId
|
|
164
|
+
);
|
|
165
|
+
|
|
26
166
|
return (
|
|
27
167
|
<HStack alignment="left">
|
|
28
168
|
{ imageUrl ? (
|
|
29
|
-
<
|
|
30
|
-
className={ classnames( 'edit-site-list-added-by__avatar', {
|
|
31
|
-
'is-loaded': isImageLoaded,
|
|
32
|
-
} ) }
|
|
33
|
-
>
|
|
34
|
-
<img
|
|
35
|
-
onLoad={ () => setIsImageLoaded( true ) }
|
|
36
|
-
alt=""
|
|
37
|
-
src={ imageUrl }
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
169
|
+
<AvatarImage imageUrl={ imageUrl } />
|
|
40
170
|
) : (
|
|
41
171
|
<div className="edit-site-list-added-by__icon">
|
|
42
172
|
<Icon icon={ icon } />
|
|
@@ -46,7 +176,7 @@ function BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {
|
|
|
46
176
|
{ text }
|
|
47
177
|
{ isCustomized && (
|
|
48
178
|
<span className="edit-site-list-added-by__customized-info">
|
|
49
|
-
{
|
|
179
|
+
{ postType === 'wp_template'
|
|
50
180
|
? _x( 'Customized', 'template' )
|
|
51
181
|
: _x( 'Customized', 'template part' ) }
|
|
52
182
|
</span>
|
|
@@ -55,129 +185,3 @@ function BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {
|
|
|
55
185
|
</HStack>
|
|
56
186
|
);
|
|
57
187
|
}
|
|
58
|
-
|
|
59
|
-
function AddedByTheme( { slug, isCustomized, templateType } ) {
|
|
60
|
-
const theme = useSelect(
|
|
61
|
-
( select ) => select( coreStore ).getTheme( slug ),
|
|
62
|
-
[ slug ]
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<BaseAddedBy
|
|
67
|
-
icon={ themeIcon }
|
|
68
|
-
text={ theme?.name?.rendered || slug }
|
|
69
|
-
isCustomized={ isCustomized }
|
|
70
|
-
templateType={ templateType }
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function AddedByPlugin( { slug, isCustomized, templateType } ) {
|
|
76
|
-
const plugin = useSelect(
|
|
77
|
-
( select ) => select( coreStore ).getPlugin( slug ),
|
|
78
|
-
[ slug ]
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<BaseAddedBy
|
|
83
|
-
icon={ pluginIcon }
|
|
84
|
-
text={ plugin?.name || slug }
|
|
85
|
-
isCustomized={ isCustomized }
|
|
86
|
-
templateType={ templateType }
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function AddedByAuthor( { id, templateType } ) {
|
|
92
|
-
const user = useSelect(
|
|
93
|
-
( select ) => select( coreStore ).getUser( id ),
|
|
94
|
-
[ id ]
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<BaseAddedBy
|
|
99
|
-
icon={ authorIcon }
|
|
100
|
-
imageUrl={ user?.avatar_urls?.[ 48 ] }
|
|
101
|
-
text={ user?.nickname }
|
|
102
|
-
templateType={ templateType }
|
|
103
|
-
/>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function AddedBySite( { templateType } ) {
|
|
108
|
-
const { name, logoURL } = useSelect( ( select ) => {
|
|
109
|
-
const { getEntityRecord, getMedia } = select( coreStore );
|
|
110
|
-
const siteData = getEntityRecord( 'root', '__unstableBase' );
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
name: siteData?.name,
|
|
114
|
-
logoURL: siteData?.site_logo
|
|
115
|
-
? getMedia( siteData.site_logo )?.source_url
|
|
116
|
-
: undefined,
|
|
117
|
-
};
|
|
118
|
-
}, [] );
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<BaseAddedBy
|
|
122
|
-
icon={ globeIcon }
|
|
123
|
-
imageUrl={ logoURL }
|
|
124
|
-
text={ name }
|
|
125
|
-
templateType={ templateType }
|
|
126
|
-
/>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export default function AddedBy( { templateType, template } ) {
|
|
131
|
-
if ( ! template ) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {
|
|
136
|
-
// Template originally provided by a theme, but customized by a user.
|
|
137
|
-
// Templates originally didn't have the 'origin' field so identify
|
|
138
|
-
// older customized templates by checking for no origin and a 'theme'
|
|
139
|
-
// or 'custom' source.
|
|
140
|
-
if (
|
|
141
|
-
template.has_theme_file &&
|
|
142
|
-
( template.origin === 'theme' ||
|
|
143
|
-
( ! template.origin &&
|
|
144
|
-
[ 'theme', 'custom' ].includes( template.source ) ) )
|
|
145
|
-
) {
|
|
146
|
-
return (
|
|
147
|
-
<AddedByTheme
|
|
148
|
-
slug={ template.theme }
|
|
149
|
-
isCustomized={ template.source === 'custom' }
|
|
150
|
-
templateType={ templateType }
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Template originally provided by a plugin, but customized by a user.
|
|
156
|
-
if ( template.has_theme_file && template.origin === 'plugin' ) {
|
|
157
|
-
return (
|
|
158
|
-
<AddedByPlugin
|
|
159
|
-
slug={ template.theme }
|
|
160
|
-
isCustomized={ template.source === 'custom' }
|
|
161
|
-
templateType={ templateType }
|
|
162
|
-
/>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Template was created from scratch, but has no author. Author support
|
|
167
|
-
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
168
|
-
// site logo and title.
|
|
169
|
-
if (
|
|
170
|
-
! template.has_theme_file &&
|
|
171
|
-
template.source === 'custom' &&
|
|
172
|
-
! template.author
|
|
173
|
-
) {
|
|
174
|
-
return <AddedBySite templateType={ templateType } />;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Simply show the author for templates created from scratch that have an
|
|
179
|
-
// author or for any other post type.
|
|
180
|
-
return (
|
|
181
|
-
<AddedByAuthor id={ template.author } templateType={ templateType } />
|
|
182
|
-
);
|
|
183
|
-
}
|
|
@@ -19,8 +19,10 @@ import useTitle from '../routes/use-title';
|
|
|
19
19
|
|
|
20
20
|
export default function List() {
|
|
21
21
|
const {
|
|
22
|
-
params: {
|
|
22
|
+
params: { path },
|
|
23
23
|
} = useLocation();
|
|
24
|
+
const templateType =
|
|
25
|
+
path === '/wp_template/all' ? 'wp_template' : 'wp_template_part';
|
|
24
26
|
|
|
25
27
|
useRegisterShortcuts();
|
|
26
28
|
|
|
@@ -89,6 +89,7 @@ export default function Table( { templateType } ) {
|
|
|
89
89
|
params={ {
|
|
90
90
|
postId: template.id,
|
|
91
91
|
postType: template.type,
|
|
92
|
+
canvas: 'edit',
|
|
92
93
|
} }
|
|
93
94
|
>
|
|
94
95
|
{ decodeEntities(
|
|
@@ -101,10 +102,12 @@ export default function Table( { templateType } ) {
|
|
|
101
102
|
</td>
|
|
102
103
|
|
|
103
104
|
<td className="edit-site-list-table-column" role="cell">
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
{ template ? (
|
|
106
|
+
<AddedBy
|
|
107
|
+
postType={ template.type }
|
|
108
|
+
postId={ template.id }
|
|
109
|
+
/>
|
|
110
|
+
) : null }
|
|
108
111
|
</td>
|
|
109
112
|
<td className="edit-site-list-table-column" role="cell">
|
|
110
113
|
<Actions template={ template } />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
4
|
+
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -21,8 +21,15 @@ export function useLink( params = {}, state, shouldReplace = false ) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const currentArgs = getQueryArgs( window.location.href );
|
|
25
|
+
const currentUrlWithoutArgs = removeQueryArgs(
|
|
26
|
+
window.location.href,
|
|
27
|
+
...Object.keys( currentArgs )
|
|
28
|
+
);
|
|
29
|
+
const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
|
|
30
|
+
|
|
24
31
|
return {
|
|
25
|
-
href:
|
|
32
|
+
href: newUrl,
|
|
26
33
|
onClick,
|
|
27
34
|
};
|
|
28
35
|
}
|
|
@@ -12,7 +12,7 @@ import { displayShortcut } from '@wordpress/keycodes';
|
|
|
12
12
|
*/
|
|
13
13
|
import { store as editSiteStore } from '../../store';
|
|
14
14
|
|
|
15
|
-
export default function SaveButton(
|
|
15
|
+
export default function SaveButton() {
|
|
16
16
|
const { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {
|
|
17
17
|
const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
|
|
18
18
|
select( coreStore );
|
|
@@ -52,7 +52,7 @@ export default function SaveButton( { showTooltip = true } ) {
|
|
|
52
52
|
* of the button that we want to avoid. By setting `showTooltip`,
|
|
53
53
|
& the tooltip is always rendered even when there's no keyboard shortcut.
|
|
54
54
|
*/
|
|
55
|
-
showTooltip
|
|
55
|
+
showTooltip
|
|
56
56
|
>
|
|
57
57
|
{ label }
|
|
58
58
|
</Button>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { Button, __experimentalHStack as HStack } from '@wordpress/components';
|
|
6
|
+
import { sprintf, __, _n } from '@wordpress/i18n';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import { displayShortcut } from '@wordpress/keycodes';
|
|
9
|
+
import { check } from '@wordpress/icons';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
15
|
+
|
|
16
|
+
export default function SaveButton() {
|
|
17
|
+
const { countUnsavedChanges, isDirty, isSaving, isSaveViewOpen } =
|
|
18
|
+
useSelect( ( select ) => {
|
|
19
|
+
const {
|
|
20
|
+
__experimentalGetDirtyEntityRecords,
|
|
21
|
+
isSavingEntityRecord,
|
|
22
|
+
} = select( coreStore );
|
|
23
|
+
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
24
|
+
const { isSaveViewOpened } = select( editSiteStore );
|
|
25
|
+
return {
|
|
26
|
+
isDirty: dirtyEntityRecords.length > 0,
|
|
27
|
+
isSaving: dirtyEntityRecords.some( ( record ) =>
|
|
28
|
+
isSavingEntityRecord( record.kind, record.name, record.key )
|
|
29
|
+
),
|
|
30
|
+
isSaveViewOpen: isSaveViewOpened(),
|
|
31
|
+
countUnsavedChanges: dirtyEntityRecords.length,
|
|
32
|
+
};
|
|
33
|
+
}, [] );
|
|
34
|
+
const { setIsSaveViewOpened } = useDispatch( editSiteStore );
|
|
35
|
+
|
|
36
|
+
const disabled = ! isDirty || isSaving;
|
|
37
|
+
|
|
38
|
+
const label = disabled ? __( 'Saved' ) : __( 'Save' );
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<HStack className="edit-site-save-hub" alignment="right" spacing={ 4 }>
|
|
42
|
+
{ isDirty && (
|
|
43
|
+
<span>
|
|
44
|
+
{ sprintf(
|
|
45
|
+
// translators: %d: number of unsaved changes (number).
|
|
46
|
+
_n(
|
|
47
|
+
'%d unsaved change',
|
|
48
|
+
'%d unsaved changes',
|
|
49
|
+
countUnsavedChanges
|
|
50
|
+
),
|
|
51
|
+
countUnsavedChanges
|
|
52
|
+
) }
|
|
53
|
+
</span>
|
|
54
|
+
) }
|
|
55
|
+
<Button
|
|
56
|
+
className="edit-site-save-hub__button"
|
|
57
|
+
variant={ disabled ? undefined : 'primary' }
|
|
58
|
+
aria-disabled={ disabled }
|
|
59
|
+
aria-expanded={ isSaveViewOpen }
|
|
60
|
+
isBusy={ isSaving }
|
|
61
|
+
onClick={
|
|
62
|
+
disabled ? undefined : () => setIsSaveViewOpened( true )
|
|
63
|
+
}
|
|
64
|
+
label={ label }
|
|
65
|
+
/*
|
|
66
|
+
* We want the tooltip to show the keyboard shortcut only when the
|
|
67
|
+
* button does something, i.e. when it's not disabled.
|
|
68
|
+
*/
|
|
69
|
+
shortcut={
|
|
70
|
+
disabled ? undefined : displayShortcut.primary( 's' )
|
|
71
|
+
}
|
|
72
|
+
icon={ disabled ? check : undefined }
|
|
73
|
+
>
|
|
74
|
+
{ label }
|
|
75
|
+
</Button>
|
|
76
|
+
</HStack>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -18,7 +18,7 @@ import useSyncPathWithURL, {
|
|
|
18
18
|
} from '../sync-state-with-url/use-sync-path-with-url';
|
|
19
19
|
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
|
|
20
20
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
21
|
-
import
|
|
21
|
+
import SaveHub from '../save-hub';
|
|
22
22
|
import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
|
|
23
23
|
import { useLocation } from '../routes';
|
|
24
24
|
|
|
@@ -61,9 +61,8 @@ function Sidebar() {
|
|
|
61
61
|
>
|
|
62
62
|
<SidebarScreens />
|
|
63
63
|
</NavigatorProvider>
|
|
64
|
-
|
|
65
64
|
<div className="edit-site-sidebar__footer">
|
|
66
|
-
<
|
|
65
|
+
<SaveHub />
|
|
67
66
|
</div>
|
|
68
67
|
</>
|
|
69
68
|
);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
.edit-site-sidebar__content {
|
|
2
2
|
flex-grow: 1;
|
|
3
3
|
overflow-y: auto;
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
.components-navigator-screen {
|
|
6
|
+
@include custom-scrollbars-on-hover;
|
|
7
|
+
}
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
.edit-site-sidebar__footer {
|
|
@@ -9,8 +12,6 @@
|
|
|
9
12
|
flex-shrink: 0;
|
|
10
13
|
margin: 0 $canvas-padding;
|
|
11
14
|
padding: $canvas-padding 0;
|
|
12
|
-
display: flex;
|
|
13
|
-
justify-content: flex-end;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.edit-site-sidebar__content.edit-site-sidebar__content {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
.edit-site-sidebar-navigation-item.components-item {
|
|
2
2
|
color: $gray-600;
|
|
3
|
-
|
|
3
|
+
margin: 0 $grid-unit-05;
|
|
4
4
|
|
|
5
5
|
&:hover,
|
|
6
6
|
&:focus,
|
|
7
7
|
&[aria-current] {
|
|
8
8
|
color: $white;
|
|
9
9
|
background: $gray-800;
|
|
10
|
-
border-width: $border-width-tab;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
&[aria-current] {
|
|
@@ -15,28 +14,7 @@
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .components-button {
|
|
19
|
-
color: $gray-600;
|
|
20
|
-
&:hover,
|
|
21
|
-
&:focus,
|
|
22
|
-
&[aria-current] {
|
|
23
|
-
color: $white;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .offcanvas-editor-list-view-leaf {
|
|
28
|
-
&:hover,
|
|
29
|
-
&:focus,
|
|
30
|
-
&[aria-current] {
|
|
31
|
-
background: $gray-800;
|
|
32
|
-
}
|
|
33
|
-
.block-editor-list-view-block__menu {
|
|
34
|
-
margin-left: -$grid-unit-10;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
17
|
.edit-site-sidebar-navigation-screen__content .block-editor-list-view-block-select-button {
|
|
39
18
|
cursor: grab;
|
|
40
|
-
width: calc(100% - #{ $border-width-focus });
|
|
41
19
|
padding: $grid-unit-10;
|
|
42
20
|
}
|
|
@@ -22,6 +22,7 @@ export default function SidebarNavigationScreen( {
|
|
|
22
22
|
title,
|
|
23
23
|
actions,
|
|
24
24
|
content,
|
|
25
|
+
description,
|
|
25
26
|
} ) {
|
|
26
27
|
const { dashboardLink } = useSelect( ( select ) => {
|
|
27
28
|
const { getSettings } = unlock( select( editSiteStore ) );
|
|
@@ -58,6 +59,11 @@ export default function SidebarNavigationScreen( {
|
|
|
58
59
|
</HStack>
|
|
59
60
|
|
|
60
61
|
<nav className="edit-site-sidebar-navigation-screen__content">
|
|
62
|
+
{ description && (
|
|
63
|
+
<p className="edit-site-sidebar-navigation-screen__description">
|
|
64
|
+
{ description }
|
|
65
|
+
</p>
|
|
66
|
+
) }
|
|
61
67
|
{ content }
|
|
62
68
|
</nav>
|
|
63
69
|
</VStack>
|
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
color: $gray-600;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.edit-site-sidebar-navigation-screen__page-link {
|
|
14
|
+
color: $gray-600;
|
|
15
|
+
|
|
16
|
+
&:hover,
|
|
17
|
+
&:focus {
|
|
18
|
+
color: $white;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.components-external-link__icon {
|
|
22
|
+
margin-left: $grid-unit-05;
|
|
23
|
+
}
|
|
24
|
+
margin-left: $grid-unit-20;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
.edit-site-sidebar-navigation-screen__title-icon {
|
|
14
29
|
position: sticky;
|
|
15
30
|
top: 0;
|
|
@@ -17,23 +17,36 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
17
17
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
18
18
|
|
|
19
19
|
export default function SidebarNavigationScreenMain() {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const hasNavigationMenus = useSelect( ( select ) => {
|
|
21
|
+
// The query needs to be the same as in the "SidebarNavigationScreenNavigationMenus" component,
|
|
22
|
+
// to avoid double network calls.
|
|
23
|
+
const navigationMenus = select( coreStore ).getEntityRecords(
|
|
24
|
+
'postType',
|
|
25
|
+
'wp_navigation',
|
|
26
|
+
{
|
|
27
|
+
per_page: 1,
|
|
25
28
|
status: 'publish',
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
order: 'desc',
|
|
30
|
+
orderby: 'date',
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return navigationMenus?.length > 0;
|
|
28
35
|
} );
|
|
29
36
|
|
|
37
|
+
const showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN
|
|
38
|
+
? hasNavigationMenus
|
|
39
|
+
: false;
|
|
30
40
|
return (
|
|
31
41
|
<SidebarNavigationScreen
|
|
32
42
|
isRoot
|
|
33
43
|
title={ __( 'Design' ) }
|
|
44
|
+
description={ __(
|
|
45
|
+
'Customize the appearance of your website using the block editor.'
|
|
46
|
+
) }
|
|
34
47
|
content={
|
|
35
48
|
<ItemGroup>
|
|
36
|
-
{
|
|
49
|
+
{ showNavigationScreen && (
|
|
37
50
|
<NavigatorButton
|
|
38
51
|
as={ SidebarNavigationItem }
|
|
39
52
|
path="/navigation"
|