Skip to content

Commit

Permalink
DataViews: revert list view as default for templates (#58079)
Browse files Browse the repository at this point in the history
* Revert "DataViews: use table layout for templates when experiment disabled (#57960)"

This reverts commit e67f6fc.

* Revert list layout as default for templates

* Make table layout the default, even with the experiment active

* Revert changes to init edited entity
  • Loading branch information
oandregal authored Jan 23, 2024
1 parent cf3dbbc commit 38f8eaa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 49 deletions.
9 changes: 4 additions & 5 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ export default function useLayoutAreas() {
}

// Templates
if (
path === '/wp_template/all' ||
( path === '/wp_template' && window?.__experimentalAdminViews )
) {
if ( path === '/wp_template/all' ) {
const isListLayout =
isCustom !== 'true' && ( ! layout || layout === 'list' );
isCustom !== 'true' &&
layout === 'list' &&
window?.__experimentalAdminViews;
return {
areas: {
content: <PageTemplates />,
Expand Down
15 changes: 1 addition & 14 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const defaultConfigPerViewType = {
};

const DEFAULT_VIEW = {
type: window?.__experimentalAdminViews ? LAYOUT_LIST : LAYOUT_TABLE,
type: LAYOUT_TABLE,
search: '',
page: 1,
perPage: 20,
Expand Down Expand Up @@ -180,18 +180,6 @@ export default function DataviewsTemplates() {
[ history, params, view?.type ]
);

const onDetailsChange = useCallback(
( items ) => {
if ( items?.length === 1 ) {
history.push( {
postId: items[ 0 ].id,
postType: TEMPLATE_POST_TYPE,
} );
}
},
[ history ]
);

const authors = useMemo( () => {
if ( ! allTemplates ) {
return EMPTY_ARRAY;
Expand Down Expand Up @@ -390,7 +378,6 @@ export default function DataviewsTemplates() {
view={ view }
onChangeView={ onChangeView }
onSelectionChange={ onSelectionChange }
onDetailsChange={ onDetailsChange }
deferredRendering={ ! view.hiddenFields?.includes( 'preview' ) }
/>
</Page>
Expand Down
6 changes: 1 addition & 5 deletions packages/edit-site/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ function SidebarScreens() {
<SidebarNavigationScreenPage />
</SidebarScreenWrapper>
<SidebarScreenWrapper path="/:postType(wp_template)">
{ window?.__experimentalAdminViews ? (
<SidebarNavigationScreenTemplatesBrowse />
) : (
<SidebarNavigationScreenTemplates />
) }
<SidebarNavigationScreenTemplates />
</SidebarScreenWrapper>
<SidebarScreenWrapper path="/patterns">
<SidebarNavigationScreenPatterns />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,7 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) {
return {};
}, [ homepageId, postType, postId, path ] );

if (
( path === '/wp_template/all' ||
( path === '/wp_template' && window?.__experimentalAdminViews ) ) &&
postId
) {
if ( path === '/wp_template/all' && postId ) {
return { isReady: true, postType: 'wp_template', postId, context };
}

Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/utils/get-is-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function getIsListPage(
return (
[ '/wp_template/all', '/wp_template_part/all' ].includes( path ) ||
( path === '/page' && window?.__experimentalAdminViews ) ||
( path === '/wp_template' && window?.__experimentalAdminViews ) ||
( path === '/patterns' &&
// Don't treat "/patterns" without categoryType and categoryId as a
// list page in mobile because the sidebar covers the whole page.
Expand Down
22 changes: 3 additions & 19 deletions test/e2e/specs/site-editor/new-templates-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ test.describe( 'Templates', () => {
] );
} );
test( 'Sorting', async ( { admin, page } ) => {
await admin.visitSiteEditor( { path: '/wp_template' } );
// Switch to table layout.
await page.getByLabel( 'View options' ).click();
await page.getByRole( 'menuitem', { name: 'Layout' } ).click();
await page.getByRole( 'menuitemradio', { name: 'Table' } ).click();
await admin.visitSiteEditor( { path: '/wp_template/all' } );
// Descending by title.
await page
.getByRole( 'button', { name: 'Template', exact: true } )
Expand Down Expand Up @@ -52,13 +48,7 @@ test.describe( 'Templates', () => {
title: 'Date Archives',
content: 'hi',
} );
await admin.visitSiteEditor( { path: '/wp_template' } );

// Switch to table layout.
await page.getByLabel( 'View options' ).click();
await page.getByRole( 'menuitem', { name: 'Layout' } ).click();
await page.getByRole( 'menuitemradio', { name: 'Table' } ).click();

await admin.visitSiteEditor( { path: '/wp_template/all' } );
// Global search.
await page.getByRole( 'searchbox', { name: 'Filter list' } ).click();
await page.keyboard.type( 'tag' );
Expand Down Expand Up @@ -94,13 +84,7 @@ test.describe( 'Templates', () => {
await expect( titles ).toHaveCount( 2 );
} );
test( 'Field visibility', async ( { admin, page } ) => {
await admin.visitSiteEditor( { path: '/wp_template' } );

// Switch to table layout.
await page.getByLabel( 'View options' ).click();
await page.getByRole( 'menuitem', { name: 'Layout' } ).click();
await page.getByRole( 'menuitemradio', { name: 'Table' } ).click();

await admin.visitSiteEditor( { path: '/wp_template/all' } );
await page.getByRole( 'button', { name: 'Description' } ).click();
await page.getByRole( 'menuitem', { name: 'Hide' } ).click();
await expect(
Expand Down

0 comments on commit 38f8eaa

Please sign in to comment.