@wordpress/edit-site 6.4.0 → 6.6.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/add-new-pattern/index.js +6 -1
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-post/index.js +2 -1
- package/build/components/add-new-post/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +2 -2
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/editor/index.js +71 -20
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +1 -4
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +3 -4
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +0 -5
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +25 -5
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +1 -8
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +23 -7
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +2 -3
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/screen-block.js +5 -7
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-typeset.js +40 -0
- package/build/components/global-styles/screen-typeset.js.map +1 -0
- package/build/components/global-styles/screen-typography-element.js +14 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +51 -59
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/size-control/index.js +10 -5
- package/build/components/global-styles/size-control/index.js.map +1 -1
- package/build/components/global-styles/typeset-button.js +97 -0
- package/build/components/global-styles/typeset-button.js.map +1 -0
- package/build/components/global-styles/typeset.js +80 -0
- package/build/components/global-styles/typeset.js.map +1 -0
- package/build/components/global-styles/ui.js +4 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +10 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/page-patterns/fields.js +230 -0
- package/build/components/page-patterns/fields.js.map +1 -0
- package/build/components/page-patterns/index.js +13 -228
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +29 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/fields.js +169 -0
- package/build/components/page-templates/fields.js.map +1 -0
- package/build/components/page-templates/index.js +10 -177
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/post-edit/index.js +46 -34
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +50 -28
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +126 -68
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +3 -2
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -3
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +81 -81
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +3 -42
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/site-hub/index.js +6 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +22 -25
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -4
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/utils/is-template-removable.js +2 -2
- package/build/utils/is-template-removable.js.map +1 -1
- package/build/utils/is-template-revertable.js +1 -1
- package/build/utils/is-template-revertable.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +6 -1
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-post/index.js +2 -1
- package/build-module/components/add-new-post/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +2 -2
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/editor/index.js +73 -22
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +1 -4
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +3 -4
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +0 -5
- 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 +26 -6
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +1 -8
- 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 +23 -7
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +2 -3
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +5 -7
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-typeset.js +34 -0
- package/build-module/components/global-styles/screen-typeset.js.map +1 -0
- package/build-module/components/global-styles/screen-typography-element.js +14 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +4 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +52 -60
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/size-control/index.js +10 -5
- package/build-module/components/global-styles/size-control/index.js.map +1 -1
- package/build-module/components/global-styles/typeset-button.js +89 -0
- package/build-module/components/global-styles/typeset-button.js.map +1 -0
- package/build-module/components/global-styles/typeset.js +71 -0
- package/build-module/components/global-styles/typeset.js.map +1 -0
- package/build-module/components/global-styles/ui.js +4 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +10 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +223 -0
- package/build-module/components/page-patterns/fields.js.map +1 -0
- package/build-module/components/page-patterns/index.js +14 -231
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +26 -0
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/fields.js +160 -0
- package/build-module/components/page-templates/fields.js.map +1 -0
- package/build-module/components/page-templates/index.js +12 -178
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +49 -37
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +50 -28
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +128 -70
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +3 -2
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -3
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +81 -81
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +3 -42
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +7 -4
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +23 -26
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +0 -2
- package/build-module/index.js.map +1 -1
- package/build-module/utils/is-template-removable.js +2 -2
- package/build-module/utils/is-template-removable.js.map +1 -1
- package/build-module/utils/is-template-revertable.js +1 -1
- package/build-module/utils/is-template-revertable.js.map +1 -1
- package/build-style/posts-rtl.css +201 -25
- package/build-style/posts.css +201 -25
- package/build-style/style-rtl.css +307 -69
- package/build-style/style.css +307 -69
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -3
- package/src/components/add-new-post/index.js +2 -1
- package/src/components/add-new-template/style.scss +1 -1
- package/src/components/add-new-template/utils.js +10 -6
- package/src/components/editor/index.js +80 -22
- package/src/components/editor/style.scss +60 -2
- package/src/components/global-styles/background-panel.js +0 -3
- package/src/components/global-styles/font-families.js +3 -5
- package/src/components/global-styles/font-library-modal/context.js +0 -5
- package/src/components/global-styles/font-library-modal/font-collection.js +34 -10
- package/src/components/global-styles/font-library-modal/index.js +2 -7
- package/src/components/global-styles/font-library-modal/installed-fonts.js +26 -6
- package/src/components/global-styles/font-library-modal/style.scss +2 -2
- package/src/components/global-styles/font-library-modal/upload-fonts.js +2 -2
- package/src/components/global-styles/screen-block.js +2 -4
- package/src/components/global-styles/screen-css.js +3 -1
- package/src/components/global-styles/screen-typeset.js +42 -0
- package/src/components/global-styles/screen-typography-element.js +14 -0
- package/src/components/global-styles/screen-typography.js +4 -4
- package/src/components/global-styles/shadows-edit-panel.js +67 -73
- package/src/components/global-styles/size-control/index.js +9 -6
- package/src/components/global-styles/style.scss +4 -7
- package/src/components/global-styles/typeset-button.js +93 -0
- package/src/components/global-styles/typeset.js +73 -0
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/global-styles/utils.js +13 -1
- package/src/components/layout/style.scss +8 -0
- package/src/components/page-patterns/fields.js +251 -0
- package/src/components/page-patterns/index.js +19 -246
- package/src/components/page-patterns/style.scss +82 -85
- package/src/components/page-patterns/use-patterns.js +33 -0
- package/src/components/page-templates/fields.js +157 -0
- package/src/components/page-templates/index.js +19 -170
- package/src/components/page-templates/style.scss +14 -5
- package/src/components/post-edit/index.js +58 -35
- package/src/components/post-fields/index.js +88 -25
- package/src/components/post-list/index.js +135 -79
- package/src/components/sidebar-dataviews/add-new-view.js +3 -4
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
- package/src/components/sidebar-dataviews/dataview-item.js +2 -2
- package/src/components/sidebar-dataviews/default-views.js +95 -95
- package/src/components/sidebar-dataviews/index.js +3 -37
- package/src/components/site-hub/index.js +11 -2
- package/src/components/site-icon/style.scss +4 -1
- package/src/components/style-book/index.js +27 -32
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/src/hooks/push-changes-to-global-styles/index.js +3 -3
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
- package/src/index.js +0 -2
- package/src/utils/is-template-removable.js +4 -2
- package/src/utils/is-template-revertable.js +2 -1
- package/build/utils/clone-deep.js +0 -15
- package/build/utils/clone-deep.js.map +0 -1
- package/build-module/utils/clone-deep.js +0 -9
- package/build-module/utils/clone-deep.js.map +0 -1
- package/src/utils/clone-deep.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","useEntityRecords","store","coreStore","useState","useMemo","useCallback","useEffect","privateApis","routerPrivateApis","useSelect","useDispatch","DataViews","editorPrivateApis","__","drawerRight","Page","useDefaultViews","defaultLayouts","OPERATOR_IS_ANY","OPERATOR_IS_NONE","LAYOUT_LIST","AddNewPostModal","unlock","useEditPostAction","usePrevious","usePostFields","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","usePostActions","useLocation","useHistory","EMPTY_ARRAY","useView","postType","params","activeView","isCustom","layout","history","DEFAULT_VIEWS","selectedDefaultView","defaultView","find","slug","view","type","setView","editedViewRecord","select","getEditedEntityRecord","dataviewRecord","Number","editEntityRecord","customView","storedView","content","JSON","parse","setCustomView","viewToSet","id","stringify","setDefaultViewAndUpdateUrl","getLocationWithParams","push","DEFAULT_STATUSES","getItemId","item","toString","PostList","_postId$split","_records$map","_usePrevious","location","postId","quickEdit","selection","setSelection","split","onChangeSelection","items","_params$isCustom","join","queryArgs","filters","forEach","filter","field","operator","status","value","author","author_exclude","per_page","perPage","page","_embed","order","sort","direction","orderby","search","records","isResolving","isLoadingMainEntities","totalItems","totalPages","ids","map","record","prevIds","deletedIds","includes","postIdWasDeleted","undefined","paginationInfo","labels","canCreateRecord","getPostType","canUser","kind","name","postTypeActions","context","editAction","actions","showAddPostModal","setShowAddPostModal","openModal","closeModal","handleNewPage","canvas","isLoading","isLoadingFields","fields","title","add_new_item","children","variant","onClick","__next40pxDefaultSize","onSave","onClose","data","onChangeView","header","window","__experimentalQuickEditDataViews","size","isPressed","icon","label"],"sources":["@wordpress/edit-site/src/components/post-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { DataViews } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport {\n\tuseDefaultViews,\n\tdefaultLayouts,\n} from '../sidebar-dataviews/default-views';\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { usePrevious } from '@wordpress/compose';\nimport usePostFields from '../post-fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst EMPTY_ARRAY = [];\n\nfunction useView( postType ) {\n\tconst {\n\t\tparams: { activeView = 'all', isCustom = 'false', layout },\n\t} = useLocation();\n\tconst history = useHistory();\n\tconst DEFAULT_VIEWS = useDefaultViews( { postType } );\n\tconst selectedDefaultView = useMemo( () => {\n\t\tconst defaultView =\n\t\t\tisCustom === 'false' &&\n\t\t\tDEFAULT_VIEWS[ postType ].find(\n\t\t\t\t( { slug } ) => slug === activeView\n\t\t\t)?.view;\n\t\tif ( isCustom === 'false' && layout ) {\n\t\t\treturn {\n\t\t\t\t...defaultView,\n\t\t\t\ttype: layout,\n\t\t\t\tlayout: defaultLayouts[ layout ]?.layout,\n\t\t\t};\n\t\t}\n\t\treturn defaultView;\n\t}, [ isCustom, activeView, layout, postType, DEFAULT_VIEWS ] );\n\tconst [ view, setView ] = useState( selectedDefaultView );\n\n\tuseEffect( () => {\n\t\tif ( selectedDefaultView ) {\n\t\t\tsetView( selectedDefaultView );\n\t\t}\n\t}, [ selectedDefaultView ] );\n\tconst editedViewRecord = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isCustom !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\tconst dataviewRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\tNumber( activeView )\n\t\t\t);\n\t\t\treturn dataviewRecord;\n\t\t},\n\t\t[ activeView, isCustom ]\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst customView = useMemo( () => {\n\t\tconst storedView =\n\t\t\teditedViewRecord?.content &&\n\t\t\tJSON.parse( editedViewRecord?.content );\n\t\tif ( ! storedView ) {\n\t\t\treturn storedView;\n\t\t}\n\n\t\treturn {\n\t\t\t...storedView,\n\t\t\tlayout: defaultLayouts[ storedView?.type ]?.layout,\n\t\t};\n\t}, [ editedViewRecord?.content ] );\n\n\tconst setCustomView = useCallback(\n\t\t( viewToSet ) => {\n\t\t\teditEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\teditedViewRecord?.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: JSON.stringify( viewToSet ),\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ editEntityRecord, editedViewRecord?.id ]\n\t);\n\n\tconst setDefaultViewAndUpdateUrl = useCallback(\n\t\t( viewToSet ) => {\n\t\t\tif ( viewToSet.type !== view?.type ) {\n\t\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: viewToSet.type,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetView( viewToSet );\n\t\t},\n\t\t[ history, view?.type ]\n\t);\n\n\tif ( isCustom === 'false' ) {\n\t\treturn [ view, setDefaultViewAndUpdateUrl ];\n\t} else if ( isCustom === 'true' && customView ) {\n\t\treturn [ customView, setCustomView ];\n\t}\n\t// Loading state where no the view was not found on custom views or default views.\n\treturn [ DEFAULT_VIEWS[ postType ][ 0 ].view, setDefaultViewAndUpdateUrl ];\n}\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nexport default function PostList( { postType } ) {\n\tconst [ view, setView ] = useView( postType );\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst { postId, quickEdit = false } = location.params;\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\tif ( ( params.isCustom ?? 'false' ) === 'false' ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingMainEntities,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecords( 'postType', postType, queryArgs );\n\n\tconst ids = records?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.push( {\n\t\t\t\t...history.getLocationWithParams().params,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ postIdWasDeleted, history ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tcloseModal();\n\t};\n\tconst { isLoading: isLoadingFields, fields } = usePostFields( view.type );\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\tlabels?.add_new_item &&\n\t\t\t\tcanCreateRecord && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\tonClose={ closeModal }\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}\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={ records || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingMainEntities || isLoadingFields }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ setView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t! quickEdit\n\t\t\t\t\t\t\t\t\t? __( 'Show quick edit sidebar' )\n\t\t\t\t\t\t\t\t\t: __( 'Close quick edit sidebar' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\t...location.params,\n\t\t\t\t\t\t\t\t\tquickEdit: quickEdit ? undefined : true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,gBAAgB,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAC3E,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,QAAQ,oBAAoB;AAC9E,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASJ,WAAW,IAAIK,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,kBAAkB;;AAE9C;AACA;AACA;AACA,OAAOC,IAAI,MAAM,SAAS;AAC1B,SACCC,eAAe,EACfC,cAAc,QACR,oCAAoC;AAC3C,SACCC,eAAe,EACfC,gBAAgB,EAChBC,WAAW,QACL,uBAAuB;AAE9B,OAAOC,eAAe,MAAM,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAOC,aAAa,MAAM,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAA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EAAE,CAAE,0BAA2B,CAClC;QACDkI,OAAO,EAAGA,CAAA,KAAM;UACfrG,OAAO,CAAC0B,IAAI,CAAE;YACb,GAAGS,QAAQ,CAACvC,MAAM;YAClByC,SAAS,EAAEA,SAAS,GAAGuC,SAAS,GAAG;UACpC,CAAE,CAAC;QACJ;MAAG,CACH;IAEF,CACD;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Button","store","coreStore","privateApis","coreDataPrivateApis","useState","useMemo","useCallback","useEffect","routerPrivateApis","useSelect","useDispatch","DataViews","filterSortAndPaginate","editorPrivateApis","__","drawerRight","Page","useDefaultViews","defaultLayouts","OPERATOR_IS_ANY","OPERATOR_IS_NONE","LAYOUT_LIST","AddNewPostModal","unlock","useEditPostAction","usePrevious","usePostFields","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","usePostActions","useLocation","useHistory","useEntityRecordsWithPermissions","EMPTY_ARRAY","getDefaultView","defaultViews","activeView","find","slug","view","getCustomView","editedEntityRecord","content","undefined","JSON","parse","layout","type","useView","postType","params","isCustom","history","editEntityRecord","select","getEditedEntityRecord","Number","setView","initialView","_getCustomView","_getDefaultView","setViewWithUrlUpdate","newView","getLocationWithParams","push","id","stringify","prevView","DEFAULT_STATUSES","getItemId","item","toString","PostList","_postId$split","_data$map","_usePrevious","location","postId","quickEdit","selection","setSelection","split","onChangeSelection","items","_params$isCustom","join","isLoading","isLoadingFields","fields","queryArgs","filters","forEach","filter","field","operator","status","value","author","author_exclude","per_page","perPage","page","_embed","order","sort","direction","orderby","search","records","isResolving","isLoadingData","totalItems","totalPages","data","ids","map","record","prevIds","deletedIds","includes","postIdWasDeleted","paginationInfo","labels","canCreateRecord","getPostType","canUser","kind","name","postTypeActions","context","editAction","actions","showAddPostModal","setShowAddPostModal","openModal","closeModal","handleNewPage","canvas","title","add_new_item","children","variant","onClick","__next40pxDefaultSize","onSave","onClose","onChangeView","header","window","__experimentalQuickEditDataViews","size","isPressed","icon","label"],"sources":["@wordpress/edit-site/src/components/post-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport {\n\tuseDefaultViews,\n\tdefaultLayouts,\n} from '../sidebar-dataviews/default-views';\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { usePrevious } from '@wordpress/compose';\nimport usePostFields from '../post-fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );\nconst EMPTY_ARRAY = [];\n\nconst getDefaultView = ( defaultViews, activeView ) => {\n\treturn defaultViews.find( ( { slug } ) => slug === activeView )?.view;\n};\n\nconst getCustomView = ( editedEntityRecord ) => {\n\tif ( ! editedEntityRecord?.content ) {\n\t\treturn undefined;\n\t}\n\n\tconst content = JSON.parse( editedEntityRecord.content );\n\tif ( ! content ) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\t...content,\n\t\tlayout: defaultLayouts[ content.type ]?.layout,\n\t};\n};\n\n/**\n * This function abstracts working with default & custom views by\n * providing a [ state, setState ] tuple based on the URL parameters.\n *\n * Consumers use the provided tuple to work with state\n * and don't have to deal with the specifics of default & custom views.\n *\n * @param {string} postType Post type to retrieve default views for.\n * @return {Array} The [ state, setState ] tuple.\n */\nfunction useView( postType ) {\n\tconst {\n\t\tparams: { activeView = 'all', isCustom = 'false', layout },\n\t} = useLocation();\n\tconst history = useHistory();\n\n\tconst defaultViews = useDefaultViews( { postType } );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst editedEntityRecord = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isCustom !== 'true' ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\treturn getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\tNumber( activeView )\n\t\t\t);\n\t\t},\n\t\t[ activeView, isCustom ]\n\t);\n\tconst [ view, setView ] = useState( () => {\n\t\tlet initialView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tinitialView = getCustomView( editedEntityRecord ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t} else {\n\t\t\tinitialView = getDefaultView( defaultViews, activeView ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t}\n\n\t\tconst type = layout ?? initialView.type;\n\t\treturn {\n\t\t\t...initialView,\n\t\t\ttype,\n\t\t};\n\t} );\n\n\tconst setViewWithUrlUpdate = useCallback(\n\t\t( newView ) => {\n\t\t\tconst { params } = history.getLocationWithParams();\n\n\t\t\tif ( newView.type === LAYOUT_LIST && ! params?.layout ) {\n\t\t\t\t// Skip updating the layout URL param if\n\t\t\t\t// it is not present and the newView.type is LAYOUT_LIST.\n\t\t\t} else if ( newView.type !== params?.layout ) {\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\n\t\t\tif ( isCustom === 'true' && editedEntityRecord?.id ) {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\teditedEntityRecord?.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: JSON.stringify( newView ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, isCustom, editEntityRecord, editedEntityRecord?.id ]\n\t);\n\n\t// When layout URL param changes, update the view type\n\t// without affecting any other config.\n\tuseEffect( () => {\n\t\tsetView( ( prevView ) => ( {\n\t\t\t...prevView,\n\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t} ) );\n\t}, [ layout ] );\n\n\t// When activeView or isCustom URL parameters change, reset the view.\n\tuseEffect( () => {\n\t\tlet newView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tnewView = getCustomView( editedEntityRecord );\n\t\t} else {\n\t\t\tnewView = getDefaultView( defaultViews, activeView );\n\t\t}\n\n\t\tif ( newView ) {\n\t\t\tconst type = layout ?? newView.type;\n\t\t\tsetView( {\n\t\t\t\t...newView,\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\t}, [ activeView, isCustom, layout, defaultViews, editedEntityRecord ] );\n\n\treturn [ view, setViewWithUrlUpdate, setViewWithUrlUpdate ];\n}\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nexport default function PostList( { postType } ) {\n\tconst [ view, setView ] = useView( postType );\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst {\n\t\tpostId,\n\t\tquickEdit = false,\n\t\tisCustom,\n\t\tactiveView = 'all',\n\t} = location.params;\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\tif ( ( params.isCustom ?? 'false' ) === 'false' ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst { isLoading: isLoadingFields, fields } = usePostFields( view.type );\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters?.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingData,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );\n\n\t// The REST API sort the authors by ID, but we want to sort them by name.\n\tconst data = useMemo( () => {\n\t\tif ( ! isLoadingFields && view?.sort?.field === 'author' ) {\n\t\t\treturn filterSortAndPaginate(\n\t\t\t\trecords,\n\t\t\t\t{ sort: { ...view.sort } },\n\t\t\t\tfields\n\t\t\t).data;\n\t\t}\n\n\t\treturn records;\n\t}, [ records, fields, isLoadingFields, view?.sort ] );\n\n\tconst ids = data?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.push( {\n\t\t\t\t...history.getLocationWithParams().params,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ postIdWasDeleted, history ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tcloseModal();\n\t};\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\tlabels?.add_new_item &&\n\t\t\t\tcanCreateRecord && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\tonClose={ closeModal }\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}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView + isCustom }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingData || isLoadingFields }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ setView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={ __( 'Toggle details panel' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\t...location.params,\n\t\t\t\t\t\t\t\t\tquickEdit: quickEdit ? undefined : true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t}\n\t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;QAAAH,QAAA,EAEnBlB,MAAM,CAACiB;MAAY,CACd,CAAC,EACPP,gBAAgB,iBACjB5G,IAAA,CAACN,eAAe;QACf+B,QAAQ,EAAGA,QAAU;QACrB+F,MAAM,EAAGR,aAAe;QACxBS,OAAO,EAAGV;MAAY,CACtB,CACD;IAAA,CACA,CAEH;IAAAK,QAAA,eAEDpH,IAAA,CAACjB,SAAS;MAETkH,cAAc,EAAGA,cAAgB;MACjCjC,MAAM,EAAGA,MAAQ;MACjB2C,OAAO,EAAGA,OAAS;MACnBlB,IAAI,EAAGA,IAAI,IAAIhF,WAAa;MAC5BqD,SAAS,EAAGwB,aAAa,IAAIvB,eAAiB;MAC9ChD,IAAI,EAAGA,IAAM;MACb2G,YAAY,EAAGzF,OAAS;MACxBsB,SAAS,EAAGA,SAAW;MACvBG,iBAAiB,EAAGA,iBAAmB;MACvCb,SAAS,EAAGA,SAAW;MACvBvD,cAAc,EAAGA,cAAgB;MACjCqI,MAAM,EACLC,MAAM,CAACC,gCAAgC,IACvC9G,IAAI,CAACQ,IAAI,KAAK9B,WAAW,IACzBgC,QAAQ,KAAK,MAAM,iBAClBzB,IAAA,CAAC7B,MAAM;QACN2J,IAAI,EAAC,SAAS;QACdC,SAAS,EAAGzE,SAAW;QACvB0E,IAAI,EAAG7I,WAAa;QACpB8I,KAAK,EAAG/I,EAAE,CAAE,sBAAuB,CAAG;QACtCoI,OAAO,EAAGA,CAAA,KAAM;UACf1F,OAAO,CAACY,IAAI,CAAE;YACb,GAAGY,QAAQ,CAAC1B,MAAM;YAClB4B,SAAS,EAAEA,SAAS,GAAGnC,SAAS,GAAG;UACpC,CAAE,CAAC;QACJ;MAAG,CACH;IAEF,GA7BKP,UAAU,GAAGe,QA8BnB;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ function AddNewItemModalContent({
|
|
|
31
31
|
} = useDispatch(coreStore);
|
|
32
32
|
const [title, setTitle] = useState('');
|
|
33
33
|
const [isSaving, setIsSaving] = useState(false);
|
|
34
|
-
const
|
|
34
|
+
const defaultViews = useDefaultViews({
|
|
35
35
|
postType: type
|
|
36
36
|
});
|
|
37
37
|
return /*#__PURE__*/_jsx("form", {
|
|
@@ -59,7 +59,7 @@ function AddNewItemModalContent({
|
|
|
59
59
|
title,
|
|
60
60
|
status: 'publish',
|
|
61
61
|
wp_dataviews_type: dataViewTaxonomyId,
|
|
62
|
-
content: JSON.stringify(
|
|
62
|
+
content: JSON.stringify(defaultViews[0].view)
|
|
63
63
|
});
|
|
64
64
|
const {
|
|
65
65
|
params: {
|
|
@@ -77,6 +77,7 @@ function AddNewItemModalContent({
|
|
|
77
77
|
children: /*#__PURE__*/_jsxs(VStack, {
|
|
78
78
|
spacing: "5",
|
|
79
79
|
children: [/*#__PURE__*/_jsx(TextControl, {
|
|
80
|
+
__next40pxDefaultSize: true,
|
|
80
81
|
__nextHasNoMarginBottom: true,
|
|
81
82
|
label: __('Name'),
|
|
82
83
|
value: title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","__","useDispatch","resolveSelect","store","coreStore","useState","plus","privateApis","routerPrivateApis","SidebarNavigationItem","useDefaultViews","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useHistory","AddNewItemModalContent","type","setIsAdding","history","saveEntityRecord","title","setTitle","isSaving","setIsSaving","
|
|
1
|
+
{"version":3,"names":["Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","__","useDispatch","resolveSelect","store","coreStore","useState","plus","privateApis","routerPrivateApis","SidebarNavigationItem","useDefaultViews","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useHistory","AddNewItemModalContent","type","setIsAdding","history","saveEntityRecord","title","setTitle","isSaving","setIsSaving","defaultViews","postType","onSubmit","event","preventDefault","getEntityRecords","dataViewTaxonomyId","dataViewTypeRecords","slug","length","id","record","name","savedRecord","status","wp_dataviews_type","content","JSON","stringify","view","params","getLocationWithParams","push","activeView","isCustom","children","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","className","justify","variant","onClick","isBusy","AddNewItem","isAdding","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 { useDefaultViews } from './default-views';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction AddNewItemModalContent( { type, setIsAdding } ) {\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst [ title, setTitle ] = useState( '' );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst defaultViews = useDefaultViews( { postType: type } );\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( defaultViews[ 0 ].view ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tconst {\n\t\t\t\t\tparams: { postType },\n\t\t\t\t} = history.getLocationWithParams();\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType,\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__next40pxDefaultSize\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,OA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,EAAE,CAAE,QAAS;QAAC,CACT,CAAC,eAETa,IAAA,CAACd,MAAM;UACNgE,OAAO,EAAC,SAAS;UACjB3C,IAAI,EAAC,QAAQ;UACb,iBAAgB,CAAEI,KAAK,IAAIE,QAAU;UACrCuC,MAAM,EAAGvC,QAAU;UAAA2B,QAAA,EAEjBrD,EAAE,CAAE,QAAS;QAAC,CACT,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET;AAEA,eAAe,SAASkE,UAAUA,CAAE;EAAE9C;AAAK,CAAC,EAAG;EAC9C,MAAM,CAAE+C,QAAQ,EAAE9C,WAAW,CAAE,GAAGhB,QAAQ,CAAE,KAAM,CAAC;EACnD,oBACCU,KAAA,CAAAE,SAAA;IAAAoC,QAAA,gBACCxC,IAAA,CAACJ,qBAAqB;MACrB2D,IAAI,EAAG9D,IAAM;MACb0D,OAAO,EAAGA,CAAA,KAAM;QACf3C,WAAW,CAAE,IAAK,CAAC;MACpB,CAAG;MACHwC,SAAS,EAAC,0CAA0C;MAAAR,QAAA,EAElDrD,EAAE,CAAE,UAAW;IAAC,CACI,CAAC,EACtBmE,QAAQ,iBACTtD,IAAA,CAACpB,KAAK;MACL+B,KAAK,EAAGxB,EAAE,CAAE,cAAe,CAAG;MAC9BqE,cAAc,EAAGA,CAAA,KAAM;QACtBhD,WAAW,CAAE,KAAM,CAAC;MACrB,CAAG;MAAAgC,QAAA,eAEHxC,IAAA,CAACM,sBAAsB;QACtBC,IAAI,EAAGA,IAAM;QACbC,WAAW,EAAGA;MAAa,CAC3B;IAAC,CACI,CACP;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1 +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","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useHistory","EMPTY_ARRAY","RenameItemModalContent","dataviewId","currentTitle","setIsRenaming","editEntityRecord","title","setTitle","onSubmit","event","preventDefault","children","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","className","justify","variant","__next40pxDefaultSize","onClick","type","CustomDataViewItem","isActive","history","dataview","select","getEditedEntityRecord","deleteEntityRecord","viewContent","JSON","parse","content","isRenaming","isCustom","customViewId","suffix","icon","toggleProps","style","color","size","onClose","id","force","params","postType","getLocationWithParams","replace","isDestructive","onRequestClose","focusOnMount","useCustomDataViews","customDataViews","getEntityRecords","dataViewTypeRecords","slug","length","dataViews","wp_dataviews_type","orderby","order","CustomDataViewsList","activeView","level","map","customViewRecord","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 } = 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\t__next40pxDefaultSize\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\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\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 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\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\tclassName=\"edit-site-sidebar-dataviews-dataview-item__dropdown-menu\"\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\tsize: 'small',\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\tconst {\n\t\t\t\t\t\t\t\t\t\t\t\tparams: { postType },\n\t\t\t\t\t\t\t\t\t\t\t} = history.getLocationWithParams();\n\t\t\t\t\t\t\t\t\t\t\thistory.replace( { postType } );\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' ) }\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\tfocusOnMount=\"firstContentElement\"\n\t\t\t\t\tsize=\"small\"\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 &&\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,S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AGD,kBAAkB,CAAE/B,IAAK,CAAC;EAClD,oBACC3B,KAAA,CAAAE,SAAA;IAAAa,QAAA,gBACCjB,IAAA;MAAKwB,SAAS,EAAC,6DAA6D;MAAAP,QAAA,eAC3EjB,IAAA,CAACrB,OAAO;QAAC6F,KAAK,EAAG,CAAG;QAAAvD,QAAA,EAAGxB,EAAE,CAAE,cAAe;MAAC,CAAW;IAAC,CACnD,CAAC,eACNS,KAAA,CAACzB,SAAS;MAAAwC,QAAA,GACP4C,eAAe,CAACY,GAAG,CAAIC,gBAAgB,IAAM;QAC9C,oBACC1E,IAAA,CAAC8B,kBAAkB;UAElBtB,UAAU,EAAGkE,gBAAgB,CAACvB,EAAI;UAClCpB,QAAQ,EACPW,QAAQ,IACRiC,MAAM,CAAEJ,UAAW,CAAC,KAAKG,gBAAgB,CAACvB;QAC1C,GALKuB,gBAAgB,CAACvB,EAMvB,CAAC;MAEJ,CAAE,CAAC,eACHnD,IAAA,CAACH,UAAU;QAACgC,IAAI,EAAGA;MAAM,CAAE,CAAC;IAAA,CAClB,CAAC;EAAA,CACX,CAAC;AAEL","ignoreList":[]}
|
|
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","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useHistory","EMPTY_ARRAY","RenameItemModalContent","dataviewId","currentTitle","setIsRenaming","editEntityRecord","title","setTitle","onSubmit","event","preventDefault","children","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","className","justify","variant","onClick","type","CustomDataViewItem","isActive","history","dataview","select","getEditedEntityRecord","deleteEntityRecord","viewContent","JSON","parse","content","isRenaming","isCustom","customViewId","suffix","icon","toggleProps","style","color","size","onClose","id","force","params","postType","getLocationWithParams","replace","isDestructive","onRequestClose","focusOnMount","useCustomDataViews","customDataViews","getEntityRecords","dataViewTypeRecords","slug","length","dataViews","wp_dataviews_type","orderby","order","CustomDataViewsList","activeView","level","map","customViewRecord","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 } = 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__next40pxDefaultSize\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\t__next40pxDefaultSize\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\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\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 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\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\tclassName=\"edit-site-sidebar-dataviews-dataview-item__dropdown-menu\"\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\tsize: 'small',\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\tconst {\n\t\t\t\t\t\t\t\t\t\t\t\tparams: { postType },\n\t\t\t\t\t\t\t\t\t\t\t} = history.getLocationWithParams();\n\t\t\t\t\t\t\t\t\t\t\thistory.replace( { postType } );\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' ) }\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\tfocusOnMount=\"firstContentElement\"\n\t\t\t\t\tsize=\"small\"\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 &&\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;AACtD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,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A,GACP4C,eAAe,CAACY,GAAG,CAAIC,gBAAgB,IAAM;QAC9C,oBACC1E,IAAA,CAAC8B,kBAAkB;UAElBtB,UAAU,EAAGkE,gBAAgB,CAACvB,EAAI;UAClCpB,QAAQ,EACPW,QAAQ,IACRiC,MAAM,CAAEJ,UAAW,CAAC,KAAKG,gBAAgB,CAACvB;QAC1C,GALKuB,gBAAgB,CAACvB,EAMvB,CAAC;MAEJ,CAAE,CAAC,eACHnD,IAAA,CAACH,UAAU;QAACgC,IAAI,EAAGA;MAAM,CAAE,CAAC;IAAA,CAClB,CAAC;EAAA,CACX,CAAC;AAEL","ignoreList":[]}
|
|
@@ -33,8 +33,7 @@ export default function DataViewItem({
|
|
|
33
33
|
}) {
|
|
34
34
|
const {
|
|
35
35
|
params: {
|
|
36
|
-
postType
|
|
37
|
-
layout
|
|
36
|
+
postType
|
|
38
37
|
}
|
|
39
38
|
} = useLocation();
|
|
40
39
|
const iconToUse = icon || VIEW_LAYOUTS.find(v => v.type === type).icon;
|
|
@@ -44,7 +43,7 @@ export default function DataViewItem({
|
|
|
44
43
|
}
|
|
45
44
|
const linkInfo = useLink({
|
|
46
45
|
postType,
|
|
47
|
-
layout,
|
|
46
|
+
layout: type,
|
|
48
47
|
activeView,
|
|
49
48
|
isCustom: isCustom ? 'true' : undefined
|
|
50
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","privateApis","routerPrivateApis","__experimentalHStack","HStack","VIEW_LAYOUTS","useLink","SidebarNavigationItem","unlock","jsx","_jsx","jsxs","_jsxs","useLocation","DataViewItem","title","slug","customViewId","type","icon","isActive","isCustom","suffix","params","postType","
|
|
1
|
+
{"version":3,"names":["clsx","privateApis","routerPrivateApis","__experimentalHStack","HStack","VIEW_LAYOUTS","useLink","SidebarNavigationItem","unlock","jsx","_jsx","jsxs","_jsxs","useLocation","DataViewItem","title","slug","customViewId","type","icon","isActive","isCustom","suffix","params","postType","iconToUse","find","v","activeView","undefined","linkInfo","layout","justify","className","children"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/dataview-item.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { VIEW_LAYOUTS } from '@wordpress/dataviews';\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\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: { postType },\n\t} = useLocation();\n\n\tconst iconToUse =\n\t\ticon || VIEW_LAYOUTS.find( ( v ) => v.type === type ).icon;\n\n\tlet activeView = isCustom ? customViewId : slug;\n\tif ( activeView === 'all' ) {\n\t\tactiveView = undefined;\n\t}\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tlayout: type,\n\t\tactiveView,\n\t\tisCustom: isCustom ? 'true' : undefined,\n\t} );\n\treturn (\n\t\t<HStack\n\t\t\tjustify=\"flex-start\"\n\t\t\tclassName={ clsx( 'edit-site-sidebar-dataviews-dataview-item', {\n\t\t\t\t'is-selected': isActive,\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,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,oBAAoB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S,SAAW;MAAAK,QAAA,EAE5CnB;IAAK,CACe,CAAC,EACtBO,MAAM;EAAA,CACD,CAAC;AAEX","ignoreList":[]}
|
|
@@ -61,86 +61,86 @@ export function useDefaultViews({
|
|
|
61
61
|
return getPostType(postType)?.labels;
|
|
62
62
|
}, [postType]);
|
|
63
63
|
return useMemo(() => {
|
|
64
|
-
return {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}, [labels
|
|
64
|
+
return [{
|
|
65
|
+
title: labels?.all_items || __('All items'),
|
|
66
|
+
slug: 'all',
|
|
67
|
+
icon: pages,
|
|
68
|
+
view: DEFAULT_POST_BASE
|
|
69
|
+
}, {
|
|
70
|
+
title: __('Published'),
|
|
71
|
+
slug: 'published',
|
|
72
|
+
icon: published,
|
|
73
|
+
view: {
|
|
74
|
+
...DEFAULT_POST_BASE,
|
|
75
|
+
filters: [{
|
|
76
|
+
field: 'status',
|
|
77
|
+
operator: OPERATOR_IS_ANY,
|
|
78
|
+
value: 'publish'
|
|
79
|
+
}]
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
title: __('Scheduled'),
|
|
83
|
+
slug: 'future',
|
|
84
|
+
icon: scheduled,
|
|
85
|
+
view: {
|
|
86
|
+
...DEFAULT_POST_BASE,
|
|
87
|
+
filters: [{
|
|
88
|
+
field: 'status',
|
|
89
|
+
operator: OPERATOR_IS_ANY,
|
|
90
|
+
value: 'future'
|
|
91
|
+
}]
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
title: __('Drafts'),
|
|
95
|
+
slug: 'drafts',
|
|
96
|
+
icon: drafts,
|
|
97
|
+
view: {
|
|
98
|
+
...DEFAULT_POST_BASE,
|
|
99
|
+
filters: [{
|
|
100
|
+
field: 'status',
|
|
101
|
+
operator: OPERATOR_IS_ANY,
|
|
102
|
+
value: 'draft'
|
|
103
|
+
}]
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
title: __('Pending'),
|
|
107
|
+
slug: 'pending',
|
|
108
|
+
icon: pending,
|
|
109
|
+
view: {
|
|
110
|
+
...DEFAULT_POST_BASE,
|
|
111
|
+
filters: [{
|
|
112
|
+
field: 'status',
|
|
113
|
+
operator: OPERATOR_IS_ANY,
|
|
114
|
+
value: 'pending'
|
|
115
|
+
}]
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
title: __('Private'),
|
|
119
|
+
slug: 'private',
|
|
120
|
+
icon: notAllowed,
|
|
121
|
+
view: {
|
|
122
|
+
...DEFAULT_POST_BASE,
|
|
123
|
+
filters: [{
|
|
124
|
+
field: 'status',
|
|
125
|
+
operator: OPERATOR_IS_ANY,
|
|
126
|
+
value: 'private'
|
|
127
|
+
}]
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
title: __('Trash'),
|
|
131
|
+
slug: 'trash',
|
|
132
|
+
icon: trash,
|
|
133
|
+
view: {
|
|
134
|
+
...DEFAULT_POST_BASE,
|
|
135
|
+
type: LAYOUT_TABLE,
|
|
136
|
+
layout: defaultLayouts[LAYOUT_TABLE].layout,
|
|
137
|
+
filters: [{
|
|
138
|
+
field: 'status',
|
|
139
|
+
operator: OPERATOR_IS_ANY,
|
|
140
|
+
value: 'trash'
|
|
141
|
+
}]
|
|
142
|
+
}
|
|
143
|
+
}];
|
|
144
|
+
}, [labels]);
|
|
145
145
|
}
|
|
146
146
|
//# sourceMappingURL=default-views.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","trash","pages","drafts","published","scheduled","pending","notAllowed","useSelect","store","coreStore","useMemo","LAYOUT_LIST","LAYOUT_TABLE","LAYOUT_GRID","OPERATOR_IS_ANY","defaultLayouts","layout","primaryField","styles","width","title","maxWidth","mediaField","DEFAULT_POST_BASE","type","search","filters","page","perPage","sort","field","direction","fields","useDefaultViews","postType","labels","select","getPostType","all_items","slug","icon","view","operator","value"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/default-views.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\ttrash,\n\tpages,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_LIST,\n\tLAYOUT_TABLE,\n\tLAYOUT_GRID,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\n\nexport const defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tstyles: {\n\t\t\t\t'featured-image': {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\tmaxWidth: 300,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tlayout: {\n\t\t\tmediaField: 'featured-image',\n\t\t\tprimaryField: 'title',\n\t\t},\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tmediaField: 'featured-image',\n\t\t},\n\t},\n};\n\nconst DEFAULT_POST_BASE = {\n\ttype: LAYOUT_LIST,\n\tsearch: '',\n\tfilters: [],\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'date',\n\t\tdirection: 'desc',\n\t},\n\tfields: [ 'title', 'author', 'status' ],\n\tlayout: defaultLayouts[ LAYOUT_LIST ].layout,\n};\n\nexport function useDefaultViews( { postType } ) {\n\tconst labels = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( postType )?.labels;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn useMemo( () => {\n\t\treturn
|
|
1
|
+
{"version":3,"names":["__","trash","pages","drafts","published","scheduled","pending","notAllowed","useSelect","store","coreStore","useMemo","LAYOUT_LIST","LAYOUT_TABLE","LAYOUT_GRID","OPERATOR_IS_ANY","defaultLayouts","layout","primaryField","styles","width","title","maxWidth","mediaField","DEFAULT_POST_BASE","type","search","filters","page","perPage","sort","field","direction","fields","useDefaultViews","postType","labels","select","getPostType","all_items","slug","icon","view","operator","value"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/default-views.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\ttrash,\n\tpages,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_LIST,\n\tLAYOUT_TABLE,\n\tLAYOUT_GRID,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\n\nexport const defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tstyles: {\n\t\t\t\t'featured-image': {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\tmaxWidth: 300,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tlayout: {\n\t\t\tmediaField: 'featured-image',\n\t\t\tprimaryField: 'title',\n\t\t},\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tmediaField: 'featured-image',\n\t\t},\n\t},\n};\n\nconst DEFAULT_POST_BASE = {\n\ttype: LAYOUT_LIST,\n\tsearch: '',\n\tfilters: [],\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'date',\n\t\tdirection: 'desc',\n\t},\n\tfields: [ 'title', 'author', 'status' ],\n\tlayout: defaultLayouts[ LAYOUT_LIST ].layout,\n};\n\nexport function useDefaultViews( { postType } ) {\n\tconst labels = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( postType )?.labels;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: labels?.all_items || __( 'All items' ),\n\t\t\t\tslug: 'all',\n\t\t\t\ticon: pages,\n\t\t\t\tview: DEFAULT_POST_BASE,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Published' ),\n\t\t\t\tslug: 'published',\n\t\t\t\ticon: published,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'publish',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Scheduled' ),\n\t\t\t\tslug: 'future',\n\t\t\t\ticon: scheduled,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'future',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Drafts' ),\n\t\t\t\tslug: 'drafts',\n\t\t\t\ticon: drafts,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'draft',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Pending' ),\n\t\t\t\tslug: 'pending',\n\t\t\t\ticon: pending,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'pending',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Private' ),\n\t\t\t\tslug: 'private',\n\t\t\t\ticon: notAllowed,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'private',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: __( 'Trash' ),\n\t\t\t\tslug: 'trash',\n\t\t\t\ticon: trash,\n\t\t\t\tview: {\n\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\ttype: LAYOUT_TABLE,\n\t\t\t\t\tlayout: defaultLayouts[ LAYOUT_TABLE ].layout,\n\t\t\t\t\tfilters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: 'trash',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ labels ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AAEpC,SACCC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ,kBAAkB;AACzB,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SACCC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,QACT,uBAAuB;AAE9B,OAAO,MAAMC,cAAc,GAAG;EAC7B,CAAEH,YAAY,GAAI;I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AE,QAAQ;UACfY,QAAQ,EAAE5B,eAAe;UACzB6B,KAAK,EAAE;QACR,CAAC;MAEH;IACD,CAAC,EACD;MACCvB,KAAK,EAAErB,EAAE,CAAE,OAAQ,CAAC;MACpBwC,IAAI,EAAE,OAAO;MACbC,IAAI,EAAExC,KAAK;MACXyC,IAAI,EAAE;QACL,GAAGlB,iBAAiB;QACpBC,IAAI,EAAEZ,YAAY;QAClBI,MAAM,EAAED,cAAc,CAAEH,YAAY,CAAE,CAACI,MAAM;QAC7CU,OAAO,EAAE,CACR;UACCI,KAAK,EAAE,QAAQ;UACfY,QAAQ,EAAE5B,eAAe;UACzB6B,KAAK,EAAE;QACR,CAAC;MAEH;IACD,CAAC,CACD;EACF,CAAC,EAAE,CAAER,MAAM,CAAG,CAAC;AAChB","ignoreList":[]}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
5
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
6
|
-
import { useRef, useEffect } from '@wordpress/element';
|
|
7
|
-
import { usePrevious } from '@wordpress/compose';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Internal dependencies
|
|
@@ -17,44 +15,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
15
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
17
|
const {
|
|
20
|
-
useLocation
|
|
21
|
-
useHistory
|
|
18
|
+
useLocation
|
|
22
19
|
} = unlock(routerPrivateApis);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Hook to switch to table layout when switching to the trash view.
|
|
26
|
-
* When going out of the trash view, it switches back to the previous layout if
|
|
27
|
-
* there was an automatic switch to table layout.
|
|
28
|
-
*/
|
|
29
|
-
function useSwitchToTableOnTrash() {
|
|
30
|
-
const {
|
|
31
|
-
params: {
|
|
32
|
-
activeView,
|
|
33
|
-
layout,
|
|
34
|
-
...restParams
|
|
35
|
-
}
|
|
36
|
-
} = useLocation();
|
|
37
|
-
const history = useHistory();
|
|
38
|
-
const viewToSwitchOutOfTrash = useRef(undefined);
|
|
39
|
-
const previousActiveView = usePrevious(activeView);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (activeView === 'trash' && previousActiveView !== 'trash') {
|
|
42
|
-
viewToSwitchOutOfTrash.current = layout || 'list';
|
|
43
|
-
history.push({
|
|
44
|
-
...restParams,
|
|
45
|
-
layout: 'table',
|
|
46
|
-
activeView
|
|
47
|
-
});
|
|
48
|
-
} else if (previousActiveView === 'trash' && activeView !== 'trash' && viewToSwitchOutOfTrash.current) {
|
|
49
|
-
history.push({
|
|
50
|
-
...restParams,
|
|
51
|
-
layout: viewToSwitchOutOfTrash.current,
|
|
52
|
-
activeView
|
|
53
|
-
});
|
|
54
|
-
viewToSwitchOutOfTrash.current = undefined;
|
|
55
|
-
}
|
|
56
|
-
}, [previousActiveView, activeView, layout, history, restParams]);
|
|
57
|
-
}
|
|
58
20
|
export default function DataViewsSidebarContent() {
|
|
59
21
|
const {
|
|
60
22
|
params: {
|
|
@@ -63,8 +25,7 @@ export default function DataViewsSidebarContent() {
|
|
|
63
25
|
isCustom = 'false'
|
|
64
26
|
}
|
|
65
27
|
} = useLocation();
|
|
66
|
-
|
|
67
|
-
const DEFAULT_VIEWS = useDefaultViews({
|
|
28
|
+
const defaultViews = useDefaultViews({
|
|
68
29
|
postType
|
|
69
30
|
});
|
|
70
31
|
if (!postType) {
|
|
@@ -73,7 +34,7 @@ export default function DataViewsSidebarContent() {
|
|
|
73
34
|
const isCustomBoolean = isCustom === 'true';
|
|
74
35
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
75
36
|
children: [/*#__PURE__*/_jsx(ItemGroup, {
|
|
76
|
-
children:
|
|
37
|
+
children: defaultViews.map(dataview => {
|
|
77
38
|
return /*#__PURE__*/_jsx(DataViewItem, {
|
|
78
39
|
slug: dataview.slug,
|
|
79
40
|
title: dataview.title,
|