From 1baf55a641d8b9e754f4df95725500b64c4d3c73 Mon Sep 17 00:00:00 2001 From: Tiago Noronha Date: Fri, 31 Jan 2025 17:07:06 +0000 Subject: [PATCH 1/2] Add upgrade link to WordPress.com/Pressable licenses --- .../licenses/license-details/actions.tsx | 21 ++++++++++++++++++- .../licenses/license-details/index.tsx | 1 + .../license-preview/use-license-actions.ts | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-details/actions.tsx b/client/a8c-for-agencies/sections/purchases/licenses/license-details/actions.tsx index ddc135fc01f20..b2210138618a3 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-details/actions.tsx +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-details/actions.tsx @@ -2,7 +2,10 @@ import { Button } from '@automattic/components'; import { Icon, external } from '@wordpress/icons'; import { useTranslate } from 'i18n-calypso'; import { useCallback, useState, useEffect } from 'react'; -import { isPressableHostingProduct } from 'calypso/a8c-for-agencies/sections/marketplace/lib/hosting'; +import { + isPressableHostingProduct, + isWPCOMHostingProduct, +} from 'calypso/a8c-for-agencies/sections/marketplace/lib/hosting'; import { LicenseRole, LicenseState, @@ -25,6 +28,7 @@ interface Props { licenseType: LicenseType; hasDownloads: boolean; isChildLicense?: boolean; + isClientLicense?: boolean; } export default function LicenseDetailsActions( { @@ -35,6 +39,7 @@ export default function LicenseDetailsActions( { licenseType, hasDownloads, isChildLicense, + isClientLicense, }: Props ) { const dispatch = useDispatch(); const translate = useTranslate(); @@ -45,6 +50,7 @@ export default function LicenseDetailsActions( { const [ revokeDialog, setRevokeDialog ] = useState( false ); const isPressableLicense = isPressableHostingProduct( licenseKey ); + const isWPCOMHostingLicense = isWPCOMHostingProduct( licenseKey ); const pressableManageUrl = 'https://my.pressable.com/agency/auth'; const debugUrl = siteUrl ? `https://jptools.wordpress.com/debug/?url=${ siteUrl }` : null; @@ -113,6 +119,19 @@ export default function LicenseDetailsActions( { ) } + { ( isPressableLicense || isWPCOMHostingLicense ) && + licenseState !== LicenseState.Revoked && + ! isClientLicense && ( + + ) } + { canRevoke && ( isChildLicense ? licenseState === LicenseState.Attached diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-details/index.tsx b/client/a8c-for-agencies/sections/purchases/licenses/license-details/index.tsx index 6f61de8b71582..b884fa6a9ad31 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-details/index.tsx +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-details/index.tsx @@ -130,6 +130,7 @@ export default function LicenseDetails( { licenseType={ licenseType } hasDownloads={ hasDownloads } isChildLicense={ isChildLicense } + isClientLicense={ !! ( isAutomatedReferralsEnabled && referral ) } /> ); diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts index 397d778996246..1fef64bad3e6b 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts @@ -82,6 +82,13 @@ export default function useLicenseActions( isExternalLink: true, isEnabled: licenseState === LicenseState.Attached, }, + { + name: translate( 'Upgrade' ), + href: `/marketplace/hosting/wpcom`, + onClick: () => handleClickMenuItem( 'calypso_a4a_licenses_upgrade_click' ), + isExternalLink: false, + isEnabled: true, + }, { name: translate( 'Revoke' ), href: `https://wordpress.com/purchases/subscriptions/${ siteSlug }`, From c81268a179a3f4f5a9f7596ff0ee88127db365a0 Mon Sep 17 00:00:00 2001 From: Tiago Noronha Date: Fri, 31 Jan 2025 17:18:34 +0000 Subject: [PATCH 2/2] Remove Upgrade option from referral sites --- .../sections/purchases/licenses/license-preview/index.tsx | 1 + .../purchases/licenses/license-preview/license-actions.tsx | 5 ++++- .../licenses/license-preview/use-license-actions.ts | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/index.tsx b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/index.tsx index aef3724d5da95..38ffbce347c1f 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/index.tsx +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/index.tsx @@ -378,6 +378,7 @@ export default function LicensePreview( { revokedAt={ revokedAt } licenseType={ licenseType } isChildLicense={ isChildLicense } + isClientLicense={ !! isClientLicense } /> ) : ( /* diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/license-actions.tsx b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/license-actions.tsx index 3a48ad0e780ba..471915625fcda 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/license-actions.tsx +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/license-actions.tsx @@ -12,6 +12,7 @@ interface Props { revokedAt: string | null; licenseType: LicenseType; isChildLicense?: boolean; + isClientLicense?: boolean; } export default function LicenseActions( { @@ -21,6 +22,7 @@ export default function LicenseActions( { revokedAt, licenseType, isChildLicense, + isClientLicense, }: Props ) { const buttonActionRef = useRef< HTMLButtonElement | null >( null ); @@ -32,7 +34,8 @@ export default function LicenseActions( { attachedAt, revokedAt, licenseType, - isChildLicense + isChildLicense, + isClientLicense ); const handleActionClick = ( action: LicenseAction ) => { diff --git a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts index 1fef64bad3e6b..3ae897700c2b0 100644 --- a/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts +++ b/client/a8c-for-agencies/sections/purchases/licenses/license-preview/use-license-actions.ts @@ -18,7 +18,8 @@ export default function useLicenseActions( attachedAt: string | null, revokedAt: string | null, licenseType: LicenseType, - isChildLicense?: boolean + isChildLicense?: boolean, + isClientLicense?: boolean ): LicenseAction[] { const translate = useTranslate(); const dispatch = useDispatch(); @@ -87,7 +88,7 @@ export default function useLicenseActions( href: `/marketplace/hosting/wpcom`, onClick: () => handleClickMenuItem( 'calypso_a4a_licenses_upgrade_click' ), isExternalLink: false, - isEnabled: true, + isEnabled: ! isClientLicense, }, { name: translate( 'Revoke' ), @@ -109,6 +110,7 @@ export default function useLicenseActions( canRevoke, dispatch, isChildLicense, + isClientLicense, isDevSite, licenseType, revokedAt,