@wordpress/edit-site 5.25.1-next.79a6196f.0 → 5.27.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 +4 -0
- package/build/components/actions/index.js +139 -36
- package/build/components/actions/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +1 -1
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-families.js +3 -2
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-family-item.js +3 -4
- package/build/components/global-styles/font-family-item.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +80 -41
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +49 -22
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/fonts-grid.js +4 -1
- package/build/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +4 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +16 -8
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +1 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/local-fonts.js +13 -4
- package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/resolvers.js +49 -20
- package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +103 -17
- 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 +4 -3
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/layout/hooks.js +6 -5
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +19 -28
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +135 -0
- package/build/components/layout/router.js.map +1 -0
- package/build/components/page-pages/index.js +92 -69
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build/components/page-patterns/index.js +295 -15
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +51 -23
- package/build/components/page-templates-template-parts/actions.js.map +1 -0
- package/build/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-templates-template-parts/index.js +395 -0
- package/build/components/page-templates-template-parts/index.js.map +1 -0
- package/build/components/preferences-modal/index.js +9 -134
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/revisions/index.js +1 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-panel/index.js +6 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +3 -1
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +2 -2
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +26 -3
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +76 -0
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -12
- 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 +25 -2
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +33 -5
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +13 -6
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +7 -6
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js +11 -29
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +85 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +2 -2
- package/build/store/selectors.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/use-actual-current-theme.js +32 -0
- package/build/utils/use-actual-current-theme.js.map +1 -0
- package/build-module/components/actions/index.js +139 -36
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -1
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +3 -2
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-family-item.js +4 -5
- package/build-module/components/global-styles/font-family-item.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +82 -42
- 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 +49 -22
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js +4 -1
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +4 -4
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +16 -8
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/local-fonts.js +13 -4
- package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/resolvers.js +45 -18
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +99 -16
- 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 +4 -3
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +4 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/layout/hooks.js +6 -5
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +19 -28
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +127 -0
- package/build-module/components/layout/router.js.map +1 -0
- package/build-module/components/page-pages/index.js +91 -70
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build-module/components/page-patterns/index.js +296 -16
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +52 -24
- package/build-module/components/page-templates-template-parts/actions.js.map +1 -0
- package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-templates-template-parts/index.js +385 -0
- package/build-module/components/page-templates-template-parts/index.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +12 -136
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/revisions/index.js +1 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +4 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +7 -6
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +3 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +4 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +2 -2
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +8 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +27 -4
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +68 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -11
- 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 +25 -2
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +33 -5
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +13 -6
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +7 -6
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +13 -30
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +83 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +2 -2
- package/build-module/store/selectors.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/use-actual-current-theme.js +24 -0
- package/build-module/utils/use-actual-current-theme.js.map +1 -0
- package/build-style/style-rtl.css +293 -188
- package/build-style/style.css +293 -188
- package/package.json +42 -42
- package/src/components/actions/index.js +236 -84
- package/src/components/editor-canvas-container/index.js +1 -1
- package/src/components/global-styles/font-families.js +14 -8
- package/src/components/global-styles/font-family-item.js +7 -4
- package/src/components/global-styles/font-library-modal/context.js +156 -50
- package/src/components/global-styles/font-library-modal/font-collection.js +56 -21
- package/src/components/global-styles/font-library-modal/fonts-grid.js +6 -2
- package/src/components/global-styles/font-library-modal/index.js +4 -4
- package/src/components/global-styles/font-library-modal/installed-fonts.js +18 -8
- package/src/components/global-styles/font-library-modal/library-font-card.js +2 -1
- package/src/components/global-styles/font-library-modal/library-font-variant.js +10 -9
- package/src/components/global-styles/font-library-modal/local-fonts.js +14 -4
- package/src/components/global-styles/font-library-modal/resolvers.js +50 -17
- package/src/components/global-styles/font-library-modal/style.scss +1 -0
- package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +19 -2
- package/src/components/global-styles/font-library-modal/utils/index.js +136 -29
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +7 -3
- package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +40 -10
- package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +5 -5
- package/src/components/global-styles/screen-typography.js +9 -3
- package/src/components/global-styles/style.scss +4 -0
- package/src/components/header-edit-mode/style.scss +15 -5
- package/src/components/layout/hooks.js +6 -5
- package/src/components/layout/index.js +80 -96
- package/src/components/layout/router.js +121 -0
- package/src/components/layout/style.scss +13 -16
- package/src/components/page/style.scss +1 -8
- package/src/components/page-pages/index.js +142 -148
- package/src/components/page-pages/style.scss +41 -2
- package/src/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/src/components/page-patterns/index.js +392 -14
- package/src/components/page-patterns/style.scss +36 -2
- package/src/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +90 -37
- package/src/components/{page-templates → page-templates-template-parts}/index.js +198 -169
- package/src/components/page-templates-template-parts/style.scss +44 -0
- package/src/components/preferences-modal/index.js +8 -211
- package/src/components/revisions/index.js +1 -1
- package/src/components/save-button/index.js +7 -4
- package/src/components/save-panel/index.js +13 -12
- package/src/components/sidebar/index.js +4 -5
- package/src/components/sidebar-dataviews/dataview-item.js +2 -1
- package/src/components/sidebar-dataviews/default-views.js +4 -2
- package/src/components/sidebar-dataviews/index.js +8 -6
- package/src/components/sidebar-navigation-item/style.scss +1 -1
- package/src/components/sidebar-navigation-screen/index.js +19 -10
- package/src/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +32 -6
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +73 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -1
- package/src/components/site-hub/index.js +4 -1
- package/src/components/site-hub/style.scss +1 -12
- package/src/components/site-icon/style.scss +1 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +40 -10
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +32 -0
- package/src/hooks/commands/use-edit-mode-commands.js +50 -3
- package/src/hooks/push-changes-to-global-styles/index.js +29 -23
- package/src/hooks/template-part-edit.js +12 -12
- package/src/index.js +1 -1
- package/src/store/actions.js +17 -51
- package/src/store/private-actions.js +133 -0
- package/src/store/selectors.js +2 -4
- package/src/style.scss +1 -1
- package/src/utils/get-is-list-page.js +3 -2
- package/src/utils/use-actual-current-theme.js +27 -0
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
- package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -71
- package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
- package/build/components/page-main/index.js +0 -44
- package/build/components/page-main/index.js.map +0 -1
- package/build/components/page-patterns/dataviews-patterns.js +0 -307
- package/build/components/page-patterns/dataviews-patterns.js.map +0 -1
- package/build/components/page-template-parts/add-new-template-part.js.map +0 -1
- package/build/components/page-template-parts/index.js +0 -81
- package/build/components/page-template-parts/index.js.map +0 -1
- package/build/components/page-templates/index.js +0 -352
- package/build/components/page-templates/index.js.map +0 -1
- package/build/components/page-templates/template-actions.js.map +0 -1
- package/build/components/post-preview/index.js +0 -29
- package/build/components/post-preview/index.js.map +0 -1
- package/build/components/preferences-modal/enable-feature.js +0 -36
- package/build/components/preferences-modal/enable-feature.js.map +0 -1
- package/build/components/preferences-modal/enable-panel-option.js +0 -33
- package/build/components/preferences-modal/enable-panel-option.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -52
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -63
- package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
- package/build-module/components/page-main/index.js +0 -36
- package/build-module/components/page-main/index.js.map +0 -1
- package/build-module/components/page-patterns/dataviews-patterns.js +0 -299
- package/build-module/components/page-patterns/dataviews-patterns.js.map +0 -1
- package/build-module/components/page-template-parts/add-new-template-part.js.map +0 -1
- package/build-module/components/page-template-parts/index.js +0 -73
- package/build-module/components/page-template-parts/index.js.map +0 -1
- package/build-module/components/page-templates/index.js +0 -344
- package/build-module/components/page-templates/index.js.map +0 -1
- package/build-module/components/page-templates/template-actions.js.map +0 -1
- package/build-module/components/post-preview/index.js +0 -21
- package/build-module/components/post-preview/index.js.map +0 -1
- package/build-module/components/preferences-modal/enable-feature.js +0 -29
- package/build-module/components/preferences-modal/enable-feature.js.map +0 -1
- package/build-module/components/preferences-modal/enable-panel-option.js +0 -26
- package/build-module/components/preferences-modal/enable-panel-option.js.map +0 -1
- package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
- package/src/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -62
- package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +0 -271
- package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +0 -58
- package/src/components/page-main/index.js +0 -38
- package/src/components/page-patterns/dataviews-patterns.js +0 -380
- package/src/components/page-template-parts/index.js +0 -99
- package/src/components/page-templates/style.scss +0 -13
- package/src/components/post-preview/index.js +0 -16
- package/src/components/preferences-modal/enable-feature.js +0 -31
- package/src/components/preferences-modal/enable-panel-option.js +0 -23
- /package/build/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
- /package/build-module/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
- /package/src/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
|
@@ -3,7 +3,7 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { backup, trash } from '@wordpress/icons';
|
|
6
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
8
|
import { useMemo, useState } from '@wordpress/element';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -14,6 +14,7 @@ import { Button, TextControl, __experimentalText as Text, __experimentalHStack a
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
17
18
|
import { store as editSiteStore } from '../../store';
|
|
18
19
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
19
20
|
import isTemplateRemovable from '../../utils/is-template-removable';
|
|
@@ -31,23 +32,32 @@ export function useResetTemplateAction() {
|
|
|
31
32
|
} = useDispatch(noticesStore);
|
|
32
33
|
return useMemo(() => ({
|
|
33
34
|
id: 'reset-template',
|
|
34
|
-
label: __('Reset
|
|
35
|
+
label: __('Reset'),
|
|
35
36
|
isPrimary: true,
|
|
36
37
|
icon: backup,
|
|
37
38
|
isEligible: isTemplateRevertable,
|
|
38
|
-
|
|
39
|
+
supportsBulk: true,
|
|
40
|
+
async callback(templates) {
|
|
39
41
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
for (const template of templates) {
|
|
43
|
+
await revertTemplate(template, {
|
|
44
|
+
allowUndo: false
|
|
45
|
+
});
|
|
46
|
+
await saveEditedEntityRecord('postType', template.type, template.id);
|
|
47
|
+
}
|
|
48
|
+
createSuccessNotice(templates.length > 1 ? sprintf( /* translators: The number of items. */
|
|
49
|
+
__('%s items reverted.'), templates.length) : sprintf( /* translators: The template/part's name. */
|
|
50
|
+
__('"%s" reverted.'), decodeEntities(templates[0].title.rendered)), {
|
|
46
51
|
type: 'snackbar',
|
|
47
52
|
id: 'edit-site-template-reverted'
|
|
48
53
|
});
|
|
49
54
|
} catch (error) {
|
|
50
|
-
|
|
55
|
+
let fallbackErrorMessage;
|
|
56
|
+
if (templates[0].type === TEMPLATE_POST_TYPE) {
|
|
57
|
+
fallbackErrorMessage = templates.length === 1 ? __('An error occurred while reverting the template.') : __('An error occurred while reverting the templates.');
|
|
58
|
+
} else {
|
|
59
|
+
fallbackErrorMessage = templates.length === 1 ? __('An error occurred while reverting the template part.') : __('An error occurred while reverting the template parts.');
|
|
60
|
+
}
|
|
51
61
|
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage;
|
|
52
62
|
createErrorNotice(errorMessage, {
|
|
53
63
|
type: 'snackbar'
|
|
@@ -58,43 +68,61 @@ export function useResetTemplateAction() {
|
|
|
58
68
|
}
|
|
59
69
|
export const deleteTemplateAction = {
|
|
60
70
|
id: 'delete-template',
|
|
61
|
-
label: __('Delete
|
|
71
|
+
label: __('Delete'),
|
|
62
72
|
isPrimary: true,
|
|
63
73
|
icon: trash,
|
|
64
74
|
isEligible: isTemplateRemovable,
|
|
75
|
+
supportsBulk: true,
|
|
65
76
|
hideModalHeader: true,
|
|
66
77
|
RenderModal: ({
|
|
67
|
-
|
|
68
|
-
closeModal
|
|
78
|
+
items: templates,
|
|
79
|
+
closeModal,
|
|
80
|
+
onPerform
|
|
69
81
|
}) => {
|
|
70
82
|
const {
|
|
71
|
-
|
|
72
|
-
} = useDispatch(editSiteStore);
|
|
83
|
+
removeTemplates
|
|
84
|
+
} = unlock(useDispatch(editSiteStore));
|
|
73
85
|
return createElement(VStack, {
|
|
74
86
|
spacing: "5"
|
|
75
|
-
}, createElement(Text, null, sprintf(
|
|
76
|
-
// translators: %
|
|
77
|
-
|
|
87
|
+
}, createElement(Text, null, templates.length > 1 ? sprintf(
|
|
88
|
+
// translators: %d: number of items to delete.
|
|
89
|
+
_n('Delete %d item?', 'Delete %d items?', templates.length), templates.length) : sprintf(
|
|
90
|
+
// translators: %s: The template or template part's titles
|
|
91
|
+
__('Delete "%s"?'), decodeEntities(templates?.[0]?.title?.rendered))), createElement(HStack, {
|
|
78
92
|
justify: "right"
|
|
79
93
|
}, createElement(Button, {
|
|
80
94
|
variant: "tertiary",
|
|
81
95
|
onClick: closeModal
|
|
82
96
|
}, __('Cancel')), createElement(Button, {
|
|
83
97
|
variant: "primary",
|
|
84
|
-
onClick: () =>
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
onClick: async () => {
|
|
99
|
+
await removeTemplates(templates, {
|
|
100
|
+
allowUndo: false
|
|
101
|
+
});
|
|
102
|
+
if (onPerform) {
|
|
103
|
+
onPerform();
|
|
104
|
+
}
|
|
105
|
+
closeModal();
|
|
106
|
+
}
|
|
87
107
|
}, __('Delete'))));
|
|
88
108
|
}
|
|
89
109
|
};
|
|
90
110
|
export const renameTemplateAction = {
|
|
91
111
|
id: 'rename-template',
|
|
92
112
|
label: __('Rename'),
|
|
93
|
-
isEligible: template =>
|
|
113
|
+
isEligible: template => {
|
|
114
|
+
// We can only remove templates or template parts that can be removed.
|
|
115
|
+
// Additionally in the case of templates, we can only remove custom templates.
|
|
116
|
+
if (!isTemplateRemovable(template) || template.type === TEMPLATE_POST_TYPE && !template.is_custom) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
},
|
|
94
121
|
RenderModal: ({
|
|
95
|
-
|
|
122
|
+
items: templates,
|
|
96
123
|
closeModal
|
|
97
124
|
}) => {
|
|
125
|
+
const template = templates[0];
|
|
98
126
|
const title = decodeEntities(template.title.rendered);
|
|
99
127
|
const [editedTitle, setEditedTitle] = useState(title);
|
|
100
128
|
const {
|
|
@@ -154,4 +182,4 @@ export const renameTemplateAction = {
|
|
|
154
182
|
}, __('Save')))));
|
|
155
183
|
}
|
|
156
184
|
};
|
|
157
|
-
//# sourceMappingURL=
|
|
185
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["backup","trash","__","sprintf","_n","useDispatch","useMemo","useState","store","coreStore","noticesStore","decodeEntities","Button","TextControl","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","unlock","editSiteStore","isTemplateRevertable","isTemplateRemovable","TEMPLATE_POST_TYPE","useResetTemplateAction","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","id","label","isPrimary","icon","isEligible","supportsBulk","callback","templates","template","allowUndo","type","length","title","rendered","error","fallbackErrorMessage","errorMessage","message","code","deleteTemplateAction","hideModalHeader","RenderModal","items","closeModal","onPerform","removeTemplates","createElement","spacing","justify","variant","onClick","renameTemplateAction","is_custom","editedTitle","setEditedTitle","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","onTemplateRename","event","preventDefault","throwOnError","onSubmit","__nextHasNoMarginBottom","value","onChange","required"],"sources":["@wordpress/edit-site/src/components/page-templates-template-parts/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup, trash } from '@wordpress/icons';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport function useResetTemplateAction() {\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'reset-template',\n\t\t\tlabel: __( 'Reset' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible: isTemplateRevertable,\n\t\t\tsupportsBulk: true,\n\t\t\tasync callback( templates ) {\n\t\t\t\ttry {\n\t\t\t\t\tfor ( const template of templates ) {\n\t\t\t\t\t\tawait revertTemplate( template, {\n\t\t\t\t\t\t\tallowUndo: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\ttemplate.id\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\ttemplates.length > 1\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t__( '%s items reverted.' ),\n\t\t\t\t\t\t\t\t\ttemplates.length\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplates[ 0 ].title.rendered\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tlet fallbackErrorMessage;\n\t\t\t\t\tif ( templates[ 0 ].type === TEMPLATE_POST_TYPE ) {\n\t\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\t\ttemplates.length === 1\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template.'\n\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\t'An error occurred while reverting the templates.'\n\t\t\t\t\t\t\t\t );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfallbackErrorMessage =\n\t\t\t\t\t\t\ttemplates.length === 1\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\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\t'An error occurred while reverting the template parts.'\n\t\t\t\t\t\t\t\t );\n\t\t\t\t\t}\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateErrorNotice,\n\t\t\tcreateSuccessNotice,\n\t\t\trevertTemplate,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const deleteTemplateAction = {\n\tid: 'delete-template',\n\tlabel: __( 'Delete' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible: isTemplateRemovable,\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items: templates, closeModal, onPerform } ) => {\n\t\tconst { removeTemplates } = unlock( useDispatch( editSiteStore ) );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ templates.length > 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: number of items to delete.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Delete %d item?',\n\t\t\t\t\t\t\t\t\t'Delete %d items?',\n\t\t\t\t\t\t\t\t\ttemplates.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\ttemplates.length\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The template or template part's titles\n\t\t\t\t\t\t\t\t__( 'Delete \"%s\"?' ),\n\t\t\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\t\t\ttemplates?.[ 0 ]?.title?.rendered\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ closeModal }>\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\tonClick={ async () => {\n\t\t\t\t\t\t\tawait removeTemplates( templates, {\n\t\t\t\t\t\t\t\tallowUndo: false,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tif ( onPerform ) {\n\t\t\t\t\t\t\t\tonPerform();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport const renameTemplateAction = {\n\tid: 'rename-template',\n\tlabel: __( 'Rename' ),\n\tisEligible: ( template ) => {\n\t\t// We can only remove templates or template parts that can be removed.\n\t\t// Additionally in the case of templates, we can only remove custom templates.\n\t\tif (\n\t\t\t! isTemplateRemovable( template ) ||\n\t\t\t( template.type === TEMPLATE_POST_TYPE && ! template.is_custom )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t},\n\tRenderModal: ( { items: templates, closeModal } ) => {\n\t\tconst template = templates[ 0 ];\n\t\tconst title = decodeEntities( template.title.rendered );\n\t\tconst [ editedTitle, setEditedTitle ] = useState( title );\n\t\tconst {\n\t\t\teditEntityRecord,\n\t\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t\t} = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tasync function onTemplateRename( event ) {\n\t\t\tevent.preventDefault();\n\t\t\ttry {\n\t\t\t\tawait editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: editedTitle,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t// Update state before saving rerenders the list.\n\t\t\t\tsetEditedTitle( '' );\n\t\t\t\tcloseModal();\n\t\t\t\t// Persist edited entity.\n\t\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id,\n\t\t\t\t\t[ 'title' ], // Only save title to avoid persisting other edits.\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t// TODO: this action will be reused in template parts list, so\n\t\t\t\t// let's keep this for a bit, even it's always a `template` now.\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? __( 'Template renamed.' )\n\t\t\t\t\t\t: __( 'Template part renamed.' ),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tconst fallbackErrorMessage =\n\t\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? __( 'An error occurred while renaming the template.' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'An error occurred while renaming the template part.'\n\t\t\t\t\t\t );\n\t\t\t\tconst errorMessage =\n\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t}\n\t\treturn (\n\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ editedTitle }\n\t\t\t\t\t\tonChange={ setEditedTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ closeModal }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,KAAK,QAAQ,kBAAkB;AAChD,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;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AAI,KAAKhB,kBAAkB,GACjCtB,EAAE,CAAE,gDAAiD,CAAC,GACtDA,EAAE,CACF,qDACA,CAAC;QACL,MAAM4C,YAAY,GACjBF,KAAK,CAACG,OAAO,IAAIH,KAAK,CAACI,IAAI,KAAK,eAAe,GAC5CJ,KAAK,CAACG,OAAO,GACbF,oBAAoB;QAExBhB,iBAAiB,CAAEiB,YAAY,EAAE;UAAEN,IAAI,EAAE;QAAW,CAAE,CAAC;MACxD;IACD;IACA,OACCgB,aAAA;MAAMgB,QAAQ,EAAGJ;IAAkB,GAClCZ,aAAA,CAACrC,MAAM;MAACsC,OAAO,EAAC;IAAG,GAClBD,aAAA,CAAC3C,WAAW;MACX4D,uBAAuB;MACvB1C,KAAK,EAAG7B,EAAE,CAAE,MAAO,CAAG;MACtBwE,KAAK,EAAGX,WAAa;MACrBY,QAAQ,EAAGX,cAAgB;MAC3BY,QAAQ;IAAA,CACR,CAAC,EACFpB,aAAA,CAACvC,MAAM;MAACyC,OAAO,EAAC;IAAO,GACtBF,aAAA,CAAC5C,MAAM;MAAC+C,OAAO,EAAC,UAAU;MAACC,OAAO,EAAGP;IAAY,GAC9CnD,EAAE,CAAE,QAAS,CACR,CAAC,EACTsD,aAAA,CAAC5C,MAAM;MAAC+C,OAAO,EAAC,SAAS;MAACnB,IAAI,EAAC;IAAQ,GACpCtC,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CAAC;EAET;AACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["privateApis","routerPrivateApis","useSelect","store","coreStore","useState","Button","unlock","editSiteStore","CreateTemplatePartModal","TEMPLATE_PART_POST_TYPE","useHistory","AddNewTemplatePart","canCreate","postType","select","supportsTemplatePartsMode","getSettings","getPostType","isModalOpen","setIsModalOpen","history","createElement","Fragment","variant","onClick","labels","add_new_item","closeModal","blocks","onCreate","templatePart","push","postId","id","canvas","onError"],"sources":["@wordpress/edit-site/src/components/page-templates-template-parts/add-new-template-part.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport { TEMPLATE_PART_POST_TYPE } from '../../utils/constants';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewTemplatePart() {\n\tconst { canCreate, postType } = useSelect( ( select ) => {\n\t\tconst { supportsTemplatePartsMode } =\n\t\t\tselect( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tcanCreate: ! supportsTemplatePartsMode,\n\t\t\tpostType: select( coreStore ).getPostType(\n\t\t\t\tTEMPLATE_PART_POST_TYPE\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst history = useHistory();\n\n\tif ( ! canCreate || ! postType ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button variant=\"primary\" onClick={ () => setIsModalOpen( true ) }>\n\t\t\t\t{ postType.labels.add_new_item }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ ( templatePart ) => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\tpostId: templatePart.id,\n\t\t\t\t\t\t\tpostType: TEMPLATE_PART_POST_TYPE,\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonError={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\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ACZG,aAAA,CAACb,uBAAuB;IACvBmB,UAAU,EAAGA,CAAA,KAAMR,cAAc,CAAE,KAAM,CAAG;IAC5CS,MAAM,EAAG,EAAI;IACbC,QAAQ,EAAKC,YAAY,IAAM;MAC9BX,cAAc,CAAE,KAAM,CAAC;MACvBC,OAAO,CAACW,IAAI,CAAE;QACbC,MAAM,EAAEF,YAAY,CAACG,EAAE;QACvBpB,QAAQ,EAAEJ,uBAAuB;QACjCyB,MAAM,EAAE;MACT,CAAE,CAAC;IACJ,CAAG;IACHC,OAAO,EAAGA,CAAA,KAAMhB,cAAc,CAAE,KAAM;EAAG,CACzC,CAED,CAAC;AAEL"}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import removeAccents from 'remove-accents';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { Icon, __experimentalText as Text, __experimentalHStack as HStack, VisuallyHidden } from '@wordpress/components';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { useState, useMemo, useCallback, useEffect } from '@wordpress/element';
|
|
13
|
+
import { useEntityRecords } from '@wordpress/core-data';
|
|
14
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
15
|
+
import { parse } from '@wordpress/blocks';
|
|
16
|
+
import { BlockPreview, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
17
|
+
import { DataViews, sortByTextFields, getPaginationResults } from '@wordpress/dataviews';
|
|
18
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
import Page from '../page';
|
|
24
|
+
import { default as Link, useLink } from '../routes/link';
|
|
25
|
+
import AddNewTemplate from '../add-new-template';
|
|
26
|
+
import { useAddedBy, AvatarImage } from '../list/added-by';
|
|
27
|
+
import { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN, LAYOUT_GRID, LAYOUT_TABLE, LAYOUT_LIST } from '../../utils/constants';
|
|
28
|
+
import { useResetTemplateAction, deleteTemplateAction, renameTemplateAction } from './actions';
|
|
29
|
+
import { postRevisionsAction } from '../actions';
|
|
30
|
+
import usePatternSettings from '../page-patterns/use-pattern-settings';
|
|
31
|
+
import { unlock } from '../../lock-unlock';
|
|
32
|
+
import AddNewTemplatePart from './add-new-template-part';
|
|
33
|
+
const {
|
|
34
|
+
ExperimentalBlockEditorProvider,
|
|
35
|
+
useGlobalStyle
|
|
36
|
+
} = unlock(blockEditorPrivateApis);
|
|
37
|
+
const {
|
|
38
|
+
useHistory,
|
|
39
|
+
useLocation
|
|
40
|
+
} = unlock(routerPrivateApis);
|
|
41
|
+
const EMPTY_ARRAY = [];
|
|
42
|
+
const SUPPORTED_LAYOUTS = window?.__experimentalAdminViews ? [LAYOUT_TABLE, LAYOUT_GRID, LAYOUT_LIST] : [LAYOUT_TABLE, LAYOUT_GRID];
|
|
43
|
+
const defaultConfigPerViewType = {
|
|
44
|
+
[LAYOUT_TABLE]: {
|
|
45
|
+
primaryField: 'title'
|
|
46
|
+
},
|
|
47
|
+
[LAYOUT_GRID]: {
|
|
48
|
+
mediaField: 'preview',
|
|
49
|
+
primaryField: 'title'
|
|
50
|
+
},
|
|
51
|
+
[LAYOUT_LIST]: {
|
|
52
|
+
primaryField: 'title',
|
|
53
|
+
mediaField: 'preview'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const DEFAULT_VIEW = {
|
|
57
|
+
type: LAYOUT_TABLE,
|
|
58
|
+
search: '',
|
|
59
|
+
page: 1,
|
|
60
|
+
perPage: 20,
|
|
61
|
+
sort: {
|
|
62
|
+
field: 'title',
|
|
63
|
+
direction: 'asc'
|
|
64
|
+
},
|
|
65
|
+
// All fields are visible by default, so it's
|
|
66
|
+
// better to keep track of the hidden ones.
|
|
67
|
+
hiddenFields: ['preview'],
|
|
68
|
+
layout: defaultConfigPerViewType[LAYOUT_TABLE],
|
|
69
|
+
filters: []
|
|
70
|
+
};
|
|
71
|
+
function normalizeSearchInput(input = '') {
|
|
72
|
+
return removeAccents(input.trim().toLowerCase());
|
|
73
|
+
}
|
|
74
|
+
function Title({
|
|
75
|
+
item,
|
|
76
|
+
viewType
|
|
77
|
+
}) {
|
|
78
|
+
if (viewType === LAYOUT_LIST) {
|
|
79
|
+
return decodeEntities(item.title?.rendered) || __('(no title)');
|
|
80
|
+
}
|
|
81
|
+
const linkProps = {
|
|
82
|
+
params: {
|
|
83
|
+
postId: item.id,
|
|
84
|
+
postType: item.type,
|
|
85
|
+
canvas: 'edit'
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (item.type === TEMPLATE_PART_POST_TYPE) {
|
|
89
|
+
linkProps.state = {
|
|
90
|
+
backPath: '/wp_template_part/all'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return createElement(Link, {
|
|
94
|
+
...linkProps
|
|
95
|
+
}, decodeEntities(item.title?.rendered) || __('(no title)'));
|
|
96
|
+
}
|
|
97
|
+
function AuthorField({
|
|
98
|
+
item,
|
|
99
|
+
viewType
|
|
100
|
+
}) {
|
|
101
|
+
const {
|
|
102
|
+
text,
|
|
103
|
+
icon,
|
|
104
|
+
imageUrl
|
|
105
|
+
} = useAddedBy(item.type, item.id);
|
|
106
|
+
const withIcon = viewType !== LAYOUT_LIST;
|
|
107
|
+
return createElement(HStack, {
|
|
108
|
+
alignment: "left",
|
|
109
|
+
spacing: 1
|
|
110
|
+
}, withIcon && imageUrl && createElement(AvatarImage, {
|
|
111
|
+
imageUrl: imageUrl
|
|
112
|
+
}), withIcon && !imageUrl && createElement("div", {
|
|
113
|
+
className: "edit-site-list-added-by__icon"
|
|
114
|
+
}, createElement(Icon, {
|
|
115
|
+
icon: icon
|
|
116
|
+
})), createElement("span", null, text));
|
|
117
|
+
}
|
|
118
|
+
function Preview({
|
|
119
|
+
item,
|
|
120
|
+
viewType
|
|
121
|
+
}) {
|
|
122
|
+
const settings = usePatternSettings();
|
|
123
|
+
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
124
|
+
const blocks = useMemo(() => {
|
|
125
|
+
return parse(item.content.raw);
|
|
126
|
+
}, [item.content.raw]);
|
|
127
|
+
const {
|
|
128
|
+
onClick
|
|
129
|
+
} = useLink({
|
|
130
|
+
postId: item.id,
|
|
131
|
+
postType: item.type,
|
|
132
|
+
canvas: 'edit'
|
|
133
|
+
});
|
|
134
|
+
const isEmpty = !blocks?.length;
|
|
135
|
+
// Wrap everything in a block editor provider to ensure 'styles' that are needed
|
|
136
|
+
// for the previews are synced between the site editor store and the block editor store.
|
|
137
|
+
// Additionally we need to have the `__experimentalBlockPatterns` setting in order to
|
|
138
|
+
// render patterns inside the previews.
|
|
139
|
+
// TODO: Same approach is used in the patterns list and it becomes obvious that some of
|
|
140
|
+
// the block editor settings are needed in context where we don't have the block editor.
|
|
141
|
+
// Explore how we can solve this in a better way.
|
|
142
|
+
return createElement(ExperimentalBlockEditorProvider, {
|
|
143
|
+
settings: settings
|
|
144
|
+
}, createElement("div", {
|
|
145
|
+
className: `page-templates-preview-field is-viewtype-${viewType}`,
|
|
146
|
+
style: {
|
|
147
|
+
backgroundColor
|
|
148
|
+
}
|
|
149
|
+
}, createElement("button", {
|
|
150
|
+
className: "page-templates-preview-field__button",
|
|
151
|
+
type: "button",
|
|
152
|
+
onClick: onClick,
|
|
153
|
+
"aria-label": item.title?.rendered || item.title
|
|
154
|
+
}, isEmpty && (item.type === TEMPLATE_POST_TYPE ? __('Empty template') : __('Empty template part')), !isEmpty && createElement(BlockPreview, {
|
|
155
|
+
blocks: blocks
|
|
156
|
+
}))));
|
|
157
|
+
}
|
|
158
|
+
export default function PageTemplatesTemplateParts({
|
|
159
|
+
postType
|
|
160
|
+
}) {
|
|
161
|
+
const {
|
|
162
|
+
params
|
|
163
|
+
} = useLocation();
|
|
164
|
+
const {
|
|
165
|
+
activeView = 'all',
|
|
166
|
+
layout
|
|
167
|
+
} = params;
|
|
168
|
+
const defaultView = useMemo(() => {
|
|
169
|
+
return {
|
|
170
|
+
...DEFAULT_VIEW,
|
|
171
|
+
type: window?.__experimentalAdminViews ? layout !== null && layout !== void 0 ? layout : DEFAULT_VIEW.type : DEFAULT_VIEW.type,
|
|
172
|
+
filters: activeView !== 'all' ? [{
|
|
173
|
+
field: 'author',
|
|
174
|
+
operator: 'in',
|
|
175
|
+
value: activeView
|
|
176
|
+
}] : []
|
|
177
|
+
};
|
|
178
|
+
}, [layout, activeView]);
|
|
179
|
+
const [view, setView] = useState(defaultView);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
setView(currentView => ({
|
|
182
|
+
...currentView,
|
|
183
|
+
filters: activeView !== 'all' ? [{
|
|
184
|
+
field: 'author',
|
|
185
|
+
operator: 'in',
|
|
186
|
+
value: activeView
|
|
187
|
+
}] : []
|
|
188
|
+
}));
|
|
189
|
+
}, [activeView]);
|
|
190
|
+
const {
|
|
191
|
+
records,
|
|
192
|
+
isResolving: isLoadingData
|
|
193
|
+
} = useEntityRecords('postType', postType, {
|
|
194
|
+
per_page: -1
|
|
195
|
+
});
|
|
196
|
+
const history = useHistory();
|
|
197
|
+
const onSelectionChange = useCallback(items => {
|
|
198
|
+
if (view?.type === LAYOUT_LIST) {
|
|
199
|
+
history.push({
|
|
200
|
+
...params,
|
|
201
|
+
postId: items.length === 1 ? items[0].id : undefined
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}, [history, params, view?.type]);
|
|
205
|
+
const authors = useMemo(() => {
|
|
206
|
+
if (!records) {
|
|
207
|
+
return EMPTY_ARRAY;
|
|
208
|
+
}
|
|
209
|
+
const authorsSet = new Set();
|
|
210
|
+
records.forEach(template => {
|
|
211
|
+
authorsSet.add(template.author_text);
|
|
212
|
+
});
|
|
213
|
+
return Array.from(authorsSet).map(author => ({
|
|
214
|
+
value: author,
|
|
215
|
+
label: author
|
|
216
|
+
}));
|
|
217
|
+
}, [records]);
|
|
218
|
+
const fields = useMemo(() => {
|
|
219
|
+
const _fields = [{
|
|
220
|
+
header: __('Preview'),
|
|
221
|
+
id: 'preview',
|
|
222
|
+
render: ({
|
|
223
|
+
item
|
|
224
|
+
}) => {
|
|
225
|
+
return createElement(Preview, {
|
|
226
|
+
item: item,
|
|
227
|
+
viewType: view.type
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
minWidth: 120,
|
|
231
|
+
maxWidth: 120,
|
|
232
|
+
enableSorting: false
|
|
233
|
+
}, {
|
|
234
|
+
header: postType === TEMPLATE_POST_TYPE ? __('Template') : __('Template Part'),
|
|
235
|
+
id: 'title',
|
|
236
|
+
getValue: ({
|
|
237
|
+
item
|
|
238
|
+
}) => item.title?.rendered,
|
|
239
|
+
render: ({
|
|
240
|
+
item
|
|
241
|
+
}) => createElement(Title, {
|
|
242
|
+
item: item,
|
|
243
|
+
viewType: view.type
|
|
244
|
+
}),
|
|
245
|
+
maxWidth: 400,
|
|
246
|
+
enableHiding: false
|
|
247
|
+
}];
|
|
248
|
+
if (postType === TEMPLATE_POST_TYPE) {
|
|
249
|
+
_fields.push({
|
|
250
|
+
header: __('Description'),
|
|
251
|
+
id: 'description',
|
|
252
|
+
getValue: ({
|
|
253
|
+
item
|
|
254
|
+
}) => item.description,
|
|
255
|
+
render: ({
|
|
256
|
+
item
|
|
257
|
+
}) => {
|
|
258
|
+
return item.description ? createElement("span", {
|
|
259
|
+
className: "page-templates-description"
|
|
260
|
+
}, decodeEntities(item.description)) : view.type === LAYOUT_TABLE && createElement(Fragment, null, createElement(Text, {
|
|
261
|
+
variant: "muted",
|
|
262
|
+
"aria-hidden": "true"
|
|
263
|
+
}, "\u2014"), createElement(VisuallyHidden, null, __('No description.')));
|
|
264
|
+
},
|
|
265
|
+
maxWidth: 400,
|
|
266
|
+
minWidth: 320,
|
|
267
|
+
enableSorting: false
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// TODO: The plan is to support fields reordering, which would require an API like `order` or something
|
|
271
|
+
// similar. With the aforementioned API we wouldn't need to construct the fields array like this.
|
|
272
|
+
_fields.push({
|
|
273
|
+
header: __('Author'),
|
|
274
|
+
id: 'author',
|
|
275
|
+
getValue: ({
|
|
276
|
+
item
|
|
277
|
+
}) => item.author_text,
|
|
278
|
+
render: ({
|
|
279
|
+
item
|
|
280
|
+
}) => {
|
|
281
|
+
return createElement(AuthorField, {
|
|
282
|
+
viewType: view.type,
|
|
283
|
+
item: item
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
enableHiding: false,
|
|
287
|
+
type: ENUMERATION_TYPE,
|
|
288
|
+
elements: authors,
|
|
289
|
+
width: '1%'
|
|
290
|
+
});
|
|
291
|
+
return _fields;
|
|
292
|
+
}, [postType, authors, view.type]);
|
|
293
|
+
const {
|
|
294
|
+
data,
|
|
295
|
+
paginationInfo
|
|
296
|
+
} = useMemo(() => {
|
|
297
|
+
if (!records) {
|
|
298
|
+
return {
|
|
299
|
+
data: EMPTY_ARRAY,
|
|
300
|
+
paginationInfo: {
|
|
301
|
+
totalItems: 0,
|
|
302
|
+
totalPages: 0
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
let filteredData = [...records];
|
|
307
|
+
// Handle global search.
|
|
308
|
+
if (view.search) {
|
|
309
|
+
const normalizedSearch = normalizeSearchInput(view.search);
|
|
310
|
+
filteredData = filteredData.filter(item => {
|
|
311
|
+
const title = item.title?.rendered || item.slug;
|
|
312
|
+
return normalizeSearchInput(title).includes(normalizedSearch) || normalizeSearchInput(item.description).includes(normalizedSearch);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Handle filters.
|
|
317
|
+
if (view.filters.length > 0) {
|
|
318
|
+
view.filters.forEach(filter => {
|
|
319
|
+
if (filter.field === 'author' && filter.operator === OPERATOR_IN && !!filter.value) {
|
|
320
|
+
filteredData = filteredData.filter(item => {
|
|
321
|
+
return item.author_text === filter.value;
|
|
322
|
+
});
|
|
323
|
+
} else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN && !!filter.value) {
|
|
324
|
+
filteredData = filteredData.filter(item => {
|
|
325
|
+
return item.author_text !== filter.value;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Handle sorting.
|
|
332
|
+
if (view.sort) {
|
|
333
|
+
filteredData = sortByTextFields({
|
|
334
|
+
data: filteredData,
|
|
335
|
+
view,
|
|
336
|
+
fields,
|
|
337
|
+
textFields: ['title', 'author']
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
// Handle pagination.
|
|
341
|
+
return getPaginationResults({
|
|
342
|
+
data: filteredData,
|
|
343
|
+
view
|
|
344
|
+
});
|
|
345
|
+
}, [records, view, fields]);
|
|
346
|
+
const resetTemplateAction = useResetTemplateAction();
|
|
347
|
+
const actions = useMemo(() => [resetTemplateAction, deleteTemplateAction, renameTemplateAction, postRevisionsAction], [resetTemplateAction]);
|
|
348
|
+
const onChangeView = useCallback(newView => {
|
|
349
|
+
if (newView.type !== view.type) {
|
|
350
|
+
newView = {
|
|
351
|
+
...newView,
|
|
352
|
+
layout: {
|
|
353
|
+
...defaultConfigPerViewType[newView.type]
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
history.push({
|
|
357
|
+
...params,
|
|
358
|
+
layout: newView.type
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
setView(newView);
|
|
362
|
+
}, [view.type, setView, history, params]);
|
|
363
|
+
return createElement(Page, {
|
|
364
|
+
title: postType === TEMPLATE_POST_TYPE ? __('Templates') : __('Template Parts'),
|
|
365
|
+
actions: postType === TEMPLATE_POST_TYPE ? createElement(AddNewTemplate, {
|
|
366
|
+
templateType: postType,
|
|
367
|
+
showIcon: false,
|
|
368
|
+
toggleProps: {
|
|
369
|
+
variant: 'primary'
|
|
370
|
+
}
|
|
371
|
+
}) : createElement(AddNewTemplatePart, null)
|
|
372
|
+
}, createElement(DataViews, {
|
|
373
|
+
paginationInfo: paginationInfo,
|
|
374
|
+
fields: fields,
|
|
375
|
+
actions: actions,
|
|
376
|
+
data: data,
|
|
377
|
+
isLoading: isLoadingData,
|
|
378
|
+
view: view,
|
|
379
|
+
onChangeView: onChangeView,
|
|
380
|
+
onSelectionChange: onSelectionChange,
|
|
381
|
+
deferredRendering: !view.hiddenFields?.includes('preview'),
|
|
382
|
+
supportedLayouts: SUPPORTED_LAYOUTS
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["removeAccents","Icon","__experimentalText","Text","__experimentalHStack","HStack","VisuallyHidden","__","useState","useMemo","useCallback","useEffect","useEntityRecords","decodeEntities","parse","BlockPreview","privateApis","blockEditorPrivateApis","DataViews","sortByTextFields","getPaginationResults","routerPrivateApis","Page","default","Link","useLink","AddNewTemplate","useAddedBy","AvatarImage","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","ENUMERATION_TYPE","OPERATOR_IN","OPERATOR_NOT_IN","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","useResetTemplateAction","deleteTemplateAction","renameTemplateAction","postRevisionsAction","usePatternSettings","unlock","AddNewTemplatePart","ExperimentalBlockEditorProvider","useGlobalStyle","useHistory","useLocation","EMPTY_ARRAY","SUPPORTED_LAYOUTS","window","__experimentalAdminViews","defaultConfigPerViewType","primaryField","mediaField","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","hiddenFields","layout","filters","normalizeSearchInput","input","trim","toLowerCase","Title","item","viewType","title","rendered","linkProps","params","postId","id","postType","canvas","state","backPath","createElement","AuthorField","text","icon","imageUrl","withIcon","alignment","spacing","className","Preview","settings","backgroundColor","blocks","content","raw","onClick","isEmpty","length","style","PageTemplatesTemplateParts","activeView","defaultView","operator","value","view","setView","currentView","records","isResolving","isLoadingData","per_page","history","onSelectionChange","items","push","undefined","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","label","fields","_fields","header","render","minWidth","maxWidth","enableSorting","getValue","enableHiding","description","Fragment","variant","elements","width","data","paginationInfo","totalItems","totalPages","filteredData","normalizedSearch","filter","slug","includes","textFields","resetTemplateAction","actions","onChangeView","newView","templateType","showIcon","toggleProps","isLoading","deferredRendering","supportedLayouts"],"sources":["@wordpress/edit-site/src/components/page-templates-template-parts/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tDataViews,\n\tsortByTextFields,\n\tgetPaginationResults,\n} from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport { default as Link, useLink } from '../routes/link';\nimport AddNewTemplate from '../add-new-template';\nimport { useAddedBy, AvatarImage } from '../list/added-by';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tENUMERATION_TYPE,\n\tOPERATOR_IN,\n\tOPERATOR_NOT_IN,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport {\n\tuseResetTemplateAction,\n\tdeleteTemplateAction,\n\trenameTemplateAction,\n} from './actions';\nimport { postRevisionsAction } from '../actions';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\nimport AddNewTemplatePart from './add-new-template-part';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst SUPPORTED_LAYOUTS = window?.__experimentalAdminViews\n\t? [ LAYOUT_TABLE, LAYOUT_GRID, LAYOUT_LIST ]\n\t: [ LAYOUT_TABLE, LAYOUT_GRID ];\n\nconst defaultConfigPerViewType = {\n\t[ LAYOUT_TABLE ]: {\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'preview',\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tprimaryField: 'title',\n\t\tmediaField: 'preview',\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_TABLE,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\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: [ 'preview' ],\n\tlayout: defaultConfigPerViewType[ LAYOUT_TABLE ],\n\tfilters: [],\n};\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nfunction Title( { item, viewType } ) {\n\tif ( viewType === LAYOUT_LIST ) {\n\t\treturn decodeEntities( item.title?.rendered ) || __( '(no title)' );\n\t}\n\tconst linkProps = {\n\t\tparams: {\n\t\t\tpostId: item.id,\n\t\t\tpostType: item.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t};\n\tif ( item.type === TEMPLATE_PART_POST_TYPE ) {\n\t\tlinkProps.state = {\n\t\t\tbackPath: '/wp_template_part/all',\n\t\t};\n\t}\n\treturn (\n\t\t<Link { ...linkProps }>\n\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t</Link>\n\t);\n}\n\nfunction AuthorField( { item, viewType } ) {\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\tconst withIcon = viewType !== LAYOUT_LIST;\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 1 }>\n\t\t\t{ withIcon && imageUrl && <AvatarImage imageUrl={ imageUrl } /> }\n\t\t\t{ withIcon && ! imageUrl && (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction Preview( { item, viewType } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty &&\n\t\t\t\t\t\t( item.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t\t? __( 'Empty template' )\n\t\t\t\t\t\t\t: __( 'Empty template part' ) ) }\n\t\t\t\t\t{ ! isEmpty && <BlockPreview blocks={ blocks } /> }\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nexport default function PageTemplatesTemplateParts( { postType } ) {\n\tconst { params } = useLocation();\n\tconst { activeView = 'all', layout } = params;\n\tconst defaultView = useMemo( () => {\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: window?.__experimentalAdminViews\n\t\t\t\t? layout ?? DEFAULT_VIEW.type\n\t\t\t\t: DEFAULT_VIEW.type,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'in',\n\t\t\t\t\t\t\t\tvalue: activeView,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'in',\n\t\t\t\t\t\t\t\tvalue: activeView,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ activeView ] );\n\n\tconst { records, isResolving: isLoadingData } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst history = useHistory();\n\tconst onSelectionChange = useCallback(\n\t\t( items ) => {\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ].id : undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history, params, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo( () => {\n\t\tconst _fields = [\n\t\t\t{\n\t\t\t\theader: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <Preview item={ item } viewType={ view.type } />;\n\t\t\t\t},\n\t\t\t\tminWidth: 120,\n\t\t\t\tmaxWidth: 120,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader:\n\t\t\t\t\tpostType === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? __( 'Template' )\n\t\t\t\t\t\t: __( 'Template Part' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<Title item={ item } viewType={ view.type } />\n\t\t\t\t),\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t];\n\t\tif ( postType === TEMPLATE_POST_TYPE ) {\n\t\t\t_fields.push( {\n\t\t\t\theader: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\tgetValue: ( { item } ) => item.description,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn item.description ? (\n\t\t\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tview.type === LAYOUT_TABLE && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Text variant=\"muted\" aria-hidden=\"true\">\n\t\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'No description.' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\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\tmaxWidth: 400,\n\t\t\t\tminWidth: 320,\n\t\t\t\tenableSorting: false,\n\t\t\t} );\n\t\t}\n\t\t// TODO: The plan is to support fields reordering, which would require an API like `order` or something\n\t\t// similar. With the aforementioned API we wouldn't need to construct the fields array like this.\n\t\t_fields.push( {\n\t\t\theader: __( 'Author' ),\n\t\t\tid: 'author',\n\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\trender: ( { item } ) => {\n\t\t\t\treturn <AuthorField viewType={ view.type } item={ item } />;\n\t\t\t},\n\t\t\tenableHiding: false,\n\t\t\ttype: ENUMERATION_TYPE,\n\t\t\telements: authors,\n\t\t\twidth: '1%',\n\t\t} );\n\t\treturn _fields;\n\t}, [ postType, authors, view.type ] );\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn {\n\t\t\t\tdata: EMPTY_ARRAY,\n\t\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t\t};\n\t\t}\n\t\tlet filteredData = [ ...records ];\n\t\t// Handle global search.\n\t\tif ( view.search ) {\n\t\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\tconst title = item.title?.rendered || item.slug;\n\t\t\t\treturn (\n\t\t\t\t\tnormalizeSearchInput( title ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t) ||\n\t\t\t\t\tnormalizeSearchInput( item.description ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\t// Handle filters.\n\t\tif ( view.filters.length > 0 ) {\n\t\t\tview.filters.forEach( ( filter ) => {\n\t\t\t\tif (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text === filter.value;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_NOT_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text !== filter.value;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Handle sorting.\n\t\tif ( view.sort ) {\n\t\t\tfilteredData = sortByTextFields( {\n\t\t\t\tdata: filteredData,\n\t\t\t\tview,\n\t\t\t\tfields,\n\t\t\t\ttextFields: [ 'title', 'author' ],\n\t\t\t} );\n\t\t}\n\t\t// Handle pagination.\n\t\treturn getPaginationResults( {\n\t\t\tdata: filteredData,\n\t\t\tview,\n\t\t} );\n\t}, [ records, view, fields ] );\n\n\tconst resetTemplateAction = useResetTemplateAction();\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\tresetTemplateAction,\n\t\t\tdeleteTemplateAction,\n\t\t\trenameTemplateAction,\n\t\t\tpostRevisionsAction,\n\t\t],\n\t\t[ resetTemplateAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\tnewView = {\n\t\t\t\t\t...newView,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...defaultConfigPerViewType[ newView.type ],\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView, history, params ]\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={\n\t\t\t\tpostType === TEMPLATE_POST_TYPE\n\t\t\t\t\t? __( 'Templates' )\n\t\t\t\t\t: __( 'Template Parts' )\n\t\t\t}\n\t\t\tactions={\n\t\t\t\tpostType === TEMPLATE_POST_TYPE ? (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\tshowIcon={ false }\n\t\t\t\t\t\ttoggleProps={ { variant: 'primary' } }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<AddNewTemplatePart />\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\tdeferredRendering={ ! view.hiddenFields?.includes( 'preview' ) }\n\t\t\t\tsupportedLayouts={ SUPPORTED_LAYOUTS }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,IAAI,EACJC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,cAAc,QACR,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,Q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