@wordpress/edit-site 5.12.6 → 5.12.8
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/block-editor/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +10 -5
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +8 -4
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/header-edit-mode/index.js +6 -2
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/index.js +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/header.js +1 -1
- package/build/components/page/header.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +84 -60
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +21 -13
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +67 -27
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +99 -126
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/index.js +1 -0
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +1 -0
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +1 -1
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +57 -17
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +4 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -11
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +2 -35
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +68 -43
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/site-hub/index.js +2 -2
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/template-actions/index.js +25 -7
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +9 -6
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/welcome-guide/page.js +2 -2
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +2 -2
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +1 -2
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +7 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +10 -5
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +7 -4
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +1 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +6 -2
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/index.js +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/header.js +1 -1
- package/build-module/components/page/header.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +85 -66
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +22 -15
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +70 -31
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +100 -127
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +1 -0
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +1 -0
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +57 -17
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -9
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -33
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +71 -44
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/site-hub/index.js +2 -2
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/template-actions/index.js +26 -8
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +8 -6
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +2 -2
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +2 -2
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +1 -2
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +7 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +149 -50
- package/build-style/style.css +149 -50
- package/package.json +19 -19
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/use-site-editor-settings.js +8 -4
- package/src/components/create-pattern-modal/index.js +6 -3
- package/src/components/global-styles/palette.js +10 -9
- package/src/components/header-edit-mode/document-actions/style.scss +12 -0
- package/src/components/header-edit-mode/index.js +17 -9
- package/src/components/layout/index.js +1 -1
- package/src/components/layout/style.scss +0 -11
- package/src/components/page/header.js +1 -1
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +187 -132
- package/src/components/page-patterns/grid.js +35 -22
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/patterns-list.js +89 -47
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +86 -26
- package/src/components/page-patterns/use-patterns.js +99 -176
- package/src/components/page-template-parts/index.js +1 -1
- package/src/components/page-templates/index.js +1 -1
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/src/components/sidebar-navigation-screen/index.js +1 -1
- package/src/components/sidebar-navigation-screen/style.scss +19 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +56 -39
- package/src/components/sidebar-navigation-screen-main/index.js +44 -40
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +36 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +8 -11
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +10 -6
- package/src/components/sidebar-navigation-screen-page/status-label.js +2 -36
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/src/components/sidebar-navigation-screen-patterns/index.js +79 -75
- package/src/components/sidebar-navigation-screen-patterns/style.scss +23 -1
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
- package/src/components/site-hub/index.js +2 -2
- package/src/components/template-actions/index.js +40 -9
- package/src/components/template-actions/rename-menu-item.js +8 -6
- package/src/components/welcome-guide/page.js +2 -2
- package/src/components/welcome-guide/template.js +2 -2
- package/src/hooks/commands/use-edit-mode-commands.js +0 -1
- package/src/hooks/push-changes-to-global-styles/index.js +8 -1
- package/src/store/private-actions.js +5 -1
- package/src/style.scss +10 -12
- package/src/utils/use-activate-theme.js +1 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -1,51 +1,87 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import { useState, useDeferredValue, useId } from '@wordpress/element';
|
|
5
5
|
import {
|
|
6
6
|
SearchControl,
|
|
7
|
-
__experimentalHeading as Heading,
|
|
8
|
-
__experimentalText as Text,
|
|
9
7
|
__experimentalVStack as VStack,
|
|
10
8
|
Flex,
|
|
11
9
|
FlexBlock,
|
|
10
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
11
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
12
|
+
__experimentalHeading as Heading,
|
|
13
|
+
__experimentalText as Text,
|
|
12
14
|
} from '@wordpress/components';
|
|
13
15
|
import { __, isRTL } from '@wordpress/i18n';
|
|
14
|
-
import {
|
|
16
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
15
17
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
16
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
18
|
+
import { useViewportMatch, useAsyncList } from '@wordpress/compose';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Internal dependencies
|
|
20
22
|
*/
|
|
23
|
+
import PatternsHeader from './header';
|
|
21
24
|
import Grid from './grid';
|
|
22
25
|
import NoPatterns from './no-patterns';
|
|
23
26
|
import usePatterns from './use-patterns';
|
|
24
27
|
import SidebarButton from '../sidebar-button';
|
|
25
28
|
import useDebouncedInput from '../../utils/use-debounced-input';
|
|
26
29
|
import { unlock } from '../../lock-unlock';
|
|
30
|
+
import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
|
|
27
31
|
|
|
28
32
|
const { useLocation, useHistory } = unlock( routerPrivateApis );
|
|
29
33
|
|
|
34
|
+
const SYNC_FILTERS = {
|
|
35
|
+
all: __( 'All' ),
|
|
36
|
+
[ SYNC_TYPES.full ]: __( 'Synced' ),
|
|
37
|
+
[ SYNC_TYPES.unsynced ]: __( 'Standard' ),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const SYNC_DESCRIPTIONS = {
|
|
41
|
+
all: '',
|
|
42
|
+
[ SYNC_TYPES.full ]: __(
|
|
43
|
+
'Patterns that are kept in sync across the site.'
|
|
44
|
+
),
|
|
45
|
+
[ SYNC_TYPES.unsynced ]: __(
|
|
46
|
+
'Patterns that can be changed freely without affecting the site.'
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
30
50
|
export default function PatternsList( { categoryId, type } ) {
|
|
31
51
|
const location = useLocation();
|
|
32
52
|
const history = useHistory();
|
|
33
53
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
34
54
|
const [ filterValue, setFilterValue, delayedFilterValue ] =
|
|
35
55
|
useDebouncedInput( '' );
|
|
56
|
+
const deferredFilterValue = useDeferredValue( delayedFilterValue );
|
|
36
57
|
|
|
37
|
-
const [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
const [ syncFilter, setSyncFilter ] = useState( 'all' );
|
|
59
|
+
const deferredSyncedFilter = useDeferredValue( syncFilter );
|
|
60
|
+
const { patterns, isResolving } = usePatterns( type, categoryId, {
|
|
61
|
+
search: deferredFilterValue,
|
|
62
|
+
syncStatus:
|
|
63
|
+
deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter,
|
|
64
|
+
} );
|
|
42
65
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
66
|
+
const id = useId();
|
|
67
|
+
const titleId = `${ id }-title`;
|
|
68
|
+
const descriptionId = `${ id }-description`;
|
|
69
|
+
|
|
70
|
+
const hasPatterns = patterns.length;
|
|
71
|
+
const title = SYNC_FILTERS[ syncFilter ];
|
|
72
|
+
const description = SYNC_DESCRIPTIONS[ syncFilter ];
|
|
73
|
+
const shownPatterns = useAsyncList( patterns );
|
|
45
74
|
|
|
46
75
|
return (
|
|
47
76
|
<VStack spacing={ 6 }>
|
|
48
|
-
<
|
|
77
|
+
<PatternsHeader
|
|
78
|
+
categoryId={ categoryId }
|
|
79
|
+
type={ type }
|
|
80
|
+
titleId={ titleId }
|
|
81
|
+
descriptionId={ descriptionId }
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
<Flex alignment="stretch" wrap>
|
|
49
85
|
{ isMobileViewport && (
|
|
50
86
|
<SidebarButton
|
|
51
87
|
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
@@ -61,7 +97,7 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
61
97
|
} }
|
|
62
98
|
/>
|
|
63
99
|
) }
|
|
64
|
-
<FlexBlock>
|
|
100
|
+
<FlexBlock className="edit-site-patterns__search-block">
|
|
65
101
|
<SearchControl
|
|
66
102
|
className="edit-site-patterns__search"
|
|
67
103
|
onChange={ ( value ) => setFilterValue( value ) }
|
|
@@ -71,42 +107,48 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
71
107
|
__nextHasNoMarginBottom
|
|
72
108
|
/>
|
|
73
109
|
</FlexBlock>
|
|
110
|
+
{ categoryId === USER_PATTERN_CATEGORY && (
|
|
111
|
+
<ToggleGroupControl
|
|
112
|
+
className="edit-site-patterns__sync-status-filter"
|
|
113
|
+
hideLabelFromVision
|
|
114
|
+
label={ __( 'Filter by sync status' ) }
|
|
115
|
+
value={ syncFilter }
|
|
116
|
+
isBlock
|
|
117
|
+
onChange={ ( value ) => setSyncFilter( value ) }
|
|
118
|
+
__nextHasNoMarginBottom
|
|
119
|
+
>
|
|
120
|
+
{ Object.entries( SYNC_FILTERS ).map(
|
|
121
|
+
( [ key, label ] ) => (
|
|
122
|
+
<ToggleGroupControlOption
|
|
123
|
+
className="edit-site-patterns__sync-status-filter-option"
|
|
124
|
+
key={ key }
|
|
125
|
+
value={ key }
|
|
126
|
+
label={ label }
|
|
127
|
+
/>
|
|
128
|
+
)
|
|
129
|
+
) }
|
|
130
|
+
</ToggleGroupControl>
|
|
131
|
+
) }
|
|
74
132
|
</Flex>
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
) }
|
|
133
|
+
{ syncFilter !== 'all' && (
|
|
134
|
+
<VStack className="edit-site-patterns__section-header">
|
|
135
|
+
<Heading as="h3" level={ 4 } id={ titleId }>
|
|
136
|
+
{ title }
|
|
137
|
+
</Heading>
|
|
138
|
+
{ description ? (
|
|
139
|
+
<Text variant="muted" as="p" id={ descriptionId }>
|
|
140
|
+
{ description }
|
|
84
141
|
</Text>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
icon={ symbol }
|
|
88
|
-
categoryId={ categoryId }
|
|
89
|
-
label={ __( 'Synced patterns' ) }
|
|
90
|
-
items={ syncedPatterns }
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
142
|
+
) : null }
|
|
143
|
+
</VStack>
|
|
93
144
|
) }
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
) }
|
|
102
|
-
</Text>
|
|
103
|
-
</VStack>
|
|
104
|
-
<Grid
|
|
105
|
-
categoryId={ categoryId }
|
|
106
|
-
label={ __( 'Standard patterns' ) }
|
|
107
|
-
items={ unsyncedPatterns }
|
|
108
|
-
/>
|
|
109
|
-
</>
|
|
145
|
+
{ hasPatterns && (
|
|
146
|
+
<Grid
|
|
147
|
+
categoryId={ categoryId }
|
|
148
|
+
items={ shownPatterns }
|
|
149
|
+
aria-labelledby={ titleId }
|
|
150
|
+
aria-describedby={ descriptionId }
|
|
151
|
+
/>
|
|
110
152
|
) }
|
|
111
153
|
{ ! isResolving && ! hasPatterns && <NoPatterns /> }
|
|
112
154
|
</VStack>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
MenuItem,
|
|
7
|
+
Modal,
|
|
8
|
+
TextControl,
|
|
9
|
+
__experimentalHStack as HStack,
|
|
10
|
+
__experimentalVStack as VStack,
|
|
11
|
+
} from '@wordpress/components';
|
|
12
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
+
import { useDispatch } from '@wordpress/data';
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
15
|
+
import { __ } from '@wordpress/i18n';
|
|
16
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import { TEMPLATE_PARTS } from './utils';
|
|
22
|
+
|
|
23
|
+
export default function RenameMenuItem( { item, onClose } ) {
|
|
24
|
+
const [ title, setTitle ] = useState( () => item.title );
|
|
25
|
+
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
26
|
+
|
|
27
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
28
|
+
useDispatch( coreStore );
|
|
29
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
30
|
+
useDispatch( noticesStore );
|
|
31
|
+
|
|
32
|
+
if ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function onRename( event ) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await editEntityRecord( 'postType', item.type, item.id, { title } );
|
|
41
|
+
|
|
42
|
+
// Update state before saving rerenders the list.
|
|
43
|
+
setTitle( '' );
|
|
44
|
+
setIsModalOpen( false );
|
|
45
|
+
onClose();
|
|
46
|
+
|
|
47
|
+
// Persist edited entity.
|
|
48
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
49
|
+
throwOnError: true,
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
createSuccessNotice( __( 'Entity renamed.' ), {
|
|
53
|
+
type: 'snackbar',
|
|
54
|
+
} );
|
|
55
|
+
} catch ( error ) {
|
|
56
|
+
const errorMessage =
|
|
57
|
+
error.message && error.code !== 'unknown_error'
|
|
58
|
+
? error.message
|
|
59
|
+
: __( 'An error occurred while renaming the entity.' );
|
|
60
|
+
|
|
61
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<MenuItem
|
|
68
|
+
onClick={ () => {
|
|
69
|
+
setIsModalOpen( true );
|
|
70
|
+
setTitle( item.title );
|
|
71
|
+
} }
|
|
72
|
+
>
|
|
73
|
+
{ __( 'Rename' ) }
|
|
74
|
+
</MenuItem>
|
|
75
|
+
{ isModalOpen && (
|
|
76
|
+
<Modal
|
|
77
|
+
title={ __( 'Rename' ) }
|
|
78
|
+
onRequestClose={ () => {
|
|
79
|
+
setIsModalOpen( false );
|
|
80
|
+
onClose();
|
|
81
|
+
} }
|
|
82
|
+
overlayClassName="edit-site-list__rename_modal"
|
|
83
|
+
>
|
|
84
|
+
<form onSubmit={ onRename }>
|
|
85
|
+
<VStack spacing="5">
|
|
86
|
+
<TextControl
|
|
87
|
+
__nextHasNoMarginBottom
|
|
88
|
+
label={ __( 'Name' ) }
|
|
89
|
+
value={ title }
|
|
90
|
+
onChange={ setTitle }
|
|
91
|
+
required
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<HStack justify="right">
|
|
95
|
+
<Button
|
|
96
|
+
variant="tertiary"
|
|
97
|
+
onClick={ () => {
|
|
98
|
+
setIsModalOpen( false );
|
|
99
|
+
onClose();
|
|
100
|
+
} }
|
|
101
|
+
>
|
|
102
|
+
{ __( 'Cancel' ) }
|
|
103
|
+
</Button>
|
|
104
|
+
|
|
105
|
+
<Button variant="primary" type="submit">
|
|
106
|
+
{ __( 'Save' ) }
|
|
107
|
+
</Button>
|
|
108
|
+
</HStack>
|
|
109
|
+
</VStack>
|
|
110
|
+
</form>
|
|
111
|
+
</Modal>
|
|
112
|
+
) }
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
.edit-site-patterns {
|
|
2
|
-
background: rgba(0, 0, 0, 0.
|
|
2
|
+
background: rgba(0, 0, 0, 0.15);
|
|
3
3
|
margin: $header-height 0 0;
|
|
4
|
+
.components-base-control {
|
|
5
|
+
width: 100%;
|
|
6
|
+
@include break-medium {
|
|
7
|
+
width: auto;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
.components-text {
|
|
5
12
|
color: $gray-600;
|
|
6
13
|
}
|
|
@@ -12,33 +19,81 @@
|
|
|
12
19
|
@include break-medium {
|
|
13
20
|
margin: 0;
|
|
14
21
|
}
|
|
22
|
+
|
|
23
|
+
.edit-site-patterns__search-block {
|
|
24
|
+
min-width: fit-content;
|
|
25
|
+
flex-grow: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The increased specificity here is to overcome component styles
|
|
29
|
+
// without relying on internal component class names.
|
|
30
|
+
.edit-site-patterns__search {
|
|
31
|
+
input[type="search"] {
|
|
32
|
+
height: $button-size-next-default-40px;
|
|
33
|
+
background: $gray-800;
|
|
34
|
+
color: $gray-200;
|
|
35
|
+
|
|
36
|
+
&:focus {
|
|
37
|
+
background: $gray-800;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
svg {
|
|
42
|
+
fill: $gray-600;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.edit-site-patterns__sync-status-filter {
|
|
47
|
+
background: $gray-800;
|
|
48
|
+
border: none;
|
|
49
|
+
height: $button-size-next-default-40px;
|
|
50
|
+
min-width: max-content;
|
|
51
|
+
width: 100%;
|
|
52
|
+
max-width: 100%;
|
|
53
|
+
|
|
54
|
+
@include break-medium {
|
|
55
|
+
width: 300px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
.edit-site-patterns__sync-status-filter-option:active {
|
|
59
|
+
background: $gray-700;
|
|
60
|
+
color: $gray-100;
|
|
61
|
+
}
|
|
15
62
|
}
|
|
16
63
|
|
|
17
|
-
.edit-site-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
column-count: 2;
|
|
64
|
+
.edit-site-patterns__section-header {
|
|
65
|
+
.screen-reader-shortcut:focus {
|
|
66
|
+
top: 0;
|
|
21
67
|
}
|
|
68
|
+
}
|
|
22
69
|
|
|
70
|
+
.edit-site-patterns__grid {
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: 1fr;
|
|
73
|
+
gap: $grid-unit-40;
|
|
23
74
|
// Small top padding required to avoid cutting off the visible outline
|
|
24
75
|
// when hovering items.
|
|
25
76
|
padding-top: $border-width-focus-fallback;
|
|
26
77
|
margin-bottom: $grid-unit-40;
|
|
27
|
-
|
|
78
|
+
@include break-large {
|
|
79
|
+
grid-template-columns: 1fr 1fr;
|
|
80
|
+
}
|
|
28
81
|
.edit-site-patterns__pattern {
|
|
29
82
|
break-inside: avoid-column;
|
|
30
83
|
display: flex;
|
|
31
84
|
flex-direction: column;
|
|
32
|
-
margin-bottom: $grid-unit-60;
|
|
33
|
-
|
|
34
85
|
.edit-site-patterns__preview {
|
|
35
|
-
|
|
86
|
+
box-shadow: none;
|
|
87
|
+
border: none;
|
|
88
|
+
padding: 0;
|
|
89
|
+
background-color: unset;
|
|
90
|
+
box-sizing: border-box;
|
|
91
|
+
border-radius: 4px;
|
|
36
92
|
cursor: pointer;
|
|
37
93
|
overflow: hidden;
|
|
38
94
|
|
|
39
95
|
&:focus {
|
|
40
|
-
box-shadow: inset 0 0 0
|
|
41
|
-
|
|
96
|
+
box-shadow: inset 0 0 0 0 $white, 0 0 0 2px var(--wp-admin-theme-color);
|
|
42
97
|
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
43
98
|
outline: 2px solid transparent;
|
|
44
99
|
}
|
|
@@ -46,6 +101,10 @@
|
|
|
46
101
|
&.is-inactive {
|
|
47
102
|
cursor: default;
|
|
48
103
|
}
|
|
104
|
+
&.is-inactive:focus {
|
|
105
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $gray-800;
|
|
106
|
+
opacity: 0.8;
|
|
107
|
+
}
|
|
49
108
|
}
|
|
50
109
|
|
|
51
110
|
.edit-site-patterns__footer,
|
|
@@ -68,31 +127,28 @@
|
|
|
68
127
|
}
|
|
69
128
|
|
|
70
129
|
.edit-site-patterns__preview {
|
|
71
|
-
flex: 1;
|
|
130
|
+
flex: 0 1 auto;
|
|
72
131
|
margin-bottom: $grid-unit-20;
|
|
73
132
|
}
|
|
74
133
|
}
|
|
75
134
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
135
|
+
.edit-site-patterns__load-more {
|
|
136
|
+
align-self: center;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.edit-site-patterns__pattern-title {
|
|
140
|
+
color: $gray-200;
|
|
141
|
+
|
|
142
|
+
.is-link {
|
|
143
|
+
text-decoration: none;
|
|
81
144
|
color: $gray-200;
|
|
82
145
|
|
|
146
|
+
&:hover,
|
|
83
147
|
&:focus {
|
|
84
|
-
|
|
148
|
+
color: $white;
|
|
85
149
|
}
|
|
86
150
|
}
|
|
87
151
|
|
|
88
|
-
svg {
|
|
89
|
-
fill: $gray-600;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.edit-site-patterns__pattern-title {
|
|
94
|
-
color: $gray-600;
|
|
95
|
-
|
|
96
152
|
.edit-site-patterns__pattern-icon {
|
|
97
153
|
border-radius: $grid-unit-05;
|
|
98
154
|
background: var(--wp-block-synced-color);
|
|
@@ -101,6 +157,10 @@
|
|
|
101
157
|
|
|
102
158
|
.edit-site-patterns__pattern-lock-icon {
|
|
103
159
|
display: inline-flex;
|
|
160
|
+
|
|
161
|
+
svg {
|
|
162
|
+
fill: currentcolor;
|
|
163
|
+
}
|
|
104
164
|
}
|
|
105
165
|
}
|
|
106
166
|
|