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

Fetch real API data in sync modal #608

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

fredrikekelund
Copy link

Fixes https:/Automattic/dotcom-forge/issues/9465

Proposed Changes

Follow-up to #601. Implements an actual API call in useSyncSites, along with some minor visual tweaks.

Testing Instructions

  • Run STUDIO_SITE_SYNC=true npm start
  • Click on Sync tab
  • Click on Connect site
  • Observe a modal opens with the list of your sites
  • Try searching and observe the sites filter correctly

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund self-assigned this Oct 18, 2024
Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

Thanks adding the request to the API.

I just discovered a better way to identify if the plan supports atomic and backups.

https:/Automattic/dotcom-forge/issues/9466

Comment on lines +216 to +217
<div className="a8c-subtitle-small text-black">{ __( 'Powered by' ) }</div>
<WordPressShortLogo className="h-4.5" />
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the fixes!

id: number;
name: string;
url: string;
isStaging: boolean;
stagingSiteIds: number[];
syncSupport: SyncSupport;
};

type Site = {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about adding a prefix?
Like ResponseSite or WpcomSite ?

Copy link
Author

Choose a reason for hiding this comment

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

Sure. Even if this type isn't exported, I guess the name is short enough to be somewhat cryptic.

if ( connectedSiteIds.some( ( id ) => id === site.ID ) ) {
return 'already-connected';
}
if ( site.plan.product_id !== 1008 ) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's check if the plan feature includes atomic or backups.

Something like: site.plan.features.active.includes('atomic')

Screenshot 2024-10-18 at 18 46 02

If we prefer to use the plan number, then in addition to Business, we need to also support Pro and eCommerce, and also all the bundles like monthly, 2 years, 3 years.

Actually, all the plans that belong to the WPCOM_Features::ATOMIC array.

fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Szh%2Qcyhtvaf%2Sjcpbz%2Qsrngherf%2Spynff%2Qjcpbz%2Qsrngherf.cuc%3Se%3Q8p2742qn%23516%2Q521-og

Copy link
Author

Choose a reason for hiding this comment

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

Good point about the Entrepreneur plan—that was an oversight on my part 👍 Regarding the Pro plan, I thought we shouldn't support those sites. From the PT (pesfPa-18P-p2):

[…] allow users to select production or staging sites with a Creator or higher hosting plan.

@wojtekn, could you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

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

@fredrikekelund
Copy link
Author

This should be good for another look now, @sejas

Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

@fredrikekelund , thanks for the changes!

I also think using the site features, and making it plan agnostic will be a better way to identify sites Sync compatible. What do you think?

src/hooks/use-sync-sites.ts Outdated Show resolved Hide resolved
Comment on lines 6 to 7
const BUSINESS_PLAN_ID = 1008;
const COMMERCE_PLAN_ID = 1011;
Copy link
Member

Choose a reason for hiding this comment

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

Let's make the Studio plan-agnostic if possible so it would only operate based on available features, e.g. atomic in this case.

Let's use site.plan.features.active.includes('atomic'). And if we want to limit the Pro plan, then we can add a condition for that specific plan.

If instead of using the site features, we prefer to use the plan ids, then we would need to add also all the bundles (monthly, 2-year, 3-year). Those have different plan IDs.

@fredrikekelund
Copy link
Author

I've landed D164205-code and updated this PR accordingly. This should be good for a final (hopefully) look now 👍

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

Successfully merging this pull request may close these issues.

3 participants