@wordpress/edit-site 5.22.0 → 5.23.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 +86 -4
- package/build/components/actions/index.js.map +1 -1
- package/build/components/add-new-template/new-template.js +0 -7
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +54 -63
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/dataviews/add-filter.js +90 -0
- package/build/components/dataviews/add-filter.js.map +1 -0
- package/build/components/dataviews/dataviews.js +23 -4
- package/build/components/dataviews/dataviews.js.map +1 -1
- package/build/components/dataviews/filters.js +36 -32
- package/build/components/dataviews/filters.js.map +1 -1
- package/build/components/dataviews/in-filter.js +22 -20
- package/build/components/dataviews/in-filter.js.map +1 -1
- package/build/components/dataviews/index.js +9 -2
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews/item-actions.js +81 -13
- package/build/components/dataviews/item-actions.js.map +1 -1
- package/build/components/dataviews/pagination.js +3 -2
- package/build/components/dataviews/pagination.js.map +1 -1
- package/build/components/dataviews/reset-filters.js +33 -0
- package/build/components/dataviews/reset-filters.js.map +1 -0
- package/build/components/dataviews/search.js +1 -0
- package/build/components/dataviews/search.js.map +1 -1
- package/build/components/dataviews/view-actions.js +27 -10
- package/build/components/dataviews/view-actions.js.map +1 -1
- package/build/components/dataviews/view-list.js +126 -5
- package/build/components/dataviews/view-list.js.map +1 -1
- package/build/components/dataviews/view-side-by-side.js +20 -0
- package/build/components/dataviews/view-side-by-side.js.map +1 -0
- package/build/components/editor/index.js +53 -53
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +42 -21
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-root.js +3 -3
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -3
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +1 -1
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/document-tools/index.js +160 -0
- package/build/components/header-edit-mode/document-tools/index.js.map +1 -0
- package/build/components/header-edit-mode/index.js +48 -116
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -1
- package/build/components/layout/index.js +4 -19
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +1 -0
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/page-content-focus-manager/back-to-page-notification.js +5 -10
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +36 -23
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-main/index.js +2 -1
- package/build/components/page-main/index.js.map +1 -1
- package/build/components/page-pages/index.js +133 -78
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-pages/side-editor.js +25 -0
- package/build/components/page-pages/side-editor.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +2 -2
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +3 -3
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/dataviews-templates.js +201 -0
- package/build/components/page-templates/dataviews-templates.js.map +1 -0
- package/build/components/page-templates/template-actions.js +168 -0
- package/build/components/page-templates/template-actions.js.map +1 -0
- package/build/components/sidebar/index.js +1 -2
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +124 -0
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -0
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +189 -0
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
- package/build/components/sidebar-dataviews/dataview-item.js +71 -0
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -0
- package/build/components/sidebar-dataviews/default-views.js +60 -0
- package/build/components/sidebar-dataviews/default-views.js.map +1 -0
- package/build/components/sidebar-dataviews/index.js +21 -38
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/default-sidebar.js +2 -6
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +11 -11
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +2 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +4 -12
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js +4 -12
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/hooks.js +3 -3
- package/build/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/page-details.js +3 -11
- package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/site-hub/index.js +18 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +12 -16
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +112 -49
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-part-converter/convert-to-regular.js +1 -1
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +6 -2
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/store/actions.js +35 -82
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -63
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +3 -3
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/actions/index.js +85 -5
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +0 -7
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +54 -62
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/dataviews/add-filter.js +83 -0
- package/build-module/components/dataviews/add-filter.js.map +1 -0
- package/build-module/components/dataviews/dataviews.js +22 -4
- package/build-module/components/dataviews/dataviews.js.map +1 -1
- package/build-module/components/dataviews/filters.js +34 -32
- package/build-module/components/dataviews/filters.js.map +1 -1
- package/build-module/components/dataviews/in-filter.js +20 -19
- package/build-module/components/dataviews/in-filter.js.map +1 -1
- package/build-module/components/dataviews/index.js +1 -1
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews/item-actions.js +84 -16
- package/build-module/components/dataviews/item-actions.js.map +1 -1
- package/build-module/components/dataviews/pagination.js +3 -2
- package/build-module/components/dataviews/pagination.js.map +1 -1
- package/build-module/components/dataviews/reset-filters.js +26 -0
- package/build-module/components/dataviews/reset-filters.js.map +1 -0
- package/build-module/components/dataviews/search.js +1 -0
- package/build-module/components/dataviews/search.js.map +1 -1
- package/build-module/components/dataviews/view-actions.js +28 -11
- package/build-module/components/dataviews/view-actions.js.map +1 -1
- package/build-module/components/dataviews/view-list.js +128 -7
- package/build-module/components/dataviews/view-list.js.map +1 -1
- package/build-module/components/dataviews/view-side-by-side.js +12 -0
- package/build-module/components/dataviews/view-side-by-side.js.map +1 -0
- package/build-module/components/editor/index.js +57 -57
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +42 -21
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +3 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/ui.js +3 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +1 -1
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/document-tools/index.js +152 -0
- package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -0
- package/build-module/components/header-edit-mode/index.js +52 -120
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -1
- package/build-module/components/layout/index.js +5 -20
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +1 -1
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js +5 -10
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +36 -23
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-main/index.js +2 -1
- package/build-module/components/page-main/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +137 -80
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-pages/side-editor.js +17 -0
- package/build-module/components/page-pages/side-editor.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +2 -2
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +4 -4
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +2 -2
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/dataviews-templates.js +193 -0
- package/build-module/components/page-templates/dataviews-templates.js.map +1 -0
- package/build-module/components/page-templates/template-actions.js +157 -0
- package/build-module/components/page-templates/template-actions.js.map +1 -0
- package/build-module/components/sidebar/index.js +1 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +116 -0
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -0
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +180 -0
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
- package/build-module/components/sidebar-dataviews/dataview-item.js +63 -0
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -0
- package/build-module/components/sidebar-dataviews/default-views.js +52 -0
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -0
- package/build-module/components/sidebar-dataviews/index.js +22 -39
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/default-sidebar.js +2 -6
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +12 -12
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +3 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +5 -13
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js +5 -13
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js +4 -4
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/page-details.js +3 -11
- package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -7
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +13 -16
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +112 -50
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +6 -2
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +0 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +33 -79
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +19 -58
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +1 -1
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +69 -119
- package/build-style/style.css +69 -119
- package/package.json +41 -41
- package/src/components/actions/index.js +113 -5
- package/src/components/add-new-template/new-template.js +0 -5
- package/src/components/block-editor/style.scss +0 -87
- package/src/components/block-editor/use-site-editor-settings.js +68 -89
- package/src/components/dataviews/README.md +77 -83
- package/src/components/dataviews/add-filter.js +111 -0
- package/src/components/dataviews/dataviews.js +20 -2
- package/src/components/dataviews/filters.js +56 -49
- package/src/components/dataviews/in-filter.js +35 -17
- package/src/components/dataviews/index.js +1 -1
- package/src/components/dataviews/item-actions.js +95 -20
- package/src/components/dataviews/pagination.js +5 -4
- package/src/components/dataviews/reset-filters.js +26 -0
- package/src/components/dataviews/search.js +1 -0
- package/src/components/dataviews/style.scss +5 -1
- package/src/components/dataviews/view-actions.js +39 -9
- package/src/components/dataviews/view-list.js +174 -3
- package/src/components/dataviews/view-side-by-side.js +9 -0
- package/src/components/editor/index.js +149 -121
- package/src/components/global-styles/screen-revisions/index.js +52 -25
- package/src/components/global-styles/screen-root.js +2 -1
- package/src/components/global-styles/ui.js +1 -1
- package/src/components/global-styles-renderer/index.js +1 -1
- package/src/components/header-edit-mode/document-tools/index.js +201 -0
- package/src/components/header-edit-mode/index.js +86 -184
- package/src/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/src/components/header-edit-mode/style.scss +35 -2
- package/src/components/layout/index.js +4 -11
- package/src/components/layout/style.scss +6 -18
- package/src/components/list/added-by.js +1 -1
- package/src/components/page-content-focus-manager/back-to-page-notification.js +4 -15
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +38 -33
- package/src/components/page-main/index.js +6 -1
- package/src/components/page-pages/index.js +162 -81
- package/src/components/page-pages/side-editor.js +14 -0
- package/src/components/page-patterns/grid-item.js +3 -3
- package/src/components/page-patterns/patterns-list.js +10 -4
- package/src/components/page-patterns/use-patterns.js +3 -2
- package/src/components/page-templates/dataviews-templates.js +224 -0
- package/src/components/page-templates/template-actions.js +209 -0
- package/src/components/sidebar/index.js +1 -2
- package/src/components/sidebar-dataviews/add-new-view.js +141 -0
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +227 -0
- package/src/components/sidebar-dataviews/dataview-item.js +67 -0
- package/src/components/sidebar-dataviews/default-views.js +54 -0
- package/src/components/sidebar-dataviews/index.js +36 -45
- package/src/components/sidebar-dataviews/style.scss +22 -0
- package/src/components/sidebar-edit-mode/default-sidebar.js +6 -6
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +14 -21
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +3 -0
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +10 -9
- package/src/components/sidebar-edit-mode/page-panels/style.scss +5 -0
- package/src/components/sidebar-edit-mode/page-panels/swap-template-button.js +10 -9
- package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +6 -6
- package/src/components/sidebar-edit-mode/template-panel/hooks.js +11 -7
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/src/components/sidebar-navigation-screen-page/page-details.js +4 -17
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
- package/src/components/site-hub/index.js +9 -8
- package/src/components/start-template-options/index.js +14 -12
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +117 -50
- package/src/components/template-part-converter/convert-to-regular.js +1 -1
- package/src/hooks/push-changes-to-global-styles/index.js +13 -6
- package/src/hooks/template-part-edit.js +4 -2
- package/src/index.js +0 -8
- package/src/store/actions.js +37 -95
- package/src/store/selectors.js +31 -91
- package/src/store/test/actions.js +11 -137
- package/src/store/test/selectors.js +0 -82
- package/src/style.scss +1 -0
- package/src/utils/constants.js +1 -1
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -77
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/index.js +0 -31
- package/build/components/block-editor/block-editor-provider/index.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -110
- package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -84
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
- package/build/components/block-editor/index.js +0 -30
- package/build/components/block-editor/index.js.map +0 -1
- package/build/components/page-pages/default-views.js +0 -62
- package/build/components/page-pages/default-views.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -69
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/index.js +0 -23
- package/build-module/components/block-editor/block-editor-provider/index.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -102
- package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -78
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
- package/build-module/components/block-editor/index.js +0 -22
- package/build-module/components/block-editor/index.js.map +0 -1
- package/build-module/components/page-pages/default-views.js +0 -55
- package/build-module/components/page-pages/default-views.js.map +0 -1
- package/src/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -75
- package/src/components/block-editor/block-editor-provider/index.js +0 -29
- package/src/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -114
- package/src/components/block-editor/block-editor-provider/test/use-page-content-blocks.js +0 -116
- package/src/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -90
- package/src/components/block-editor/index.js +0 -28
- package/src/components/page-pages/default-views.js +0 -60
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memo","useRef","__","__experimentalNavigatorProvider","NavigatorProvider","__experimentalNavigatorScreen","NavigatorScreen","privateApis","routerPrivateApis","SidebarNavigationScreenMain","SidebarNavigationScreenTemplates","SidebarNavigationScreenTemplate","SidebarNavigationScreenPatterns","SidebarNavigationScreenPattern","useSyncPathWithURL","getPathFromURL","SidebarNavigationScreenNavigationMenus","SidebarNavigationScreenNavigationMenu","SidebarNavigationScreenGlobalStyles","SidebarNavigationScreenTemplatesBrowse","SaveHub","unlock","SidebarNavigationScreenPages","SidebarNavigationScreenPage","SidebarNavigationScreen","DataViewsSidebarContent","useLocation","SidebarScreens","createElement","Fragment","path","window","__experimentalAdminViews","title","
|
|
1
|
+
{"version":3,"names":["memo","useRef","__","__experimentalNavigatorProvider","NavigatorProvider","__experimentalNavigatorScreen","NavigatorScreen","privateApis","routerPrivateApis","SidebarNavigationScreenMain","SidebarNavigationScreenTemplates","SidebarNavigationScreenTemplate","SidebarNavigationScreenPatterns","SidebarNavigationScreenPattern","useSyncPathWithURL","getPathFromURL","SidebarNavigationScreenNavigationMenus","SidebarNavigationScreenNavigationMenu","SidebarNavigationScreenGlobalStyles","SidebarNavigationScreenTemplatesBrowse","SaveHub","unlock","SidebarNavigationScreenPages","SidebarNavigationScreenPage","SidebarNavigationScreen","DataViewsSidebarContent","useLocation","SidebarScreens","createElement","Fragment","path","window","__experimentalAdminViews","title","backPath","content","Sidebar","params","urlParams","initialPath","className","current"],"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n} from '@wordpress/components';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns';\nimport SidebarNavigationScreenPattern from '../sidebar-navigation-screen-pattern';\nimport useSyncPathWithURL, {\n\tgetPathFromURL,\n} from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenNavigationMenu from '../sidebar-navigation-screen-navigation-menu';\nimport SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveHub from '../save-hub';\nimport { unlock } from '../../lock-unlock';\nimport SidebarNavigationScreenPages from '../sidebar-navigation-screen-pages';\nimport SidebarNavigationScreenPage from '../sidebar-navigation-screen-page';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport DataViewsSidebarContent from '../sidebar-dataviews';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t<SidebarNavigationScreenMain />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation\">\n\t\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation/:postType/:postId\">\n\t\t\t\t<SidebarNavigationScreenNavigationMenu />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/wp_global_styles\">\n\t\t\t\t<SidebarNavigationScreenGlobalStyles />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/page\">\n\t\t\t\t<SidebarNavigationScreenPages />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/page/:postId\">\n\t\t\t\t<SidebarNavigationScreenPage />\n\t\t\t</NavigatorScreen>\n\t\t\t{ window?.__experimentalAdminViews && (\n\t\t\t\t<NavigatorScreen path=\"/pages\">\n\t\t\t\t\t<SidebarNavigationScreen\n\t\t\t\t\t\ttitle={ __( 'Pages' ) }\n\t\t\t\t\t\tbackPath=\"/page\"\n\t\t\t\t\t\tcontent={ <DataViewsSidebarContent /> }\n\t\t\t\t\t/>\n\t\t\t\t</NavigatorScreen>\n\t\t\t) }\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template)\">\n\t\t\t\t<SidebarNavigationScreenTemplates />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/patterns\">\n\t\t\t\t<SidebarNavigationScreenPatterns />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/all\">\n\t\t\t\t<SidebarNavigationScreenTemplatesBrowse />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template_part|wp_block)/:postId\">\n\t\t\t\t<SidebarNavigationScreenPattern />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template)/:postId\">\n\t\t\t\t<SidebarNavigationScreenTemplate />\n\t\t\t</NavigatorScreen>\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\tconst { params: urlParams } = useLocation();\n\tconst initialPath = useRef( getPathFromURL( urlParams ) );\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath={ initialPath.current }\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\t\t\t<SaveHub />\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AACjD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,QAC1C,uBAAuB;AAC9B,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAE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C,EACpBC,aAAA,CAACR,OAAO,MAAE,CACT,CAAC;AAEL;AAEA,eAAepB,IAAI,CAAEoC,OAAQ,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack, Button } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useDispatch, resolveSelect } from '@wordpress/data';
|
|
8
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { plus } from '@wordpress/icons';
|
|
11
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
17
|
+
import DEFAULT_VIEWS from './default-views';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
const {
|
|
20
|
+
useHistory,
|
|
21
|
+
useLocation
|
|
22
|
+
} = unlock(routerPrivateApis);
|
|
23
|
+
function AddNewItemModalContent({
|
|
24
|
+
type,
|
|
25
|
+
setIsAdding
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
params: {
|
|
29
|
+
path
|
|
30
|
+
}
|
|
31
|
+
} = useLocation();
|
|
32
|
+
const history = useHistory();
|
|
33
|
+
const {
|
|
34
|
+
saveEntityRecord
|
|
35
|
+
} = useDispatch(coreStore);
|
|
36
|
+
const [title, setTitle] = useState('');
|
|
37
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
38
|
+
return createElement("form", {
|
|
39
|
+
onSubmit: async event => {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
setIsSaving(true);
|
|
42
|
+
const {
|
|
43
|
+
getEntityRecords
|
|
44
|
+
} = resolveSelect(coreStore);
|
|
45
|
+
let dataViewTaxonomyId;
|
|
46
|
+
const dataViewTypeRecords = await getEntityRecords('taxonomy', 'wp_dataviews_type', {
|
|
47
|
+
slug: type
|
|
48
|
+
});
|
|
49
|
+
if (dataViewTypeRecords && dataViewTypeRecords.length > 0) {
|
|
50
|
+
dataViewTaxonomyId = dataViewTypeRecords[0].id;
|
|
51
|
+
} else {
|
|
52
|
+
const record = await saveEntityRecord('taxonomy', 'wp_dataviews_type', {
|
|
53
|
+
name: type
|
|
54
|
+
});
|
|
55
|
+
if (record && record.id) {
|
|
56
|
+
dataViewTaxonomyId = record.id;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const savedRecord = await saveEntityRecord('postType', 'wp_dataviews', {
|
|
60
|
+
title,
|
|
61
|
+
status: 'publish',
|
|
62
|
+
wp_dataviews_type: dataViewTaxonomyId,
|
|
63
|
+
content: JSON.stringify(DEFAULT_VIEWS[type][0].view)
|
|
64
|
+
});
|
|
65
|
+
history.push({
|
|
66
|
+
path,
|
|
67
|
+
activeView: savedRecord.id,
|
|
68
|
+
isCustom: 'true'
|
|
69
|
+
});
|
|
70
|
+
setIsSaving(false);
|
|
71
|
+
setIsAdding(false);
|
|
72
|
+
}
|
|
73
|
+
}, createElement(VStack, {
|
|
74
|
+
spacing: "5"
|
|
75
|
+
}, createElement(TextControl, {
|
|
76
|
+
__nextHasNoMarginBottom: true,
|
|
77
|
+
label: __('Name'),
|
|
78
|
+
value: title,
|
|
79
|
+
onChange: setTitle,
|
|
80
|
+
placeholder: __('My view'),
|
|
81
|
+
className: "patterns-create-modal__name-input"
|
|
82
|
+
}), createElement(HStack, {
|
|
83
|
+
justify: "right"
|
|
84
|
+
}, createElement(Button, {
|
|
85
|
+
variant: "tertiary",
|
|
86
|
+
onClick: () => {
|
|
87
|
+
setIsAdding(false);
|
|
88
|
+
}
|
|
89
|
+
}, __('Cancel')), createElement(Button, {
|
|
90
|
+
variant: "primary",
|
|
91
|
+
type: "submit",
|
|
92
|
+
"aria-disabled": !title || isSaving,
|
|
93
|
+
isBusy: isSaving
|
|
94
|
+
}, __('Create')))));
|
|
95
|
+
}
|
|
96
|
+
export default function AddNewItem({
|
|
97
|
+
type
|
|
98
|
+
}) {
|
|
99
|
+
const [isAdding, setIsAdding] = useState(false);
|
|
100
|
+
return createElement(Fragment, null, createElement(SidebarNavigationItem, {
|
|
101
|
+
icon: plus,
|
|
102
|
+
onClick: () => {
|
|
103
|
+
setIsAdding(true);
|
|
104
|
+
},
|
|
105
|
+
className: "dataviews__siderbar-content-add-new-item"
|
|
106
|
+
}, __('New view')), isAdding && createElement(Modal, {
|
|
107
|
+
title: __('Add new view'),
|
|
108
|
+
onRequestClose: () => {
|
|
109
|
+
setIsAdding(false);
|
|
110
|
+
}
|
|
111
|
+
}, createElement(AddNewItemModalContent, {
|
|
112
|
+
type: type,
|
|
113
|
+
setIsAdding: setIsAdding
|
|
114
|
+
})));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=add-new-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","__","useDispatch","resolveSelect","store","coreStore","useState","plus","privateApis","routerPrivateApis","SidebarNavigationItem","DEFAULT_VIEWS","unlock","useHistory","useLocation","AddNewItemModalContent","type","setIsAdding","params","path","history","saveEntityRecord","title","setTitle","isSaving","setIsSaving","createElement","onSubmit","event","preventDefault","getEntityRecords","dataViewTaxonomyId","dataViewTypeRecords","slug","length","id","record","name","savedRecord","status","wp_dataviews_type","content","JSON","stringify","view","push","activeView","isCustom","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","className","justify","variant","onClick","isBusy","AddNewItem","isAdding","Fragment","icon","onRequestClose"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/add-new-view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, resolveSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport DEFAULT_VIEWS from './default-views';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction AddNewItemModalContent( { type, setIsAdding } ) {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst [ title, setTitle ] = useState( '' );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsSaving( true );\n\t\t\t\tconst { getEntityRecords } = resolveSelect( coreStore );\n\t\t\t\tlet dataViewTaxonomyId;\n\t\t\t\tconst dataViewTypeRecords = await getEntityRecords(\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\t'wp_dataviews_type',\n\t\t\t\t\t{ slug: type }\n\t\t\t\t);\n\t\t\t\tif ( dataViewTypeRecords && dataViewTypeRecords.length > 0 ) {\n\t\t\t\t\tdataViewTaxonomyId = dataViewTypeRecords[ 0 ].id;\n\t\t\t\t} else {\n\t\t\t\t\tconst record = await saveEntityRecord(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'wp_dataviews_type',\n\t\t\t\t\t\t{ name: type }\n\t\t\t\t\t);\n\t\t\t\t\tif ( record && record.id ) {\n\t\t\t\t\t\tdataViewTaxonomyId = record.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\twp_dataviews_type: dataViewTaxonomyId,\n\t\t\t\t\t\tcontent: JSON.stringify(\n\t\t\t\t\t\t\tDEFAULT_VIEWS[ type ][ 0 ].view\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath,\n\t\t\t\t\tactiveView: savedRecord.id,\n\t\t\t\t\tisCustom: 'true',\n\t\t\t\t} );\n\t\t\t\tsetIsSaving( false );\n\t\t\t\tsetIsAdding( false );\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\tplaceholder={ __( 'My view' ) }\n\t\t\t\t\tclassName=\"patterns-create-modal__name-input\"\n\t\t\t\t/>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsAdding( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSaving }\n\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nexport default function AddNewItem( { type } ) {\n\tconst [ isAdding, setIsAdding ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationItem\n\t\t\t\ticon={ plus }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsAdding( true );\n\t\t\t\t} }\n\t\t\t\tclassName=\"dataviews__siderbar-content-add-new-item\"\n\t\t\t>\n\t\t\t\t{ __( 'New view' ) }\n\t\t\t</SidebarNavigationItem>\n\t\t\t{ isAdding && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Add new view' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsAdding( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<AddNewItemModalContent\n\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\tsetIsAdding={ setIsAdding }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,KAAK,EACLC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,aAAa,QAAQ,iBAAiB;AAC5D,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC,UAAU;EAAEC;AAAY,CAAC,GAAGF,MAAM,CAAEH,iBAAkB,CAAC;AAE/D,SAASM,sBAAsBA,CAAE;EAAEC,IAAI;EAAEC;AAAY,CAAC,EAAG;EACxD,MAAM;IACLC,MAAM,EAAE;MAAEC;IAAK;EAChB,CAAC,GAA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pB,CAAG;IACHqC,SAAS,EAAC;EAA0C,GAElDrD,EAAE,CAAE,UAAW,CACK,CAAC,EACtB2D,QAAQ,IACTlC,aAAA,CAAChC,KAAK;IACL4B,KAAK,EAAGrB,EAAE,CAAE,cAAe,CAAG;IAC9B8D,cAAc,EAAGA,CAAA,KAAM;MACtB9C,WAAW,CAAE,KAAM,CAAC;IACrB;EAAG,GAEHS,aAAA,CAACX,sBAAsB;IACtBC,IAAI,EAAGA,IAAM;IACbC,WAAW,EAAGA;EAAa,CAC3B,CACK,CAEP,CAAC;AAEL"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalHeading as Heading, DropdownMenu, MenuGroup, MenuItem, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack, Button, Modal } from '@wordpress/components';
|
|
8
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
9
|
+
import { moreVertical } from '@wordpress/icons';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import DataViewItem from './dataview-item';
|
|
17
|
+
import AddNewItem from './add-new-view';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
const {
|
|
20
|
+
useHistory,
|
|
21
|
+
useLocation
|
|
22
|
+
} = unlock(routerPrivateApis);
|
|
23
|
+
const EMPTY_ARRAY = [];
|
|
24
|
+
function RenameItemModalContent({
|
|
25
|
+
dataviewId,
|
|
26
|
+
currentTitle,
|
|
27
|
+
setIsRenaming
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
editEntityRecord
|
|
31
|
+
} = useDispatch(coreStore);
|
|
32
|
+
const [title, setTitle] = useState(currentTitle);
|
|
33
|
+
return createElement("form", {
|
|
34
|
+
onSubmit: async event => {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
await editEntityRecord('postType', 'wp_dataviews', dataviewId, {
|
|
37
|
+
title
|
|
38
|
+
});
|
|
39
|
+
setIsRenaming(false);
|
|
40
|
+
}
|
|
41
|
+
}, createElement(VStack, {
|
|
42
|
+
spacing: "5"
|
|
43
|
+
}, createElement(TextControl, {
|
|
44
|
+
__nextHasNoMarginBottom: true,
|
|
45
|
+
label: __('Name'),
|
|
46
|
+
value: title,
|
|
47
|
+
onChange: setTitle,
|
|
48
|
+
placeholder: __('My view'),
|
|
49
|
+
className: "patterns-create-modal__name-input"
|
|
50
|
+
}), createElement(HStack, {
|
|
51
|
+
justify: "right"
|
|
52
|
+
}, createElement(Button, {
|
|
53
|
+
variant: "tertiary",
|
|
54
|
+
onClick: () => {
|
|
55
|
+
setIsRenaming(false);
|
|
56
|
+
}
|
|
57
|
+
}, __('Cancel')), createElement(Button, {
|
|
58
|
+
variant: "primary",
|
|
59
|
+
type: "submit",
|
|
60
|
+
"aria-disabled": !title
|
|
61
|
+
}, __('Rename')))));
|
|
62
|
+
}
|
|
63
|
+
function CustomDataViewItem({
|
|
64
|
+
dataviewId,
|
|
65
|
+
isActive
|
|
66
|
+
}) {
|
|
67
|
+
const {
|
|
68
|
+
params: {
|
|
69
|
+
path
|
|
70
|
+
}
|
|
71
|
+
} = useLocation();
|
|
72
|
+
const history = useHistory();
|
|
73
|
+
const {
|
|
74
|
+
dataview
|
|
75
|
+
} = useSelect(select => {
|
|
76
|
+
const {
|
|
77
|
+
getEditedEntityRecord
|
|
78
|
+
} = select(coreStore);
|
|
79
|
+
return {
|
|
80
|
+
dataview: getEditedEntityRecord('postType', 'wp_dataviews', dataviewId)
|
|
81
|
+
};
|
|
82
|
+
}, [dataviewId]);
|
|
83
|
+
const {
|
|
84
|
+
deleteEntityRecord
|
|
85
|
+
} = useDispatch(coreStore);
|
|
86
|
+
const type = useMemo(() => {
|
|
87
|
+
const viewContent = JSON.parse(dataview.content);
|
|
88
|
+
return viewContent.type;
|
|
89
|
+
}, [dataview.content]);
|
|
90
|
+
const [isRenaming, setIsRenaming] = useState(false);
|
|
91
|
+
return createElement(Fragment, null, createElement(DataViewItem, {
|
|
92
|
+
title: dataview.title,
|
|
93
|
+
type: type,
|
|
94
|
+
isActive: isActive,
|
|
95
|
+
isCustom: "true",
|
|
96
|
+
customViewId: dataviewId,
|
|
97
|
+
suffix: createElement(DropdownMenu, {
|
|
98
|
+
icon: moreVertical,
|
|
99
|
+
label: __('Actions'),
|
|
100
|
+
toggleProps: {
|
|
101
|
+
style: {
|
|
102
|
+
color: 'inherit'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, ({
|
|
106
|
+
onClose
|
|
107
|
+
}) => createElement(MenuGroup, null, createElement(MenuItem, {
|
|
108
|
+
onClick: () => {
|
|
109
|
+
setIsRenaming(true);
|
|
110
|
+
onClose();
|
|
111
|
+
}
|
|
112
|
+
}, __('Rename')), createElement(MenuItem, {
|
|
113
|
+
onClick: async () => {
|
|
114
|
+
await deleteEntityRecord('postType', 'wp_dataviews', dataview.id, {
|
|
115
|
+
force: true
|
|
116
|
+
});
|
|
117
|
+
if (isActive) {
|
|
118
|
+
history.replace({
|
|
119
|
+
path
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
onClose();
|
|
123
|
+
},
|
|
124
|
+
isDestructive: true
|
|
125
|
+
}, __('Delete'))))
|
|
126
|
+
}), isRenaming && createElement(Modal, {
|
|
127
|
+
title: __('Rename view'),
|
|
128
|
+
onRequestClose: () => {
|
|
129
|
+
setIsRenaming(false);
|
|
130
|
+
}
|
|
131
|
+
}, createElement(RenameItemModalContent, {
|
|
132
|
+
dataviewId: dataviewId,
|
|
133
|
+
setIsRenaming: setIsRenaming,
|
|
134
|
+
currentTitle: dataview.title
|
|
135
|
+
})));
|
|
136
|
+
}
|
|
137
|
+
export function useCustomDataViews(type) {
|
|
138
|
+
const customDataViews = useSelect(select => {
|
|
139
|
+
const {
|
|
140
|
+
getEntityRecords
|
|
141
|
+
} = select(coreStore);
|
|
142
|
+
const dataViewTypeRecords = getEntityRecords('taxonomy', 'wp_dataviews_type', {
|
|
143
|
+
slug: type
|
|
144
|
+
});
|
|
145
|
+
if (!dataViewTypeRecords || dataViewTypeRecords.length === 0) {
|
|
146
|
+
return EMPTY_ARRAY;
|
|
147
|
+
}
|
|
148
|
+
const dataViews = getEntityRecords('postType', 'wp_dataviews', {
|
|
149
|
+
wp_dataviews_type: dataViewTypeRecords[0].id,
|
|
150
|
+
orderby: 'date',
|
|
151
|
+
order: 'asc'
|
|
152
|
+
});
|
|
153
|
+
if (!dataViews) {
|
|
154
|
+
return EMPTY_ARRAY;
|
|
155
|
+
}
|
|
156
|
+
return dataViews;
|
|
157
|
+
});
|
|
158
|
+
return customDataViews;
|
|
159
|
+
}
|
|
160
|
+
export default function CustomDataViewsList({
|
|
161
|
+
type,
|
|
162
|
+
activeView,
|
|
163
|
+
isCustom
|
|
164
|
+
}) {
|
|
165
|
+
const customDataViews = useCustomDataViews(type);
|
|
166
|
+
return createElement(Fragment, null, createElement("div", {
|
|
167
|
+
className: "edit-site-sidebar-navigation-screen-dataviews__group-header"
|
|
168
|
+
}, createElement(Heading, {
|
|
169
|
+
level: 2
|
|
170
|
+
}, __('Custom Views'))), createElement(ItemGroup, null, customDataViews.map(customViewRecord => {
|
|
171
|
+
return createElement(CustomDataViewItem, {
|
|
172
|
+
key: customViewRecord.id,
|
|
173
|
+
dataviewId: customViewRecord.id,
|
|
174
|
+
isActive: isCustom === 'true' && Number(activeView) === customViewRecord.id
|
|
175
|
+
});
|
|
176
|
+
}), createElement(AddNewItem, {
|
|
177
|
+
type: type
|
|
178
|
+
})));
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=custom-dataviews-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","store","coreStore","__experimentalItemGroup","ItemGroup","__experimentalHeading","Heading","DropdownMenu","MenuGroup","MenuItem","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","Modal","useMemo","useState","moreVertical","__","privateApis","routerPrivateApis","DataViewItem","AddNewItem","unlock","useHistory","useLocation","EMPTY_ARRAY","RenameItemModalContent","dataviewId","currentTitle","setIsRenaming","editEntityRecord","title","setTitle","createElement","onSubmit","event","preventDefault","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","className","justify","variant","onClick","type","CustomDataViewItem","isActive","params","path","history","dataview","select","getEditedEntityRecord","deleteEntityRecord","viewContent","JSON","parse","content","isRenaming","Fragment","isCustom","customViewId","suffix","icon","toggleProps","style","color","onClose","id","force","replace","isDestructive","onRequestClose","useCustomDataViews","customDataViews","getEntityRecords","dataViewTypeRecords","slug","length","dataViews","wp_dataviews_type","orderby","order","CustomDataViewsList","activeView","level","map","customViewRecord","key","Number"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/custom-dataviews-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHeading as Heading,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport DataViewItem from './dataview-item';\nimport AddNewItem from './add-new-view';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nfunction RenameItemModalContent( { dataviewId, currentTitle, setIsRenaming } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ title, setTitle ] = useState( currentTitle );\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\tdataviewId,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tsetIsRenaming( false );\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\tplaceholder={ __( 'My view' ) }\n\t\t\t\t\tclassName=\"patterns-create-modal__name-input\"\n\t\t\t\t/>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsRenaming( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nfunction CustomDataViewItem( { dataviewId, isActive } ) {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\tconst history = useHistory();\n\tconst { dataview } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tdataview: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\tdataviewId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ dataviewId ]\n\t);\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst type = useMemo( () => {\n\t\tconst viewContent = JSON.parse( dataview.content );\n\t\treturn viewContent.type;\n\t}, [ dataview.content ] );\n\tconst [ isRenaming, setIsRenaming ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<DataViewItem\n\t\t\t\ttitle={ dataview.title }\n\t\t\t\ttype={ type }\n\t\t\t\tisActive={ isActive }\n\t\t\t\tisCustom=\"true\"\n\t\t\t\tcustomViewId={ dataviewId }\n\t\t\t\tsuffix={\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\tcolor: 'inherit',\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\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsRenaming( true );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\t\t\t\t\t\t\tdataview.id,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( isActive ) {\n\t\t\t\t\t\t\t\t\t\t\thistory.replace( {\n\t\t\t\t\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isRenaming && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename view' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsRenaming( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<RenameItemModalContent\n\t\t\t\t\t\tdataviewId={ dataviewId }\n\t\t\t\t\t\tsetIsRenaming={ setIsRenaming }\n\t\t\t\t\t\tcurrentTitle={ dataview.title }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function useCustomDataViews( type ) {\n\tconst customDataViews = useSelect( ( select ) => {\n\t\tconst { getEntityRecords } = select( coreStore );\n\t\tconst dataViewTypeRecords = getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\t'wp_dataviews_type',\n\t\t\t{ slug: type }\n\t\t);\n\t\tif ( ! dataViewTypeRecords || dataViewTypeRecords.length === 0 ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst dataViews = getEntityRecords( 'postType', 'wp_dataviews', {\n\t\t\twp_dataviews_type: dataViewTypeRecords[ 0 ].id,\n\t\t\torderby: 'date',\n\t\t\torder: 'asc',\n\t\t} );\n\t\tif ( ! dataViews ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn dataViews;\n\t} );\n\treturn customDataViews;\n}\n\nexport default function CustomDataViewsList( { type, activeView, isCustom } ) {\n\tconst customDataViews = useCustomDataViews( type );\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-site-sidebar-navigation-screen-dataviews__group-header\">\n\t\t\t\t<Heading level={ 2 }>{ __( 'Custom Views' ) }</Heading>\n\t\t\t</div>\n\t\t\t<ItemGroup>\n\t\t\t\t{ customDataViews.map( ( customViewRecord ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<CustomDataViewItem\n\t\t\t\t\t\t\tkey={ customViewRecord.id }\n\t\t\t\t\t\t\tdataviewId={ customViewRecord.id }\n\t\t\t\t\t\t\tisActive={\n\t\t\t\t\t\t\t\tisCustom === 'true' &&\n\t\t\t\t\t\t\t\tNumber( activeView ) === customViewRecord.id\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t<AddNewItem type={ type } />\n\t\t\t</ItemGroup>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,uBAAuB,IAAIC,SAAS,EACpCC,qBAAqB,IAAIC,OAAO,EAChCC,YAAY,EACZC,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,KAAK,QACC,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;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AEJ,CAAE,CAAC,EACHtC,aAAA,CAACZ,UAAU;IAAC0B,IAAI,EAAGA;EAAM,CAAE,CACjB,CACV,CAAC;AAEL"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { page, columns, pullRight } from '@wordpress/icons';
|
|
11
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
12
|
+
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { useLink } from '../routes/link';
|
|
18
|
+
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
const {
|
|
21
|
+
useLocation
|
|
22
|
+
} = unlock(routerPrivateApis);
|
|
23
|
+
function getDataViewIcon(type) {
|
|
24
|
+
const icons = {
|
|
25
|
+
list: page,
|
|
26
|
+
grid: columns,
|
|
27
|
+
'side-by-side': pullRight
|
|
28
|
+
};
|
|
29
|
+
return icons[type];
|
|
30
|
+
}
|
|
31
|
+
export default function DataViewItem({
|
|
32
|
+
title,
|
|
33
|
+
slug,
|
|
34
|
+
customViewId,
|
|
35
|
+
type,
|
|
36
|
+
icon,
|
|
37
|
+
isActive,
|
|
38
|
+
isCustom,
|
|
39
|
+
suffix
|
|
40
|
+
}) {
|
|
41
|
+
const {
|
|
42
|
+
params: {
|
|
43
|
+
path
|
|
44
|
+
}
|
|
45
|
+
} = useLocation();
|
|
46
|
+
const iconToUse = icon || getDataViewIcon(type);
|
|
47
|
+
const linkInfo = useLink({
|
|
48
|
+
path,
|
|
49
|
+
activeView: isCustom === 'true' ? customViewId : slug,
|
|
50
|
+
isCustom
|
|
51
|
+
});
|
|
52
|
+
return createElement(HStack, {
|
|
53
|
+
justify: "flex-start",
|
|
54
|
+
className: classnames('edit-site-sidebar-dataviews-dataview-item', {
|
|
55
|
+
'is-selected': isActive
|
|
56
|
+
})
|
|
57
|
+
}, createElement(SidebarNavigationItem, {
|
|
58
|
+
icon: iconToUse,
|
|
59
|
+
...linkInfo,
|
|
60
|
+
"aria-current": isActive ? 'true' : undefined
|
|
61
|
+
}, title), suffix);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=dataview-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["classnames","page","columns","pullRight","privateApis","routerPrivateApis","__experimentalHStack","HStack","useLink","SidebarNavigationItem","unlock","useLocation","getDataViewIcon","type","icons","list","grid","DataViewItem","title","slug","customViewId","icon","isActive","isCustom","suffix","params","path","iconToUse","linkInfo","activeView","createElement","justify","className","undefined"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/dataview-item.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { page, columns, pullRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { __experimentalHStack as HStack } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { unlock } from '../../lock-unlock';\nconst { useLocation } = unlock( routerPrivateApis );\n\nfunction getDataViewIcon( type ) {\n\tconst icons = { list: page, grid: columns, 'side-by-side': pullRight };\n\treturn icons[ type ];\n}\n\nexport default function DataViewItem( {\n\ttitle,\n\tslug,\n\tcustomViewId,\n\ttype,\n\ticon,\n\tisActive,\n\tisCustom,\n\tsuffix,\n} ) {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\n\tconst iconToUse = icon || getDataViewIcon( type );\n\n\tconst linkInfo = useLink( {\n\t\tpath,\n\t\tactiveView: isCustom === 'true' ? customViewId : slug,\n\t\tisCustom,\n\t} );\n\treturn (\n\t\t<HStack\n\t\t\tjustify=\"flex-start\"\n\t\t\tclassName={ classnames(\n\t\t\t\t'edit-site-sidebar-dataviews-dataview-item',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': isActive,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<SidebarNavigationItem\n\t\t\t\ticon={ iconToUse }\n\t\t\t\t{ ...linkInfo }\n\t\t\t\taria-current={ isActive ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</SidebarNavigationItem>\n\t\t\t{ suffix }\n\t\t</HStack>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,IAAI,EAAEC,OAAO,EAAEC,SAAS,QAAQ,kBAAkB;AAC3D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;;AAEtE;AACA;AACA;AACA,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,MAAM;EAAEC;AAAY,CAAC,GAAGD,MAAM,CAAEL,iBAAkB,CAAC;AAEnD,SAASO,eAAeA,CAAEC,IAAI,EAAG;EAChC,MAAMC,KAAK,GAAG;IAAEC,IAAI,EAAEd,IAAI;IAAEe,IAAI,EAAEd,OAAO;IAAE,cAAc,EAAEC;EAAU,CAAC;EACtE,OAAOW,KAAK,CAAED,IAAI,CAAE;AACrB;AAEA,eAAe,SAASI,YAAYA,CAAE;EACrCC,KAAK;EACLC,IAAI;EACJC,YAAY;EACZP,IAAI;EACJQ,IAAI;EACJC,QAAQ;EACRC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,MAAM,EAAE;MAAEC;IAAK;EAChB,CAAC,GAAGf,WAAW,CAAC,CAAC;EAEjB,MAAMgB,SAAS,GAAGN,IAAI,IAAIT,eAAe,CAAEC,IAAK,CAAC;EAEjD,MAAMe,QAAQ,GAAGpB,OAAO,CAAE;IACzBkB,IAAI;IACJG,UAAU,EAAEN,QAAQ,KAAK,MAAM,GAAGH,YAAY,GAAGD,IAAI;IACrDI;EACD,CAAE,CAAC;EACH,OACCO,aAAA,CAACvB,MAAM;IACNwB,OAAO,EAAC,YAAY;IACpBC,SAAS,EAAGhC,UAAU,CACrB,2CAA2C,EAC3C;MACC,aAAa,EAAEsB;IAChB,CACD;EAAG,GAEHQ,aAAA,CAACrB,qBAAqB;IACrBY,IAAI,EAAGM,SAAW;IAAA,GACbC,QAAQ;IACb,gBAAeN,QAAQ,GAAG,MAAM,GAAGW;EAAW,GAE5Cf,KACoB,CAAC,EACtBM,MACK,CAAC;AAEX"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { trash } from '@wordpress/icons';
|
|
6
|
+
const DEFAULT_PAGE_BASE = {
|
|
7
|
+
type: 'list',
|
|
8
|
+
search: '',
|
|
9
|
+
filters: [],
|
|
10
|
+
page: 1,
|
|
11
|
+
perPage: 20,
|
|
12
|
+
sort: {
|
|
13
|
+
field: 'date',
|
|
14
|
+
direction: 'desc'
|
|
15
|
+
},
|
|
16
|
+
// All fields are visible by default, so it's
|
|
17
|
+
// better to keep track of the hidden ones.
|
|
18
|
+
hiddenFields: ['date', 'featured-image'],
|
|
19
|
+
layout: {}
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_VIEWS = {
|
|
22
|
+
page: [{
|
|
23
|
+
title: __('All'),
|
|
24
|
+
slug: 'all',
|
|
25
|
+
view: DEFAULT_PAGE_BASE
|
|
26
|
+
}, {
|
|
27
|
+
title: __('Drafts'),
|
|
28
|
+
slug: 'drafts',
|
|
29
|
+
view: {
|
|
30
|
+
...DEFAULT_PAGE_BASE,
|
|
31
|
+
filters: [{
|
|
32
|
+
field: 'status',
|
|
33
|
+
operator: 'in',
|
|
34
|
+
value: 'draft'
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
title: __('Trash'),
|
|
39
|
+
slug: 'trash',
|
|
40
|
+
icon: trash,
|
|
41
|
+
view: {
|
|
42
|
+
...DEFAULT_PAGE_BASE,
|
|
43
|
+
filters: [{
|
|
44
|
+
field: 'status',
|
|
45
|
+
operator: 'in',
|
|
46
|
+
value: 'trash'
|
|
47
|
+
}]
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
};
|
|
51
|
+
export default DEFAULT_VIEWS;
|
|
52
|
+
//# sourceMappingURL=default-views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","trash","DEFAULT_PAGE_BASE","type","search","filters","page","perPage","sort","field","direction","hiddenFields","layout","DEFAULT_VIEWS","title","slug","view","operator","value","icon"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/default-views.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { trash } from '@wordpress/icons';\n\nconst DEFAULT_PAGE_BASE = {\n\ttype: 'list',\n\tsearch: '',\n\tfilters: [],\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'date',\n\t\tdirection: 'desc',\n\t},\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'date', 'featured-image' ],\n\tlayout: {},\n};\n\nconst DEFAULT_VIEWS = {\n\tpage: [\n\t\t{\n\t\t\ttitle: __( 'All' ),\n\t\t\tslug: 'all',\n\t\t\tview: DEFAULT_PAGE_BASE,\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Drafts' ),\n\t\t\tslug: 'drafts',\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{ field: 'status', operator: 'in', value: 'draft' },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle: __( 'Trash' ),\n\t\t\tslug: 'trash',\n\t\t\ticon: trash,\n\t\t\tview: {\n\t\t\t\t...DEFAULT_PAGE_BASE,\n\t\t\t\tfilters: [\n\t\t\t\t\t{ field: 'status', operator: 'in', value: 'trash' },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default DEFAULT_VIEWS;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,kBAAkB;AAExC,MAAMC,iBAAiB,GAAG;EACzBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,EAAE;EACVC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE;IACLC,KAAK,EAAE,MAAM;IACbC,SAAS,EAAE;EACZ,CAAC;EACD;EACA;EACAC,YAAY,EAAE,CAAE,MAAM,EAAE,gBAAgB,CAAE;EAC1CC,MAAM,EAAE,CAAC;AACV,CAAC;AAED,MAAMC,aAAa,GAAG;EACrBP,IAAI,EAAE,CACL;IACCQ,KAAK,EAAEd,EAAE,CAAE,KAAM,CAAC;IAClBe,IAAI,EAAE,KAAK;IACXC,IAAI,EAAEd;EACP,CAAC,EACD;IACCY,KAAK,EAAEd,EAAE,CAAE,QAAS,CAAC;IACrBe,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE;MACL,GAAGd,iBAAiB;MACpBG,OAAO,EAAE,CACR;QAAEI,KAAK,EAAE,QAAQ;QAAEQ,QAAQ,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAQ,CAAC;IAErD;EACD,CAAC,EACD;IACCJ,KAAK,EAAEd,EAAE,CAAE,OAAQ,CAAC;IACpBe,IAAI,EAAE,OAAO;IACbI,IAAI,EAAElB,KAAK;IACXe,IAAI,EAAE;MACL,GAAGd,iBAAiB;MACpBG,OAAO,EAAE,CACR;QAAEI,KAAK,EAAE,QAAQ;QAAEQ,QAAQ,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAQ,CAAC;IAErD;EACD,CAAC;AAEH,CAAC;AAED,eAAeL,aAAa"}
|
|
@@ -1,66 +1,49 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
6
|
-
import { page, columns } from '@wordpress/icons';
|
|
7
6
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* Internal dependencies
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
import { default as DEFAULT_VIEWS } from '
|
|
10
|
+
|
|
11
|
+
import { default as DEFAULT_VIEWS } from './default-views';
|
|
14
12
|
import { unlock } from '../../lock-unlock';
|
|
15
13
|
const {
|
|
16
14
|
useLocation
|
|
17
15
|
} = unlock(routerPrivateApis);
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
return icons[dataview.view.type];
|
|
25
|
-
}
|
|
26
|
-
function DataViewItem({
|
|
27
|
-
dataview,
|
|
28
|
-
isActive,
|
|
29
|
-
icon
|
|
30
|
-
}) {
|
|
31
|
-
const {
|
|
32
|
-
params: {
|
|
33
|
-
path
|
|
34
|
-
}
|
|
35
|
-
} = useLocation();
|
|
36
|
-
const _icon = icon || getDataViewIcon(dataview);
|
|
37
|
-
const linkInfo = useLink({
|
|
38
|
-
path,
|
|
39
|
-
activeView: dataview.slug
|
|
40
|
-
});
|
|
41
|
-
return createElement(SidebarNavigationItem, {
|
|
42
|
-
icon: _icon,
|
|
43
|
-
...linkInfo,
|
|
44
|
-
"aria-current": isActive ? 'true' : undefined
|
|
45
|
-
}, dataview.title);
|
|
46
|
-
}
|
|
16
|
+
import DataViewItem from './dataview-item';
|
|
17
|
+
import CustomDataViewsList from './custom-dataviews-list';
|
|
18
|
+
const PATH_TO_TYPE = {
|
|
19
|
+
'/pages': 'page'
|
|
20
|
+
};
|
|
47
21
|
export default function DataViewsSidebarContent() {
|
|
48
22
|
const {
|
|
49
23
|
params: {
|
|
50
24
|
path,
|
|
51
|
-
activeView = 'all'
|
|
25
|
+
activeView = 'all',
|
|
26
|
+
isCustom = 'false'
|
|
52
27
|
}
|
|
53
28
|
} = useLocation();
|
|
54
|
-
if (!path || path
|
|
29
|
+
if (!path || !PATH_TO_TYPE[path]) {
|
|
55
30
|
return null;
|
|
56
31
|
}
|
|
57
|
-
|
|
32
|
+
const type = PATH_TO_TYPE[path];
|
|
33
|
+
return createElement(Fragment, null, createElement(ItemGroup, null, DEFAULT_VIEWS[type].map(dataview => {
|
|
58
34
|
return createElement(DataViewItem, {
|
|
59
35
|
key: dataview.slug,
|
|
36
|
+
slug: dataview.slug,
|
|
37
|
+
title: dataview.title,
|
|
60
38
|
icon: dataview.icon,
|
|
61
|
-
|
|
62
|
-
isActive: dataview.slug === activeView
|
|
39
|
+
type: dataview.view.type,
|
|
40
|
+
isActive: isCustom === 'false' && dataview.slug === activeView,
|
|
41
|
+
isCustom: "false"
|
|
63
42
|
});
|
|
43
|
+
})), createElement(CustomDataViewsList, {
|
|
44
|
+
activeView: activeView,
|
|
45
|
+
type: type,
|
|
46
|
+
isCustom: "true"
|
|
64
47
|
}));
|
|
65
48
|
}
|
|
66
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalItemGroup","ItemGroup","
|
|
1
|
+
{"version":3,"names":["__experimentalItemGroup","ItemGroup","privateApis","routerPrivateApis","default","DEFAULT_VIEWS","unlock","useLocation","DataViewItem","CustomDataViewsList","PATH_TO_TYPE","DataViewsSidebarContent","params","path","activeView","isCustom","type","createElement","Fragment","map","dataview","key","slug","title","icon","view","isActive"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\n\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n/**\n * Internal dependencies\n */\n\nimport { default as DEFAULT_VIEWS } from './default-views';\nimport { unlock } from '../../lock-unlock';\nconst { useLocation } = unlock( routerPrivateApis );\nimport DataViewItem from './dataview-item';\nimport CustomDataViewsList from './custom-dataviews-list';\n\nconst PATH_TO_TYPE = {\n\t'/pages': 'page',\n};\n\nexport default function DataViewsSidebarContent() {\n\tconst {\n\t\tparams: { path, activeView = 'all', isCustom = 'false' },\n\t} = useLocation();\n\tif ( ! path || ! PATH_TO_TYPE[ path ] ) {\n\t\treturn null;\n\t}\n\tconst type = PATH_TO_TYPE[ path ];\n\n\treturn (\n\t\t<>\n\t\t\t<ItemGroup>\n\t\t\t\t{ DEFAULT_VIEWS[ type ].map( ( dataview ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DataViewItem\n\t\t\t\t\t\t\tkey={ dataview.slug }\n\t\t\t\t\t\t\tslug={ dataview.slug }\n\t\t\t\t\t\t\ttitle={ dataview.title }\n\t\t\t\t\t\t\ticon={ dataview.icon }\n\t\t\t\t\t\t\ttype={ dataview.view.type }\n\t\t\t\t\t\t\tisActive={\n\t\t\t\t\t\t\t\tisCustom === 'false' &&\n\t\t\t\t\t\t\t\tdataview.slug === activeView\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisCustom=\"false\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ItemGroup>\n\t\t\t<CustomDataViewsList\n\t\t\t\tactiveView={ activeView }\n\t\t\t\ttype={ type }\n\t\t\t\tisCustom=\"true\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,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