Skip to content

Commit

Permalink
Action: issue new license
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jan 15, 2025
1 parent f5a5f67 commit c54fb5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export const JetpackSitesDataViews = ( {
[ translate ]
);*/

const actions = useSiteActionsDataViews();
const actions = useSiteActionsDataViews( { isLargeScreen } );

// Update the data packet
useEffect( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import isA4AClientSite from 'calypso/state/sites/selectors/is-a4a-client-site';
import { JETPACK_ACTIVITY_ID, JETPACK_BACKUP_ID } from '../features/features';
import SitesDashboardContext from '../sites-dashboard-context';
import getActionEventName from './get-action-event-name';
import type { SiteData } from '../../../../jetpack-cloud/sections/agency-dashboard/sites-overview/types';
import type { SiteNode, AllowedActionTypes } from '../types';

type Props = {
Expand Down Expand Up @@ -203,7 +204,32 @@ export default function useSiteActions( {
] );
}

const EMPTY_ARRAY: any[] = [];
export function useSiteActionsDataViews() {
return EMPTY_ARRAY;
type SiteActions = {
isLargeScreen: boolean;
};

export function useSiteActionsDataViews( { isLargeScreen }: SiteActions ) {
const translate = useTranslate();
const dispatch = useDispatch();

const isUrlOnly = ( item: SiteData ) =>
item.site?.value?.sticker?.includes( 'jetpack-manage-url-only-site' );
const isWPComSite = ( item: SiteData ) => item.site.value.is_atomic || item.site.value.is_simple;

return useMemo(
() => [
{
id: 'issue-new-license',
label: translate( 'Issue new license' ),
isEligible( item: SiteData ) {
return ! item.site.error && ! isWPComSite( item ) && ! isUrlOnly( item );
},
callback: () => {
page( A4A_MARKETPLACE_LINK );
dispatch( recordTracksEvent( getActionEventName( 'issue_license', isLargeScreen ) ) );
},
},
],
[ isLargeScreen, translate, dispatch ]
);
}

0 comments on commit c54fb5b

Please sign in to comment.