Skip to content

Commit

Permalink
Hide Overview action in the list view
Browse files Browse the repository at this point in the history
  • Loading branch information
okmttdhr committed Nov 25, 2024
1 parent 061c55a commit 8ff191c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
63 changes: 33 additions & 30 deletions client/sites/components/sites-dataviews/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ import type { Action } from '@wordpress/dataviews';
export function useActions( {
openSitePreviewPane,
selectedItem,
viewType,
}: {
openSitePreviewPane?: (
site: SiteExcerptData,
source: 'site_field' | 'action' | 'list_row_click' | 'environment_switcher'
) => void;
selectedItem?: SiteExcerptData | null;
viewType: 'list' | 'table';
} ): Action< SiteExcerptData >[] {
const { __ } = useI18n();
const dispatch = useReduxDispatch();
Expand Down Expand Up @@ -98,36 +100,37 @@ export function useActions( {

return useMemo(
() => [
{
id: 'site-overview',
isPrimary: true,
label: __( 'Overview' ),
icon: drawerLeft,
callback: ( sites ) => {
const site = sites[ 0 ];
const adminUrl = site.options?.admin_url ?? '';
const isAdmin = capabilities[ site.ID ]?.manage_options;
if (
isAdmin &&
! isP2Site( site ) &&
! isNotAtomicJetpack( site ) &&
! isDisconnectedJetpackAndNotAtomic( site )
) {
openSitePreviewPane && openSitePreviewPane( site, 'action' );
} else {
navigate( adminUrl );
}
},
isEligible: ( site ) => {
if ( site.ID === selectedItem?.ID ) {
return false;
}
if ( site.is_deleted ) {
return false;
}
return true;
},
},
...( viewType !== 'list'
? [
{
id: 'site-overview',
isPrimary: true,
label: __( 'Overview' ),
icon: drawerLeft,
callback: ( sites: SiteExcerptData[] ) => {
const site = sites[ 0 ];
const adminUrl = site.options?.admin_url ?? '';
const isAdmin = capabilities[ site.ID ]?.manage_options;
if (
isAdmin &&
! isP2Site( site ) &&
! isNotAtomicJetpack( site ) &&
! isDisconnectedJetpackAndNotAtomic( site )
) {
openSitePreviewPane && openSitePreviewPane( site, 'action' );
} else {
navigate( adminUrl );
}
},
isEligible: ( site: SiteExcerptData ) => {
if ( site.is_deleted ) {
return false;
}
return true;
},
},
]
: [] ),
{
id: 'open-site',
isPrimary: true,
Expand Down
6 changes: 5 additions & 1 deletion client/sites/components/sites-dataviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ const DotcomSitesDataViews = ( {
[ __, openSitePreviewPane, userId, siteStatusGroups ]
);

const actions = useActions( { openSitePreviewPane, selectedItem } );
const actions = useActions( {
openSitePreviewPane,
selectedItem,
viewType: dataViewsState.type,
} );

return (
<div className="sites-dataviews">
Expand Down

0 comments on commit 8ff191c

Please sign in to comment.