@wordpress/edit-site 4.17.0 → 4.18.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/app/index.js +8 -3
- package/build/components/app/index.js.map +1 -1
- package/build/components/editor/index.js +9 -13
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +6 -5
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +1 -0
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/header-edit-mode/index.js +1 -6
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +5 -5
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +9 -8
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/save-button/index.js +17 -13
- package/build/components/save-button/index.js.map +1 -1
- package/build/index.js +5 -10
- package/build/index.js.map +1 -1
- package/build/store/actions.js +15 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +28 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +13 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/app/index.js +8 -3
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/editor/index.js +10 -14
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +2 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +7 -6
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +1 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +1 -6
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +5 -5
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +9 -7
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/save-button/index.js +19 -15
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/index.js +5 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +13 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +26 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +11 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +2 -0
- package/build-style/style.css +2 -0
- package/package.json +29 -29
- package/src/components/app/index.js +11 -2
- package/src/components/block-editor/style.scss +1 -0
- package/src/components/editor/index.js +16 -25
- package/src/components/global-styles/border-panel.js +1 -0
- package/src/components/global-styles/global-styles-provider.js +5 -6
- package/src/components/global-styles/style.scss +1 -0
- package/src/components/global-styles/typography-panel.js +1 -0
- package/src/components/header-edit-mode/index.js +2 -9
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +15 -18
- package/src/components/keyboard-shortcuts/index.js +3 -2
- package/src/components/navigation-sidebar/navigation-panel/index.js +30 -24
- package/src/components/navigation-sidebar/navigation-toggle/test/__snapshots__/index.js.snap +41 -0
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +10 -12
- package/src/components/save-button/index.js +14 -14
- package/src/index.js +10 -3
- package/src/store/actions.js +13 -0
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +11 -0
- package/build/components/main-dashboard-button/index.js +0 -41
- package/build/components/main-dashboard-button/index.js.map +0 -1
- package/build-module/components/main-dashboard-button/index.js +0 -32
- package/build-module/components/main-dashboard-button/index.js.map +0 -1
- package/src/components/main-dashboard-button/index.js +0 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useEffect,
|
|
4
|
+
import { useEffect, useMemo } from '@wordpress/element';
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { Popover, Button, Notice } from '@wordpress/components';
|
|
7
7
|
import { EntityProvider, store as coreStore } from '@wordpress/core-data';
|
|
@@ -65,6 +65,7 @@ function Editor( { onError } ) {
|
|
|
65
65
|
const {
|
|
66
66
|
isInserterOpen,
|
|
67
67
|
isListViewOpen,
|
|
68
|
+
isSaveViewOpen,
|
|
68
69
|
sidebarIsOpened,
|
|
69
70
|
settings,
|
|
70
71
|
entityId,
|
|
@@ -82,6 +83,7 @@ function Editor( { onError } ) {
|
|
|
82
83
|
const {
|
|
83
84
|
isInserterOpened,
|
|
84
85
|
isListViewOpened,
|
|
86
|
+
isSaveViewOpened,
|
|
85
87
|
getSettings,
|
|
86
88
|
getEditedPostType,
|
|
87
89
|
getEditedPostId,
|
|
@@ -98,6 +100,7 @@ function Editor( { onError } ) {
|
|
|
98
100
|
return {
|
|
99
101
|
isInserterOpen: isInserterOpened(),
|
|
100
102
|
isListViewOpen: isListViewOpened(),
|
|
103
|
+
isSaveViewOpen: isSaveViewOpened(),
|
|
101
104
|
sidebarIsOpened: !! select(
|
|
102
105
|
interfaceStore
|
|
103
106
|
).getActiveComplementaryArea( editSiteStore.name ),
|
|
@@ -130,19 +133,10 @@ function Editor( { onError } ) {
|
|
|
130
133
|
blockEditorMode: __unstableGetEditorMode(),
|
|
131
134
|
};
|
|
132
135
|
}, [] );
|
|
133
|
-
const { setPage, setIsInserterOpened } =
|
|
136
|
+
const { setPage, setIsInserterOpened, setIsSaveViewOpened } =
|
|
137
|
+
useDispatch( editSiteStore );
|
|
134
138
|
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
135
139
|
|
|
136
|
-
const [ isEntitiesSavedStatesOpen, setIsEntitiesSavedStatesOpen ] =
|
|
137
|
-
useState( false );
|
|
138
|
-
const openEntitiesSavedStates = useCallback(
|
|
139
|
-
() => setIsEntitiesSavedStatesOpen( true ),
|
|
140
|
-
[]
|
|
141
|
-
);
|
|
142
|
-
const closeEntitiesSavedStates = useCallback( () => {
|
|
143
|
-
setIsEntitiesSavedStatesOpen( false );
|
|
144
|
-
}, [] );
|
|
145
|
-
|
|
146
140
|
const blockContext = useMemo(
|
|
147
141
|
() => ( {
|
|
148
142
|
...page?.context,
|
|
@@ -247,9 +241,6 @@ function Editor( { onError } ) {
|
|
|
247
241
|
}
|
|
248
242
|
header={
|
|
249
243
|
<Header
|
|
250
|
-
openEntitiesSavedStates={
|
|
251
|
-
openEntitiesSavedStates
|
|
252
|
-
}
|
|
253
244
|
showIconLabels={
|
|
254
245
|
showIconLabels
|
|
255
246
|
}
|
|
@@ -286,19 +277,17 @@ function Editor( { onError } ) {
|
|
|
286
277
|
) }
|
|
287
278
|
</Notice>
|
|
288
279
|
) }
|
|
289
|
-
<KeyboardShortcuts
|
|
290
|
-
openEntitiesSavedStates={
|
|
291
|
-
openEntitiesSavedStates
|
|
292
|
-
}
|
|
293
|
-
/>
|
|
280
|
+
<KeyboardShortcuts />
|
|
294
281
|
</>
|
|
295
282
|
}
|
|
296
283
|
actions={
|
|
297
284
|
<>
|
|
298
|
-
{
|
|
285
|
+
{ isSaveViewOpen ? (
|
|
299
286
|
<EntitiesSavedStates
|
|
300
|
-
close={
|
|
301
|
-
|
|
287
|
+
close={ () =>
|
|
288
|
+
setIsSaveViewOpened(
|
|
289
|
+
false
|
|
290
|
+
)
|
|
302
291
|
}
|
|
303
292
|
/>
|
|
304
293
|
) : (
|
|
@@ -306,8 +295,10 @@ function Editor( { onError } ) {
|
|
|
306
295
|
<Button
|
|
307
296
|
variant="secondary"
|
|
308
297
|
className="edit-site-editor__toggle-save-panel-button"
|
|
309
|
-
onClick={
|
|
310
|
-
|
|
298
|
+
onClick={ () =>
|
|
299
|
+
setIsSaveViewOpened(
|
|
300
|
+
true
|
|
301
|
+
)
|
|
311
302
|
}
|
|
312
303
|
aria-expanded={
|
|
313
304
|
false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { mergeWith,
|
|
4
|
+
import { mergeWith, isEmpty, mapValues } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -15,8 +15,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
15
15
|
*/
|
|
16
16
|
import { GlobalStylesContext } from './context';
|
|
17
17
|
|
|
18
|
-
const identity = ( x ) => x;
|
|
19
|
-
|
|
20
18
|
function mergeTreesCustomizer( _, srcValue ) {
|
|
21
19
|
// We only pass as arrays the presets,
|
|
22
20
|
// in which case we want the new array of values
|
|
@@ -38,9 +36,10 @@ const cleanEmptyObject = ( object ) => {
|
|
|
38
36
|
) {
|
|
39
37
|
return object;
|
|
40
38
|
}
|
|
41
|
-
const cleanedNestedObjects =
|
|
42
|
-
mapValues( object, cleanEmptyObject )
|
|
43
|
-
|
|
39
|
+
const cleanedNestedObjects = Object.fromEntries(
|
|
40
|
+
Object.entries( mapValues( object, cleanEmptyObject ) ).filter(
|
|
41
|
+
( [ , value ] ) => Boolean( value )
|
|
42
|
+
)
|
|
44
43
|
);
|
|
45
44
|
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
|
|
46
45
|
};
|
|
@@ -256,6 +256,7 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
256
256
|
fontSizes={ fontSizesWithFluidValues }
|
|
257
257
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
258
258
|
withReset={ false }
|
|
259
|
+
withSlider
|
|
259
260
|
size="__unstable-large"
|
|
260
261
|
__nextHasNoMarginBottom
|
|
261
262
|
/>
|
|
@@ -41,11 +41,7 @@ const preventDefault = ( event ) => {
|
|
|
41
41
|
event.preventDefault();
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export default function Header( {
|
|
45
|
-
openEntitiesSavedStates,
|
|
46
|
-
isEntitiesSavedStatesOpen,
|
|
47
|
-
showIconLabels,
|
|
48
|
-
} ) {
|
|
44
|
+
export default function Header( { showIconLabels } ) {
|
|
49
45
|
const inserterButton = useRef();
|
|
50
46
|
const {
|
|
51
47
|
deviceType,
|
|
@@ -238,10 +234,7 @@ export default function Header( {
|
|
|
238
234
|
</PreviewOptions>
|
|
239
235
|
</div>
|
|
240
236
|
) }
|
|
241
|
-
<SaveButton
|
|
242
|
-
openEntitiesSavedStates={ openEntitiesSavedStates }
|
|
243
|
-
isEntitiesSavedStatesOpen={ isEntitiesSavedStatesOpen }
|
|
244
|
-
/>
|
|
237
|
+
<SaveButton />
|
|
245
238
|
<PinnedItems.Slot scope="core/edit-site" />
|
|
246
239
|
<MoreMenu showIconLabels={ showIconLabels } />
|
|
247
240
|
</div>
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -26,20 +21,22 @@ function KeyCombination( { keyCombination, forceAriaLabel } ) {
|
|
|
26
21
|
className="edit-site-keyboard-shortcut-help-modal__shortcut-key-combination"
|
|
27
22
|
aria-label={ forceAriaLabel || ariaLabel }
|
|
28
23
|
>
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
{ ( Array.isArray( shortcut ) ? shortcut : [ shortcut ] ).map(
|
|
25
|
+
( character, index ) => {
|
|
26
|
+
if ( character === '+' ) {
|
|
27
|
+
return <Fragment key={ index }>{ character }</Fragment>;
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
return (
|
|
31
|
+
<kbd
|
|
32
|
+
key={ index }
|
|
33
|
+
className="edit-site-keyboard-shortcut-help-modal__shortcut-key"
|
|
34
|
+
>
|
|
35
|
+
{ character }
|
|
36
|
+
</kbd>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
) }
|
|
43
40
|
</kbd>
|
|
44
41
|
);
|
|
45
42
|
}
|
|
@@ -18,7 +18,7 @@ import { store as editSiteStore } from '../../store';
|
|
|
18
18
|
import { SIDEBAR_BLOCK } from '../sidebar-edit-mode/constants';
|
|
19
19
|
import { STORE_NAME } from '../../store/constants';
|
|
20
20
|
|
|
21
|
-
function KeyboardShortcuts(
|
|
21
|
+
function KeyboardShortcuts() {
|
|
22
22
|
const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
|
|
23
23
|
useSelect( coreStore );
|
|
24
24
|
const { getEditorMode } = useSelect( editSiteStore );
|
|
@@ -38,6 +38,7 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
|
|
|
38
38
|
useDispatch( editSiteStore );
|
|
39
39
|
const { enableComplementaryArea, disableComplementaryArea } =
|
|
40
40
|
useDispatch( interfaceStore );
|
|
41
|
+
const { setIsSaveViewOpened } = useDispatch( editSiteStore );
|
|
41
42
|
|
|
42
43
|
useShortcut( 'core/edit-site/save', ( event ) => {
|
|
43
44
|
event.preventDefault();
|
|
@@ -49,7 +50,7 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
|
|
|
49
50
|
);
|
|
50
51
|
|
|
51
52
|
if ( ! isSaving && isDirty ) {
|
|
52
|
-
|
|
53
|
+
setIsSaveViewOpened( true );
|
|
53
54
|
}
|
|
54
55
|
} );
|
|
55
56
|
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
* Internal dependencies
|
|
29
29
|
*/
|
|
30
30
|
import { useLink } from '../../routes/link';
|
|
31
|
-
import MainDashboardButton from '../../main-dashboard-button';
|
|
32
31
|
import { store as editSiteStore } from '../../../store';
|
|
33
32
|
|
|
34
33
|
const SITE_EDITOR_KEY = 'site-editor';
|
|
@@ -39,24 +38,33 @@ function NavLink( { params, replace, ...props } ) {
|
|
|
39
38
|
return <NavigationItem { ...linkProps } { ...props } />;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
const NavigationPanel = ( { activeItem
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const NavigationPanel = ( { activeItem } ) => {
|
|
42
|
+
const {
|
|
43
|
+
homeTemplate,
|
|
44
|
+
isNavigationOpen,
|
|
45
|
+
isTemplatePartsMode,
|
|
46
|
+
siteTitle,
|
|
47
|
+
dashboardLink,
|
|
48
|
+
} = useSelect( ( select ) => {
|
|
49
|
+
const { getEntityRecord } = select( coreDataStore );
|
|
50
|
+
const { getSettings, isNavigationOpened } = select( editSiteStore );
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
const siteData =
|
|
53
|
+
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
54
|
+
const {
|
|
55
|
+
supportsTemplatePartsMode,
|
|
56
|
+
__unstableHomeTemplate,
|
|
57
|
+
__experimentalDashboardLink,
|
|
58
|
+
} = getSettings();
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
+
return {
|
|
61
|
+
siteTitle: siteData.name,
|
|
62
|
+
homeTemplate: __unstableHomeTemplate,
|
|
63
|
+
dashboardLink: __experimentalDashboardLink,
|
|
64
|
+
isNavigationOpen: isNavigationOpened(),
|
|
65
|
+
isTemplatePartsMode: !! supportsTemplatePartsMode,
|
|
66
|
+
};
|
|
67
|
+
}, [] );
|
|
60
68
|
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
61
69
|
|
|
62
70
|
const closeOnEscape = ( event ) => {
|
|
@@ -82,13 +90,11 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
|
82
90
|
</div>
|
|
83
91
|
<div className="edit-site-navigation-panel__scroll-container">
|
|
84
92
|
<Navigation activeItem={ activeItem }>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/>
|
|
91
|
-
</MainDashboardButton.Slot>
|
|
93
|
+
<NavigationBackButton
|
|
94
|
+
backButtonLabel={ __( 'Dashboard' ) }
|
|
95
|
+
className="edit-site-navigation-panel__back-to-dashboard"
|
|
96
|
+
href={ dashboardLink ?? 'index.php' }
|
|
97
|
+
/>
|
|
92
98
|
|
|
93
99
|
<NavigationMenu>
|
|
94
100
|
<NavigationGroup title={ __( 'Editor' ) }>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`NavigationToggle when in full screen mode should display a default site icon if no user uploaded site icon exists 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="edit-site-navigation-toggle"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
aria-label="Toggle navigation"
|
|
10
|
+
aria-pressed="false"
|
|
11
|
+
class="components-button edit-site-navigation-toggle__button"
|
|
12
|
+
type="button"
|
|
13
|
+
>
|
|
14
|
+
<svg
|
|
15
|
+
aria-hidden="true"
|
|
16
|
+
focusable="false"
|
|
17
|
+
height="36px"
|
|
18
|
+
viewBox="-2 -2 24 24"
|
|
19
|
+
width="36px"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
d="M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
<div
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
class="components-popover components-tooltip"
|
|
29
|
+
style="position: absolute;"
|
|
30
|
+
tabindex="-1"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
class="components-popover__content"
|
|
34
|
+
>
|
|
35
|
+
Toggle navigation
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -38,12 +38,11 @@ describe( 'NavigationToggle', () => {
|
|
|
38
38
|
} ) );
|
|
39
39
|
} );
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
41
|
+
render( <NavigationToggle /> );
|
|
42
|
+
|
|
43
|
+
const siteIcon = screen.getByAltText( 'Site Icon' );
|
|
45
44
|
|
|
46
|
-
expect( siteIcon ).
|
|
45
|
+
expect( siteIcon ).toBeVisible();
|
|
47
46
|
} );
|
|
48
47
|
|
|
49
48
|
it( 'should display a default site icon if no user uploaded site icon exists', () => {
|
|
@@ -59,13 +58,12 @@ describe( 'NavigationToggle', () => {
|
|
|
59
58
|
} );
|
|
60
59
|
|
|
61
60
|
const { container } = render( <NavigationToggle /> );
|
|
62
|
-
const siteIcon = container.querySelector(
|
|
63
|
-
'.edit-site-navigation-toggle__site-icon'
|
|
64
|
-
);
|
|
65
|
-
const defaultIcon = container.querySelector( 'svg' );
|
|
66
61
|
|
|
67
|
-
expect(
|
|
68
|
-
|
|
62
|
+
expect(
|
|
63
|
+
screen.queryByAltText( 'Site Icon' )
|
|
64
|
+
).not.toBeInTheDocument();
|
|
65
|
+
|
|
66
|
+
expect( container ).toMatchSnapshot();
|
|
69
67
|
} );
|
|
70
68
|
} );
|
|
71
69
|
} );
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
5
|
import { Button } from '@wordpress/components';
|
|
11
6
|
import { __ } from '@wordpress/i18n';
|
|
12
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
export default function SaveButton() {
|
|
15
|
+
const { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {
|
|
19
16
|
const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
|
|
20
17
|
select( coreStore );
|
|
21
18
|
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
19
|
+
const { isSaveViewOpened } = select( editSiteStore );
|
|
22
20
|
return {
|
|
23
21
|
isDirty: dirtyEntityRecords.length > 0,
|
|
24
|
-
isSaving: some(
|
|
22
|
+
isSaving: dirtyEntityRecords.some( ( record ) =>
|
|
25
23
|
isSavingEntityRecord( record.kind, record.name, record.key )
|
|
26
24
|
),
|
|
25
|
+
isSaveViewOpen: isSaveViewOpened(),
|
|
27
26
|
};
|
|
28
27
|
}, [] );
|
|
28
|
+
const { setIsSaveViewOpened } = useDispatch( editSiteStore );
|
|
29
29
|
|
|
30
30
|
const disabled = ! isDirty || isSaving;
|
|
31
31
|
|
|
@@ -34,9 +34,9 @@ export default function SaveButton( {
|
|
|
34
34
|
variant="primary"
|
|
35
35
|
className="edit-site-save-button__button"
|
|
36
36
|
aria-disabled={ disabled }
|
|
37
|
-
aria-expanded={
|
|
37
|
+
aria-expanded={ isSaveViewOpen }
|
|
38
38
|
isBusy={ isSaving }
|
|
39
|
-
onClick={ disabled ? undefined :
|
|
39
|
+
onClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }
|
|
40
40
|
>
|
|
41
41
|
{ __( 'Save' ) }
|
|
42
42
|
</Button>
|
package/src/index.js
CHANGED
|
@@ -45,7 +45,9 @@ export function reinitializeEditor( target, settings ) {
|
|
|
45
45
|
message={ __(
|
|
46
46
|
'The editor is unable to find a block template for the homepage.'
|
|
47
47
|
) }
|
|
48
|
-
dashboardLink=
|
|
48
|
+
dashboardLink={
|
|
49
|
+
settings.__experimentalDashboardLink ?? 'index.php'
|
|
50
|
+
}
|
|
49
51
|
/>,
|
|
50
52
|
target
|
|
51
53
|
);
|
|
@@ -132,7 +134,13 @@ export function reinitializeEditor( target, settings ) {
|
|
|
132
134
|
window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
|
|
133
135
|
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );
|
|
134
136
|
|
|
135
|
-
render(
|
|
137
|
+
render(
|
|
138
|
+
<EditSiteApp
|
|
139
|
+
reboot={ reboot }
|
|
140
|
+
homeTemplate={ settings.__unstableHomeTemplate }
|
|
141
|
+
/>,
|
|
142
|
+
target
|
|
143
|
+
);
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
/**
|
|
@@ -159,7 +167,6 @@ export function initializeEditor( id, settings ) {
|
|
|
159
167
|
reinitializeEditor( target, settings );
|
|
160
168
|
}
|
|
161
169
|
|
|
162
|
-
export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';
|
|
163
170
|
export { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';
|
|
164
171
|
export { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';
|
|
165
172
|
export { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';
|
package/src/store/actions.js
CHANGED
|
@@ -320,6 +320,19 @@ export function setIsListViewOpened( isOpen ) {
|
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Sets whether the save view panel should be open.
|
|
325
|
+
*
|
|
326
|
+
* @param {boolean} isOpen If true, opens the save view. If false, closes it.
|
|
327
|
+
* It does not toggle the state, but sets it directly.
|
|
328
|
+
*/
|
|
329
|
+
export function setIsSaveViewOpened( isOpen ) {
|
|
330
|
+
return {
|
|
331
|
+
type: 'SET_IS_SAVE_VIEW_OPENED',
|
|
332
|
+
isOpen,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
323
336
|
/**
|
|
324
337
|
* Reverts a template to its original theme-provided file.
|
|
325
338
|
*
|
package/src/store/reducer.js
CHANGED
|
@@ -183,6 +183,24 @@ export function listViewPanel( state = false, action ) {
|
|
|
183
183
|
return state;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Reducer to set the save view panel open or closed.
|
|
188
|
+
*
|
|
189
|
+
* @param {Object} state Current state.
|
|
190
|
+
* @param {Object} action Dispatched action.
|
|
191
|
+
*/
|
|
192
|
+
export function saveViewPanel( state = false, action ) {
|
|
193
|
+
switch ( action.type ) {
|
|
194
|
+
case 'OPEN_NAVIGATION_PANEL_TO_MENU':
|
|
195
|
+
return false;
|
|
196
|
+
case 'SET_IS_NAVIGATION_PANEL_OPENED':
|
|
197
|
+
return action.isOpen ? false : state;
|
|
198
|
+
case 'SET_IS_SAVE_VIEW_OPENED':
|
|
199
|
+
return action.isOpen;
|
|
200
|
+
}
|
|
201
|
+
return state;
|
|
202
|
+
}
|
|
203
|
+
|
|
186
204
|
export default combineReducers( {
|
|
187
205
|
deviceType,
|
|
188
206
|
settings,
|
|
@@ -191,4 +209,5 @@ export default combineReducers( {
|
|
|
191
209
|
navigationPanel,
|
|
192
210
|
blockInserterPanel,
|
|
193
211
|
listViewPanel,
|
|
212
|
+
saveViewPanel,
|
|
194
213
|
} );
|
package/src/store/selectors.js
CHANGED
|
@@ -320,6 +320,17 @@ export function isListViewOpened( state ) {
|
|
|
320
320
|
return state.listViewPanel;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Returns the current opened/closed state of the save panel.
|
|
325
|
+
*
|
|
326
|
+
* @param {Object} state Global application state.
|
|
327
|
+
*
|
|
328
|
+
* @return {boolean} True if the save panel should be open; false if closed.
|
|
329
|
+
*/
|
|
330
|
+
export function isSaveViewOpened( state ) {
|
|
331
|
+
return state.saveViewPanel;
|
|
332
|
+
}
|
|
333
|
+
|
|
323
334
|
/**
|
|
324
335
|
* Returns the template parts and their blocks for the current edited template.
|
|
325
336
|
*
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
const slotName = '__experimentalMainDashboardButton';
|
|
16
|
-
const {
|
|
17
|
-
Fill,
|
|
18
|
-
Slot: MainDashboardButtonSlot
|
|
19
|
-
} = (0, _components.createSlotFill)(slotName);
|
|
20
|
-
const MainDashboardButton = Fill;
|
|
21
|
-
|
|
22
|
-
const Slot = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
children
|
|
25
|
-
} = _ref;
|
|
26
|
-
const fills = (0, _components.__experimentalUseSlotFills)(slotName);
|
|
27
|
-
const hasFills = Boolean(fills && fills.length);
|
|
28
|
-
|
|
29
|
-
if (!hasFills) {
|
|
30
|
-
return children;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (0, _element.createElement)(MainDashboardButtonSlot, {
|
|
34
|
-
bubblesVirtually: true
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
MainDashboardButton.Slot = Slot;
|
|
39
|
-
var _default = MainDashboardButton;
|
|
40
|
-
exports.default = _default;
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/main-dashboard-button/index.js"],"names":["slotName","Fill","Slot","MainDashboardButtonSlot","MainDashboardButton","children","fills","hasFills","Boolean","length"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAMA,MAAMA,QAAQ,GAAG,mCAAjB;AAEA,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,IAAI,EAAEC;AAAd,IAA0C,gCAAgBH,QAAhB,CAAhD;AAEA,MAAMI,mBAAmB,GAAGH,IAA5B;;AAEA,MAAMC,IAAI,GAAG,QAAoB;AAAA,MAAlB;AAAEG,IAAAA;AAAF,GAAkB;AAChC,QAAMC,KAAK,GAAG,4CAAcN,QAAd,CAAd;AACA,QAAMO,QAAQ,GAAGC,OAAO,CAAEF,KAAK,IAAIA,KAAK,CAACG,MAAjB,CAAxB;;AAEA,MAAK,CAAEF,QAAP,EAAkB;AACjB,WAAOF,QAAP;AACA;;AAED,SAAO,4BAAC,uBAAD;AAAyB,IAAA,gBAAgB;AAAzC,IAAP;AACA,CATD;;AAWAD,mBAAmB,CAACF,IAApB,GAA2BA,IAA3B;eAEeE,mB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseSlotFills as useSlotFills,\n\tcreateSlotFill,\n} from '@wordpress/components';\n\nconst slotName = '__experimentalMainDashboardButton';\n\nconst { Fill, Slot: MainDashboardButtonSlot } = createSlotFill( slotName );\n\nconst MainDashboardButton = Fill;\n\nconst Slot = ( { children } ) => {\n\tconst fills = useSlotFills( slotName );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn children;\n\t}\n\n\treturn <MainDashboardButtonSlot bubblesVirtually />;\n};\n\nMainDashboardButton.Slot = Slot;\n\nexport default MainDashboardButton;\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { __experimentalUseSlotFills as useSlotFills, createSlotFill } from '@wordpress/components';
|
|
7
|
-
const slotName = '__experimentalMainDashboardButton';
|
|
8
|
-
const {
|
|
9
|
-
Fill,
|
|
10
|
-
Slot: MainDashboardButtonSlot
|
|
11
|
-
} = createSlotFill(slotName);
|
|
12
|
-
const MainDashboardButton = Fill;
|
|
13
|
-
|
|
14
|
-
const Slot = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
children
|
|
17
|
-
} = _ref;
|
|
18
|
-
const fills = useSlotFills(slotName);
|
|
19
|
-
const hasFills = Boolean(fills && fills.length);
|
|
20
|
-
|
|
21
|
-
if (!hasFills) {
|
|
22
|
-
return children;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return createElement(MainDashboardButtonSlot, {
|
|
26
|
-
bubblesVirtually: true
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
MainDashboardButton.Slot = Slot;
|
|
31
|
-
export default MainDashboardButton;
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/main-dashboard-button/index.js"],"names":["__experimentalUseSlotFills","useSlotFills","createSlotFill","slotName","Fill","Slot","MainDashboardButtonSlot","MainDashboardButton","children","fills","hasFills","Boolean","length"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,0BAA0B,IAAIC,YAD/B,EAECC,cAFD,QAGO,uBAHP;AAKA,MAAMC,QAAQ,GAAG,mCAAjB;AAEA,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,IAAI,EAAEC;AAAd,IAA0CJ,cAAc,CAAEC,QAAF,CAA9D;AAEA,MAAMI,mBAAmB,GAAGH,IAA5B;;AAEA,MAAMC,IAAI,GAAG,QAAoB;AAAA,MAAlB;AAAEG,IAAAA;AAAF,GAAkB;AAChC,QAAMC,KAAK,GAAGR,YAAY,CAAEE,QAAF,CAA1B;AACA,QAAMO,QAAQ,GAAGC,OAAO,CAAEF,KAAK,IAAIA,KAAK,CAACG,MAAjB,CAAxB;;AAEA,MAAK,CAAEF,QAAP,EAAkB;AACjB,WAAOF,QAAP;AACA;;AAED,SAAO,cAAC,uBAAD;AAAyB,IAAA,gBAAgB;AAAzC,IAAP;AACA,CATD;;AAWAD,mBAAmB,CAACF,IAApB,GAA2BA,IAA3B;AAEA,eAAeE,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseSlotFills as useSlotFills,\n\tcreateSlotFill,\n} from '@wordpress/components';\n\nconst slotName = '__experimentalMainDashboardButton';\n\nconst { Fill, Slot: MainDashboardButtonSlot } = createSlotFill( slotName );\n\nconst MainDashboardButton = Fill;\n\nconst Slot = ( { children } ) => {\n\tconst fills = useSlotFills( slotName );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn children;\n\t}\n\n\treturn <MainDashboardButtonSlot bubblesVirtually />;\n};\n\nMainDashboardButton.Slot = Slot;\n\nexport default MainDashboardButton;\n"]}
|