Skip to content

Commit

Permalink
DataViews: revert list view as default for pages (#58081)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
oandregal and ntsekouras authored Jan 23, 2024
1 parent fab426a commit 41d6a41
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 35 deletions.
27 changes: 16 additions & 11 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ export default function useLayoutAreas() {
const { postType, postId, path, layout, isCustom } = params ?? {};
// Regular page
if ( path === '/page' ) {
const isListLayout =
isCustom !== 'true' && ( ! layout || layout === 'list' );
return {
areas: {
content: window.__experimentalAdminViews ? (
<PagePages />
) : undefined,
preview: ( isListLayout ||
! window.__experimentalAdminViews ) && (
content: undefined,
preview: <Editor isLoading={ isSiteEditorLoading } />,
},
widths: {
content: undefined,
},
};
}

if ( path === '/pages' && window?.__experimentalAdminViews ) {
const isListLayout = isCustom !== 'true' && layout === 'list';
return {
areas: {
content: <PagePages />,
preview: isListLayout && (
<Editor isLoading={ isSiteEditorLoading } />
),
},
widths: {
content:
window.__experimentalAdminViews && isListLayout
? 380
: undefined,
content: isListLayout ? 380 : undefined,
},
};
}
Expand Down
13 changes: 0 additions & 13 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,6 @@ export default function PagePages() {
[ history, params, view?.type, isCustom ]
);

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

const queryArgs = useMemo( () => {
const filters = {};
view.filters.forEach( ( filter ) => {
Expand Down Expand Up @@ -430,7 +418,6 @@ export default function PagePages() {
view={ view }
onChangeView={ onChangeView }
onSelectionChange={ onSelectionChange }
onDetailsChange={ onDetailsChange }
/>
</Page>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const DEFAULT_CONFIG_PER_VIEW_TYPE = {
};

const DEFAULT_PAGE_BASE = {
type: LAYOUT_LIST,
type: LAYOUT_TABLE,
search: '',
filters: [],
page: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DataViewItem from './dataview-item';
import CustomDataViewsList from './custom-dataviews-list';

const PATH_TO_TYPE = {
'/page': 'page',
'/pages': 'page',
};

export default function DataViewsSidebarContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function SidebarNavigationScreenPagesDataViews() {
title={ __( 'Pages' ) }
description={ __( 'Browse and manage pages.' ) }
content={ <DataViewsSidebarContent /> }
backPath="/page"
footer={
<VStack spacing={ 0 }>
{ templates?.map( ( item ) => (
Expand Down
11 changes: 6 additions & 5 deletions packages/edit-site/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ function SidebarScreens() {
<SidebarNavigationScreenGlobalStyles />
</SidebarScreenWrapper>
<SidebarScreenWrapper path="/page">
{ window?.__experimentalAdminViews ? (
<SidebarNavigationScreenPagesDataViews />
) : (
<SidebarNavigationScreenPages />
) }
<SidebarNavigationScreenPages />
</SidebarScreenWrapper>
{ window?.__experimentalAdminViews && (
<SidebarScreenWrapper path="/pages">
<SidebarNavigationScreenPagesDataViews />
</SidebarScreenWrapper>
) }
<SidebarScreenWrapper path="/page/:postId">
<SidebarNavigationScreenPage />
</SidebarScreenWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) {
}

// Some URLs in list views are different
if ( path === '/page' && postId ) {
if ( path === '/pages' && postId ) {
return resolveTemplateForPostTypeAndId( 'page', postId );
}

Expand Down Expand Up @@ -196,7 +196,7 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) {
}

// Some URLs in list views are different
if ( path === '/page' && postId ) {
if ( path === '/pages' && postId ) {
return { postType: 'page', postId };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function useSyncPathWithURL() {
} else if (
// These sidebar paths are special in the sense that the url in these pages may or may not have a postId and we need to retain it if it has.
// The "type" property should be kept as well.
( navigatorLocation.path === '/page' &&
( navigatorLocation.path === '/pages' &&
window?.__experimentalAdminViews ) ||
( navigatorLocation.path === '/wp_template/all' &&
window?.__experimentalAdminViews ) ||
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/utils/get-is-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function getIsListPage(
) {
return (
[ '/wp_template/all', '/wp_template_part/all' ].includes( path ) ||
( path === '/page' && window?.__experimentalAdminViews ) ||
( path === '/pages' && 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

0 comments on commit 41d6a41

Please sign in to comment.