-
Notifications
You must be signed in to change notification settings - Fork 53
Update environment types and related badge handling #1645
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
Conversation
sandbox environment type with developmentsandbox environment type with development and simplify Environment badge logic
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, Ivan! The code looks clean and simple. I tested it, and it works well except for an edge case. If a WPcom user set a custom environment type, Studio displays different labels in the sites modal and in the connected sites screens.
I think we should be consistent and display always the environment type set by the user.
Happy Path works great
Inconsistent results for WPcom sites with custom labels
It seems we should update the code in
studio/src/modules/sync/components/sync-sites-modal-selector.tsx
Lines 287 to 297 in 669d146
| { ! isPressable && ( | |
| <> | |
| <EnvironmentBadge type="production" selected={ isSelected } /> | |
| { site.stagingSiteIds.length > 0 && ( | |
| <EnvironmentBadge type="staging" selected={ isSelected } /> | |
| ) } | |
| </> | |
| ) } | |
| { isPressable && ( | |
| <EnvironmentBadge type={ getSiteEnvironment( site ) } selected={ isSelected } /> | |
| ) } |
|
Thank you for the review, Antonio!
Indeed! That's a great catch! Thank you for noticing that. I will address it tomorrow morning. 🙂 |
|
What happens if the user sets this variable to an unsupported environment type? |
| return connectedSite.environmentType ?? 'production'; | ||
| } | ||
| return connectedSite.isStaging ? 'staging' : 'production'; | ||
| return connectedSite.environmentType ?? 'production'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified this logic to support only the four environment types. See:
If the environment type is not supported, I suggest that Studio will display the badge as Production. const EnvironmentSchema = z.enum( [ 'production', 'staging', 'development', 'local' ] );
export type EnvironmentType = z.infer< typeof EnvironmentSchema >;
export const getSiteEnvironment = ( site: SyncSite ): EnvironmentType => {
const parsed = EnvironmentSchema.safeParse( site.environmentType );
return parsed.success ? parsed.data : 'production';
}; |
sandbox environment type with development and simplify Environment badge logicSandbox environment badge with Development and ensure all envrionment_type values are respected
|
@ivan-ottinger , I've merged #1648 |
9e3036b to
cc9f76f
Compare
Thank you, Antonio. This PR is now ready for another review round. I have also updated the PR title, description and testing instructions. |
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivan-ottinger , I tested the PR and works great. I see the real Environment type in the modal and when the site is connected.
I left a suggestion about removing renderStagingSiteBadge. It's not a strong opinion, so let me know what you think.
|
@ivan-ottinger @sejas the part with supporting "local" as a type of remote environment seems a bit weird. Should we diverge from core here and support only labels that make sense as labels used by WordPress.com or Pressable (production, staging, development), and ignore the rest? Or take a step back and only support labels that we show in the WordPress.com sites dashboard, so we would go back to using production and staging? |
I see what you mean.
If I am understand your point of view correctly, in the case of In that case we would need to rethink the copy displayed on the sync modal as well though. Instead of Curious to hear what Antonio thinks as well. |
|
@ivan-ottinger maybe we should follow what @sejas proposed above?
|
Yes, that should work. 👍🏼 There's one issue I have observed with relying on the With the current staging site sync logic (on the WordPress.com side), the
We could adjust the |
|
Good catch @ivan-ottinger . It makes sense to have such a series of fallbacks indeed. |
|
I see both solutions can be a bit confusing for some users, but keeping the old logic that limited WPcom to only use production and staging seems the most reasonable. |
Sandbox environment badge with Development and ensure all envrionment_type values are respected
Yes, I agree that neither of the two solutions is 100% ideal. I have updated the PR (including the title, description and testing instructions). Feel free to take another look if you like. |
sejas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivan-ottinger , great work! 🚢
WPcom sites will display only Production and Staging based on isStaging.
Pressable sites will display any valid Studio environment type (Production, Staging, Development).

Related issues
Proposed Changes
Pressable is no longer setting
sandboxenvironment type for their sandbox sites. Instead, these sites are now using thedevelopmentenvironment type. Because of that, we are adjusting the related environment badges in Studio to useDevelopmentbadge for sites withdevelopmentenvironment type set.Related discussion: p1753471348570109-slack-C08AHBHGDEZ.
Together with this change we are also removing support for the
localenvironment type (and related badge and Push / Pull modal copy). Only the following three environment types will be represented in badges:Production,StagingandDevelopment. All other environments, including local will useProductionas their badge.We are also adjusting the logic of
getSiteEnvironmentto rely onsite.isStagingfor WordPress.com sites - instead of environment type. More context can be found here.Testing Instructions
npm start.Testing with Pressable site
jetpack_callable_wp_get_environment_typeof your connected Pressable sits to any value (e.g.local,staging,production,development).developmentenvironment type is used, theDevelopmentbadge should be rendered and use the blue color that was previously used forSandboxbadgeslocalenvironment type is used, the site should have theProductionbadge; if you click the Push / Pull button, the copy for theproductionsite should be displayed in the modal (not forlocal)stagingandproductionenvironment types should be respected and related badges displayed in Studio UITesting with WordPress.com site
ProductionandStagingbadges should render correctly in Studio.General
Pre-merge Checklist