Skip to content

Commit

Permalink
DataViews: make the "Manage Pages" stable (#58166)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored Jan 24, 2024
1 parent 6c9fde4 commit 37ec4b6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 31 deletions.
18 changes: 8 additions & 10 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ export default function useLayoutAreas() {
};
}

if ( path === '/pages' && window?.__experimentalAdminViews ) {
const isListLayout = isCustom !== 'true' && layout === 'list';
// List layout is still experimental.
// Extracted it here out of the conditionals so it doesn't unintentionally becomes stable.
const isListLayout =
isCustom !== 'true' &&
layout === 'list' &&
window?.__experimentalAdminViews;

if ( path === '/pages' ) {
return {
areas: {
content: <PagePages />,
Expand All @@ -63,10 +69,6 @@ export default function useLayoutAreas() {

// Templates
if ( path === '/wp_template/all' ) {
const isListLayout =
isCustom !== 'true' &&
layout === 'list' &&
window?.__experimentalAdminViews;
return {
areas: {
content: (
Expand All @@ -86,10 +88,6 @@ export default function useLayoutAreas() {

// Template parts
if ( path === '/wp_template_part/all' ) {
const isListLayout =
isCustom !== 'true' &&
layout === 'list' &&
window?.__experimentalAdminViews;
return {
areas: {
content: (
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import { unlock } from '../../lock-unlock';
const { useLocation, useHistory } = unlock( routerPrivateApis );

const EMPTY_ARRAY = [];
const SUPPORTED_LAYOUTS = window?.__experimentalAdminViews
? [ LAYOUT_GRID, LAYOUT_TABLE, LAYOUT_LIST ]
: [ LAYOUT_GRID, LAYOUT_TABLE ];

function useView( postType ) {
const { params } = useLocation();
Expand Down Expand Up @@ -418,6 +421,7 @@ export default function PagePages() {
view={ view }
onChangeView={ onChangeView }
onSelectionChange={ onSelectionChange }
supportedLayouts={ SUPPORTED_LAYOUTS }
/>
</Page>
);
Expand Down
12 changes: 7 additions & 5 deletions packages/edit-site/src/components/sidebar-dataviews/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export default function DataViewsSidebarContent() {
);
} ) }
</ItemGroup>
<CustomDataViewsList
activeView={ activeView }
type={ type }
isCustom="true"
/>
{ window?.__experimentalAdminViews && (
<CustomDataViewsList
activeView={ activeView }
type={ type }
isCustom="true"
/>
) }
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ export default function SidebarNavigationScreenPages() {
};

const pagesLink = useLink( { path: '/pages' } );
const manageAllPagesProps = window?.__experimentalAdminViews
? { ...pagesLink }
: {
href: 'edit.php?post_type=page',
onClick: () => {
document.location = 'edit.php?post_type=page';
},
};

return (
<>
Expand Down Expand Up @@ -230,7 +222,7 @@ export default function SidebarNavigationScreenPages() {
) ) }
<SidebarNavigationItem
className="edit-site-sidebar-navigation-screen-pages__see-all"
{ ...manageAllPagesProps }
{ ...pagesLink }
>
{ __( 'Manage all pages' ) }
</SidebarNavigationItem>
Expand Down
8 changes: 3 additions & 5 deletions packages/edit-site/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ function SidebarScreens() {
<SidebarScreenWrapper path="/page">
<SidebarNavigationScreenPages />
</SidebarScreenWrapper>
{ window?.__experimentalAdminViews && (
<SidebarScreenWrapper path="/pages">
<SidebarNavigationScreenPagesDataViews />
</SidebarScreenWrapper>
) }
<SidebarScreenWrapper path="/pages">
<SidebarNavigationScreenPagesDataViews />
</SidebarScreenWrapper>
<SidebarScreenWrapper path="/page/:postId">
<SidebarNavigationScreenPage />
</SidebarScreenWrapper>
Expand Down
5 changes: 3 additions & 2 deletions packages/edit-site/src/utils/get-is-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export default function getIsListPage(
isMobileViewport
) {
return (
[ '/wp_template/all', '/wp_template_part/all' ].includes( path ) ||
( path === '/pages' && window?.__experimentalAdminViews ) ||
[ '/wp_template/all', '/wp_template_part/all', '/pages' ].includes(
path
) ||
( 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 37ec4b6

Please sign in to comment.