Skip to content

Commit

Permalink
DataViews: make list layout stable (#59858)
Browse files Browse the repository at this point in the history
Co-authored-by: oandregal <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent 7ae3500 commit c187e22
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 37 deletions.
7 changes: 1 addition & 6 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ export default function useLayoutAreas() {
};
}

// 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;
const isListLayout = isCustom !== 'true' && layout === 'list';

if ( path === '/pages' ) {
return {
Expand Down
4 changes: 0 additions & 4 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ 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 @@ -429,7 +426,6 @@ export default function PagePages() {
view={ view }
onChangeView={ onChangeView }
onSelectionChange={ onSelectionChange }
supportedLayouts={ SUPPORTED_LAYOUTS }
/>
</Page>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ const { useHistory, useLocation } = unlock( routerPrivateApis );

const EMPTY_ARRAY = [];

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

const defaultConfigPerViewType = {
[ LAYOUT_TABLE ]: {
primaryField: 'title',
Expand Down Expand Up @@ -209,9 +205,7 @@ export default function PageTemplatesTemplateParts( { postType } ) {
const { params } = useLocation();
const { activeView = 'all', layout } = params;
const defaultView = useMemo( () => {
const usedType = window?.__experimentalAdminViews
? layout ?? DEFAULT_VIEW.type
: DEFAULT_VIEW.type;
const usedType = layout ?? DEFAULT_VIEW.type;
return {
...DEFAULT_VIEW,
type: usedType,
Expand Down Expand Up @@ -473,7 +467,6 @@ export default function PageTemplatesTemplateParts( { postType } ) {
onChangeView={ onChangeView }
onSelectionChange={ onSelectionChange }
deferredRendering={ ! view.hiddenFields?.includes( 'preview' ) }
supportedLayouts={ SUPPORTED_LAYOUTS }
/>
</Page>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,12 @@ export default function useSyncPathWithURL() {
canvas: undefined,
path: navigatorLocation.path,
} );
} else if (
navigatorLocation.path === '/wp_template/all' &&
! window?.__experimentalAdminViews
) {
// When the experiment is disabled, we only support table layout.
// Clear it out from the URL, so layouts other than table cannot be accessed.
updateUrlParams( {
postType: undefined,
categoryType: undefined,
categoryId: undefined,
path: navigatorLocation.path,
layout: undefined,
} );
} 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 === '/pages' &&
window?.__experimentalAdminViews ) ||
( navigatorLocation.path === '/wp_template/all' &&
window?.__experimentalAdminViews ) ||
( navigatorLocation.path === '/wp_template_part/all' &&
window?.__experimentalAdminViews )
navigatorLocation.path === '/pages' ||
navigatorLocation.path === '/wp_template/all' ||
navigatorLocation.path === '/wp_template_part/all'
) {
updateUrlParams( {
postType: undefined,
Expand Down

1 comment on commit c187e22

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in c187e22.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8295141486
📝 Reported issues:

Please sign in to comment.