@wordpress/edit-site 5.30.0 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/actions/index.js +2 -4
- package/build/components/actions/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +16 -3
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +1 -1
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +0 -9
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +15 -8
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +3 -2
- package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +44 -10
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +2 -2
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +3 -0
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +50 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview-iframe.js +0 -1
- package/build/components/global-styles/preview-iframe.js.map +1 -1
- package/build/components/global-styles/preview-styles.js +2 -2
- package/build/components/global-styles/preview-styles.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +2 -9
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +1 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-elements.js +3 -1
- package/build/components/global-styles/typography-elements.js.map +1 -1
- package/build/components/global-styles/{preview-typography.js → typography-example.js} +4 -2
- package/build/components/global-styles/typography-example.js.map +1 -0
- package/build/components/global-styles/typography-preview.js +3 -1
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +8 -9
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +27 -37
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/header-edit-mode/index.js +2 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/global.js +17 -3
- package/build/components/keyboard-shortcuts/global.js.map +1 -1
- package/build/components/layout/router.js +2 -5
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +6 -11
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/index.js +1 -4
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +9 -9
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates-template-parts/index.js +11 -16
- package/build/components/page-templates-template-parts/index.js.map +1 -1
- package/build/components/save-panel/index.js +14 -9
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +2 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +2 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +4 -3
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +2 -2
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +3 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/sidebar-card/index.js +12 -6
- package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +23 -3
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +13 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +4 -5
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +5 -1
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -11
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +44 -27
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +11 -2
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +15 -2
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/utils/constants.js +5 -3
- package/build/utils/constants.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/math.js +98 -0
- package/build/utils/math.js.map +1 -0
- package/build-module/components/actions/index.js +3 -5
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +16 -3
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +0 -8
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +16 -9
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +4 -3
- package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +44 -10
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +2 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +3 -0
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/header.js +1 -1
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +48 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview-iframe.js +0 -1
- package/build-module/components/global-styles/preview-iframe.js.map +1 -1
- package/build-module/components/global-styles/preview-styles.js +2 -2
- package/build-module/components/global-styles/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +2 -9
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +1 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-elements.js +3 -1
- package/build-module/components/global-styles/typography-elements.js.map +1 -1
- package/build-module/components/global-styles/{preview-typography.js → typography-example.js} +4 -2
- package/build-module/components/global-styles/typography-example.js.map +1 -0
- package/build-module/components/global-styles/typography-preview.js +3 -1
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +8 -9
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +28 -38
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +2 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +6 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/global.js +17 -3
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -1
- package/build-module/components/layout/router.js +2 -5
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +7 -12
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js +6 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/index.js +2 -5
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +9 -9
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates-template-parts/index.js +12 -17
- package/build-module/components/page-templates-template-parts/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +14 -9
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +2 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +3 -3
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +4 -3
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +3 -3
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +4 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +13 -7
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +24 -4
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +14 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +3 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +6 -6
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +5 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +44 -27
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +11 -2
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +15 -2
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/utils/constants.js +4 -2
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/math.js +92 -0
- package/build-module/utils/math.js.map +1 -0
- package/build-style/style-rtl.css +41 -37
- package/build-style/style.css +41 -37
- package/package.json +42 -42
- package/src/components/actions/index.js +3 -5
- package/src/components/block-editor/editor-canvas.js +20 -7
- package/src/components/block-editor/use-site-editor-settings.js +0 -2
- package/src/components/global-styles/color-palette-panel.js +0 -11
- package/src/components/global-styles/font-library-modal/context.js +34 -17
- package/src/components/global-styles/font-library-modal/font-collection.js +4 -3
- package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +9 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -1
- package/src/components/global-styles/font-library-modal/style.scss +14 -5
- package/src/components/global-styles/font-library-modal/upload-fonts.js +53 -8
- package/src/components/global-styles/font-library-modal/utils/index.js +4 -4
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +4 -0
- package/src/components/global-styles/header.js +1 -1
- package/src/components/global-styles/hooks.js +68 -1
- package/src/components/global-styles/preview-iframe.js +0 -1
- package/src/components/global-styles/preview-styles.js +2 -2
- package/src/components/global-styles/screen-colors.js +2 -13
- package/src/components/global-styles/screen-typography.js +1 -12
- package/src/components/global-styles/style.scss +4 -1
- package/src/components/global-styles/typography-elements.js +5 -1
- package/src/components/global-styles/{preview-typography.js → typography-example.js} +3 -1
- package/src/components/global-styles/typography-preview.js +3 -1
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/global-styles/variations/style.scss +0 -6
- package/src/components/global-styles/variations/variations-color.js +9 -5
- package/src/components/global-styles/variations/variations-typography.js +37 -59
- package/src/components/header-edit-mode/index.js +1 -0
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcuts/global.js +16 -4
- package/src/components/layout/router.js +2 -7
- package/src/components/page-pages/index.js +8 -13
- package/src/components/page-patterns/delete-category-menu-item.js +7 -0
- package/src/components/page-patterns/index.js +2 -3
- package/src/components/page-patterns/use-patterns.js +17 -10
- package/src/components/page-templates-template-parts/index.js +14 -22
- package/src/components/save-panel/index.js +24 -17
- package/src/components/sidebar/index.js +2 -3
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -2
- package/src/components/sidebar-dataviews/dataview-item.js +2 -2
- package/src/components/sidebar-dataviews/default-views.js +11 -3
- package/src/components/sidebar-dataviews/index.js +4 -3
- package/src/components/sidebar-edit-mode/page-panels/index.js +2 -2
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +2 -0
- package/src/components/sidebar-edit-mode/sidebar-card/index.js +30 -11
- package/src/components/sidebar-edit-mode/sidebar-card/style.scss +10 -11
- package/src/components/sidebar-edit-mode/template-panel/index.js +24 -5
- package/src/components/sidebar-navigation-screen/style.scss +10 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +35 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/{delete-modal.js → delete-confirm-dialog.js} +2 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +11 -9
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +6 -3
- package/src/components/sidebar-navigation-screen-template/index.js +6 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +3 -19
- package/src/components/template-actions/index.js +63 -46
- package/src/components/welcome-guide/editor.js +9 -6
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +21 -4
- package/src/style.scss +0 -1
- package/src/utils/constants.js +4 -2
- package/src/utils/get-is-list-page.js +1 -1
- package/src/utils/math.js +93 -0
- package/build/components/global-styles/preview-typography.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/template-actions.js +0 -50
- package/build/components/sidebar-edit-mode/template-panel/template-actions.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +0 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +0 -132
- package/build/components/sidebar-navigation-screen-templates/index.js.map +0 -1
- package/build-module/components/global-styles/preview-typography.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js +0 -42
- package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +0 -124
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +0 -1
- package/src/components/sidebar-edit-mode/template-panel/template-actions.js +0 -49
- package/src/components/sidebar-navigation-screen-templates/index.js +0 -156
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -9
|
@@ -11,7 +11,7 @@ var _icons = require("@wordpress/icons");
|
|
|
11
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
12
|
var _element = require("@wordpress/element");
|
|
13
13
|
var _renameModal = _interopRequireDefault(require("./rename-modal"));
|
|
14
|
-
var
|
|
14
|
+
var _deleteConfirmDialog = _interopRequireDefault(require("./delete-confirm-dialog"));
|
|
15
15
|
/**
|
|
16
16
|
* WordPress dependencies
|
|
17
17
|
*/
|
|
@@ -31,13 +31,13 @@ function ScreenNavigationMoreMenu(props) {
|
|
|
31
31
|
menuTitle
|
|
32
32
|
} = props;
|
|
33
33
|
const [renameModalOpen, setRenameModalOpen] = (0, _element.useState)(false);
|
|
34
|
-
const [
|
|
34
|
+
const [deleteConfirmDialogOpen, setDeleteConfirmDialogOpen] = (0, _element.useState)(false);
|
|
35
35
|
const closeModals = () => {
|
|
36
36
|
setRenameModalOpen(false);
|
|
37
|
-
|
|
37
|
+
setDeleteConfirmDialogOpen(false);
|
|
38
38
|
};
|
|
39
39
|
const openRenameModal = () => setRenameModalOpen(true);
|
|
40
|
-
const
|
|
40
|
+
const openDeleteConfirmDialog = () => setDeleteConfirmDialogOpen(true);
|
|
41
41
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.DropdownMenu, {
|
|
42
42
|
className: "sidebar-navigation__more-menu",
|
|
43
43
|
label: (0, _i18n.__)('Actions'),
|
|
@@ -59,12 +59,12 @@ function ScreenNavigationMoreMenu(props) {
|
|
|
59
59
|
}, (0, _i18n.__)('Duplicate')), (0, _react.createElement)(_components.MenuItem, {
|
|
60
60
|
isDestructive: true,
|
|
61
61
|
onClick: () => {
|
|
62
|
-
|
|
62
|
+
openDeleteConfirmDialog();
|
|
63
63
|
|
|
64
64
|
// Close the dropdown after opening the modal.
|
|
65
65
|
onClose();
|
|
66
66
|
}
|
|
67
|
-
}, (0, _i18n.__)('Delete'))))),
|
|
67
|
+
}, (0, _i18n.__)('Delete'))))), deleteConfirmDialogOpen && (0, _react.createElement)(_deleteConfirmDialog.default, {
|
|
68
68
|
onClose: closeModals,
|
|
69
69
|
onConfirm: onDelete
|
|
70
70
|
}), renameModalOpen && (0, _react.createElement)(_renameModal.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_icons","_i18n","_element","_renameModal","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_components","require","_icons","_i18n","_element","_renameModal","_interopRequireDefault","_deleteConfirmDialog","POPOVER_PROPS","position","ScreenNavigationMoreMenu","props","onDelete","onSave","onDuplicate","menuTitle","renameModalOpen","setRenameModalOpen","useState","deleteConfirmDialogOpen","setDeleteConfirmDialogOpen","closeModals","openRenameModal","openDeleteConfirmDialog","_react","createElement","Fragment","DropdownMenu","className","label","__","icon","moreVertical","popoverProps","onClose","MenuGroup","MenuItem","onClick","isDestructive","default","onConfirm"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport RenameModal from './rename-modal';\nimport DeleteConfirmDialog from './delete-confirm-dialog';\n\nconst POPOVER_PROPS = {\n\tposition: 'bottom right',\n};\n\nexport default function ScreenNavigationMoreMenu( props ) {\n\tconst { onDelete, onSave, onDuplicate, menuTitle } = props;\n\n\tconst [ renameModalOpen, setRenameModalOpen ] = useState( false );\n\tconst [ deleteConfirmDialogOpen, setDeleteConfirmDialogOpen ] =\n\t\tuseState( false );\n\n\tconst closeModals = () => {\n\t\tsetRenameModalOpen( false );\n\t\tsetDeleteConfirmDialogOpen( false );\n\t};\n\tconst openRenameModal = () => setRenameModalOpen( true );\n\tconst openDeleteConfirmDialog = () => setDeleteConfirmDialogOpen( true );\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"sidebar-navigation__more-menu\"\n\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topenRenameModal();\n\t\t\t\t\t\t\t\t\t// Close the dropdown after opening the modal.\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonDuplicate();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Duplicate' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topenDeleteConfirmDialog();\n\n\t\t\t\t\t\t\t\t\t// Close the dropdown after opening the modal.\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ deleteConfirmDialogOpen && (\n\t\t\t\t<DeleteConfirmDialog\n\t\t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components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js
CHANGED
|
@@ -38,7 +38,7 @@ function useDeleteNavigationMenu() {
|
|
|
38
38
|
}, {
|
|
39
39
|
throwOnError: true
|
|
40
40
|
});
|
|
41
|
-
createSuccessNotice((0, _i18n.__)('
|
|
41
|
+
createSuccessNotice((0, _i18n.__)('Navigation menu successfully deleted.'), {
|
|
42
42
|
type: 'snackbar'
|
|
43
43
|
});
|
|
44
44
|
goTo('/navigation');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_components","_i18n","_data","_notices","_","_constants","useDeleteNavigationMenu","goTo","useNavigator","deleteEntityRecord","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","handleDelete","navigationMenu","postId","id","postType","force","throwOnError","__","type","error","sprintf","message","useSaveNavigationMenu","getEditedEntityRecord","useSelect","select","getEditedEntityRecordSelector","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","handleSave","edits","originalRecord","NAVIGATION_POST_TYPE","recordPropertiesToSave","Object","keys","useDuplicateNavigationMenu","saveEntityRecord","handleDuplicate","menuTitle","title","rendered","slug","savedRecord","content","raw","status","useNavigationMenuHandlers"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { postType } from '.';\nimport { NAVIGATION_POST_TYPE } from '../../utils/constants';\n\nfunction useDeleteNavigationMenu() {\n\tconst { goTo } = useNavigator();\n\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleDelete = async ( navigationMenu ) => {\n\t\tconst postId = navigationMenu?.id;\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\t{\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice(
|
|
1
|
+
{"version":3,"names":["_coreData","require","_components","_i18n","_data","_notices","_","_constants","useDeleteNavigationMenu","goTo","useNavigator","deleteEntityRecord","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","handleDelete","navigationMenu","postId","id","postType","force","throwOnError","__","type","error","sprintf","message","useSaveNavigationMenu","getEditedEntityRecord","useSelect","select","getEditedEntityRecordSelector","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","handleSave","edits","originalRecord","NAVIGATION_POST_TYPE","recordPropertiesToSave","Object","keys","useDuplicateNavigationMenu","saveEntityRecord","handleDuplicate","menuTitle","title","rendered","slug","savedRecord","content","raw","status","useNavigationMenuHandlers"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { postType } from '.';\nimport { NAVIGATION_POST_TYPE } from '../../utils/constants';\n\nfunction useDeleteNavigationMenu() {\n\tconst { goTo } = useNavigator();\n\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleDelete = async ( navigationMenu ) => {\n\t\tconst postId = navigationMenu?.id;\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\t{\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__( 'Navigation menu successfully deleted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tgoTo( '/navigation' );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to delete Navigation menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDelete;\n}\n\nfunction useSaveNavigationMenu() {\n\tconst { getEditedEntityRecord } = useSelect( ( select ) => {\n\t\tconst { getEditedEntityRecord: getEditedEntityRecordSelector } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\tgetEditedEntityRecord: getEditedEntityRecordSelector,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleSave = async ( navigationMenu, edits ) => {\n\t\tif ( ! edits ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst postId = navigationMenu?.id;\n\t\t// Prepare for revert in case of error.\n\t\tconst originalRecord = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tNAVIGATION_POST_TYPE,\n\t\t\tpostId\n\t\t);\n\n\t\t// Apply the edits.\n\t\teditEntityRecord( 'postType', postType, postId, edits );\n\n\t\tconst recordPropertiesToSave = Object.keys( edits );\n\n\t\t// Attempt to persist.\n\t\ttry {\n\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\trecordPropertiesToSave,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice( __( 'Renamed Navigation menu' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Revert to original in case of error.\n\t\t\teditEntityRecord( 'postType', postType, postId, originalRecord );\n\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be renamed. */\n\t\t\t\t\t__( `Unable to rename Navigation menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleSave;\n}\n\nfunction useDuplicateNavigationMenu() {\n\tconst { goTo } = useNavigator();\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleDuplicate = async ( navigationMenu ) => {\n\t\tconst menuTitle =\n\t\t\tnavigationMenu?.title?.rendered || navigationMenu?.slug;\n\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t/* translators: %s: Navigation menu title */\n\t\t\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\t\t\tmenuTitle\n\t\t\t\t\t),\n\t\t\t\t\tcontent: navigationMenu?.content?.raw,\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\tcreateSuccessNotice( __( 'Duplicated Navigation menu' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\tgoTo( `/navigation/${ postType }/${ savedRecord.id }` );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to duplicate Navigation menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDuplicate;\n}\n\nexport default function useNavigationMenuHandlers() {\n\treturn {\n\t\thandleDelete: useDeleteNavigationMenu(),\n\t\thandleSave: useSaveNavigationMenu(),\n\t\thandleDuplicate: useDuplicateNavigationMenu(),\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,CAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,SAASO,uBAAuBA,CAAA,EAAG;EAClC,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,sCAAY,EAAC,CAAC;EAE/B,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EAEvD,MAAM;IAAEC,mBAAmB;IAAEC;EAAkB,CAAC,GAC/C,IAAAH,iBAAW,EAAEI,cAAa,CAAC;EAE5B,MAAMC,YAAY,GAAG,MAAQC,cAAc,IAAM;IAChD,MAAMC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AAE,WAAY,CAAC,EACjBuB,SACD,CAAC;QACDK,OAAO,EAAElC,cAAc,EAAEkC,OAAO,EAAEC,GAAG;QACrCC,MAAM,EAAE;MACT,CAAC,EACD;QACC/B,YAAY,EAAE;MACf,CACD,CAAC;MAED,IAAK4B,WAAW,EAAG;QAClBrC,mBAAmB,CAAE,IAAAU,QAAE,EAAE,4BAA6B,CAAC,EAAE;UACxDC,IAAI,EAAE;QACP,CAAE,CAAC;QACHhB,IAAI,CAAG,eAAeY,UAAU,IAAI8B,WAAW,CAAC/B,EAAI,EAAE,CAAC;MACxD;IACD,CAAC,CAAC,OAAQM,KAAK,EAAG;MACjBX,iBAAiB,CAChB,IAAAY,aAAO,GACN;MACA,IAAAH,QAAE,EAAG,2CAA2C,CAAC,EACjDE,KAAK,EAAEE,OACR,CAAC,EAED;QACCH,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAC;EAED,OAAOqB,eAAe;AACvB;AAEe,SAASS,yBAAyBA,CAAA,EAAG;EACnD,OAAO;IACNtC,YAAY,EAAET,uBAAuB,CAAC,CAAC;IACvC6B,UAAU,EAAER,qBAAqB,CAAC,CAAC;IACnCiB,eAAe,EAAEF,0BAA0B,CAAC;EAC7C,CAAC;AACF"}
|
|
@@ -70,6 +70,10 @@ function useTemplateDetails(postType, postId) {
|
|
|
70
70
|
footer
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
const POST_TYPE_PATH = {
|
|
74
|
+
wp_template: '/wp_template',
|
|
75
|
+
wp_template_part: '/wp_template_part/all'
|
|
76
|
+
};
|
|
73
77
|
function SidebarNavigationScreenTemplate() {
|
|
74
78
|
const navigator = (0, _components.__experimentalUseNavigator)();
|
|
75
79
|
const {
|
|
@@ -96,7 +100,7 @@ function SidebarNavigationScreenTemplate() {
|
|
|
96
100
|
as: _sidebarButton.default
|
|
97
101
|
},
|
|
98
102
|
onRemove: () => {
|
|
99
|
-
navigator.goTo(
|
|
103
|
+
navigator.goTo(POST_TYPE_PATH[postType]);
|
|
100
104
|
}
|
|
101
105
|
}), (0, _react.createElement)(_sidebarButton.default, {
|
|
102
106
|
onClick: () => setCanvasMode('edit'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_icons","_components","_coreData","_templateAreas","_interopRequireDefault","_sidebarNavigationScreen","_useEditedEntityRecord","_lockUnlock","_store","_sidebarButton","_hooks","_templateActions","_homeTemplateDetails","_sidebarNavigationScreenDetailsFooter","useTemplateDetails","postType","postId","getDescription","getTitle","record","useEditedEntityRecord","currentTheme","useSelect","select","coreStore","getCurrentTheme","addedBy","useAddedBy","isAddedByActiveTheme","type","theme","stylesheet","title","descriptionText","text","__","content","slug","_react","createElement","Fragment","default","footer","modified","description","className","imageUrl","src","alt","width","height","Icon","icon","isCustomized","_x","SidebarNavigationScreenTemplate","navigator","useNavigator","params","setCanvasMode","unlock","useDispatch","editSiteStore","actions","toggleProps","as","SidebarButton","onRemove","goTo","onClick","label","pencil"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { pencil } from '@wordpress/icons';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tIcon,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n/**\n * Internal dependencies\n */\nimport TemplateAreas from './template-areas';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport TemplateActions from '../template-actions';\nimport HomeTemplateDetails from './home-template-details';\nimport SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';\n\nfunction useTemplateDetails( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme(),\n\t\t[]\n\t);\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet descriptionText = getDescription();\n\n\tif ( ! descriptionText && addedBy.text ) {\n\t\tdescriptionText = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\tconst content =\n\t\trecord?.slug === 'home' || record?.slug === 'index' ? (\n\t\t\t<>\n\t\t\t\t<HomeTemplateDetails />\n\t\t\t\t<TemplateAreas />\n\t\t\t</>\n\t\t) : (\n\t\t\t<TemplateAreas />\n\t\t);\n\n\tconst footer = record?.modified ? (\n\t\t<SidebarNavigationScreenDetailsFooter record={ record } />\n\t) : null;\n\n\tconst description = (\n\t\t<>\n\t\t\t{ descriptionText }\n\n\t\t\t{ addedBy.text && ! isAddedByActiveTheme && (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description\">\n\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author\">\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author-icon\">\n\t\t\t\t\t\t\t{ addedBy.imageUrl ? (\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\tsrc={ addedBy.imageUrl }\n\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ addedBy.icon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ addedBy.text }\n\t\t\t\t\t</span>\n\n\t\t\t\t\t{ addedBy.isCustomized && (\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-customized\">\n\t\t\t\t\t\t\t{ _x( '(Customized)', 'template' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description, content, footer };\n}\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst navigator = useNavigator();\n\tconst {\n\t\tparams: { postType, postId },\n\t} = navigator;\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { title, content, description, footer } = useTemplateDetails(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ title }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t<TemplateActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\ttoggleProps={ { as: SidebarButton } }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tnavigator.goTo(
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_icons","_components","_coreData","_templateAreas","_interopRequireDefault","_sidebarNavigationScreen","_useEditedEntityRecord","_lockUnlock","_store","_sidebarButton","_hooks","_templateActions","_homeTemplateDetails","_sidebarNavigationScreenDetailsFooter","useTemplateDetails","postType","postId","getDescription","getTitle","record","useEditedEntityRecord","currentTheme","useSelect","select","coreStore","getCurrentTheme","addedBy","useAddedBy","isAddedByActiveTheme","type","theme","stylesheet","title","descriptionText","text","__","content","slug","_react","createElement","Fragment","default","footer","modified","description","className","imageUrl","src","alt","width","height","Icon","icon","isCustomized","_x","POST_TYPE_PATH","wp_template","wp_template_part","SidebarNavigationScreenTemplate","navigator","useNavigator","params","setCanvasMode","unlock","useDispatch","editSiteStore","actions","toggleProps","as","SidebarButton","onRemove","goTo","onClick","label","pencil"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { pencil } from '@wordpress/icons';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tIcon,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n/**\n * Internal dependencies\n */\nimport TemplateAreas from './template-areas';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport TemplateActions from '../template-actions';\nimport HomeTemplateDetails from './home-template-details';\nimport SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';\n\nfunction useTemplateDetails( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme(),\n\t\t[]\n\t);\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet descriptionText = getDescription();\n\n\tif ( ! descriptionText && addedBy.text ) {\n\t\tdescriptionText = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\tconst content =\n\t\trecord?.slug === 'home' || record?.slug === 'index' ? (\n\t\t\t<>\n\t\t\t\t<HomeTemplateDetails />\n\t\t\t\t<TemplateAreas />\n\t\t\t</>\n\t\t) : (\n\t\t\t<TemplateAreas />\n\t\t);\n\n\tconst footer = record?.modified ? (\n\t\t<SidebarNavigationScreenDetailsFooter record={ record } />\n\t) : null;\n\n\tconst description = (\n\t\t<>\n\t\t\t{ descriptionText }\n\n\t\t\t{ addedBy.text && ! isAddedByActiveTheme && (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description\">\n\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author\">\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author-icon\">\n\t\t\t\t\t\t\t{ addedBy.imageUrl ? (\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\tsrc={ addedBy.imageUrl }\n\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ addedBy.icon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ addedBy.text }\n\t\t\t\t\t</span>\n\n\t\t\t\t\t{ addedBy.isCustomized && (\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-customized\">\n\t\t\t\t\t\t\t{ _x( '(Customized)', 'template' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description, content, footer };\n}\n\nconst POST_TYPE_PATH = {\n\twp_template: '/wp_template',\n\twp_template_part: '/wp_template_part/all',\n};\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst navigator = useNavigator();\n\tconst {\n\t\tparams: { postType, postId },\n\t} = navigator;\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { title, content, description, footer } = useTemplateDetails(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ title }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t<TemplateActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\ttoggleProps={ { as: SidebarButton } }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tnavigator.goTo( POST_TYPE_PATH[ postType ] );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\t\ticon={ pencil }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tdescription={ description }\n\t\t\tcontent={ content }\n\t\t\tfooter={ footer }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,SAAA,GAAAJ,OAAA;AAIA,IAAAK,cAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,wBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,sBAAA,GAAAF,sBAAA,CAAAN,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,cAAA,GAAAL,sBAAA,CAAAN,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,gBAAA,GAAAP,sBAAA,CAAAN,OAAA;AACA,IAAAc,oBAAA,GAAAR,sBAAA,CAAAN,OAAA;AACA,IAAAe,qCAAA,GAAAT,sBAAA,CAAAN,OAAA;AAvBA;AACA;AACA;;AASA;AACA;AACA;;AAYA,SAASgB,kBAAkBA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EAC/C,MAAM;IAAEC,cAAc;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAG,IAAAC,8BAAqB,EACjEL,QAAQ,EACRC,MACD,CAAC;EACD,MAAMK,YAAY,GAAG,IAAAC,eAAS,EAC3BC,MAAM,IAAMA,MAAM,CA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AAO,EACN,IAAA5B,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAAC5B,gBAAA,CAAA8B,OAAe;MACf1B,QAAQ,EAAGA,QAAU;MACrBC,MAAM,EAAGA,MAAQ;MACjBmD,WAAW,EAAG;QAAEC,EAAE,EAAEC;MAAc,CAAG;MACrCC,QAAQ,EAAGA,CAAA,KAAM;QAChBX,SAAS,CAACY,IAAI,CAAEhB,cAAc,CAAExC,QAAQ,CAAG,CAAC;MAC7C;IAAG,CACH,CAAC,EACF,IAAAuB,MAAA,CAAAC,aAAA,EAAC9B,cAAA,CAAAgC,OAAa;MACb+B,OAAO,EAAGA,CAAA,KAAMV,aAAa,CAAE,MAAO,CAAG;MACzCW,KAAK,EAAG,IAAAtC,QAAE,EAAE,MAAO,CAAG;MACtBiB,IAAI,EAAGsB;IAAQ,CACf,CACA,CACF;IACD9B,WAAW,EAAGA,WAAa;IAC3BR,OAAO,EAAGA,OAAS;IACnBM,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ"}
|
|
@@ -35,7 +35,7 @@ function TemplateDataviewItem({
|
|
|
35
35
|
title: text,
|
|
36
36
|
icon: icon,
|
|
37
37
|
isActive: isActive,
|
|
38
|
-
isCustom:
|
|
38
|
+
isCustom: false
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
function DataviewsTemplatesSidebarContent({
|
|
@@ -64,7 +64,7 @@ function DataviewsTemplatesSidebarContent({
|
|
|
64
64
|
title: title,
|
|
65
65
|
icon: _icons.layout,
|
|
66
66
|
isActive: activeView === 'all',
|
|
67
|
-
isCustom:
|
|
67
|
+
isCustom: false
|
|
68
68
|
}), firstItemPerAuthorText.map(template => {
|
|
69
69
|
return (0, _react.createElement)(TemplateDataviewItem, {
|
|
70
70
|
key: template.author_text,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_element","_components","_dataviewItem","_interopRequireDefault","_hooks","_icons","EMPTY_ARRAY","TemplateDataviewItem","template","isActive","text","icon","useAddedBy","type","id","_react","createElement","default","key","slug","title","isCustom","DataviewsTemplatesSidebarContent","activeView","postType","records","useEntityRecords","per_page","firstItemPerAuthorText","useMemo","_ref","firstItemPerAuthor","reduce","acc","author","author_text","Object","values","__experimentalItemGroup","layout","map"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DataViewItem from '../sidebar-dataviews/dataview-item';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport { layout } from '@wordpress/icons';\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\treturn (\n\t\t<DataViewItem\n\t\t\tkey={ text }\n\t\t\tslug={ text }\n\t\t\ttitle={ text }\n\t\t\ticon={ icon }\n\t\t\tisActive={ isActive }\n\t\t\tisCustom
|
|
1
|
+
{"version":3,"names":["_coreData","require","_element","_components","_dataviewItem","_interopRequireDefault","_hooks","_icons","EMPTY_ARRAY","TemplateDataviewItem","template","isActive","text","icon","useAddedBy","type","id","_react","createElement","default","key","slug","title","isCustom","DataviewsTemplatesSidebarContent","activeView","postType","records","useEntityRecords","per_page","firstItemPerAuthorText","useMemo","_ref","firstItemPerAuthor","reduce","acc","author","author_text","Object","values","__experimentalItemGroup","layout","map"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DataViewItem from '../sidebar-dataviews/dataview-item';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport { layout } from '@wordpress/icons';\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\treturn (\n\t\t<DataViewItem\n\t\t\tkey={ text }\n\t\t\tslug={ text }\n\t\t\ttitle={ text }\n\t\t\ticon={ icon }\n\t\t\tisActive={ isActive }\n\t\t\tisCustom={ false }\n\t\t/>\n\t);\n}\n\nexport default function DataviewsTemplatesSidebarContent( {\n\tactiveView,\n\tpostType,\n\ttitle,\n} ) {\n\tconst { records } = useEntityRecords( 'postType', postType, {\n\t\tper_page: -1,\n\t} );\n\tconst firstItemPerAuthorText = useMemo( () => {\n\t\tconst firstItemPerAuthor = records?.reduce( ( acc, template ) => {\n\t\t\tconst author = template.author_text;\n\t\t\tif ( author && ! acc[ author ] ) {\n\t\t\t\tacc[ author ] = template;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn (\n\t\t\t( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??\n\t\t\tEMPTY_ARRAY\n\t\t);\n\t}, [ records ] );\n\n\treturn (\n\t\t<ItemGroup>\n\t\t\t<DataViewItem\n\t\t\t\tslug={ 'all' }\n\t\t\t\ttitle={ title }\n\t\t\t\ticon={ layout }\n\t\t\t\tisActive={ activeView === 'all' }\n\t\t\t\tisCustom={ false }\n\t\t\t/>\n\t\t\t{ firstItemPerAuthorText.map( ( template ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<TemplateDataviewItem\n\t\t\t\t\t\tkey={ template.author_text }\n\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\tisActive={ activeView === template.author_text }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ItemGroup>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAA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H,IAAA,GACGC,kBAAkB,IAAIK,MAAM,CAACC,MAAM,CAAEN,kBAAmB,CAAC,cAAAD,IAAA,cAAAA,IAAA,GAC3DxB,WAAW;EAEb,CAAC,EAAE,CAAEmB,OAAO,CAAG,CAAC;EAEhB,OACC,IAAAV,MAAA,CAAAC,aAAA,EAACf,WAAA,CAAAqC,uBAAS,QACT,IAAAvB,MAAA,CAAAC,aAAA,EAACd,aAAA,CAAAe,OAAY;IACZE,IAAI,EAAG,KAAO;IACdC,KAAK,EAAGA,KAAO;IACfT,IAAI,EAAG4B,aAAQ;IACf9B,QAAQ,EAAGc,UAAU,KAAK,KAAO;IACjCF,QAAQ,EAAG;EAAO,CAClB,CAAC,EACAO,sBAAsB,CAACY,GAAG,CAAIhC,QAAQ,IAAM;IAC7C,OACC,IAAAO,MAAA,CAAAC,aAAA,EAACT,oBAAoB;MACpBW,GAAG,EAAGV,QAAQ,CAAC2B,WAAa;MAC5B3B,QAAQ,EAAGA,QAAU;MACrBC,QAAQ,EAAGc,UAAU,KAAKf,QAAQ,CAAC2B;IAAa,CAChD,CAAC;EAEJ,CAAE,CACQ,CAAC;AAEd"}
|
|
@@ -169,7 +169,7 @@ function useResolveEditedEntityAndContext({
|
|
|
169
169
|
}
|
|
170
170
|
return {};
|
|
171
171
|
}, [homepageId, postType, postId, path]);
|
|
172
|
-
if (path === '/wp_template
|
|
172
|
+
if (path === '/wp_template' && postId) {
|
|
173
173
|
return {
|
|
174
174
|
isReady: true,
|
|
175
175
|
postType: 'wp_template',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_coreData","_router","_store","_lockUnlock","_constants","useLocation","unlock","routerPrivateApis","postTypesWithoutParentTemplate","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","PATTERN_TYPES","user","useResolveEditedEntityAndContext","path","postId","postType","hasLoadedAllDependencies","homepageId","url","frontPageTemplateId","useSelect","select","getSite","getUnstableBase","getEntityRecords","coreDataStore","siteData","base","templates","per_page","_frontPateTemplateId","frontPageTemplate","find","t","slug","id","show_on_front","includes","page_on_front","toString","home","resolvedTemplateId","undefined","getEditedEntityRecord","getDefaultTemplateId","__experimentalGetTemplateForLink","resolveTemplateForPostTypeAndId","postTypeToResolve","postIdToResolve","editedEntity","currentTemplateSlug","template","currentTemplate","slugToCheck","context","useMemo","isReady","useInitEditedEntityFromURL","params","setEditedEntity","useDispatch","editSiteStore","useEffect"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nfunction useResolveEditedEntityAndContext( { path, postId, postType } ) {\n\tconst { hasLoadedAllDependencies, homepageId, url, frontPageTemplateId } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getSite, getUnstableBase, getEntityRecords } =\n\t\t\t\tselect( coreDataStore );\n\t\t\tconst siteData = getSite();\n\t\t\tconst base = getUnstableBase();\n\t\t\tconst templates = getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tlet _frontPateTemplateId;\n\t\t\tif ( templates ) {\n\t\t\t\tconst frontPageTemplate = templates.find(\n\t\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t\t);\n\t\t\t\t_frontPateTemplateId = frontPageTemplate\n\t\t\t\t\t? frontPageTemplate.id\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasLoadedAllDependencies: !! base && !! siteData,\n\t\t\t\thomepageId:\n\t\t\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t\t\t[ 'number', 'string' ].includes(\n\t\t\t\t\t\ttypeof siteData.page_on_front\n\t\t\t\t\t)\n\t\t\t\t\t\t? siteData.page_on_front.toString()\n\t\t\t\t\t\t: null,\n\t\t\t\turl: base?.home,\n\t\t\t\tfrontPageTemplateId: _frontPateTemplateId,\n\t\t\t};\n\t\t}, [] );\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetDefaultTemplateId,\n\t\t\t\t__experimentalGetTemplateForLink,\n\t\t\t} = select( coreDataStore );\n\n\t\t\tfunction resolveTemplateForPostTypeAndId(\n\t\t\t\tpostTypeToResolve,\n\t\t\t\tpostIdToResolve\n\t\t\t) {\n\t\t\t\t// For the front page, we always use the front page template if existing.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\thomepageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\t// We're still checking whether the front page template exists.\n\t\t\t\t\t// Don't resolve the template yet.\n\t\t\t\t\tif ( frontPageTemplateId === undefined ) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !! frontPageTemplateId ) {\n\t\t\t\t\t\treturn frontPageTemplateId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst editedEntity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeToResolve,\n\t\t\t\t\tpostIdToResolve\n\t\t\t\t);\n\t\t\t\tif ( ! editedEntity ) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\t// First see if the post/page has an assigned template and fetch it.\n\t\t\t\tconst currentTemplateSlug = editedEntity.template;\n\t\t\t\tif ( currentTemplateSlug ) {\n\t\t\t\t\tconst currentTemplate = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\t\t\tif ( currentTemplate ) {\n\t\t\t\t\t\treturn currentTemplate.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If no template is assigned, use the default template.\n\t\t\t\tlet slugToCheck;\n\t\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t\t// through template hierarchy.\n\t\t\t\tif ( editedEntity.slug ) {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? `${ postTypeToResolve }-${ editedEntity.slug }`\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }-${ editedEntity.slug }`;\n\t\t\t\t} else {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }`;\n\t\t\t\t}\n\t\t\t\treturn getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( ! hasLoadedAllDependencies ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// If we're rendering a specific page, post... we need to resolve its template.\n\t\t\tif ( postType && postId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( postType, postId );\n\t\t\t}\n\n\t\t\t// Some URLs in list views are different\n\t\t\tif ( path === '/pages' && postId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', homepageId );\n\t\t\t}\n\n\t\t\t// If we're not rendering a specific page, use the front page template.\n\t\t\tif ( url ) {\n\t\t\t\tconst template = __experimentalGetTemplateForLink( url );\n\t\t\t\treturn template?.id;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\thomepageId,\n\t\t\thasLoadedAllDependencies,\n\t\t\turl,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tpath,\n\t\t\tfrontPageTemplateId,\n\t\t]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\n\t\t// Some URLs in list views are different\n\t\tif ( path === '/pages' && postId ) {\n\t\t\treturn { postType: 'page', postId };\n\t\t}\n\n\t\tif ( homepageId ) {\n\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homepageId, postType, postId, path ] );\n\n\tif ( path === '/wp_template/all' && postId ) {\n\t\treturn { isReady: true, postType: 'wp_template', postId, context };\n\t}\n\n\tif ( path === '/wp_template_part/all' && postId ) {\n\t\treturn { isReady: true, postType: 'wp_template_part', postId, context };\n\t}\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( hasLoadedAllDependencies ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, postId, context, isReady } =\n\t\tuseResolveEditedEntityAndContext( params );\n\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [ isReady, postType, postId, context, setEditedEntity ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAMA;AACA;AACA;;AAUA,MAAM;EAAEO;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAEnD,MAAMC,8BAA8B,GAAG,CACtCC,6BAAkB,EAClBC,kCAAuB,EACvBC,+BAAoB,EACpBC,wBAAa,CAACC,IAAI,CAClB;AAED,SAASC,gCAAgCA,CAAE;EAAEC,IAAI;EAAEC,MAAM;EAAEC;AAAS,CAAC,EAAG;EACvE,MAAM;IAAEC,wBAAwB;IAAEC,UAAU;IAAEC,GAAG;IAAEC;EAAoB,CAAC,GACvE,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACxB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AAED,MAAM;MAAEwC;IAAQ,CAAC;EACnE;EAEA,IAAKzC,IAAI,KAAK,uBAAuB,IAAIC,MAAM,EAAG;IACjD,OAAO;MAAE0C,OAAO,EAAE,IAAI;MAAEzC,QAAQ,EAAE,kBAAkB;MAAED,MAAM;MAAEwC;IAAQ,CAAC;EACxE;EAEA,IAAKhD,8BAA8B,CAAC+B,QAAQ,CAAEtB,QAAS,CAAC,EAAG;IAC1D,OAAO;MAAEyC,OAAO,EAAE,IAAI;MAAEzC,QAAQ;MAAED,MAAM;MAAEwC;IAAQ,CAAC;EACpD;EAEA,IAAKtC,wBAAwB,EAAG;IAC/B,OAAO;MACNwC,OAAO,EAAEf,kBAAkB,KAAKC,SAAS;MACzC3B,QAAQ,EAAER,6BAAkB;MAC5BO,MAAM,EAAE2B,kBAAkB;MAC1Ba;IACD,CAAC;EACF;EAEA,OAAO;IAAEE,OAAO,EAAE;EAAM,CAAC;AAC1B;AAEe,SAASC,0BAA0BA,CAAA,EAAG;EACpD,MAAM;IAAEC,MAAM,GAAG,CAAC;EAAE,CAAC,GAAGvD,WAAW,CAAC,CAAC;EACrC,MAAM;IAAEY,QAAQ;IAAED,MAAM;IAAEwC,OAAO;IAAEE;EAAQ,CAAC,GAC3C5C,gCAAgC,CAAE8C,MAAO,CAAC;EAE3C,MAAM;IAAEC;EAAgB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAc,CAAC;EAExD,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKN,OAAO,EAAG;MACdG,eAAe,CAAE5C,QAAQ,EAAED,MAAM,EAAEwC,OAAQ,CAAC;IAC7C;EACD,CAAC,EAAE,CAAEE,OAAO,EAAEzC,QAAQ,EAAED,MAAM,EAAEwC,OAAO,EAAEK,eAAe,CAAG,CAAC;AAC7D"}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_coreData","_router","_store","_lockUnlock","_constants","useLocation","unlock","routerPrivateApis","postTypesWithoutParentTemplate","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","PATTERN_TYPES","user","useResolveEditedEntityAndContext","path","postId","postType","hasLoadedAllDependencies","homepageId","url","frontPageTemplateId","useSelect","select","getSite","getUnstableBase","getEntityRecords","coreDataStore","siteData","base","templates","per_page","_frontPateTemplateId","frontPageTemplate","find","t","slug","id","show_on_front","includes","page_on_front","toString","home","resolvedTemplateId","undefined","getEditedEntityRecord","getDefaultTemplateId","__experimentalGetTemplateForLink","resolveTemplateForPostTypeAndId","postTypeToResolve","postIdToResolve","editedEntity","currentTemplateSlug","template","currentTemplate","slugToCheck","context","useMemo","isReady","useInitEditedEntityFromURL","params","setEditedEntity","useDispatch","editSiteStore","useEffect"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nfunction useResolveEditedEntityAndContext( { path, postId, postType } ) {\n\tconst { hasLoadedAllDependencies, homepageId, url, frontPageTemplateId } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getSite, getUnstableBase, getEntityRecords } =\n\t\t\t\tselect( coreDataStore );\n\t\t\tconst siteData = getSite();\n\t\t\tconst base = getUnstableBase();\n\t\t\tconst templates = getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tlet _frontPateTemplateId;\n\t\t\tif ( templates ) {\n\t\t\t\tconst frontPageTemplate = templates.find(\n\t\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t\t);\n\t\t\t\t_frontPateTemplateId = frontPageTemplate\n\t\t\t\t\t? frontPageTemplate.id\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasLoadedAllDependencies: !! base && !! siteData,\n\t\t\t\thomepageId:\n\t\t\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t\t\t[ 'number', 'string' ].includes(\n\t\t\t\t\t\ttypeof siteData.page_on_front\n\t\t\t\t\t)\n\t\t\t\t\t\t? siteData.page_on_front.toString()\n\t\t\t\t\t\t: null,\n\t\t\t\turl: base?.home,\n\t\t\t\tfrontPageTemplateId: _frontPateTemplateId,\n\t\t\t};\n\t\t}, [] );\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetDefaultTemplateId,\n\t\t\t\t__experimentalGetTemplateForLink,\n\t\t\t} = select( coreDataStore );\n\n\t\t\tfunction resolveTemplateForPostTypeAndId(\n\t\t\t\tpostTypeToResolve,\n\t\t\t\tpostIdToResolve\n\t\t\t) {\n\t\t\t\t// For the front page, we always use the front page template if existing.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\thomepageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\t// We're still checking whether the front page template exists.\n\t\t\t\t\t// Don't resolve the template yet.\n\t\t\t\t\tif ( frontPageTemplateId === undefined ) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !! frontPageTemplateId ) {\n\t\t\t\t\t\treturn frontPageTemplateId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst editedEntity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeToResolve,\n\t\t\t\t\tpostIdToResolve\n\t\t\t\t);\n\t\t\t\tif ( ! editedEntity ) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\t// First see if the post/page has an assigned template and fetch it.\n\t\t\t\tconst currentTemplateSlug = editedEntity.template;\n\t\t\t\tif ( currentTemplateSlug ) {\n\t\t\t\t\tconst currentTemplate = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\t\t\tif ( currentTemplate ) {\n\t\t\t\t\t\treturn currentTemplate.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If no template is assigned, use the default template.\n\t\t\t\tlet slugToCheck;\n\t\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t\t// through template hierarchy.\n\t\t\t\tif ( editedEntity.slug ) {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? `${ postTypeToResolve }-${ editedEntity.slug }`\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }-${ editedEntity.slug }`;\n\t\t\t\t} else {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }`;\n\t\t\t\t}\n\t\t\t\treturn getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( ! hasLoadedAllDependencies ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// If we're rendering a specific page, post... we need to resolve its template.\n\t\t\tif ( postType && postId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( postType, postId );\n\t\t\t}\n\n\t\t\t// Some URLs in list views are different\n\t\t\tif ( path === '/pages' && postId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', homepageId );\n\t\t\t}\n\n\t\t\t// If we're not rendering a specific page, use the front page template.\n\t\t\tif ( url ) {\n\t\t\t\tconst template = __experimentalGetTemplateForLink( url );\n\t\t\t\treturn template?.id;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\thomepageId,\n\t\t\thasLoadedAllDependencies,\n\t\t\turl,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tpath,\n\t\t\tfrontPageTemplateId,\n\t\t]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\n\t\t// Some URLs in list views are different\n\t\tif ( path === '/pages' && postId ) {\n\t\t\treturn { postType: 'page', postId };\n\t\t}\n\n\t\tif ( homepageId ) {\n\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homepageId, postType, postId, path ] );\n\n\tif ( path === '/wp_template' && postId ) {\n\t\treturn { isReady: true, postType: 'wp_template', postId, context };\n\t}\n\n\tif ( path === '/wp_template_part/all' && postId ) {\n\t\treturn { isReady: true, postType: 'wp_template_part', postId, context };\n\t}\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( hasLoadedAllDependencies ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, postId, context, isReady } =\n\t\tuseResolveEditedEntityAndContext( params );\n\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [ isReady, postType, postId, context, setEditedEntity ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAMA;AACA;AACA;;AAUA,MAAM;EAAEO;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAEnD,MAAMC,8BAA8B,GAAG,CACtCC,6BAAkB,EAClBC,kCAAuB,EACvBC,+BAAoB,EACpBC,wBAAa,CAACC,IAAI,CAClB;AAED,SAASC,gCAAgCA,CAAE;EAAEC,IAAI;EAAEC,MAAM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AG,CAAC;AAC7D"}
|
|
@@ -95,20 +95,10 @@ function useSyncPathWithURL() {
|
|
|
95
95
|
canvas: undefined,
|
|
96
96
|
path: navigatorLocation.path
|
|
97
97
|
});
|
|
98
|
-
} else if (navigatorLocation.path === '/wp_template/all' && !window?.__experimentalAdminViews) {
|
|
99
|
-
// When the experiment is disabled, we only support table layout.
|
|
100
|
-
// Clear it out from the URL, so layouts other than table cannot be accessed.
|
|
101
|
-
updateUrlParams({
|
|
102
|
-
postType: undefined,
|
|
103
|
-
categoryType: undefined,
|
|
104
|
-
categoryId: undefined,
|
|
105
|
-
path: navigatorLocation.path,
|
|
106
|
-
layout: undefined
|
|
107
|
-
});
|
|
108
98
|
} else if (
|
|
109
99
|
// These sidebar paths are special in the sense that the url in these pages may or may not have a postId and we need to retain it if it has.
|
|
110
100
|
// The "type" property should be kept as well.
|
|
111
|
-
navigatorLocation.path === '/pages'
|
|
101
|
+
navigatorLocation.path === '/pages' || navigatorLocation.path === '/wp_template' || navigatorLocation.path === '/wp_template_part/all') {
|
|
112
102
|
updateUrlParams({
|
|
113
103
|
postType: undefined,
|
|
114
104
|
categoryType: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_router","_lockUnlock","_constants","useLocation","useHistory","unlock","routerPrivateApis","getPathFromURL","urlParams","_urlParams$path","path","postType","postId","PATTERN_TYPES","user","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","encodeURIComponent","isSubset","subset","superset","Object","entries","every","key","value","useSyncPathWithURL","history","params","location","navigatorLocation","navigatorParams","goTo","useNavigator","isMounting","useRef","useEffect","current","updateUrlParams","newUrlParams","updatedParams","push","undefined","layout","startsWith","canvas","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_router","_lockUnlock","_constants","useLocation","useHistory","unlock","routerPrivateApis","getPathFromURL","urlParams","_urlParams$path","path","postType","postId","PATTERN_TYPES","user","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","encodeURIComponent","isSubset","subset","superset","Object","entries","every","key","value","useSyncPathWithURL","history","params","location","navigatorLocation","navigatorParams","goTo","useNavigator","isMounting","useRef","useEffect","current","updateUrlParams","newUrlParams","updatedParams","push","undefined","layout","startsWith","canvas","categoryType","categoryId"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport function getPathFromURL( urlParams ) {\n\tlet path = urlParams?.path ?? '/';\n\n\t// Compute the navigator path based on the URL params.\n\tif ( urlParams?.postType && urlParams?.postId ) {\n\t\tswitch ( urlParams.postType ) {\n\t\t\tcase PATTERN_TYPES.user:\n\t\t\tcase TEMPLATE_POST_TYPE:\n\t\t\tcase TEMPLATE_PART_POST_TYPE:\n\t\t\tcase 'page':\n\t\t\t\tpath = `/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tpath = `/navigation/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t}\n\t}\n\n\treturn path;\n}\n\nfunction isSubset( subset, superset ) {\n\treturn Object.entries( subset ).every( ( [ key, value ] ) => {\n\t\treturn superset[ key ] === value;\n\t} );\n}\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params: urlParams } = useLocation();\n\tconst {\n\t\tlocation: navigatorLocation,\n\t\tparams: navigatorParams,\n\t\tgoTo,\n\t} = useNavigator();\n\tconst isMounting = useRef( true );\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// The navigatorParams are only initially filled properly when the\n\t\t\t// navigator screens mount. so we ignore the first synchronisation.\n\t\t\tif ( isMounting.current ) {\n\t\t\t\tisMounting.current = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction updateUrlParams( newUrlParams ) {\n\t\t\t\tif ( isSubset( newUrlParams, urlParams ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst updatedParams = {\n\t\t\t\t\t...urlParams,\n\t\t\t\t\t...newUrlParams,\n\t\t\t\t};\n\t\t\t\thistory.push( updatedParams );\n\t\t\t}\n\n\t\t\tif ( navigatorParams?.postType && navigatorParams?.postId ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\tnavigatorLocation.path.startsWith( '/page/' ) &&\n\t\t\t\tnavigatorParams?.postId\n\t\t\t) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\t\t\t} else if ( navigatorLocation.path === '/patterns' ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcanvas: undefined,\n\t\t\t\t\tpath: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\t// These sidebar paths are special in the sense that the url in these pages may or may not have a postId and we need to retain it if it has.\n\t\t\t\t// The \"type\" property should be kept as well.\n\t\t\t\tnavigatorLocation.path === '/pages' ||\n\t\t\t\tnavigatorLocation.path === '/wp_template' ||\n\t\t\t\tnavigatorLocation.path === '/wp_template_part/all'\n\t\t\t) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tcategoryType: undefined,\n\t\t\t\t\tcategoryId: undefined,\n\t\t\t\t\tpath: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcategoryType: undefined,\n\t\t\t\t\tcategoryId: undefined,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t\tpath:\n\t\t\t\t\t\tnavigatorLocation.path === '/'\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when navigator changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ navigatorLocation?.path, navigatorParams ]\n\t);\n\n\tuseEffect(\n\t\t() => {\n\t\t\tconst path = getPathFromURL( urlParams );\n\t\t\tif ( navigatorLocation.path !== path ) {\n\t\t\t\tgoTo( path );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when URL changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ urlParams ]\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAQA,MAAM;EAAEK,WAAW;EAAEC;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAExD,SAASC,cAAcA,CAAEC,SAAS,EAAG;EAAA,IAAAC,eAAA;EAC3C,IAAIC,IAAI,IAAAD,eAAA,GAA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ACvBK,UAAU,EAAEL,SAAS;QACrBhC,IAAI,EAAEoB,iBAAiB,CAACpB;MACzB,CAAE,CAAC;IACJ,CAAC,MAAM;MACN4B,eAAe,CAAE;QAChB3B,QAAQ,EAAE+B,SAAS;QACnB9B,MAAM,EAAE8B,SAAS;QACjBI,YAAY,EAAEJ,SAAS;QACvBK,UAAU,EAAEL,SAAS;QACrBC,MAAM,EAAED,SAAS;QACjBhC,IAAI,EACHoB,iBAAiB,CAACpB,IAAI,KAAK,GAAG,GAC3BgC,SAAS,GACTZ,iBAAiB,CAACpB;MACvB,CAAE,CAAC;IACJ;EACD,CAAC;EACD;EACA;EACA,CAAEoB,iBAAiB,EAAEpB,IAAI,EAAEqB,eAAe,CAC3C,CAAC;EAED,IAAAK,kBAAS,EACR,MAAM;IACL,MAAM1B,IAAI,GAAGH,cAAc,CAAEC,SAAU,CAAC;IACxC,IAAKsB,iBAAiB,CAACpB,IAAI,KAAKA,IAAI,EAAG;MACtCsB,IAAI,CAAEtB,IAAK,CAAC;IACb;EACD,CAAC;EACD;EACA;EACA,CAAEF,SAAS,CACZ,CAAC;AACF"}
|
|
@@ -36,7 +36,41 @@ function TemplateActions({
|
|
|
36
36
|
}) {
|
|
37
37
|
const template = (0, _data.useSelect)(select => select(_coreData.store).getEntityRecord('postType', postType, postId), [postType, postId]);
|
|
38
38
|
const {
|
|
39
|
-
removeTemplate
|
|
39
|
+
removeTemplate
|
|
40
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
41
|
+
const isRemovable = (0, _isTemplateRemovable.default)(template);
|
|
42
|
+
const isRevertable = (0, _isTemplateRevertable.default)(template);
|
|
43
|
+
if (!isRemovable && !isRevertable) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return (0, _react.createElement)(_components.DropdownMenu, {
|
|
47
|
+
icon: _icons.moreVertical,
|
|
48
|
+
label: (0, _i18n.__)('Actions'),
|
|
49
|
+
className: className,
|
|
50
|
+
toggleProps: toggleProps
|
|
51
|
+
}, ({
|
|
52
|
+
onClose
|
|
53
|
+
}) => (0, _react.createElement)(_components.MenuGroup, null, isRemovable && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_renameMenuItem.default, {
|
|
54
|
+
template: template,
|
|
55
|
+
onClose: onClose
|
|
56
|
+
}), (0, _react.createElement)(DeleteMenuItem, {
|
|
57
|
+
onRemove: () => {
|
|
58
|
+
removeTemplate(template);
|
|
59
|
+
onRemove?.();
|
|
60
|
+
onClose();
|
|
61
|
+
},
|
|
62
|
+
title: template.title.rendered
|
|
63
|
+
})), isRevertable && (0, _react.createElement)(ResetMenuItem, {
|
|
64
|
+
template: template,
|
|
65
|
+
onClose: onClose
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
68
|
+
function ResetMenuItem({
|
|
69
|
+
template,
|
|
70
|
+
onClose
|
|
71
|
+
}) {
|
|
72
|
+
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
73
|
+
const {
|
|
40
74
|
revertTemplate
|
|
41
75
|
} = (0, _data.useDispatch)(_store.store);
|
|
42
76
|
const {
|
|
@@ -46,11 +80,6 @@ function TemplateActions({
|
|
|
46
80
|
createSuccessNotice,
|
|
47
81
|
createErrorNotice
|
|
48
82
|
} = (0, _data.useDispatch)(_notices.store);
|
|
49
|
-
const isRemovable = (0, _isTemplateRemovable.default)(template);
|
|
50
|
-
const isRevertable = (0, _isTemplateRevertable.default)(template);
|
|
51
|
-
if (!isRemovable && !isRevertable) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
83
|
async function revertAndSaveTemplate() {
|
|
55
84
|
try {
|
|
56
85
|
await revertTemplate(template, {
|
|
@@ -70,30 +99,18 @@ function TemplateActions({
|
|
|
70
99
|
});
|
|
71
100
|
}
|
|
72
101
|
}
|
|
73
|
-
return (0, _react.createElement)(_components.
|
|
74
|
-
icon: _icons.moreVertical,
|
|
75
|
-
label: (0, _i18n.__)('Actions'),
|
|
76
|
-
className: className,
|
|
77
|
-
toggleProps: toggleProps
|
|
78
|
-
}, ({
|
|
79
|
-
onClose
|
|
80
|
-
}) => (0, _react.createElement)(_components.MenuGroup, null, isRemovable && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_renameMenuItem.default, {
|
|
81
|
-
template: template,
|
|
82
|
-
onClose: onClose
|
|
83
|
-
}), (0, _react.createElement)(DeleteMenuItem, {
|
|
84
|
-
onRemove: () => {
|
|
85
|
-
removeTemplate(template);
|
|
86
|
-
onRemove?.();
|
|
87
|
-
onClose();
|
|
88
|
-
},
|
|
89
|
-
title: template.title.rendered
|
|
90
|
-
})), isRevertable && (0, _react.createElement)(_components.MenuItem, {
|
|
102
|
+
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.MenuItem, {
|
|
91
103
|
info: (0, _i18n.__)('Use the template as supplied by the theme.'),
|
|
92
|
-
onClick: () =>
|
|
104
|
+
onClick: () => setIsModalOpen(true)
|
|
105
|
+
}, (0, _i18n.__)('Clear customizations')), (0, _react.createElement)(_components.__experimentalConfirmDialog, {
|
|
106
|
+
isOpen: isModalOpen,
|
|
107
|
+
onConfirm: () => {
|
|
93
108
|
revertAndSaveTemplate();
|
|
94
109
|
onClose();
|
|
95
|
-
}
|
|
96
|
-
|
|
110
|
+
},
|
|
111
|
+
onCancel: () => setIsModalOpen(false),
|
|
112
|
+
confirmButtonText: (0, _i18n.__)('Clear')
|
|
113
|
+
}, (0, _i18n.__)('Are you sure you want to clear these customizations?')));
|
|
97
114
|
}
|
|
98
115
|
function DeleteMenuItem({
|
|
99
116
|
onRemove,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_icons","_notices","_htmlEntities","_store","_isTemplateRemovable","_interopRequireDefault","_isTemplateRevertable","_renameMenuItem","_constants","TemplateActions","postType","postId","className","toggleProps","onRemove","template","useSelect","select","coreStore","getEntityRecord","removeTemplate","revertTemplate","useDispatch","editSiteStore","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","isRemovable","isTemplateRemovable","isRevertable","isTemplateRevertable","revertAndSaveTemplate","allowUndo","type","id","sprintf","__","decodeEntities","title","rendered","error","fallbackErrorMessage","TEMPLATE_POST_TYPE","errorMessage","message","code","_react","createElement","DropdownMenu","icon","moreVertical","label","onClose","MenuGroup","Fragment","default","DeleteMenuItem","MenuItem","info","onClick","isModalOpen","setIsModalOpen","useState","isDestructive","__experimentalConfirmDialog","isOpen","onConfirm","onCancel","confirmButtonText"],"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\tdecodeEntities( template.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-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst fallbackErrorMessage =\n\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t? __( 'An error occurred while reverting the template.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t );\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: fallbackErrorMessage;\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttitle={ template.title.rendered }\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\t{ isRevertable && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t'Use the template as supplied by the theme.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, title } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem isDestructive onClick={ () => setIsModalOpen( true ) }>\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={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: The template or template part's title.\n\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG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L"}
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_icons","_notices","_htmlEntities","_store","_isTemplateRemovable","_interopRequireDefault","_isTemplateRevertable","_renameMenuItem","_constants","TemplateActions","postType","postId","className","toggleProps","onRemove","template","useSelect","select","coreStore","getEntityRecord","removeTemplate","useDispatch","editSiteStore","isRemovable","isTemplateRemovable","isRevertable","isTemplateRevertable","_react","createElement","DropdownMenu","icon","moreVertical","label","__","onClose","MenuGroup","Fragment","default","DeleteMenuItem","title","rendered","ResetMenuItem","isModalOpen","setIsModalOpen","useState","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","noticesStore","revertAndSaveTemplate","allowUndo","type","id","sprintf","decodeEntities","error","fallbackErrorMessage","TEMPLATE_POST_TYPE","errorMessage","message","code","MenuItem","info","onClick","__experimentalConfirmDialog","isOpen","onConfirm","onCancel","confirmButtonText","isDestructive"],"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate } = useDispatch( editSiteStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\ttitle={ template.title.rendered }\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\t{ isRevertable && (\n\t\t\t\t\t\t<ResetMenuItem\n\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction ResetMenuItem( { template, onClose } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\tdecodeEntities( template.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-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst fallbackErrorMessage =\n\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t? __( 'An error occurred while reverting the template.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t );\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: fallbackErrorMessage;\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tinfo={ __( 'Use the template as supplied by the theme.' ) }\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Clear' ) }\n\t\t\t>\n\t\t\t\t{ __( 'Are you sure you want to clear these customizations?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, title } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem isDestructive onClick={ () => setIsModalOpen( true ) }>\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={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: The template or template part's title.\n\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,oBAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,eAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AAxBA;AACA;AACA;;AAeA;AACA;AACA;;AAOe,SAASc,eAAeA,CAAE;EACxCC,QAAQ;EACRC,MAAM;EACNC,SAAS;EACTC,WAAW;EACXC;AACD,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EACvBC,MAAM,IACPA,MAAM,CAAEC,eAAU,CAAC,CAACC,eAAe,CAAE,UAAU,EAAET,QAAQ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ElC,IAAAqB,aAAO;EACR;EACA,IAAArB,QAAE,EAAE,uCAAwC,CAAC,EAC7C,IAAAsB,4BAAc,EAAEhB,KAAM,CACvB,CACc,CACd,CAAC;AAEL"}
|
|
@@ -11,6 +11,7 @@ var _components = require("@wordpress/components");
|
|
|
11
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
12
|
var _element = require("@wordpress/element");
|
|
13
13
|
var _preferences = require("@wordpress/preferences");
|
|
14
|
+
var _coreData = require("@wordpress/core-data");
|
|
14
15
|
var _image = _interopRequireDefault(require("./image"));
|
|
15
16
|
/**
|
|
16
17
|
* WordPress dependencies
|
|
@@ -24,8 +25,16 @@ function WelcomeGuideEditor() {
|
|
|
24
25
|
const {
|
|
25
26
|
toggle
|
|
26
27
|
} = (0, _data.useDispatch)(_preferences.store);
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const {
|
|
29
|
+
isActive,
|
|
30
|
+
isBlockBasedTheme
|
|
31
|
+
} = (0, _data.useSelect)(select => {
|
|
32
|
+
return {
|
|
33
|
+
isActive: !!select(_preferences.store).get('core/edit-site', 'welcomeGuide'),
|
|
34
|
+
isBlockBasedTheme: select(_coreData.store).getCurrentTheme()?.is_block_theme
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
if (!isActive || !isBlockBasedTheme) {
|
|
29
38
|
return null;
|
|
30
39
|
}
|
|
31
40
|
return (0, _react.createElement)(_components.Guide, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_components","_i18n","_element","_preferences","_image","_interopRequireDefault","WelcomeGuideEditor","toggle","useDispatch","preferencesStore","isActive","useSelect","select","get","_react","createElement","Guide","className","contentLabel","__","finishButtonText","onFinish","pages","image","default","nonAnimatedSrc","animatedSrc","content","Fragment","createInterpolateElement","StylesIconImage","alt","src"],"sources":["@wordpress/edit-site/src/components/welcome-guide/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\n\nexport default function WelcomeGuideEditor() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isActive = useSelect(
|
|
1
|
+
{"version":3,"names":["_data","require","_components","_i18n","_element","_preferences","_coreData","_image","_interopRequireDefault","WelcomeGuideEditor","toggle","useDispatch","preferencesStore","isActive","isBlockBasedTheme","useSelect","select","get","coreStore","getCurrentTheme","is_block_theme","_react","createElement","Guide","className","contentLabel","__","finishButtonText","onFinish","pages","image","default","nonAnimatedSrc","animatedSrc","content","Fragment","createInterpolateElement","StylesIconImage","alt","src"],"sources":["@wordpress/edit-site/src/components/welcome-guide/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\n\nexport default function WelcomeGuideEditor() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst { isActive, isBlockBasedTheme } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tisActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t\tisBlockBasedTheme:\n\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive || ! isBlockBasedTheme ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide guide-editor\"\n\t\t\tcontentLabel={ __( 'Welcome to the site editor' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () => toggle( 'core/edit-site', 'welcomeGuide' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/edit-your-site.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Edit your site' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Design everything on your site — from the header right down to the footer — using blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStylesIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'styles' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 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