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: revert list view as default for pages #58081

Merged
merged 9 commits into from
Jan 23, 2024
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 @@ -24,23 +24,28 @@ export default function useLayoutAreas() {

// 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 ) {
oandregal marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -169,18 +169,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 @@ -421,7 +409,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
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 @@ -104,7 +104,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' &&
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