@wordpress/edit-site 6.4.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/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/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 +21 -6
- 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-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 +50 -59
- package/build/components/global-styles/shadows-edit-panel.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 +8 -226
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +26 -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 +18 -6
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +19 -15
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +125 -67
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +2 -2
- package/build/components/sidebar-dataviews/add-new-view.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 +2 -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-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/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 +21 -6
- 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-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 +51 -60
- package/build-module/components/global-styles/shadows-edit-panel.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 +11 -229
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +26 -1
- 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 +20 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +19 -15
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +127 -69
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +2 -2
- package/build-module/components/sidebar-dataviews/add-new-view.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 +2 -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-style/posts-rtl.css +190 -11
- package/build-style/posts.css +190 -11
- package/build-style/style-rtl.css +296 -55
- package/build-style/style.css +296 -55
- 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/utils.js +10 -6
- package/src/components/editor/index.js +80 -22
- package/src/components/editor/style.scss +59 -1
- 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 +23 -5
- package/src/components/global-styles/font-library-modal/style.scss +1 -1
- package/src/components/global-styles/font-library-modal/upload-fonts.js +2 -2
- 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 +66 -73
- 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 +15 -244
- package/src/components/page-patterns/style.scss +82 -85
- package/src/components/page-patterns/use-patterns.js +31 -1
- 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 +27 -8
- package/src/components/post-fields/index.js +29 -17
- package/src/components/post-list/index.js +134 -74
- package/src/components/sidebar-dataviews/add-new-view.js +2 -4
- 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 +2 -3
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
- package/src/index.js +0 -2
- 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
|
@@ -188,15 +188,16 @@ function usePostFields(viewType) {
|
|
|
188
188
|
item
|
|
189
189
|
}) => {
|
|
190
190
|
const addLink = [LAYOUT_TABLE, LAYOUT_GRID].includes(viewType) && item.status !== 'trash';
|
|
191
|
+
const renderedTitle = typeof item.title === 'string' ? item.title : item.title?.rendered;
|
|
191
192
|
const title = addLink ? /*#__PURE__*/_jsx(Link, {
|
|
192
193
|
params: {
|
|
193
194
|
postId: item.id,
|
|
194
195
|
postType: item.type,
|
|
195
196
|
canvas: 'edit'
|
|
196
197
|
},
|
|
197
|
-
children: decodeEntities(
|
|
198
|
+
children: decodeEntities(renderedTitle) || __('(no title)')
|
|
198
199
|
}) : /*#__PURE__*/_jsx("span", {
|
|
199
|
-
children: decodeEntities(
|
|
200
|
+
children: decodeEntities(renderedTitle) || __('(no title)')
|
|
200
201
|
});
|
|
201
202
|
let suffix = '';
|
|
202
203
|
if (item.id === frontPageId) {
|
|
@@ -221,9 +222,7 @@ function usePostFields(viewType) {
|
|
|
221
222
|
}, {
|
|
222
223
|
label: __('Author'),
|
|
223
224
|
id: 'author',
|
|
224
|
-
|
|
225
|
-
item
|
|
226
|
-
}) => item._embedded?.author[0]?.name,
|
|
225
|
+
type: 'integer',
|
|
227
226
|
elements: authors?.map(({
|
|
228
227
|
id,
|
|
229
228
|
name
|
|
@@ -231,7 +230,12 @@ function usePostFields(viewType) {
|
|
|
231
230
|
value: id,
|
|
232
231
|
label: name
|
|
233
232
|
})) || [],
|
|
234
|
-
render: PostAuthorField
|
|
233
|
+
render: PostAuthorField,
|
|
234
|
+
sort: (a, b, direction) => {
|
|
235
|
+
const nameA = a._embedded?.author?.[0]?.name || '';
|
|
236
|
+
const nameB = b._embedded?.author?.[0]?.name || '';
|
|
237
|
+
return direction === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
|
|
238
|
+
}
|
|
235
239
|
}, {
|
|
236
240
|
label: __('Status'),
|
|
237
241
|
id: 'status',
|
|
@@ -271,8 +275,16 @@ function usePostFields(viewType) {
|
|
|
271
275
|
time: /*#__PURE__*/_jsx("time", {})
|
|
272
276
|
});
|
|
273
277
|
}
|
|
278
|
+
const isPublished = item.status === 'publish';
|
|
279
|
+
if (isPublished) {
|
|
280
|
+
return createInterpolateElement(sprintf( /* translators: %s: page creation time */
|
|
281
|
+
__('<span>Published: <time>%s</time></span>'), getFormattedDate(item.date)), {
|
|
282
|
+
span: /*#__PURE__*/_jsx("span", {}),
|
|
283
|
+
time: /*#__PURE__*/_jsx("time", {})
|
|
284
|
+
});
|
|
285
|
+
}
|
|
274
286
|
|
|
275
|
-
// Pending
|
|
287
|
+
// Pending posts show the modified date if it's newer.
|
|
276
288
|
const dateToDisplay = getDate(item.modified) > getDate(item.date) ? item.modified : item.date;
|
|
277
289
|
const isPending = item.status === 'pending';
|
|
278
290
|
if (isPending) {
|
|
@@ -282,14 +294,6 @@ function usePostFields(viewType) {
|
|
|
282
294
|
time: /*#__PURE__*/_jsx("time", {})
|
|
283
295
|
});
|
|
284
296
|
}
|
|
285
|
-
const isPublished = item.status === 'publish';
|
|
286
|
-
if (isPublished) {
|
|
287
|
-
return createInterpolateElement(sprintf( /* translators: %s: the newest of created or modified date for the page */
|
|
288
|
-
__('<span>Published: <time>%s</time></span>'), getFormattedDate(dateToDisplay)), {
|
|
289
|
-
span: /*#__PURE__*/_jsx("span", {}),
|
|
290
|
-
time: /*#__PURE__*/_jsx("time", {})
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
297
|
|
|
294
298
|
// Unknow status.
|
|
295
299
|
return /*#__PURE__*/_jsx("time", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","sprintf","decodeEntities","createInterpolateElement","useMemo","useState","dateI18n","getDate","getSettings","trash","drafts","published","scheduled","pending","notAllowed","commentAuthorAvatar","authorIcon","__experimentalHStack","HStack","Icon","useSelect","useEntityRecords","store","coreStore","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","OPERATOR_IS_ANY","default","Link","useLink","Media","jsx","_jsx","jsxs","_jsxs","STATUSES","value","label","icon","getFormattedDate","dateToDisplay","formats","datetimeAbbreviated","FeaturedImage","item","viewType","isDisabled","status","onClick","postId","id","postType","type","canvas","hasMedia","featured_media","size","media","className","renderButton","children","title","rendered","PostStatusField","find","alignment","spacing","PostAuthorField","text","imageUrl","select","getUser","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","onLoad","alt","src","usePostFields","records","authors","isResolving","isLoadingAuthors","per_page","frontPageId","postsPageId","getEntityRecord","siteSettings","page_on_front","page_for_posts","fields","getValue","render","enableSorting","raw","addLink","includes","params","suffix","justify","enableHiding","_embedded","elements","map","_STATUSES$find$label","filterBy","operators","isDraftOrPrivate","date","span","time","isScheduled","modified","isPending","isPublished","isLoading"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tcreateInterpolateElement,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n\tcommentAuthorAvatar as authorIcon,\n} from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\nimport { default as Link, useLink } from '../routes/link';\nimport Media from '../media';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{ value: 'draft', label: __( 'Draft' ), icon: drafts },\n\t{ value: 'future', label: __( 'Scheduled' ), icon: scheduled },\n\t{ value: 'pending', label: __( 'Pending Review' ), icon: pending },\n\t{ value: 'private', label: __( 'Private' ), icon: notAllowed },\n\t{ value: 'publish', label: __( 'Published' ), icon: published },\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nconst getFormattedDate = ( dateToDisplay ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nfunction FeaturedImage( { item, viewType } ) {\n\tconst isDisabled = item.status === 'trash';\n\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\tconst hasMedia = !! item.featured_media;\n\tconst size =\n\t\tviewType === LAYOUT_GRID\n\t\t\t? [ 'large', 'full', 'medium', 'thumbnail' ]\n\t\t\t: [ 'thumbnail', 'medium', 'large', 'full' ];\n\tconst media = hasMedia ? (\n\t\t<Media\n\t\t\tclassName=\"edit-site-post-list__featured-image\"\n\t\t\tid={ item.featured_media }\n\t\t\tsize={ size }\n\t\t/>\n\t) : null;\n\tconst renderButton = viewType !== LAYOUT_LIST && ! isDisabled;\n\treturn (\n\t\t<div\n\t\t\tclassName={ `edit-site-post-list__featured-image-wrapper is-layout-${ viewType }` }\n\t\t>\n\t\t\t{ renderButton ? (\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"edit-site-post-list__featured-image-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 || __( '(no title)' ) }\n\t\t\t\t>\n\t\t\t\t\t{ media }\n\t\t\t\t</button>\n\t\t\t) : (\n\t\t\t\tmedia\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction PostStatusField( { item } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-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>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction usePostFields( viewType ) {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tid: 'featured-image',\n\t\t\t\tlabel: __( 'Featured Image' ),\n\t\t\t\tgetValue: ( { item } ) => item.featured_media,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<FeaturedImage item={ item } viewType={ viewType } />\n\t\t\t\t),\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Title' ),\n\t\t\t\tid: 'title',\n\t\t\t\ttype: 'text',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t: item.title?.raw,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst addLink =\n\t\t\t\t\t\t[ LAYOUT_TABLE, LAYOUT_GRID ].includes( viewType ) &&\n\t\t\t\t\t\titem.status !== 'trash';\n\t\t\t\t\tconst title = addLink ? (\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( item.title?.rendered ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ decodeEntities( item.title?.rendered ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t);\n\n\t\t\t\t\tlet suffix = '';\n\t\t\t\t\tif ( item.id === frontPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Homepage' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( item.id === postsPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Posts Page' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tclassName=\"edit-site-post-list__title\"\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item._embedded?.author[ 0 ]?.name,\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Status' ),\n\t\t\t\tid: 'status',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\tSTATUSES.find( ( { value } ) => value === item.status )\n\t\t\t\t\t\t?.label ?? item.status,\n\t\t\t\telements: STATUSES,\n\t\t\t\trender: PostStatusField,\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [ OPERATOR_IS_ANY ],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Date' ),\n\t\t\t\tid: 'date',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\t\t\t\t\titem.status\n\t\t\t\t\t);\n\t\t\t\t\tif ( isDraftOrPrivate ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isScheduled = item.status === 'future';\n\t\t\t\t\tif ( isScheduled ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Pending & Published posts show the modified date if it's newer.\n\t\t\t\t\tconst dateToDisplay =\n\t\t\t\t\t\tgetDate( item.modified ) > getDate( item.date )\n\t\t\t\t\t\t\t? item.modified\n\t\t\t\t\t\t\t: item.date;\n\n\t\t\t\t\tconst isPending = item.status === 'pending';\n\t\t\t\t\tif ( isPending ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: the newest of created or modified date for the page */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( dateToDisplay )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isPublished = item.status === 'publish';\n\t\t\t\t\tif ( isPublished ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: the newest of created or modified date for the page */\n\t\t\t\t\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( dateToDisplay )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Unknow status.\n\t\t\t\t\treturn <time>{ getFormattedDate( item.date ) }</time>;\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\t[ authors, viewType, frontPageId, postsPageId ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SACCC,wBAAwB,EACxBC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ACmE,IAAK,CAAC,GAC5CnE,IAAI,CAACuE,QAAQ,GACbvE,IAAI,CAACmE,IAAI;MAEb,MAAMK,SAAS,GAAGxE,IAAI,CAACG,MAAM,KAAK,SAAS;MAC3C,IAAKqE,SAAS,EAAG;QAChB,OAAOlH,wBAAwB,CAC9BF,OAAO,EACN;QACAD,EAAE,CAAE,wCAAyC,CAAC,EAC9CwC,gBAAgB,CAAEC,aAAc,CACjC,CAAC,EACD;UACCwE,IAAI,eAAEhF,IAAA,WAAO,CAAC;UACdiF,IAAI,eAAEjF,IAAA,WAAO;QACd,CACD,CAAC;MACF;MAEA,MAAMqF,WAAW,GAAGzE,IAAI,CAACG,MAAM,KAAK,SAAS;MAC7C,IAAKsE,WAAW,EAAG;QAClB,OAAOnH,wBAAwB,CAC9BF,OAAO,EACN;QACAD,EAAE,CAAE,yCAA0C,CAAC,EAC/CwC,gBAAgB,CAAEC,aAAc,CACjC,CAAC,EACD;UACCwE,IAAI,eAAEhF,IAAA,WAAO,CAAC;UACdiF,IAAI,eAAEjF,IAAA,WAAO;QACd,CACD,CAAC;MACF;;MAEA;MACA,oBAAOA,IAAA;QAAA4B,QAAA,EAAQrB,gBAAgB,CAAEK,IAAI,CAACmE,IAAK;MAAC,CAAQ,CAAC;IACtD;EACD,CAAC,CACD,EACD,CAAE5B,OAAO,EAAEtC,QAAQ,EAAE0C,WAAW,EAAEC,WAAW,CAC9C,CAAC;EAED,OAAO;IACN8B,SAAS,EAAEjC,gBAAgB;IAC3BQ;EACD,CAAC;AACF;AAEA,eAAeZ,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__","sprintf","decodeEntities","createInterpolateElement","useMemo","useState","dateI18n","getDate","getSettings","trash","drafts","published","scheduled","pending","notAllowed","commentAuthorAvatar","authorIcon","__experimentalHStack","HStack","Icon","useSelect","useEntityRecords","store","coreStore","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","OPERATOR_IS_ANY","default","Link","useLink","Media","jsx","_jsx","jsxs","_jsxs","STATUSES","value","label","icon","getFormattedDate","dateToDisplay","formats","datetimeAbbreviated","FeaturedImage","item","viewType","isDisabled","status","onClick","postId","id","postType","type","canvas","hasMedia","featured_media","size","media","className","renderButton","children","title","rendered","PostStatusField","find","alignment","spacing","PostAuthorField","text","imageUrl","select","getUser","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","onLoad","alt","src","usePostFields","records","authors","isResolving","isLoadingAuthors","per_page","frontPageId","postsPageId","getEntityRecord","siteSettings","page_on_front","page_for_posts","fields","getValue","render","enableSorting","raw","addLink","includes","renderedTitle","params","suffix","justify","enableHiding","elements","map","sort","a","b","direction","nameA","_embedded","nameB","localeCompare","_STATUSES$find$label","filterBy","operators","isDraftOrPrivate","date","span","time","isScheduled","isPublished","modified","isPending","isLoading"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tcreateInterpolateElement,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n\tcommentAuthorAvatar as authorIcon,\n} from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\nimport { default as Link, useLink } from '../routes/link';\nimport Media from '../media';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{ value: 'draft', label: __( 'Draft' ), icon: drafts },\n\t{ value: 'future', label: __( 'Scheduled' ), icon: scheduled },\n\t{ value: 'pending', label: __( 'Pending Review' ), icon: pending },\n\t{ value: 'private', label: __( 'Private' ), icon: notAllowed },\n\t{ value: 'publish', label: __( 'Published' ), icon: published },\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nconst getFormattedDate = ( dateToDisplay ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nfunction FeaturedImage( { item, viewType } ) {\n\tconst isDisabled = item.status === 'trash';\n\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\tconst hasMedia = !! item.featured_media;\n\tconst size =\n\t\tviewType === LAYOUT_GRID\n\t\t\t? [ 'large', 'full', 'medium', 'thumbnail' ]\n\t\t\t: [ 'thumbnail', 'medium', 'large', 'full' ];\n\tconst media = hasMedia ? (\n\t\t<Media\n\t\t\tclassName=\"edit-site-post-list__featured-image\"\n\t\t\tid={ item.featured_media }\n\t\t\tsize={ size }\n\t\t/>\n\t) : null;\n\tconst renderButton = viewType !== LAYOUT_LIST && ! isDisabled;\n\treturn (\n\t\t<div\n\t\t\tclassName={ `edit-site-post-list__featured-image-wrapper is-layout-${ viewType }` }\n\t\t>\n\t\t\t{ renderButton ? (\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"edit-site-post-list__featured-image-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 || __( '(no title)' ) }\n\t\t\t\t>\n\t\t\t\t\t{ media }\n\t\t\t\t</button>\n\t\t\t) : (\n\t\t\t\tmedia\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction PostStatusField( { item } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-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>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction usePostFields( viewType ) {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tid: 'featured-image',\n\t\t\t\tlabel: __( 'Featured Image' ),\n\t\t\t\tgetValue: ( { item } ) => item.featured_media,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<FeaturedImage item={ item } viewType={ viewType } />\n\t\t\t\t),\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Title' ),\n\t\t\t\tid: 'title',\n\t\t\t\ttype: 'text',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t: item.title?.raw,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst addLink =\n\t\t\t\t\t\t[ LAYOUT_TABLE, LAYOUT_GRID ].includes( viewType ) &&\n\t\t\t\t\t\titem.status !== 'trash';\n\t\t\t\t\tconst renderedTitle =\n\t\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t\t: item.title?.rendered;\n\t\t\t\t\tconst title = addLink ? (\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t);\n\n\t\t\t\t\tlet suffix = '';\n\t\t\t\t\tif ( item.id === frontPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Homepage' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( item.id === postsPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Posts Page' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tclassName=\"edit-site-post-list__title\"\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\ttype: 'integer',\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t\tsort: ( a, b, direction ) => {\n\t\t\t\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\t\t\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\t\t\t\treturn direction === 'asc'\n\t\t\t\t\t\t? nameA.localeCompare( nameB )\n\t\t\t\t\t\t: nameB.localeCompare( nameA );\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Status' ),\n\t\t\t\tid: 'status',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\tSTATUSES.find( ( { value } ) => value === item.status )\n\t\t\t\t\t\t?.label ?? item.status,\n\t\t\t\telements: STATUSES,\n\t\t\t\trender: PostStatusField,\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [ OPERATOR_IS_ANY ],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Date' ),\n\t\t\t\tid: 'date',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\t\t\t\t\titem.status\n\t\t\t\t\t);\n\t\t\t\t\tif ( isDraftOrPrivate ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isScheduled = item.status === 'future';\n\t\t\t\t\tif ( isScheduled ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isPublished = item.status === 'publish';\n\t\t\t\t\tif ( isPublished ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation time */\n\t\t\t\t\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Pending posts show the modified date if it's newer.\n\t\t\t\t\tconst dateToDisplay =\n\t\t\t\t\t\tgetDate( item.modified ) > getDate( item.date )\n\t\t\t\t\t\t\t? item.modified\n\t\t\t\t\t\t\t: item.date;\n\n\t\t\t\t\tconst isPending = item.status === 'pending';\n\t\t\t\t\tif ( isPending ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: the newest of created or modified date for the page */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( dateToDisplay )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Unknow status.\n\t\t\t\t\treturn <time>{ getFormattedDate( item.date ) }</time>;\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\t[ authors, viewType, frontPageId, postsPageId ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC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;MAAC,CAAQ,CAAC;IACtD;EACD,CAAC,CACD,EACD,CAAEpC,OAAO,EAAEtC,QAAQ,EAAE0C,WAAW,EAAEC,WAAW,CAC9C,CAAC;EAED,OAAO;IACNsC,SAAS,EAAEzC,gBAAgB;IAC3BQ;EACD,CAAC;AACF;AAEA,eAAeZ,aAAa","ignoreList":[]}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Button } from '@wordpress/components';
|
|
5
|
-
import {
|
|
5
|
+
import { store as coreStore, privateApis as coreDataPrivateApis } from '@wordpress/core-data';
|
|
6
6
|
import { useState, useMemo, useCallback, useEffect } from '@wordpress/element';
|
|
7
7
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
8
8
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
-
import { DataViews } from '@wordpress/dataviews';
|
|
9
|
+
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
|
|
10
10
|
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { drawerRight } from '@wordpress/icons';
|
|
@@ -32,7 +32,39 @@ const {
|
|
|
32
32
|
useLocation,
|
|
33
33
|
useHistory
|
|
34
34
|
} = unlock(routerPrivateApis);
|
|
35
|
+
const {
|
|
36
|
+
useEntityRecordsWithPermissions
|
|
37
|
+
} = unlock(coreDataPrivateApis);
|
|
35
38
|
const EMPTY_ARRAY = [];
|
|
39
|
+
const getDefaultView = (defaultViews, activeView) => {
|
|
40
|
+
return defaultViews.find(({
|
|
41
|
+
slug
|
|
42
|
+
}) => slug === activeView)?.view;
|
|
43
|
+
};
|
|
44
|
+
const getCustomView = editedEntityRecord => {
|
|
45
|
+
if (!editedEntityRecord?.content) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const content = JSON.parse(editedEntityRecord.content);
|
|
49
|
+
if (!content) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
...content,
|
|
54
|
+
layout: defaultLayouts[content.type]?.layout
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This function abstracts working with default & custom views by
|
|
60
|
+
* providing a [ state, setState ] tuple based on the URL parameters.
|
|
61
|
+
*
|
|
62
|
+
* Consumers use the provided tuple to work with state
|
|
63
|
+
* and don't have to deal with the specifics of default & custom views.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} postType Post type to retrieve default views for.
|
|
66
|
+
* @return {Array} The [ state, setState ] tuple.
|
|
67
|
+
*/
|
|
36
68
|
function useView(postType) {
|
|
37
69
|
const {
|
|
38
70
|
params: {
|
|
@@ -42,75 +74,87 @@ function useView(postType) {
|
|
|
42
74
|
}
|
|
43
75
|
} = useLocation();
|
|
44
76
|
const history = useHistory();
|
|
45
|
-
const
|
|
77
|
+
const defaultViews = useDefaultViews({
|
|
46
78
|
postType
|
|
47
79
|
});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (isCustom === 'false' && layout) {
|
|
53
|
-
return {
|
|
54
|
-
...defaultView,
|
|
55
|
-
type: layout,
|
|
56
|
-
layout: defaultLayouts[layout]?.layout
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return defaultView;
|
|
60
|
-
}, [isCustom, activeView, layout, postType, DEFAULT_VIEWS]);
|
|
61
|
-
const [view, setView] = useState(selectedDefaultView);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (selectedDefaultView) {
|
|
64
|
-
setView(selectedDefaultView);
|
|
65
|
-
}
|
|
66
|
-
}, [selectedDefaultView]);
|
|
67
|
-
const editedViewRecord = useSelect(select => {
|
|
80
|
+
const {
|
|
81
|
+
editEntityRecord
|
|
82
|
+
} = useDispatch(coreStore);
|
|
83
|
+
const editedEntityRecord = useSelect(select => {
|
|
68
84
|
if (isCustom !== 'true') {
|
|
69
|
-
return;
|
|
85
|
+
return undefined;
|
|
70
86
|
}
|
|
71
87
|
const {
|
|
72
88
|
getEditedEntityRecord
|
|
73
89
|
} = select(coreStore);
|
|
74
|
-
|
|
75
|
-
return dataviewRecord;
|
|
90
|
+
return getEditedEntityRecord('postType', 'wp_dataviews', Number(activeView));
|
|
76
91
|
}, [activeView, isCustom]);
|
|
77
|
-
const {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
const [view, setView] = useState(() => {
|
|
93
|
+
let initialView;
|
|
94
|
+
if (isCustom === 'true') {
|
|
95
|
+
var _getCustomView;
|
|
96
|
+
initialView = (_getCustomView = getCustomView(editedEntityRecord)) !== null && _getCustomView !== void 0 ? _getCustomView : {
|
|
97
|
+
type: layout !== null && layout !== void 0 ? layout : LAYOUT_LIST
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
var _getDefaultView;
|
|
101
|
+
initialView = (_getDefaultView = getDefaultView(defaultViews, activeView)) !== null && _getDefaultView !== void 0 ? _getDefaultView : {
|
|
102
|
+
type: layout !== null && layout !== void 0 ? layout : LAYOUT_LIST
|
|
103
|
+
};
|
|
84
104
|
}
|
|
105
|
+
const type = layout !== null && layout !== void 0 ? layout : initialView.type;
|
|
85
106
|
return {
|
|
86
|
-
...
|
|
87
|
-
|
|
107
|
+
...initialView,
|
|
108
|
+
type
|
|
88
109
|
};
|
|
89
|
-
}
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
params
|
|
99
|
-
} = history.getLocationWithParams();
|
|
110
|
+
});
|
|
111
|
+
const setViewWithUrlUpdate = useCallback(newView => {
|
|
112
|
+
const {
|
|
113
|
+
params
|
|
114
|
+
} = history.getLocationWithParams();
|
|
115
|
+
if (newView.type === LAYOUT_LIST && !params?.layout) {
|
|
116
|
+
// Skip updating the layout URL param if
|
|
117
|
+
// it is not present and the newView.type is LAYOUT_LIST.
|
|
118
|
+
} else if (newView.type !== params?.layout) {
|
|
100
119
|
history.push({
|
|
101
120
|
...params,
|
|
102
|
-
layout:
|
|
121
|
+
layout: newView.type
|
|
103
122
|
});
|
|
104
123
|
}
|
|
105
|
-
setView(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
setView(newView);
|
|
125
|
+
if (isCustom === 'true' && editedEntityRecord?.id) {
|
|
126
|
+
editEntityRecord('postType', 'wp_dataviews', editedEntityRecord?.id, {
|
|
127
|
+
content: JSON.stringify(newView)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, [history, isCustom, editEntityRecord, editedEntityRecord?.id]);
|
|
131
|
+
|
|
132
|
+
// When layout URL param changes, update the view type
|
|
133
|
+
// without affecting any other config.
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
setView(prevView => ({
|
|
136
|
+
...prevView,
|
|
137
|
+
type: layout !== null && layout !== void 0 ? layout : LAYOUT_LIST
|
|
138
|
+
}));
|
|
139
|
+
}, [layout]);
|
|
140
|
+
|
|
141
|
+
// When activeView or isCustom URL parameters change, reset the view.
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
let newView;
|
|
144
|
+
if (isCustom === 'true') {
|
|
145
|
+
newView = getCustomView(editedEntityRecord);
|
|
146
|
+
} else {
|
|
147
|
+
newView = getDefaultView(defaultViews, activeView);
|
|
148
|
+
}
|
|
149
|
+
if (newView) {
|
|
150
|
+
const type = layout !== null && layout !== void 0 ? layout : newView.type;
|
|
151
|
+
setView({
|
|
152
|
+
...newView,
|
|
153
|
+
type
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, [activeView, isCustom, layout, defaultViews, editedEntityRecord]);
|
|
157
|
+
return [view, setViewWithUrlUpdate, setViewWithUrlUpdate];
|
|
114
158
|
}
|
|
115
159
|
const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.
|
|
116
160
|
|
|
@@ -120,13 +164,15 @@ function getItemId(item) {
|
|
|
120
164
|
export default function PostList({
|
|
121
165
|
postType
|
|
122
166
|
}) {
|
|
123
|
-
var _postId$split,
|
|
167
|
+
var _postId$split, _data$map, _usePrevious;
|
|
124
168
|
const [view, setView] = useView(postType);
|
|
125
169
|
const history = useHistory();
|
|
126
170
|
const location = useLocation();
|
|
127
171
|
const {
|
|
128
172
|
postId,
|
|
129
|
-
quickEdit = false
|
|
173
|
+
quickEdit = false,
|
|
174
|
+
isCustom,
|
|
175
|
+
activeView = 'all'
|
|
130
176
|
} = location.params;
|
|
131
177
|
const [selection, setSelection] = useState((_postId$split = postId?.split(',')) !== null && _postId$split !== void 0 ? _postId$split : []);
|
|
132
178
|
const onChangeSelection = useCallback(items => {
|
|
@@ -142,9 +188,13 @@ export default function PostList({
|
|
|
142
188
|
});
|
|
143
189
|
}
|
|
144
190
|
}, [history]);
|
|
191
|
+
const {
|
|
192
|
+
isLoading: isLoadingFields,
|
|
193
|
+
fields
|
|
194
|
+
} = usePostFields(view.type);
|
|
145
195
|
const queryArgs = useMemo(() => {
|
|
146
196
|
const filters = {};
|
|
147
|
-
view.filters
|
|
197
|
+
view.filters?.forEach(filter => {
|
|
148
198
|
if (filter.field === 'status' && filter.operator === OPERATOR_IS_ANY) {
|
|
149
199
|
filters.status = filter.value;
|
|
150
200
|
}
|
|
@@ -171,11 +221,23 @@ export default function PostList({
|
|
|
171
221
|
}, [view]);
|
|
172
222
|
const {
|
|
173
223
|
records,
|
|
174
|
-
isResolving:
|
|
224
|
+
isResolving: isLoadingData,
|
|
175
225
|
totalItems,
|
|
176
226
|
totalPages
|
|
177
|
-
} =
|
|
178
|
-
|
|
227
|
+
} = useEntityRecordsWithPermissions('postType', postType, queryArgs);
|
|
228
|
+
|
|
229
|
+
// The REST API sort the authors by ID, but we want to sort them by name.
|
|
230
|
+
const data = useMemo(() => {
|
|
231
|
+
if (!isLoadingFields && view?.sort?.field === 'author') {
|
|
232
|
+
return filterSortAndPaginate(records, {
|
|
233
|
+
sort: {
|
|
234
|
+
...view.sort
|
|
235
|
+
}
|
|
236
|
+
}, fields).data;
|
|
237
|
+
}
|
|
238
|
+
return records;
|
|
239
|
+
}, [records, fields, isLoadingFields, view?.sort]);
|
|
240
|
+
const ids = (_data$map = data?.map(record => getItemId(record))) !== null && _data$map !== void 0 ? _data$map : [];
|
|
179
241
|
const prevIds = (_usePrevious = usePrevious(ids)) !== null && _usePrevious !== void 0 ? _usePrevious : [];
|
|
180
242
|
const deletedIds = prevIds.filter(id => !ids.includes(id));
|
|
181
243
|
const postIdWasDeleted = deletedIds.includes(postId);
|
|
@@ -227,10 +289,6 @@ export default function PostList({
|
|
|
227
289
|
});
|
|
228
290
|
closeModal();
|
|
229
291
|
};
|
|
230
|
-
const {
|
|
231
|
-
isLoading: isLoadingFields,
|
|
232
|
-
fields
|
|
233
|
-
} = usePostFields(view.type);
|
|
234
292
|
return /*#__PURE__*/_jsx(Page, {
|
|
235
293
|
title: labels?.name,
|
|
236
294
|
actions: labels?.add_new_item && canCreateRecord && /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -249,8 +307,8 @@ export default function PostList({
|
|
|
249
307
|
paginationInfo: paginationInfo,
|
|
250
308
|
fields: fields,
|
|
251
309
|
actions: actions,
|
|
252
|
-
data:
|
|
253
|
-
isLoading:
|
|
310
|
+
data: data || EMPTY_ARRAY,
|
|
311
|
+
isLoading: isLoadingData || isLoadingFields,
|
|
254
312
|
view: view,
|
|
255
313
|
onChangeView: setView,
|
|
256
314
|
selection: selection,
|
|
@@ -269,7 +327,7 @@ export default function PostList({
|
|
|
269
327
|
});
|
|
270
328
|
}
|
|
271
329
|
})
|
|
272
|
-
})
|
|
330
|
+
}, activeView + isCustom)
|
|
273
331
|
});
|
|
274
332
|
}
|
|
275
333
|
//# sourceMappingURL=index.js.map
|
|
@@ -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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,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={\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,SA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AgB,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,EACJ,CAAE3E,SAAS,GACRpE,EAAE,CAAE,yBAA0B,CAAC,GAC/BA,EAAE,CAAE,0BAA2B,CAClC;QACDoI,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,GAjCKP,UAAU,GAAGe,QAkCnB;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: {
|