Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purchases: Highlight Upgrades Owned by Other Administrators #97198

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

Aurorum
Copy link
Contributor

@Aurorum Aurorum commented Dec 6, 2024

Addresses #96328

Proposed Changes

Provides an informational notice when the user goes to manage their upgrades, and sees the "no purchases EmptyContent" because the subscriptions on the sites for which they are an admin are managed by somebody else.

NOTE: this only works when the user has no purchases (as opposed to having their own sites with purchases). I imagine that would capture most the use cases in practice, but the problem is that when the user has their own sites, we need to check whether they own that specific purchase. This would require checking the individual site purchases (as opposed to the general getSites data), but without owning the purchase, they don't have the authorisation to do so. I think that might, therefore, require an endpoint change. As such, this only implements one of the two designs in the original issue.

Why are these changes being made?

See original issue - lots of users apparently face confusion over why they can't manage an upgrade.

Testing Instructions

  1. Create a site with a purchase
  2. Add another user to that site as an administrator
  3. Confirm that on that user's account, you see the correct notice under Me > Purchases
  4. Verify that the notice shows all the sites for which that applies, and it doesn't show any sites which the user is not an administrator on
Screenshot 2024-12-06 at 21 42 53

cc @sirbrillig, @DavidRothstein

Comment on lines +72 to +78
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do feel this is a bit clunky and fully open to recommendations - but looks like it's the approach used here (which is where I've also taken the string from to avoid the need for re-translation):

return uniqBy( xPostedToList, 'siteName' ).map( ( xPostedTo, index, array ) => {
return (
<span className="reader__x-post-site" key={ xPostedTo.siteURL + '-' + index }>
{ xPostedTo.siteName }
{ index + 2 < array.length && <span>, </span> }
{ index + 2 === array.length && (
<span>
{ ' ' }
{ translate( 'and', {
comment:
'last conjunction in a list of blognames: (blog1, blog2,) blog3 _and_ blog4',
} ) }{ ' ' }
</span>
) }
</span>
);
} );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant