From 072dc0d8de06e7896d3a83c973d1f5fc81976b81 Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Fri, 6 Dec 2024 21:27:16 +0000 Subject: [PATCH 1/5] Purchases: Highlight Upgrades Owned by Other Administrators --- client/me/purchases/purchases-list/index.jsx | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/client/me/purchases/purchases-list/index.jsx b/client/me/purchases/purchases-list/index.jsx index 4007193a8aec5..905aa57e5572a 100644 --- a/client/me/purchases/purchases-list/index.jsx +++ b/client/me/purchases/purchases-list/index.jsx @@ -13,6 +13,7 @@ import NoSitesMessage from 'calypso/components/empty-content/no-sites-message'; import InlineSupportLink from 'calypso/components/inline-support-link'; import Main from 'calypso/components/main'; import NavigationHeader from 'calypso/components/navigation-header'; +import Notice from 'calypso/components/notice'; import PageViewTracker from 'calypso/lib/analytics/page-view-tracker'; import TrackComponentView from 'calypso/lib/analytics/track-component-view'; import { getPurchasesBySite, getSubscriptionsBySite } from 'calypso/lib/purchases'; @@ -44,6 +45,55 @@ class PurchasesList extends Component { return ! this.props.sites.length && ! this.props.subscriptions.length; } + renderPurchasesByOtherAdminsNotice() { + const { sites, translate } = this.props; + + /* + * Because this is only rendered when the user has no purchases, + * we don't need to check each site to ensure the purchases aren't + * linked with the user (they can't be, since they don't have any). + */ + const affectedSites = sites + .filter( + ( site ) => + ( ! site.plan.is_free || site.products.length > 0 ) && site.capabilities.manage_options + ) + .map( ( site ) => site.slug ); + + if ( ! affectedSites ) { + return; + } + + let affectedSitesString = ''; + + if ( affectedSites.length === 1 ) { + affectedSitesString = affectedSites[ 0 ]; + } else { + const allButLast = affectedSites.slice( 0, -1 ).join( ', ' ); + const translatedAnd = translate( 'and', { + comment: 'last conjunction in a list of blognames: (blog1, blog2,) blog3 _and_ blog4', + } ); + const last = affectedSites[ affectedSites.length - 1 ]; + + affectedSitesString = allButLast + ' ' + translatedAnd + ' ' + last; + } + + return ( + + { translate( + 'The upgrades for {{strong}}%(affectedSitesString)s{{/strong}} are owned by another site administrator. ' + + 'These can only be managed by the purchase owner.', + { + components: { strong: }, + args: { + affectedSitesString, + }, + } + ) } + + ); + } + renderConciergeBanner() { const { nextAppointment, availableSessions, isUserBlocked } = this.props; return ( @@ -118,6 +168,7 @@ class PurchasesList extends Component { eventName="calypso_no_purchases_upgrade_nudge_impression" eventProperties={ commonEventProps } /> + { this.renderPurchasesByOtherAdminsNotice() } Date: Thu, 12 Dec 2024 21:55:02 +0000 Subject: [PATCH 2/5] Fix reported bug --- client/me/purchases/purchases-list/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/me/purchases/purchases-list/index.jsx b/client/me/purchases/purchases-list/index.jsx index 905aa57e5572a..10edf62b4d0be 100644 --- a/client/me/purchases/purchases-list/index.jsx +++ b/client/me/purchases/purchases-list/index.jsx @@ -60,7 +60,7 @@ class PurchasesList extends Component { ) .map( ( site ) => site.slug ); - if ( ! affectedSites ) { + if ( ! affectedSites.length ) { return; } From d88d3a3e93120bd4e5d9105a120a94eed490e7da Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:43:54 +0000 Subject: [PATCH 3/5] Revert changes --- client/me/purchases/purchases-list/index.jsx | 51 -------------------- 1 file changed, 51 deletions(-) diff --git a/client/me/purchases/purchases-list/index.jsx b/client/me/purchases/purchases-list/index.jsx index 10edf62b4d0be..4007193a8aec5 100644 --- a/client/me/purchases/purchases-list/index.jsx +++ b/client/me/purchases/purchases-list/index.jsx @@ -13,7 +13,6 @@ import NoSitesMessage from 'calypso/components/empty-content/no-sites-message'; import InlineSupportLink from 'calypso/components/inline-support-link'; import Main from 'calypso/components/main'; import NavigationHeader from 'calypso/components/navigation-header'; -import Notice from 'calypso/components/notice'; import PageViewTracker from 'calypso/lib/analytics/page-view-tracker'; import TrackComponentView from 'calypso/lib/analytics/track-component-view'; import { getPurchasesBySite, getSubscriptionsBySite } from 'calypso/lib/purchases'; @@ -45,55 +44,6 @@ class PurchasesList extends Component { return ! this.props.sites.length && ! this.props.subscriptions.length; } - renderPurchasesByOtherAdminsNotice() { - const { sites, translate } = this.props; - - /* - * Because this is only rendered when the user has no purchases, - * we don't need to check each site to ensure the purchases aren't - * linked with the user (they can't be, since they don't have any). - */ - const affectedSites = sites - .filter( - ( site ) => - ( ! site.plan.is_free || site.products.length > 0 ) && site.capabilities.manage_options - ) - .map( ( site ) => site.slug ); - - if ( ! affectedSites.length ) { - return; - } - - let affectedSitesString = ''; - - if ( affectedSites.length === 1 ) { - affectedSitesString = affectedSites[ 0 ]; - } else { - const allButLast = affectedSites.slice( 0, -1 ).join( ', ' ); - const translatedAnd = translate( 'and', { - comment: 'last conjunction in a list of blognames: (blog1, blog2,) blog3 _and_ blog4', - } ); - const last = affectedSites[ affectedSites.length - 1 ]; - - affectedSitesString = allButLast + ' ' + translatedAnd + ' ' + last; - } - - return ( - - { translate( - 'The upgrades for {{strong}}%(affectedSitesString)s{{/strong}} are owned by another site administrator. ' + - 'These can only be managed by the purchase owner.', - { - components: { strong: }, - args: { - affectedSitesString, - }, - } - ) } - - ); - } - renderConciergeBanner() { const { nextAppointment, availableSessions, isUserBlocked } = this.props; return ( @@ -168,7 +118,6 @@ class PurchasesList extends Component { eventName="calypso_no_purchases_upgrade_nudge_impression" eventProperties={ commonEventProps } /> - { this.renderPurchasesByOtherAdminsNotice() } Date: Tue, 17 Dec 2024 17:45:31 +0000 Subject: [PATCH 4/5] Force conflict --- client/me/purchases/purchases-site/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/me/purchases/purchases-site/index.tsx b/client/me/purchases/purchases-site/index.tsx index f36e4ac453131..77137f4b49875 100644 --- a/client/me/purchases/purchases-site/index.tsx +++ b/client/me/purchases/purchases-site/index.tsx @@ -22,7 +22,7 @@ export default function PurchasesSite( siteId?: number; } | { - getManagePurchaseUrlFor: ( slug: string, purchaseId: number ) => string; + getManagePurchaseUrlFor!: ( slug: string, purchaseId: number ) => string; isPlaceholder?: false; siteId: number; purchases: Purchase[]; From 573216ca18de65c7fcb2283c143952772df7d5e9 Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Tue, 17 Dec 2024 18:22:31 +0000 Subject: [PATCH 5/5] Recommit previous code --- client/me/purchases/purchases-list/index.tsx | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/client/me/purchases/purchases-list/index.tsx b/client/me/purchases/purchases-list/index.tsx index 660d16aed03d9..385b2493b09e0 100644 --- a/client/me/purchases/purchases-list/index.tsx +++ b/client/me/purchases/purchases-list/index.tsx @@ -14,6 +14,7 @@ import NoSitesMessage from 'calypso/components/empty-content/no-sites-message'; import InlineSupportLink from 'calypso/components/inline-support-link'; import Main from 'calypso/components/main'; import NavigationHeader from 'calypso/components/navigation-header'; +import Notice from 'calypso/components/notice'; import PageViewTracker from 'calypso/lib/analytics/page-view-tracker'; import TrackComponentView from 'calypso/lib/analytics/track-component-view'; import { getPurchasesBySite, getSubscriptionsBySite } from 'calypso/lib/purchases'; @@ -70,6 +71,55 @@ class PurchasesList extends Component< return ! this.props.sites.length && ! this.props.subscriptions.length; } + renderPurchasesByOtherAdminsNotice() { + const { sites, translate } = this.props; + + /* + * Because this is only rendered when the user has no purchases, + * we don't need to check each site to ensure the purchases aren't + * linked with the user (they can't be, since they don't have any). + */ + const affectedSites = sites + .filter( + ( site ) => + ( ! site?.plan.is_free || site?.products.length > 0 ) && site.capabilities.manage_options + ) + .map( ( site ) => site.slug ); + + if ( ! affectedSites.length ) { + return; + } + + let affectedSitesString = ''; + + if ( affectedSites.length === 1 ) { + affectedSitesString = affectedSites[ 0 ]; + } else { + const allButLast = affectedSites.slice( 0, -1 ).join( ', ' ); + const translatedAnd = translate( 'and', { + comment: 'last conjunction in a list of blognames: (blog1, blog2,) blog3 _and_ blog4', + } ); + const last = affectedSites[ affectedSites.length - 1 ]; + + affectedSitesString = allButLast + ' ' + translatedAnd + ' ' + last; + } + + return ( + + { translate( + 'The upgrades for {{strong}}%(affectedSitesString)s{{/strong}} are owned by another site administrator. ' + + 'These can only be managed by the purchase owners.', + { + components: { strong: }, + args: { + affectedSitesString, + }, + } + ) } + + ); + } + renderConciergeBanner() { const { nextAppointment, availableSessions, isUserBlocked } = this.props; return ( @@ -144,6 +194,7 @@ class PurchasesList extends Component< eventName="calypso_no_purchases_upgrade_nudge_impression" eventProperties={ commonEventProps } /> + { this.renderPurchasesByOtherAdminsNotice() }