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: make the "Manage Pages" stable #58166

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -38,8 +38,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 @@ -64,10 +70,6 @@ export default function useLayoutAreas() {

// Templates
if ( path === '/wp_template/all' ) {
const isListLayout =
isCustom !== 'true' &&
layout === 'list' &&
window?.__experimentalAdminViews;
return {
areas: {
content: (
Expand All @@ -87,10 +89,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
Loading