@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,27 +1,40 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useState, useDeferredValue, useId } from '@wordpress/element';
|
|
7
|
+
import { SearchControl, __experimentalVStack as VStack, Flex, FlexBlock, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalHeading as Heading, __experimentalText as Text } from '@wordpress/components';
|
|
7
8
|
import { __, isRTL } from '@wordpress/i18n';
|
|
8
|
-
import {
|
|
9
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
9
10
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
11
|
+
import { useViewportMatch, useAsyncList } from '@wordpress/compose';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
14
15
|
|
|
16
|
+
import PatternsHeader from './header';
|
|
15
17
|
import Grid from './grid';
|
|
16
18
|
import NoPatterns from './no-patterns';
|
|
17
19
|
import usePatterns from './use-patterns';
|
|
18
20
|
import SidebarButton from '../sidebar-button';
|
|
19
21
|
import useDebouncedInput from '../../utils/use-debounced-input';
|
|
20
22
|
import { unlock } from '../../lock-unlock';
|
|
23
|
+
import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
|
|
21
24
|
const {
|
|
22
25
|
useLocation,
|
|
23
26
|
useHistory
|
|
24
27
|
} = unlock(routerPrivateApis);
|
|
28
|
+
const SYNC_FILTERS = {
|
|
29
|
+
all: __('All'),
|
|
30
|
+
[SYNC_TYPES.full]: __('Synced'),
|
|
31
|
+
[SYNC_TYPES.unsynced]: __('Standard')
|
|
32
|
+
};
|
|
33
|
+
const SYNC_DESCRIPTIONS = {
|
|
34
|
+
all: '',
|
|
35
|
+
[SYNC_TYPES.full]: __('Patterns that are kept in sync across the site.'),
|
|
36
|
+
[SYNC_TYPES.unsynced]: __('Patterns that can be changed freely without affecting the site.')
|
|
37
|
+
};
|
|
25
38
|
export default function PatternsList({
|
|
26
39
|
categoryId,
|
|
27
40
|
type
|
|
@@ -30,15 +43,34 @@ export default function PatternsList({
|
|
|
30
43
|
const history = useHistory();
|
|
31
44
|
const isMobileViewport = useViewportMatch('medium', '<');
|
|
32
45
|
const [filterValue, setFilterValue, delayedFilterValue] = useDebouncedInput('');
|
|
33
|
-
const
|
|
46
|
+
const deferredFilterValue = useDeferredValue(delayedFilterValue);
|
|
47
|
+
const [syncFilter, setSyncFilter] = useState('all');
|
|
48
|
+
const deferredSyncedFilter = useDeferredValue(syncFilter);
|
|
34
49
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} =
|
|
38
|
-
|
|
50
|
+
patterns,
|
|
51
|
+
isResolving
|
|
52
|
+
} = usePatterns(type, categoryId, {
|
|
53
|
+
search: deferredFilterValue,
|
|
54
|
+
syncStatus: deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter
|
|
55
|
+
});
|
|
56
|
+
const id = useId();
|
|
57
|
+
const titleId = `${id}-title`;
|
|
58
|
+
const descriptionId = `${id}-description`;
|
|
59
|
+
const hasPatterns = patterns.length;
|
|
60
|
+
const title = SYNC_FILTERS[syncFilter];
|
|
61
|
+
const description = SYNC_DESCRIPTIONS[syncFilter];
|
|
62
|
+
const shownPatterns = useAsyncList(patterns);
|
|
39
63
|
return createElement(VStack, {
|
|
40
64
|
spacing: 6
|
|
41
|
-
}, createElement(
|
|
65
|
+
}, createElement(PatternsHeader, {
|
|
66
|
+
categoryId: categoryId,
|
|
67
|
+
type: type,
|
|
68
|
+
titleId: titleId,
|
|
69
|
+
descriptionId: descriptionId
|
|
70
|
+
}), createElement(Flex, {
|
|
71
|
+
alignment: "stretch",
|
|
72
|
+
wrap: true
|
|
73
|
+
}, isMobileViewport && createElement(SidebarButton, {
|
|
42
74
|
icon: isRTL() ? chevronRight : chevronLeft,
|
|
43
75
|
label: __('Back'),
|
|
44
76
|
onClick: () => {
|
|
@@ -52,36 +84,43 @@ export default function PatternsList({
|
|
|
52
84
|
});
|
|
53
85
|
}
|
|
54
86
|
}
|
|
55
|
-
}), createElement(FlexBlock,
|
|
87
|
+
}), createElement(FlexBlock, {
|
|
88
|
+
className: "edit-site-patterns__search-block"
|
|
89
|
+
}, createElement(SearchControl, {
|
|
56
90
|
className: "edit-site-patterns__search",
|
|
57
91
|
onChange: value => setFilterValue(value),
|
|
58
92
|
placeholder: __('Search patterns'),
|
|
59
93
|
label: __('Search patterns'),
|
|
60
94
|
value: filterValue,
|
|
61
95
|
__nextHasNoMarginBottom: true
|
|
62
|
-
}))
|
|
63
|
-
className: "edit-site-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
})), categoryId === USER_PATTERN_CATEGORY && createElement(ToggleGroupControl, {
|
|
97
|
+
className: "edit-site-patterns__sync-status-filter",
|
|
98
|
+
hideLabelFromVision: true,
|
|
99
|
+
label: __('Filter by sync status'),
|
|
100
|
+
value: syncFilter,
|
|
101
|
+
isBlock: true,
|
|
102
|
+
onChange: value => setSyncFilter(value),
|
|
103
|
+
__nextHasNoMarginBottom: true
|
|
104
|
+
}, Object.entries(SYNC_FILTERS).map(([key, label]) => createElement(ToggleGroupControlOption, {
|
|
105
|
+
className: "edit-site-patterns__sync-status-filter-option",
|
|
106
|
+
key: key,
|
|
107
|
+
value: key,
|
|
108
|
+
label: label
|
|
109
|
+
})))), syncFilter !== 'all' && createElement(VStack, {
|
|
75
110
|
className: "edit-site-patterns__section-header"
|
|
76
111
|
}, createElement(Heading, {
|
|
77
|
-
|
|
78
|
-
|
|
112
|
+
as: "h3",
|
|
113
|
+
level: 4,
|
|
114
|
+
id: titleId
|
|
115
|
+
}, title), description ? createElement(Text, {
|
|
79
116
|
variant: "muted",
|
|
80
|
-
as: "p"
|
|
81
|
-
|
|
117
|
+
as: "p",
|
|
118
|
+
id: descriptionId
|
|
119
|
+
}, description) : null), hasPatterns && createElement(Grid, {
|
|
82
120
|
categoryId: categoryId,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
121
|
+
items: shownPatterns,
|
|
122
|
+
"aria-labelledby": titleId,
|
|
123
|
+
"aria-describedby": descriptionId
|
|
124
|
+
}), !isResolving && !hasPatterns && createElement(NoPatterns, null));
|
|
86
125
|
}
|
|
87
126
|
//# sourceMappingURL=patterns-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["SearchControl","__experimentalHeading","Heading","__experimentalText","Text","__experimentalVStack","VStack","Flex","FlexBlock","__","isRTL","symbol","chevronLeft","chevronRight","privateApis","routerPrivateApis","useViewportMatch","Grid","NoPatterns","usePatterns","SidebarButton","useDebouncedInput","unlock","useLocation","useHistory","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","patterns","isResolving","syncedPatterns","unsyncedPatterns","hasPatterns","length","state","backPath","back","push","path","value"],"mappings":";;AAAA;AACA;AACA;AAEA,SACCA,aADD,EAECC,qBAAqB,IAAIC,OAF1B,EAGCC,kBAAkB,IAAIC,IAHvB,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,IALD,EAMCC,SAND,QAOO,uBAPP;AAQA,SAASC,EAAT,EAAaC,KAAb,QAA0B,iBAA1B;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,YAA9B,QAAkD,kBAAlD;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,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ADG,CADL,CAFD,CADD,EASC,cAAC,IAAD;AACC,IAAA,UAAU,EAAGiB,UADd;AAEC,IAAA,KAAK,EAAGjB,EAAE,CAAE,mBAAF,CAFX;AAGC,IAAA,KAAK,EAAG4B;AAHT,IATD,CAhDF,EAgEG,CAAEF,WAAF,IAAiB,CAAEG,WAAnB,IAAkC,cAAC,UAAD,OAhErC,CADD;AAoEA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport {\n\tSearchControl,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { symbol, chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\n\tconst [ patterns, isResolving ] = usePatterns(\n\t\ttype,\n\t\tcategoryId,\n\t\tdelayedFilterValue\n\t);\n\n\tconst { syncedPatterns, unsyncedPatterns } = patterns;\n\tconst hasPatterns = !! syncedPatterns.length || !! unsyncedPatterns.length;\n\n\treturn (\n\t\t<VStack spacing={ 6 }>\n\t\t\t<Flex>\n\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\tif ( location.state?.backPath === '/patterns' ) {\n\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t\t{ isResolving && __( 'Loading' ) }\n\t\t\t{ ! isResolving && !! syncedPatterns.length && (\n\t\t\t\t<>\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading level={ 4 }>{ __( 'Synced' ) }</Heading>\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Patterns that are kept in sync across your site'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<Grid\n\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t\t\t\t\titems={ syncedPatterns }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isResolving && !! unsyncedPatterns.length && (\n\t\t\t\t<>\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading level={ 4 }>{ __( 'Standard' ) }</Heading>\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Patterns that can be changed freely without affecting your site'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\tlabel={ __( 'Standard patterns' ) }\n\t\t\t\t\t\titems={ unsyncedPatterns }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["useState","useDeferredValue","useId","SearchControl","__experimentalVStack","VStack","Flex","FlexBlock","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalHeading","Heading","__experimentalText","Text","__","isRTL","chevronLeft","chevronRight","privateApis","routerPrivateApis","useViewportMatch","useAsyncList","PatternsHeader","Grid","NoPatterns","usePatterns","SidebarButton","useDebouncedInput","unlock","SYNC_TYPES","USER_PATTERN_CATEGORY","useLocation","useHistory","SYNC_FILTERS","all","full","unsynced","SYNC_DESCRIPTIONS","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","deferredFilterValue","syncFilter","setSyncFilter","deferredSyncedFilter","patterns","isResolving","search","syncStatus","undefined","id","titleId","descriptionId","hasPatterns","length","title","description","shownPatterns","state","backPath","back","push","path","value","Object","entries","map","key","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,gBAAnB,EAAqCC,KAArC,QAAkD,oBAAlD;AACA,SACCC,aADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,IAHD,EA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AAC,+CADX;AAEC,IAAA,GAAG,EAAGD,GAFP;AAGC,IAAA,KAAK,EAAGA,GAHT;AAIC,IAAA,KAAK,EAAGC;AAJT,IAFA,CATH,CA3BF,CARD,EAyDG1B,UAAU,KAAK,KAAf,IACD,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AAAS,IAAA,EAAE,EAAC,IAAZ;AAAiB,IAAA,KAAK,EAAG,CAAzB;AAA6B,IAAA,EAAE,EAAGS;AAAlC,KACGI,KADH,CADD,EAIGC,WAAW,GACZ,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,EAAE,EAAGJ;AAAlC,KACGI,WADH,CADY,GAIT,IARL,CA1DF,EAqEGH,WAAW,IACZ,cAAC,IAAD;AACC,IAAA,UAAU,EAAGpB,UADd;AAEC,IAAA,KAAK,EAAGwB,aAFT;AAGC,uBAAkBN,OAHnB;AAIC,wBAAmBC;AAJpB,IAtEF,EA6EG,CAAEN,WAAF,IAAiB,CAAEO,WAAnB,IAAkC,cAAC,UAAD,OA7ErC,CADD;AAiFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useDeferredValue, useId } from '@wordpress/element';\nimport {\n\tSearchControl,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useViewportMatch, useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternsHeader from './header';\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\nimport { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nconst SYNC_FILTERS = {\n\tall: __( 'All' ),\n\t[ SYNC_TYPES.full ]: __( 'Synced' ),\n\t[ SYNC_TYPES.unsynced ]: __( 'Standard' ),\n};\n\nconst SYNC_DESCRIPTIONS = {\n\tall: '',\n\t[ SYNC_TYPES.full ]: __(\n\t\t'Patterns that are kept in sync across the site.'\n\t),\n\t[ SYNC_TYPES.unsynced ]: __(\n\t\t'Patterns that can be changed freely without affecting the site.'\n\t),\n};\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\tconst deferredFilterValue = useDeferredValue( delayedFilterValue );\n\n\tconst [ syncFilter, setSyncFilter ] = useState( 'all' );\n\tconst deferredSyncedFilter = useDeferredValue( syncFilter );\n\tconst { patterns, isResolving } = usePatterns( type, categoryId, {\n\t\tsearch: deferredFilterValue,\n\t\tsyncStatus:\n\t\t\tdeferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter,\n\t} );\n\n\tconst id = useId();\n\tconst titleId = `${ id }-title`;\n\tconst descriptionId = `${ id }-description`;\n\n\tconst hasPatterns = patterns.length;\n\tconst title = SYNC_FILTERS[ syncFilter ];\n\tconst description = SYNC_DESCRIPTIONS[ syncFilter ];\n\tconst shownPatterns = useAsyncList( patterns );\n\n\treturn (\n\t\t<VStack spacing={ 6 }>\n\t\t\t<PatternsHeader\n\t\t\t\tcategoryId={ categoryId }\n\t\t\t\ttype={ type }\n\t\t\t\ttitleId={ titleId }\n\t\t\t\tdescriptionId={ descriptionId }\n\t\t\t/>\n\n\t\t\t<Flex alignment=\"stretch\" wrap>\n\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\tif ( location.state?.backPath === '/patterns' ) {\n\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<FlexBlock className=\"edit-site-patterns__search-block\">\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t\t{ categoryId === USER_PATTERN_CATEGORY && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter\"\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tlabel={ __( 'Filter by sync status' ) }\n\t\t\t\t\t\tvalue={ syncFilter }\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tonChange={ ( value ) => setSyncFilter( value ) }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t>\n\t\t\t\t\t\t{ Object.entries( SYNC_FILTERS ).map(\n\t\t\t\t\t\t\t( [ key, label ] ) => (\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter-option\"\n\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ syncFilter !== 'all' && (\n\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t<Heading as=\"h3\" level={ 4 } id={ titleId }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t{ description ? (\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) : null }\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t\t{ hasPatterns && (\n\t\t\t\t<Grid\n\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\titems={ shownPatterns }\n\t\t\t\t\taria-labelledby={ titleId }\n\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Button, MenuItem, Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { TEMPLATE_PARTS } from './utils';
|
|
17
|
+
export default function RenameMenuItem({
|
|
18
|
+
item,
|
|
19
|
+
onClose
|
|
20
|
+
}) {
|
|
21
|
+
const [title, setTitle] = useState(() => item.title);
|
|
22
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
23
|
+
const {
|
|
24
|
+
editEntityRecord,
|
|
25
|
+
saveEditedEntityRecord
|
|
26
|
+
} = useDispatch(coreStore);
|
|
27
|
+
const {
|
|
28
|
+
createSuccessNotice,
|
|
29
|
+
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, {
|
|
41
|
+
title
|
|
42
|
+
}); // Update state before saving rerenders the list.
|
|
43
|
+
|
|
44
|
+
setTitle('');
|
|
45
|
+
setIsModalOpen(false);
|
|
46
|
+
onClose(); // Persist edited entity.
|
|
47
|
+
|
|
48
|
+
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
49
|
+
throwOnError: true
|
|
50
|
+
});
|
|
51
|
+
createSuccessNotice(__('Entity renamed.'), {
|
|
52
|
+
type: 'snackbar'
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while renaming the entity.');
|
|
56
|
+
createErrorNotice(errorMessage, {
|
|
57
|
+
type: 'snackbar'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return createElement(Fragment, null, createElement(MenuItem, {
|
|
63
|
+
onClick: () => {
|
|
64
|
+
setIsModalOpen(true);
|
|
65
|
+
setTitle(item.title);
|
|
66
|
+
}
|
|
67
|
+
}, __('Rename')), isModalOpen && createElement(Modal, {
|
|
68
|
+
title: __('Rename'),
|
|
69
|
+
onRequestClose: () => {
|
|
70
|
+
setIsModalOpen(false);
|
|
71
|
+
onClose();
|
|
72
|
+
},
|
|
73
|
+
overlayClassName: "edit-site-list__rename_modal"
|
|
74
|
+
}, createElement("form", {
|
|
75
|
+
onSubmit: onRename
|
|
76
|
+
}, createElement(VStack, {
|
|
77
|
+
spacing: "5"
|
|
78
|
+
}, createElement(TextControl, {
|
|
79
|
+
__nextHasNoMarginBottom: true,
|
|
80
|
+
label: __('Name'),
|
|
81
|
+
value: title,
|
|
82
|
+
onChange: setTitle,
|
|
83
|
+
required: true
|
|
84
|
+
}), createElement(HStack, {
|
|
85
|
+
justify: "right"
|
|
86
|
+
}, createElement(Button, {
|
|
87
|
+
variant: "tertiary",
|
|
88
|
+
onClick: () => {
|
|
89
|
+
setIsModalOpen(false);
|
|
90
|
+
onClose();
|
|
91
|
+
}
|
|
92
|
+
}, __('Cancel')), createElement(Button, {
|
|
93
|
+
variant: "primary",
|
|
94
|
+
type: "submit"
|
|
95
|
+
}, __('Save')))))));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=rename-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/rename-menu-item.js"],"names":["Button","MenuItem","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useState","__","noticesStore","TEMPLATE_PARTS","RenameMenuItem","item","onClose","title","setTitle","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","type","isCustom","onRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,oBAAoB,IAAIC,MALzB,EAMCC,o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AAA,OAAO,EAAG,MAAM;AACfE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAJ,MAAAA,OAAO;AACP;AALF,KAOGL,EAAE,CAAE,QAAF,CAPL,CADD,EAWC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CAXD,CATD,CADD,CARD,CAVF,CADD;AAkDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PARTS } from './utils';\n\nexport default function RenameMenuItem( { item, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => item.title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {\n\t\treturn null;\n\t}\n\n\tasync function onRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, { title } );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( item.title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename_modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import { parse } from '@wordpress/blocks';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
import {
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { CORE_PATTERN_SOURCES, PATTERNS, SYNC_TYPES, TEMPLATE_PARTS, USER_PATTERNS,
|
|
12
|
+
import { CORE_PATTERN_SOURCES, PATTERNS, SYNC_TYPES, TEMPLATE_PARTS, USER_PATTERNS, filterOutDuplicatesByName } from './utils';
|
|
13
13
|
import { unlock } from '../../lock-unlock';
|
|
14
14
|
import { searchItems } from './search-items';
|
|
15
15
|
import { store as editSiteStore } from '../../store';
|
|
@@ -21,92 +21,68 @@ const templatePartToPattern = templatePart => ({
|
|
|
21
21
|
blocks: parse(templatePart.content.raw),
|
|
22
22
|
categories: [templatePart.area],
|
|
23
23
|
description: templatePart.description || '',
|
|
24
|
+
isCustom: templatePart.source === 'custom',
|
|
24
25
|
keywords: templatePart.keywords || [],
|
|
26
|
+
id: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
25
27
|
name: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
26
|
-
title: templatePart.title.rendered,
|
|
28
|
+
title: decodeEntities(templatePart.title.rendered),
|
|
27
29
|
type: templatePart.type,
|
|
28
30
|
templatePart
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
const
|
|
33
|
+
const templatePartHasCategory = (item, category) => item.templatePart.area === category;
|
|
32
34
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return item.templatePart.area === category;
|
|
39
|
-
};
|
|
35
|
+
const selectTemplatePartsAsPatterns = (select, {
|
|
36
|
+
categoryId,
|
|
37
|
+
search = ''
|
|
38
|
+
} = {}) => {
|
|
39
|
+
var _getEntityRecords;
|
|
40
40
|
|
|
41
|
-
const useTemplatePartsAsPatterns = (categoryId, postType = TEMPLATE_PARTS, filterValue = '') => {
|
|
42
41
|
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} = select(coreStore);
|
|
57
|
-
const query = {
|
|
58
|
-
per_page: -1
|
|
59
|
-
};
|
|
60
|
-
const rawTemplateParts = getEntityRecords('postType', postType, query);
|
|
61
|
-
const partsAsPatterns = rawTemplateParts?.map(templatePart => templatePartToPattern(templatePart));
|
|
62
|
-
return {
|
|
63
|
-
templateParts: partsAsPatterns,
|
|
64
|
-
isResolving: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
|
|
65
|
-
};
|
|
66
|
-
}, [postType]);
|
|
67
|
-
const filteredTemplateParts = useMemo(() => {
|
|
68
|
-
if (!templateParts) {
|
|
69
|
-
return EMPTY_PATTERN_LIST;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return searchItems(templateParts, filterValue, {
|
|
73
|
-
categoryId,
|
|
74
|
-
hasCategory: templatePartHasCategory
|
|
75
|
-
});
|
|
76
|
-
}, [templateParts, filterValue, categoryId]);
|
|
42
|
+
getEntityRecords,
|
|
43
|
+
getIsResolving
|
|
44
|
+
} = select(coreStore);
|
|
45
|
+
const query = {
|
|
46
|
+
per_page: -1
|
|
47
|
+
};
|
|
48
|
+
const rawTemplateParts = (_getEntityRecords = getEntityRecords('postType', TEMPLATE_PARTS, query)) !== null && _getEntityRecords !== void 0 ? _getEntityRecords : EMPTY_PATTERN_LIST;
|
|
49
|
+
const templateParts = rawTemplateParts.map(templatePart => templatePartToPattern(templatePart));
|
|
50
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', 'wp_template_part', query]);
|
|
51
|
+
const patterns = searchItems(templateParts, search, {
|
|
52
|
+
categoryId,
|
|
53
|
+
hasCategory: templatePartHasCategory
|
|
54
|
+
});
|
|
77
55
|
return {
|
|
78
|
-
|
|
56
|
+
patterns,
|
|
79
57
|
isResolving
|
|
80
58
|
};
|
|
81
59
|
};
|
|
82
60
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
const selectThemePatterns = (select, {
|
|
62
|
+
categoryId,
|
|
63
|
+
search = ''
|
|
64
|
+
} = {}) => {
|
|
65
|
+
var _settings$__experimen;
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const patterns = useMemo(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !CORE_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).map(pattern => ({ ...pattern,
|
|
67
|
+
const {
|
|
68
|
+
getSettings
|
|
69
|
+
} = unlock(select(editSiteStore));
|
|
70
|
+
const settings = getSettings();
|
|
71
|
+
const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns;
|
|
72
|
+
const restBlockPatterns = select(coreStore).getBlockPatterns();
|
|
73
|
+
let patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !CORE_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).map(pattern => ({ ...pattern,
|
|
95
74
|
keywords: pattern.keywords || [],
|
|
96
75
|
type: 'pattern',
|
|
97
76
|
blocks: parse(pattern.content)
|
|
98
|
-
}))
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
}, [patterns, filterValue, categoryId, postType]);
|
|
109
|
-
return filteredPatterns;
|
|
77
|
+
}));
|
|
78
|
+
patterns = searchItems(patterns, search, {
|
|
79
|
+
categoryId,
|
|
80
|
+
hasCategory: (item, currentCategory) => item.categories?.includes(currentCategory)
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
patterns,
|
|
84
|
+
isResolving: false
|
|
85
|
+
};
|
|
110
86
|
};
|
|
111
87
|
|
|
112
88
|
const reusableBlockToPattern = reusableBlock => ({
|
|
@@ -114,73 +90,70 @@ const reusableBlockToPattern = reusableBlock => ({
|
|
|
114
90
|
categories: reusableBlock.wp_pattern,
|
|
115
91
|
id: reusableBlock.id,
|
|
116
92
|
name: reusableBlock.slug,
|
|
117
|
-
syncStatus: reusableBlock.
|
|
93
|
+
syncStatus: reusableBlock.wp_pattern_sync_status || SYNC_TYPES.full,
|
|
118
94
|
title: reusableBlock.title.raw,
|
|
119
95
|
type: reusableBlock.type,
|
|
120
96
|
reusableBlock
|
|
121
97
|
});
|
|
122
98
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (!records) {
|
|
138
|
-
return EMPTY_PATTERN_LIST;
|
|
139
|
-
}
|
|
99
|
+
const selectUserPatterns = (select, {
|
|
100
|
+
search = '',
|
|
101
|
+
syncStatus
|
|
102
|
+
} = {}) => {
|
|
103
|
+
const {
|
|
104
|
+
getEntityRecords,
|
|
105
|
+
getIsResolving
|
|
106
|
+
} = select(coreStore);
|
|
107
|
+
const query = {
|
|
108
|
+
per_page: -1
|
|
109
|
+
};
|
|
110
|
+
const records = getEntityRecords('postType', USER_PATTERNS, query);
|
|
111
|
+
let patterns = records ? records.map(record => reusableBlockToPattern(record)) : EMPTY_PATTERN_LIST;
|
|
112
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', USER_PATTERNS, query]);
|
|
140
113
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (!unfilteredPatterns.length) {
|
|
145
|
-
return EMPTY_PATTERN_LIST;
|
|
146
|
-
}
|
|
114
|
+
if (syncStatus) {
|
|
115
|
+
patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus);
|
|
116
|
+
}
|
|
147
117
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}, [unfilteredPatterns, filterValue]);
|
|
155
|
-
const patterns = {
|
|
156
|
-
syncedPatterns: [],
|
|
157
|
-
unsyncedPatterns: []
|
|
158
|
-
};
|
|
159
|
-
filteredPatterns.forEach(pattern => {
|
|
160
|
-
if (pattern.syncStatus === SYNC_TYPES.full) {
|
|
161
|
-
patterns.syncedPatterns.push(pattern);
|
|
162
|
-
} else {
|
|
163
|
-
patterns.unsyncedPatterns.push(pattern);
|
|
164
|
-
}
|
|
118
|
+
patterns = searchItems(patterns, search, {
|
|
119
|
+
// We exit user pattern retrieval early if we aren't in the
|
|
120
|
+
// catch-all category for user created patterns, so it has
|
|
121
|
+
// to be in the category.
|
|
122
|
+
hasCategory: () => true
|
|
165
123
|
});
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
export const usePatterns = (categoryType, categoryId, filterValue) => {
|
|
170
|
-
const blockPatterns = useThemePatterns(categoryId, categoryType, filterValue);
|
|
171
|
-
const {
|
|
172
|
-
syncedPatterns = [],
|
|
173
|
-
unsyncedPatterns = []
|
|
174
|
-
} = useUserPatterns(categoryId, categoryType, filterValue);
|
|
175
|
-
const {
|
|
176
|
-
templateParts,
|
|
124
|
+
return {
|
|
125
|
+
patterns,
|
|
177
126
|
isResolving
|
|
178
|
-
} = useTemplatePartsAsPatterns(categoryId, categoryType, filterValue);
|
|
179
|
-
const patterns = {
|
|
180
|
-
syncedPatterns: [...templateParts, ...syncedPatterns],
|
|
181
|
-
unsyncedPatterns: [...blockPatterns, ...unsyncedPatterns]
|
|
182
127
|
};
|
|
183
|
-
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const usePatterns = (categoryType, categoryId, {
|
|
131
|
+
search = '',
|
|
132
|
+
syncStatus
|
|
133
|
+
}) => {
|
|
134
|
+
return useSelect(select => {
|
|
135
|
+
if (categoryType === TEMPLATE_PARTS) {
|
|
136
|
+
return selectTemplatePartsAsPatterns(select, {
|
|
137
|
+
categoryId,
|
|
138
|
+
search
|
|
139
|
+
});
|
|
140
|
+
} else if (categoryType === PATTERNS) {
|
|
141
|
+
return selectThemePatterns(select, {
|
|
142
|
+
categoryId,
|
|
143
|
+
search
|
|
144
|
+
});
|
|
145
|
+
} else if (categoryType === USER_PATTERNS) {
|
|
146
|
+
return selectUserPatterns(select, {
|
|
147
|
+
search,
|
|
148
|
+
syncStatus
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
patterns: EMPTY_PATTERN_LIST,
|
|
154
|
+
isResolving: false
|
|
155
|
+
};
|
|
156
|
+
}, [categoryId, categoryType, search, syncStatus]);
|
|
184
157
|
};
|
|
185
158
|
export default usePatterns;
|
|
186
159
|
//# sourceMappingURL=use-patterns.js.map
|