Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataViews: Combine featured image and title in the posts table #63449

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/post-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function useView( postType ) {
if ( isCustom === 'false' && layout ) {
return {
...defaultView,
...defaultLayouts[ layout ],
type: layout,
layout: defaultLayouts[ layout ]?.layout,
};
}
return defaultView;
Expand Down Expand Up @@ -124,7 +124,7 @@ function useView( postType ) {

return {
...storedView,
layout: defaultLayouts[ storedView?.type ]?.layout,
...defaultLayouts[ layout ],
};
}, [ editedViewRecord?.content ] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,38 @@ export const defaultLayouts = {
[ LAYOUT_TABLE ]: {
layout: {
primaryField: 'title',
combinedFields: [
{
id: 'post',
header: __( 'Title' ),
children: [ 'featured-image', 'title' ],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if Front Page and Posts Page could now also be a field. Not sure if that needs to be filterable though.

Copy link
Contributor

@jameskoster jameskoster Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The features associated with making these fields don't seem particularly useful to me. Columns in particular would add weight to the table, especially as all records except one will be false.

I appreciate it would make these pages a bit easier to locate, but not in a very ergonomic way. Add filter > is posts page > true isn't the quickest flow. Some alternatives we might consider could be:

  1. Add a dedicated view for pages associated with settings. It would include the front page, posts page, privacy policy page (if set), products page, cart, checkout (if Woo is installed), etc.
  2. Include the badge in when searching. IE if I search the All pages view for 'Front page', 'homepage', etc. then the static homepage should be listed even if the title doesn't contain those words.

Edit: I suppose they could be coded as fields, but 'hidden' in the UI except for the badge that exists today. Apologies if that was the implied idea and I went off on a tangent :)

direction: 'horizontal',
},
],
styles: {
'featured-image': {
width: '1%',
},
title: {
post: {
maxWidth: 300,
},
},
},
fields: [ 'post', 'author', 'status' ],
},
[ LAYOUT_GRID ]: {
layout: {
mediaField: 'featured-image',
primaryField: 'title',
},
fields: [ 'title', 'author', 'status' ],
},
[ LAYOUT_LIST ]: {
layout: {
primaryField: 'title',
mediaField: 'featured-image',
},
fields: [ 'title', 'author', 'status' ],
},
};

Expand All @@ -64,8 +75,8 @@ const DEFAULT_POST_BASE = {
field: 'date',
direction: 'desc',
},
fields: [ 'title', 'author', 'status' ],
layout: defaultLayouts[ LAYOUT_LIST ].layout,
fields: defaultLayouts[ LAYOUT_LIST ].fields,
};

export function useDefaultViews( { postType } ) {
Expand Down
Loading