@wordpress/edit-site 5.12.8 → 5.12.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-page/index.js +1 -6
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +10 -2
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/block-editor/index.js +0 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +12 -6
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +10 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/layout/index.js +25 -22
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-actions/index.js +2 -2
- package/build/components/page-actions/index.js.map +1 -1
- package/build/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -15
- package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +1 -1
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +72 -12
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +3 -4
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +12 -4
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +74 -0
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-template-parts/index.js +2 -23
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +75 -32
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +13 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +13 -18
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +11 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.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/sync-state-with-url/use-sync-path-with-url.js +15 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/add-new-page/index.js +1 -6
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +8 -2
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +0 -4
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +13 -7
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +10 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/layout/index.js +25 -22
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-actions/index.js +2 -2
- package/build-module/components/page-actions/index.js.map +1 -1
- package/build-module/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -16
- package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +1 -1
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +75 -15
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +4 -5
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +12 -4
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-template-parts/index.js +3 -22
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +76 -35
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +14 -8
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +13 -18
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.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/sync-state-with-url/use-sync-path-with-url.js +16 -12
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-style/style-rtl.css +53 -15
- package/build-style/style.css +53 -15
- package/package.json +21 -21
- package/src/components/add-new-page/index.js +0 -3
- package/src/components/add-new-pattern/index.js +8 -2
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/use-site-editor-settings.js +16 -11
- package/src/components/editor/index.js +15 -1
- package/src/components/layout/index.js +38 -43
- package/src/components/layout/style.scss +1 -0
- package/src/components/page-actions/index.js +2 -2
- package/src/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +9 -21
- package/src/components/page-patterns/grid-item.js +1 -1
- package/src/components/page-patterns/grid.js +101 -16
- package/src/components/page-patterns/patterns-list.js +15 -9
- package/src/components/page-patterns/style.scss +21 -1
- package/src/components/page-patterns/use-patterns.js +11 -5
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -22
- package/src/components/resizable-frame/index.js +100 -31
- package/src/components/resizable-frame/style.scss +26 -9
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +1 -1
- package/src/components/sidebar-navigation-item/style.scss +10 -1
- package/src/components/sidebar-navigation-screen/index.js +13 -6
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +1 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-pages/index.js +39 -29
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
- package/src/components/sidebar-navigation-screen-patterns/index.js +29 -30
- package/src/components/sidebar-navigation-screen-patterns/style.scss +5 -7
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +9 -0
- package/src/components/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -0
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
- package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
.edit-site-resizable-frame__inner {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
|
+
&.edit-site-layout__resizable-frame-oversized {
|
|
5
|
+
@at-root {
|
|
6
|
+
body:has(&) {
|
|
7
|
+
.edit-site-site-hub {
|
|
8
|
+
.edit-site-site-hub__site-title,
|
|
9
|
+
.edit-site-site-hub_toggle-command-center {
|
|
10
|
+
opacity: 0 !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.edit-site-site-hub__view-mode-toggle-container {
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
4
21
|
&.is-resizing {
|
|
5
22
|
@at-root {
|
|
6
23
|
body:has(&) {
|
|
@@ -30,11 +47,13 @@
|
|
|
30
47
|
.edit-site-resizable-frame__handle {
|
|
31
48
|
align-items: center;
|
|
32
49
|
background-color: rgba($gray-700, 0.4);
|
|
50
|
+
border: 0;
|
|
33
51
|
border-radius: $grid-unit-05;
|
|
34
52
|
cursor: col-resize;
|
|
35
53
|
display: flex;
|
|
36
54
|
height: $grid-unit-80;
|
|
37
55
|
justify-content: flex-end;
|
|
56
|
+
padding: 0;
|
|
38
57
|
position: absolute;
|
|
39
58
|
top: calc(50% - #{$grid-unit-40});
|
|
40
59
|
width: $grid-unit-05;
|
|
@@ -56,16 +75,14 @@
|
|
|
56
75
|
width: $grid-unit-40;
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
&:
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
&:focus-visible {
|
|
79
|
+
// Works with Windows high contrast mode while also hiding weird outline in Safari.
|
|
80
|
+
outline: 2px solid transparent;
|
|
62
81
|
}
|
|
63
82
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
color:
|
|
68
|
-
margin-right: $grid-unit-10;
|
|
69
|
-
padding: 4px 8px;
|
|
83
|
+
&:hover,
|
|
84
|
+
&:focus,
|
|
85
|
+
&.is-resizing {
|
|
86
|
+
background-color: var(--wp-admin-theme-color);
|
|
70
87
|
}
|
|
71
88
|
}
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
&[aria-current] {
|
|
12
12
|
color: $gray-200;
|
|
13
13
|
background: $gray-800;
|
|
14
|
+
|
|
15
|
+
.edit-site-sidebar-navigation-item__drilldown-indicator {
|
|
16
|
+
fill: $gray-200;
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
&[aria-current] {
|
|
@@ -19,7 +23,7 @@
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
.edit-site-sidebar-navigation-item__drilldown-indicator {
|
|
22
|
-
fill: $gray-
|
|
26
|
+
fill: $gray-600;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
&:is(a) {
|
|
@@ -31,6 +35,11 @@
|
|
|
31
35
|
box-shadow: none;
|
|
32
36
|
outline: none;
|
|
33
37
|
}
|
|
38
|
+
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
41
|
+
outline: 2px solid transparent;
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
&.with-suffix {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import {
|
|
5
5
|
__experimentalHStack as HStack,
|
|
6
6
|
__experimentalHeading as Heading,
|
|
7
|
-
__experimentalNavigatorToParentButton as NavigatorToParentButton,
|
|
8
7
|
__experimentalUseNavigator as useNavigator,
|
|
9
8
|
__experimentalVStack as VStack,
|
|
10
9
|
} from '@wordpress/components';
|
|
@@ -41,7 +40,7 @@ export default function SidebarNavigationScreen( {
|
|
|
41
40
|
};
|
|
42
41
|
}, [] );
|
|
43
42
|
const { getTheme } = useSelect( coreStore );
|
|
44
|
-
const
|
|
43
|
+
const navigator = useNavigator();
|
|
45
44
|
const theme = getTheme( currentlyPreviewingTheme() );
|
|
46
45
|
const icon = isRTL() ? chevronRight : chevronLeft;
|
|
47
46
|
|
|
@@ -58,16 +57,24 @@ export default function SidebarNavigationScreen( {
|
|
|
58
57
|
className="edit-site-sidebar-navigation-screen__title-icon"
|
|
59
58
|
>
|
|
60
59
|
{ ! isRoot && ! backPath && (
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
<SidebarButton
|
|
61
|
+
onClick={ () => {
|
|
62
|
+
if ( navigator.location.isInitial ) {
|
|
63
|
+
navigator.goToParent( { replace: true } );
|
|
64
|
+
} else {
|
|
65
|
+
navigator.goBack();
|
|
66
|
+
}
|
|
67
|
+
} }
|
|
68
|
+
icon={ icon }
|
|
64
69
|
label={ __( 'Back' ) }
|
|
65
70
|
showTooltip={ false }
|
|
66
71
|
/>
|
|
67
72
|
) }
|
|
68
73
|
{ ! isRoot && backPath && (
|
|
69
74
|
<SidebarButton
|
|
70
|
-
onClick={ () =>
|
|
75
|
+
onClick={ () =>
|
|
76
|
+
navigator.goTo( backPath, { isBack: true } )
|
|
77
|
+
}
|
|
71
78
|
icon={ icon }
|
|
72
79
|
label={ __( 'Back' ) }
|
|
73
80
|
showTooltip={ false }
|
|
@@ -28,9 +28,7 @@ export default function TemplatePartHint() {
|
|
|
28
28
|
setPreference( 'core', PREFERENCE_NAME, false );
|
|
29
29
|
} }
|
|
30
30
|
>
|
|
31
|
-
{ __(
|
|
32
|
-
'Looking for template parts? You can now find them in the new "Patterns" page.'
|
|
33
|
-
) }
|
|
31
|
+
{ __( 'Looking for template parts? Find them in "Patterns".' ) }
|
|
34
32
|
</Notice>
|
|
35
33
|
);
|
|
36
34
|
}
|
|
@@ -23,13 +23,13 @@ export default function SingleNavigationMenu( {
|
|
|
23
23
|
<SidebarNavigationScreenWrapper
|
|
24
24
|
actions={
|
|
25
25
|
<>
|
|
26
|
-
<EditButton postId={ navigationMenu?.id } />
|
|
27
26
|
<ScreenNavigationMoreMenu
|
|
28
27
|
menuTitle={ decodeEntities( menuTitle ) }
|
|
29
28
|
onDelete={ handleDelete }
|
|
30
29
|
onSave={ handleSave }
|
|
31
30
|
onDuplicate={ handleDuplicate }
|
|
32
31
|
/>
|
|
32
|
+
<EditButton postId={ navigationMenu?.id } />
|
|
33
33
|
</>
|
|
34
34
|
}
|
|
35
35
|
title={ decodeEntities( menuTitle ) }
|
|
@@ -58,13 +58,16 @@ export default function SidebarNavigationScreenPages() {
|
|
|
58
58
|
templates?.find( ( template ) => template.slug === 'home' ) ||
|
|
59
59
|
templates?.find( ( template ) => template.slug === 'index' );
|
|
60
60
|
|
|
61
|
+
const getPostsPageTemplate = () =>
|
|
62
|
+
templates?.find( ( template ) => template.slug === 'home' ) ||
|
|
63
|
+
templates?.find( ( template ) => template.slug === 'index' );
|
|
64
|
+
|
|
61
65
|
const pagesAndTemplates = pages?.concat( dynamicPageTemplates, [
|
|
62
66
|
homeTemplate,
|
|
63
67
|
] );
|
|
64
68
|
|
|
65
69
|
const { frontPage, postsPage } = useSelect( ( select ) => {
|
|
66
70
|
const { getEntityRecord } = select( coreStore );
|
|
67
|
-
|
|
68
71
|
const siteSettings = getEntityRecord( 'root', 'site' );
|
|
69
72
|
return {
|
|
70
73
|
frontPage: siteSettings?.page_on_front,
|
|
@@ -106,6 +109,27 @@ export default function SidebarNavigationScreenPages() {
|
|
|
106
109
|
setShowAddPage( false );
|
|
107
110
|
};
|
|
108
111
|
|
|
112
|
+
const getPageProps = ( id ) => {
|
|
113
|
+
let itemIcon = page;
|
|
114
|
+
const postsPageTemplateId =
|
|
115
|
+
postsPage && postsPage === id ? getPostsPageTemplate()?.id : null;
|
|
116
|
+
|
|
117
|
+
switch ( id ) {
|
|
118
|
+
case frontPage:
|
|
119
|
+
itemIcon = home;
|
|
120
|
+
break;
|
|
121
|
+
case postsPage:
|
|
122
|
+
itemIcon = verse;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
icon: itemIcon,
|
|
128
|
+
postType: postsPageTemplateId ? 'wp_template' : 'page',
|
|
129
|
+
postId: postsPageTemplateId || id,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
109
133
|
return (
|
|
110
134
|
<>
|
|
111
135
|
{ showAddPage && (
|
|
@@ -152,34 +176,20 @@ export default function SidebarNavigationScreenPages() {
|
|
|
152
176
|
</Truncate>
|
|
153
177
|
</PageItem>
|
|
154
178
|
) }
|
|
155
|
-
{ reorderedPages?.map( (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
postId={ item.id }
|
|
170
|
-
key={ item.id }
|
|
171
|
-
icon={ itemIcon }
|
|
172
|
-
withChevron
|
|
173
|
-
>
|
|
174
|
-
<Truncate numberOfLines={ 1 }>
|
|
175
|
-
{ decodeEntities(
|
|
176
|
-
item?.title?.rendered ||
|
|
177
|
-
__( '(no title)' )
|
|
178
|
-
) }
|
|
179
|
-
</Truncate>
|
|
180
|
-
</PageItem>
|
|
181
|
-
);
|
|
182
|
-
} ) }
|
|
179
|
+
{ reorderedPages?.map( ( { id, title } ) => (
|
|
180
|
+
<PageItem
|
|
181
|
+
{ ...getPageProps( id ) }
|
|
182
|
+
key={ id }
|
|
183
|
+
withChevron
|
|
184
|
+
>
|
|
185
|
+
<Truncate numberOfLines={ 1 }>
|
|
186
|
+
{ decodeEntities(
|
|
187
|
+
title?.rendered ||
|
|
188
|
+
__( '(no title)' )
|
|
189
|
+
) }
|
|
190
|
+
</Truncate>
|
|
191
|
+
</PageItem>
|
|
192
|
+
) ) }
|
|
183
193
|
</ItemGroup>
|
|
184
194
|
) }
|
|
185
195
|
</>
|
|
@@ -19,8 +19,9 @@ export default function TemplatePartNavigationMenu( { id } ) {
|
|
|
19
19
|
<>
|
|
20
20
|
<Heading
|
|
21
21
|
className="edit-site-sidebar-navigation-screen-template-part-navigation-menu__title"
|
|
22
|
-
size="
|
|
22
|
+
size="11"
|
|
23
23
|
upperCase={ true }
|
|
24
|
+
weight={ 500 }
|
|
24
25
|
>
|
|
25
26
|
{ title?.rendered || __( 'Navigation' ) }
|
|
26
27
|
</Heading>
|
|
@@ -22,8 +22,9 @@ export default function TemplatePartNavigationMenus( { menus } ) {
|
|
|
22
22
|
<>
|
|
23
23
|
<Heading
|
|
24
24
|
className="edit-site-sidebar-navigation-screen-template-part-navigation-menu__title"
|
|
25
|
-
size="
|
|
25
|
+
size="11"
|
|
26
26
|
upperCase={ true }
|
|
27
|
+
weight={ 500 }
|
|
27
28
|
>
|
|
28
29
|
{ __( 'Navigation' ) }
|
|
29
30
|
</Heading>
|
|
@@ -61,9 +61,6 @@ function TemplatePartGroup( { areas, currentArea, currentType } ) {
|
|
|
61
61
|
function ThemePatternsGroup( { categories, currentCategory, currentType } ) {
|
|
62
62
|
return (
|
|
63
63
|
<>
|
|
64
|
-
<div className="edit-site-sidebar-navigation-screen-patterns__group-header">
|
|
65
|
-
<Heading level={ 2 }>{ __( 'Theme patterns' ) }</Heading>
|
|
66
|
-
</div>
|
|
67
64
|
<ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
|
|
68
65
|
{ categories.map( ( category ) => (
|
|
69
66
|
<CategoryItem
|
|
@@ -107,7 +104,7 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
107
104
|
const { templatePartAreas, hasTemplateParts, isLoading } =
|
|
108
105
|
useTemplatePartAreas();
|
|
109
106
|
const { patternCategories, hasPatterns } = usePatternCategories();
|
|
110
|
-
const { myPatterns
|
|
107
|
+
const { myPatterns } = useMyPatterns();
|
|
111
108
|
|
|
112
109
|
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
113
110
|
const settings = select( editSiteStore ).getSettings();
|
|
@@ -117,9 +114,6 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
117
114
|
const templatePartsLink = useLink( { path: '/wp_template_part/all' } );
|
|
118
115
|
const footer = ! isMobileViewport ? (
|
|
119
116
|
<ItemGroup>
|
|
120
|
-
<SidebarNavigationItem withChevron { ...templatePartsLink }>
|
|
121
|
-
{ __( 'Manage all template parts' ) }
|
|
122
|
-
</SidebarNavigationItem>
|
|
123
117
|
<SidebarNavigationItem
|
|
124
118
|
as="a"
|
|
125
119
|
href="edit.php?post_type=wp_block"
|
|
@@ -127,6 +121,9 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
127
121
|
>
|
|
128
122
|
{ __( 'Manage all of my patterns' ) }
|
|
129
123
|
</SidebarNavigationItem>
|
|
124
|
+
<SidebarNavigationItem withChevron { ...templatePartsLink }>
|
|
125
|
+
{ __( 'Manage all template parts' ) }
|
|
126
|
+
</SidebarNavigationItem>
|
|
130
127
|
</ItemGroup>
|
|
131
128
|
) : undefined;
|
|
132
129
|
|
|
@@ -153,30 +150,25 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
153
150
|
</Item>
|
|
154
151
|
</ItemGroup>
|
|
155
152
|
) }
|
|
156
|
-
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
{ hasTemplateParts && (
|
|
174
|
-
<TemplatePartGroup
|
|
175
|
-
areas={ templatePartAreas }
|
|
176
|
-
currentArea={ currentCategory }
|
|
177
|
-
currentType={ currentType }
|
|
153
|
+
<ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
|
|
154
|
+
<CategoryItem
|
|
155
|
+
key={ myPatterns.name }
|
|
156
|
+
count={
|
|
157
|
+
! myPatterns.count
|
|
158
|
+
? '0'
|
|
159
|
+
: myPatterns.count
|
|
160
|
+
}
|
|
161
|
+
label={ myPatterns.label }
|
|
162
|
+
icon={ starFilled }
|
|
163
|
+
id={ myPatterns.name }
|
|
164
|
+
type="wp_block"
|
|
165
|
+
isActive={
|
|
166
|
+
currentCategory ===
|
|
167
|
+
`${ myPatterns.name }` &&
|
|
168
|
+
currentType === 'wp_block'
|
|
169
|
+
}
|
|
178
170
|
/>
|
|
179
|
-
|
|
171
|
+
</ItemGroup>
|
|
180
172
|
{ hasPatterns && (
|
|
181
173
|
<ThemePatternsGroup
|
|
182
174
|
categories={ patternCategories }
|
|
@@ -184,6 +176,13 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
184
176
|
currentType={ currentType }
|
|
185
177
|
/>
|
|
186
178
|
) }
|
|
179
|
+
{ hasTemplateParts && (
|
|
180
|
+
<TemplatePartGroup
|
|
181
|
+
areas={ templatePartAreas }
|
|
182
|
+
currentArea={ currentCategory }
|
|
183
|
+
currentType={ currentType }
|
|
184
|
+
/>
|
|
185
|
+
) }
|
|
187
186
|
</>
|
|
188
187
|
) }
|
|
189
188
|
</>
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
.edit-site-sidebar-navigation-screen-patterns__group {
|
|
2
|
-
margin-bottom: $grid-unit-
|
|
3
|
-
|
|
4
|
-
&:
|
|
2
|
+
margin-bottom: $grid-unit-30;
|
|
3
|
+
|
|
4
|
+
&:last-of-type {
|
|
5
5
|
border-bottom: 0;
|
|
6
6
|
padding-bottom: 0;
|
|
7
7
|
margin-bottom: 0;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
&:first-of-type {
|
|
11
|
-
margin-bottom: $grid-unit-40;
|
|
12
|
-
}
|
|
13
9
|
}
|
|
14
10
|
|
|
15
11
|
.edit-site-sidebar-navigation-screen-patterns__group-header {
|
|
12
|
+
margin-top: $grid-unit-20;
|
|
13
|
+
|
|
16
14
|
p {
|
|
17
15
|
color: $gray-600;
|
|
18
16
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -11,6 +12,10 @@ import useThemePatterns from './use-theme-patterns';
|
|
|
11
12
|
|
|
12
13
|
export default function usePatternCategories() {
|
|
13
14
|
const defaultCategories = useDefaultPatternCategories();
|
|
15
|
+
defaultCategories.push( {
|
|
16
|
+
name: 'uncategorized',
|
|
17
|
+
label: __( 'Uncategorized' ),
|
|
18
|
+
} );
|
|
14
19
|
const themePatterns = useThemePatterns();
|
|
15
20
|
|
|
16
21
|
const patternCategories = useMemo( () => {
|
|
@@ -31,6 +36,10 @@ export default function usePatternCategories() {
|
|
|
31
36
|
categoryMap[ category ].count += 1;
|
|
32
37
|
}
|
|
33
38
|
} );
|
|
39
|
+
// If the pattern has no categories, add it to uncategorized.
|
|
40
|
+
if ( ! pattern.categories?.length ) {
|
|
41
|
+
categoryMap.uncategorized.count += 1;
|
|
42
|
+
}
|
|
34
43
|
} );
|
|
35
44
|
|
|
36
45
|
// Filter categories so we only have those containing patterns.
|
|
@@ -51,7 +51,10 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
51
51
|
const { open: openCommandCenter } = useDispatch( commandsStore );
|
|
52
52
|
|
|
53
53
|
const disableMotion = useReducedMotion();
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
setCanvasMode,
|
|
56
|
+
__experimentalSetPreviewDeviceType: setPreviewDeviceType,
|
|
57
|
+
} = unlock( useDispatch( editSiteStore ) );
|
|
55
58
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
56
59
|
const isBackToDashboardButton = canvasMode === 'view';
|
|
57
60
|
const siteIconButtonProps = isBackToDashboardButton
|
|
@@ -67,6 +70,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
67
70
|
event.preventDefault();
|
|
68
71
|
if ( canvasMode === 'edit' ) {
|
|
69
72
|
clearSelectedBlock();
|
|
73
|
+
setPreviewDeviceType( 'desktop' );
|
|
70
74
|
setCanvasMode( 'view' );
|
|
71
75
|
}
|
|
72
76
|
},
|
|
@@ -36,6 +36,12 @@ export function getPathFromURL( urlParams ) {
|
|
|
36
36
|
return path;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function isSubset( subset, superset ) {
|
|
40
|
+
return Object.entries( subset ).every( ( [ key, value ] ) => {
|
|
41
|
+
return superset[ key ] === value;
|
|
42
|
+
} );
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
export default function useSyncPathWithURL() {
|
|
40
46
|
const history = useHistory();
|
|
41
47
|
const { params: urlParams } = useLocation();
|
|
@@ -44,76 +50,77 @@ export default function useSyncPathWithURL() {
|
|
|
44
50
|
params: navigatorParams,
|
|
45
51
|
goTo,
|
|
46
52
|
} = useNavigator();
|
|
47
|
-
const currentUrlParams = useRef( urlParams );
|
|
48
|
-
const currentPath = useRef( navigatorLocation.path );
|
|
49
53
|
const isMounting = useRef( true );
|
|
50
54
|
|
|
51
|
-
useEffect(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
isMounting.current
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function updateUrlParams( newUrlParams ) {
|
|
60
|
-
if (
|
|
61
|
-
Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
|
|
62
|
-
return currentUrlParams.current[ key ] === value;
|
|
63
|
-
} )
|
|
64
|
-
) {
|
|
55
|
+
useEffect(
|
|
56
|
+
() => {
|
|
57
|
+
// The navigatorParams are only initially filled properly when the
|
|
58
|
+
// navigator screens mount. so we ignore the first synchronisation.
|
|
59
|
+
if ( isMounting.current ) {
|
|
60
|
+
isMounting.current = false;
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
67
|
-
const updatedParams = {
|
|
68
|
-
...currentUrlParams.current,
|
|
69
|
-
...newUrlParams,
|
|
70
|
-
};
|
|
71
|
-
currentUrlParams.current = updatedParams;
|
|
72
|
-
history.push( updatedParams );
|
|
73
|
-
}
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
updateUrlParams( {
|
|
86
|
-
postType: 'page',
|
|
87
|
-
postId: navigatorParams?.postId,
|
|
88
|
-
path: undefined,
|
|
89
|
-
} );
|
|
90
|
-
} else if ( navigatorLocation.path === '/patterns' ) {
|
|
91
|
-
updateUrlParams( {
|
|
92
|
-
postType: undefined,
|
|
93
|
-
postId: undefined,
|
|
94
|
-
canvas: undefined,
|
|
95
|
-
path: navigatorLocation.path,
|
|
96
|
-
} );
|
|
97
|
-
} else {
|
|
98
|
-
updateUrlParams( {
|
|
99
|
-
postType: undefined,
|
|
100
|
-
postId: undefined,
|
|
101
|
-
categoryType: undefined,
|
|
102
|
-
categoryId: undefined,
|
|
103
|
-
path:
|
|
104
|
-
navigatorLocation.path === '/'
|
|
105
|
-
? undefined
|
|
106
|
-
: navigatorLocation.path,
|
|
107
|
-
} );
|
|
108
|
-
}
|
|
109
|
-
}, [ navigatorLocation?.path, navigatorParams, history ] );
|
|
64
|
+
function updateUrlParams( newUrlParams ) {
|
|
65
|
+
if ( isSubset( newUrlParams, urlParams ) ) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const updatedParams = {
|
|
69
|
+
...urlParams,
|
|
70
|
+
...newUrlParams,
|
|
71
|
+
};
|
|
72
|
+
history.push( updatedParams );
|
|
73
|
+
}
|
|
110
74
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
75
|
+
if ( navigatorParams?.postType && navigatorParams?.postId ) {
|
|
76
|
+
updateUrlParams( {
|
|
77
|
+
postType: navigatorParams?.postType,
|
|
78
|
+
postId: navigatorParams?.postId,
|
|
79
|
+
path: undefined,
|
|
80
|
+
} );
|
|
81
|
+
} else if (
|
|
82
|
+
navigatorLocation.path.startsWith( '/page/' ) &&
|
|
83
|
+
navigatorParams?.postId
|
|
84
|
+
) {
|
|
85
|
+
updateUrlParams( {
|
|
86
|
+
postType: 'page',
|
|
87
|
+
postId: navigatorParams?.postId,
|
|
88
|
+
path: undefined,
|
|
89
|
+
} );
|
|
90
|
+
} else if ( navigatorLocation.path === '/patterns' ) {
|
|
91
|
+
updateUrlParams( {
|
|
92
|
+
postType: undefined,
|
|
93
|
+
postId: undefined,
|
|
94
|
+
canvas: undefined,
|
|
95
|
+
path: navigatorLocation.path,
|
|
96
|
+
} );
|
|
97
|
+
} else {
|
|
98
|
+
updateUrlParams( {
|
|
99
|
+
postType: undefined,
|
|
100
|
+
postId: undefined,
|
|
101
|
+
categoryType: undefined,
|
|
102
|
+
categoryId: undefined,
|
|
103
|
+
path:
|
|
104
|
+
navigatorLocation.path === '/'
|
|
105
|
+
? undefined
|
|
106
|
+
: navigatorLocation.path,
|
|
107
|
+
} );
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
// Trigger only when navigator changes to prevent infinite loops.
|
|
111
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
+
[ navigatorLocation?.path, navigatorParams ]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
useEffect(
|
|
116
|
+
() => {
|
|
117
|
+
const path = getPathFromURL( urlParams );
|
|
118
|
+
if ( navigatorLocation.path !== path ) {
|
|
119
|
+
goTo( path );
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
// Trigger only when URL changes to prevent infinite loops.
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
+
[ urlParams ]
|
|
125
|
+
);
|
|
119
126
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-actions/delete-page-menu-item.js"],"names":["DeletePageMenuItem","postId","onRemove","isModalOpen","setIsModalOpen","createSuccessNotice","createErrorNotice","noticesStore","deleteEntityRecord","coreStore","page","select","getEntityRecord","removePage","throwOnError","title","rendered","type","id","error","errorMessage","message","code"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AACA;;AACA;;AAIA;;AAZA;AACA;AACA;AAYe,SAASA,kBAAT,CAA6B;AAAEC,EAAAA,MAAF;AAAUC,EAAAA;AAAV,CAA7B,EAAoD;AAClE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL,uBAAaC,cAAb,CADD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaC,eAAb,CAA/B;AACA,QAAMC,IAAI,GAAG,qBACVC,MAAF,IACCA,MAAM,CAAEF,eAAF,CAAN,CAAoBG,eAApB,CAAqC,UAArC,EAAiD,MAAjD,EAAyDX,MAAzD,CAFW,EAGZ,CAAEA,MAAF,CAHY,CAAb;;AAKA,iBAAeY,UAAf,GAA4B;AAC3B,QAAI;AACH,YAAML,kBAAkB,CACvB,UADuB,EAEvB,MAFuB,EAGvBP,MAHuB,EAIvB,EAJuB,EAKvB;AAAEa,QAAAA,YAAY,EAAE;AAAhB,OALuB,CAAxB;AAOAT,MAAAA,mBAAmB,CAClB;AACC;AACA,oBAAI,eAAJ,CAFD,EAGC,kCAAgBK,IAAI,CAACK,KAAL,CAAWC,QAA3B,CAHD,CADkB,EAMlB;AACCC,QAAAA,IAAI,EAAE,UADP;AAECC,QAAAA,EAAE,EAAE;AAFL,OANkB,CAAnB;AAWAhB,MAAAA,QAAQ;AACR,KApBD,CAoBE,OAAQiB,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,4CAAJ,CAHJ;AAKAf,MAAAA,iBAAiB,CAAEc,YAAF,EAAgB;AAAEH,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA,KA3BD,SA2BU;AACTb,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AACD,SACC,qDACC,4BAAC,oBAAD;AAAU,IAAA,OAAO,EAAG,MAAMA,cAAc,CAAE,IAAF,CAAxC;AAAmD,IAAA,aAAa;AAAhE,KACG,cAAI,QAAJ,CADH,CADD,EAIC,4BAAC,uCAAD;AACC,IAAA,MAAM,EAAGD,WADV;AAEC,IAAA,SAAS,EAAGU,UAFb;AAGC,IAAA,QAAQ,EAAG,MAAMT,cAAc,CAAE,KAAF;AAHhC,KAKG,cAAI,4CAAJ,CALH,CAJD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function DeletePageMenuItem( { postId, onRemove } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst page = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', 'page', postId ),\n\t\t[ postId ]\n\t);\n\tasync function removePage() {\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\tpostId,\n\t\t\t\t{},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\tdecodeEntities( page.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-page-removed',\n\t\t\t\t}\n\t\t\t);\n\t\t\tonRemove?.();\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the page.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t} finally {\n\t\t\tsetIsModalOpen( false );\n\t\t}\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setIsModalOpen( true ) } isDestructive>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ removePage }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t>\n\t\t\t\t{ __( 'Are you sure you want to delete this page?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-actions/delete-page-menu-item.js"],"names":["useDispatch","useSelect","decodeEntities","useState","store","coreStore","__","sprintf","MenuItem","__experimentalConfirmDialog","ConfirmDialog","noticesStore","DeletePageMenuItem","postId","onRemove","isModalOpen","setIsModalOpen","createSuccessNotice","createErrorNotice","deleteEntityRecord","page","select","getEntityRecord","removePage","throwOnError","title","rendered","type","id","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,QADD,EAECC,2BAA2B,IAAIC,aAFhC,QAGO,uBAHP;AAIA,SAASN,KAAK,IAAIO,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,MAAF;AAAUC,EAAAA;AAAV,CAA7B,EAAoD;AAClE,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCb,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAEc,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACLlB,WAAW,CAAEW,YAAF,CADZ;AAEA,QAAM;AAAEQ,IAAAA;AAAF,MAAyBnB,WAAW,CAAEK,SAAF,CAA1C;AACA,QAAMe,IAAI,GAAGnB,SAAS,CACnBoB,MAAF,IACCA,MAAM,CAAEhB,SAAF,CAAN,CAAoBiB,eAApB,CAAqC,UAArC,EAAiD,MAAjD,EAAyDT,MAAzD,CAFoB,EAGrB,CAAEA,MAAF,CAHqB,CAAtB;;AAKA,iBAAeU,UAAf,GAA4B;AAC3B,QAAI;AACH,YAAMJ,kBAAkB,CACvB,UADuB,EAEvB,MAFuB,EAGvBN,MAHuB,EAIvB,EAJuB,EAKvB;AAAEW,QAAAA,YAAY,EAAE;AAAhB,OALuB,CAAxB;AAOAP,MAAAA,mBAAmB,CAClBV,OAAO;AACN;AACAD,MAAAA,EAAE,CAAE,eAAF,CAFI,EAGNJ,cAAc,CAAEkB,IAAI,CAACK,KAAL,CAAWC,QAAb,CAHR,CADW,EAMlB;AACCC,QAAAA,IAAI,EAAE,UADP;AAECC,QAAAA,EAAE,EAAE;AAFL,OANkB,CAAnB;AAWAd,MAAAA,QAAQ;AACR,KApBD,CAoBE,OAAQe,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEGzB,EAAE,CAAE,4CAAF,CAHN;AAKAY,MAAAA,iBAAiB,CAAEY,YAAF,EAAgB;AAAEH,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA,KA3BD,SA2BU;AACTX,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AACD,SACC,8BACC,cAAC,QAAD;AAAU,IAAA,OAAO,EAAG,MAAMA,cAAc,CAAE,IAAF,CAAxC;AAAmD,IAAA,aAAa;AAAhE,KACGV,EAAE,CAAE,QAAF,CADL,CADD,EAIC,cAAC,aAAD;AACC,IAAA,MAAM,EAAGS,WADV;AAEC,IAAA,SAAS,EAAGQ,UAFb;AAGC,IAAA,QAAQ,EAAG,MAAMP,cAAc,CAAE,KAAF;AAHhC,KAKGV,EAAE,CAAE,4CAAF,CALL,CAJD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function DeletePageMenuItem( { postId, onRemove } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst page = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', 'page', postId ),\n\t\t[ postId ]\n\t);\n\tasync function removePage() {\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\tpostId,\n\t\t\t\t{},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\tdecodeEntities( page.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-page-removed',\n\t\t\t\t}\n\t\t\t);\n\t\t\tonRemove?.();\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the page.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t} finally {\n\t\t\tsetIsModalOpen( false );\n\t\t}\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setIsModalOpen( true ) } isDestructive>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ removePage }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t>\n\t\t\t\t{ __( 'Are you sure you want to delete this page?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"]}
|