-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Site Editor: Redesign table views #50766
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e09ad12
add page component
SaxonF eef5c5c
hooked up filtering and table
SaxonF 80b1c9b
clean up and add new to page component
SaxonF 1299294
style updates to templates page
SaxonF c475b7f
templates page title
SaxonF c31318e
template parts using new page component
SaxonF a253ae8
change page header size
SaxonF 9f08386
remove tanstack table
SaxonF e81c8ef
Merge branch 'trunk' into try/table-view
SaxonF acec789
Merge branch 'trunk' into try/table-view
SaxonF f8f7884
Merge branch 'trunk' into try/table-view
SaxonF bf43495
Merge branch 'trunk' into try/table-view
SaxonF 69fec59
remove filter bar for now and simplify code
SaxonF 086596c
update package lock
SaxonF 3a69e20
revert package lock
SaxonF 85ed2fa
mobile styles for table view
SaxonF d6516a5
Fix page header z-index
jameskoster c4bd21b
Don't show description wrapper if description is empty
jameskoster 4956497
Adjust alignment of last item in each row
jameskoster 854cb4c
fix table padding and scroll
SaxonF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
packages/edit-site/src/components/page-library/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
VisuallyHidden, | ||
__experimentalHeading as Heading, | ||
__experimentalVStack as VStack, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore, useEntityRecords } from '@wordpress/core-data'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Page from '../page'; | ||
import Table from '../table'; | ||
import Link from '../routes/link'; | ||
import AddedBy from '../list/added-by'; | ||
import TemplateActions from '../template-actions'; | ||
import AddNewTemplate from '../add-new-template'; | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
export default function PageTemplates() { | ||
const { records: templateParts } = useEntityRecords( | ||
'postType', | ||
'wp_template_part', | ||
{ | ||
per_page: -1, | ||
} | ||
); | ||
|
||
const { canCreate } = useSelect( ( select ) => { | ||
const { supportsTemplatePartsMode } = | ||
select( editSiteStore ).getSettings(); | ||
return { | ||
postType: select( coreStore ).getPostType( 'wp_template_part' ), | ||
canCreate: ! supportsTemplatePartsMode, | ||
}; | ||
} ); | ||
|
||
const columns = [ | ||
{ | ||
header: __( 'Template Part' ), | ||
cell: ( templatePart ) => ( | ||
<VStack> | ||
<Heading level={ 5 }> | ||
<Link | ||
params={ { | ||
postId: templatePart.id, | ||
postType: templatePart.type, | ||
canvas: 'edit', | ||
} } | ||
> | ||
{ decodeEntities( | ||
templatePart.title?.rendered || | ||
templatePart.slug | ||
) } | ||
</Link> | ||
</Heading> | ||
</VStack> | ||
), | ||
maxWidth: 400, | ||
}, | ||
{ | ||
header: __( 'Added by' ), | ||
cell: ( templatePart ) => ( | ||
<AddedBy | ||
postType={ templatePart.type } | ||
postId={ templatePart.id } | ||
/> | ||
), | ||
}, | ||
{ | ||
header: <VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>, | ||
cell: ( templatePart ) => ( | ||
<TemplateActions | ||
postType={ templatePart.type } | ||
postId={ templatePart.id } | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Page | ||
title={ __( 'Template Parts' ) } | ||
actions={ | ||
canCreate && ( | ||
<AddNewTemplate | ||
templateType={ 'wp_template_part' } | ||
showIcon={ false } | ||
toggleProps={ { variant: 'primary' } } | ||
/> | ||
) | ||
} | ||
> | ||
{ templateParts && ( | ||
<Table data={ templateParts } columns={ columns } /> | ||
) } | ||
</Page> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { privateApis as routerPrivateApis } from '@wordpress/router'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import PageTemplates from '../page-templates'; | ||
import PageLibrary from '../page-library'; | ||
import { unlock } from '../../private-apis'; | ||
|
||
const { useLocation } = unlock( routerPrivateApis ); | ||
|
||
export default function PageMain() { | ||
const { | ||
params: { path }, | ||
} = useLocation(); | ||
|
||
if ( path === '/wp_template/all' ) { | ||
return <PageTemplates />; | ||
} else if ( path === '/wp_template_part/all' ) { | ||
return <PageLibrary />; | ||
} | ||
|
||
return null; | ||
} |
104 changes: 104 additions & 0 deletions
104
packages/edit-site/src/components/page-templates/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
VisuallyHidden, | ||
__experimentalHeading as Heading, | ||
__experimentalText as Text, | ||
__experimentalVStack as VStack, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore, useEntityRecords } from '@wordpress/core-data'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Page from '../page'; | ||
import Table from '../table'; | ||
import Link from '../routes/link'; | ||
import AddedBy from '../list/added-by'; | ||
import TemplateActions from '../template-actions'; | ||
import AddNewTemplate from '../add-new-template'; | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
export default function PageTemplates() { | ||
const { records: templates } = useEntityRecords( | ||
'postType', | ||
'wp_template', | ||
{ | ||
per_page: -1, | ||
} | ||
); | ||
|
||
const { canCreate } = useSelect( ( select ) => { | ||
const { supportsTemplatePartsMode } = | ||
select( editSiteStore ).getSettings(); | ||
return { | ||
postType: select( coreStore ).getPostType( 'wp_template' ), | ||
canCreate: ! supportsTemplatePartsMode, | ||
}; | ||
} ); | ||
|
||
const columns = [ | ||
{ | ||
header: __( 'Template' ), | ||
cell: ( template ) => ( | ||
<VStack> | ||
<Heading level={ 5 }> | ||
<Link | ||
params={ { | ||
postId: template.id, | ||
postType: template.type, | ||
canvas: 'edit', | ||
} } | ||
> | ||
{ decodeEntities( | ||
template.title?.rendered || template.slug | ||
) } | ||
</Link> | ||
</Heading> | ||
{ template.description && ( | ||
<Text variant="muted"> | ||
{ decodeEntities( template.description ) } | ||
</Text> | ||
) } | ||
</VStack> | ||
), | ||
maxWidth: 400, | ||
}, | ||
{ | ||
header: __( 'Added by' ), | ||
cell: ( template ) => ( | ||
<AddedBy postType={ template.type } postId={ template.id } /> | ||
), | ||
}, | ||
{ | ||
header: <VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>, | ||
cell: ( template ) => ( | ||
<TemplateActions | ||
postType={ template.type } | ||
postId={ template.id } | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Page | ||
title={ __( 'Templates' ) } | ||
actions={ | ||
canCreate && ( | ||
<AddNewTemplate | ||
templateType={ 'wp_template' } | ||
showIcon={ false } | ||
toggleProps={ { variant: 'primary' } } | ||
/> | ||
) | ||
} | ||
> | ||
{ templates && <Table data={ templates } columns={ columns } /> } | ||
</Page> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to render a loading spinner or something like that as a follow-up?
Also for an empty list?