-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Make bundled theme generic (pre checkout) #84483
Conversation
547ca45
to
0412ddc
Compare
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~3656 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~2860 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
a8708ff
to
5031f33
Compare
@@ -80,5 +80,5 @@ export const DEFAULT_ASSEMBLER_DESIGN = { | |||
export const FREE_THEME = 'free'; | |||
export const PREMIUM_THEME = 'premium'; | |||
export const DOT_ORG_THEME = 'dot-org'; | |||
export const WOOCOMMERCE_THEME = 'woocommerce'; | |||
export const BUNDLED_THEME = 'bundled'; |
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.
Is it a good name?
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.
Good question. I'd consider flipping it around so we're looking at THEME_WITH_BUNDLED_SOFTWARE
, but that looks nothing like the other constants. 🤔
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.
Yeah! 🤔
I'll keep this one for now, but if any idea comes to your mind, feel free to let me know that I can change it. 😉
return []; | ||
} | ||
|
||
return themeSoftwareSetTaxonomy.map( ( item ) => item.slug ); |
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.
Is it the slug
the correct reference we should use here? I went with this approach based on this interface I found in the code during the refactor:
export interface SoftwareSet { |
05a7950
to
15f999e
Compare
@@ -44,6 +46,8 @@ const ThemeTypeBadge = ( { | |||
} ); | |||
}, [ type, themeId, isLockedStyleVariation ] ); | |||
|
|||
const themeSoftware = themeSoftwareSet[ 0 ]; |
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.
In some places, we are hard coding the themeSoftwareSet[ 0 ]
to get the first one. Do we plan to have multiple plugins bundled with a team? Sensei LMS + WooCommerce, for example. If so, we need some more refactor.
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.
You can have multiple plugins already - the Woo software set includes Woo and Woo Payments plugins.
I think the question is more 'do we plan to have multiple software sets for a theme'. There aren't any plans that I know of, and from a data pov it could just be a new software set that contains e.g. woo+sensei plugins, it's from a UI perspective it gets trickier - which badge do we display etc.
I don't think we should worry too much about this right now, lets assume that there are always zero or one software sets for any given theme.
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.
For this thread, it may be worth considering a way to identify the primary software set: what does the user think they are getting/installing when they pick this theme?
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 think the question is more 'do we plan to have multiple software sets for a theme'.
Sorry! That's correct!
I think the question is more 'do we plan to have multiple software sets for a theme'.
Could you elaborate a little more your idea @daledupreez? I'm not sure if I understand it.
Do you mean improving the UI with the details of what would be installed? Or something in the showcase editor to set the primary software set? Or something else not related to this at all? 🤭
'woo-on-plans': { | ||
name: 'WooCommerce', | ||
badgeIcon: ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
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.
The original icon was changed to this one, so it uses the currentColor
to set the icon as white, and the "Woo" text is transparent. It will make it easier to create the icons generically for all bundles.
} | ||
|
||
const bundleSettings: BundleSettings = { | ||
'woo-on-plans': { |
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 was planning to change the 'woo-on-plans'
to a constant. But it appears in many places, so I didn't want to risk an accidental issue for now.
const bundleName = bundleSettings[ themeSoftware ].name; | ||
|
||
if ( isIncludedCurrentPlan ) { | ||
message = translate( 'This %(bundleName)s theme is included in your plan.', { |
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.
Currently, for many of the texts, I'm just interpolating the bundle name. If we want a specific text for any part, we can add it to the bundleSettings
.
…e details through props
…ic for any bundle
It will be documented and discussed in the PR.
The reference for this name appears in many places, so I'm keeping at for now to avoid any accidental issue.
7e6fe0f
to
38b814a
Compare
const is_bundled_with_woo_commerce = ( design.software_sets || [] ).some( | ||
( { slug } ) => slug === 'woo-on-plans' | ||
); |
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.
Hello, @renatho! I have a question 🙋♀️
The original function is_bundled_with_woo_commerce
checks for the presence of woo-on-plans
. However, the PR modifies this to check if software_sets.length > 0
.
As far as checking useBundleSettings
, there will be additional types of software_sets
. In that case, these changes will break the original behavior in the future, am I correct?
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.
Hi @okmttdhr! Correct! That's the idea.
We want to consider the theme as a bundled theme when it has any software set. And apply the specific settings for each software set.
Currently, it has only the woo-on-plans
. But in a following PR, we also want to introduce a software set for Sensei LMS, which will have its specific settings.
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.
Thanks for your comment, @renatho!
This PR changes that instead of checking for woo-on-plans
, we should only verify if software_sets.length > 0
(as seen in design-setup/unified-design-picker.tsx
for example). This approach means that the condition will be true
if any new software sets introduced in the future not limited to Woo.
And I assume this is the intended purpose of this PR. I'm highlighting this to clarify my understanding 🙂
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.
That's completely correct! 🙂
For context, there are some more details in pekYwv-3rN-p2 and in p1700605581879429-slack-C048CUFRGFQ.
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.
Doing some testing and after purchasing a business plan via /themes I don't get sent back to /setup/site-setup/designSetup?siteSlug=SLUG.wordpress.com&theme=tsubaki
to activate the Woo theme, I go to the congrats page ahead. This isn't the case on staging - it works as expected.
It works as expected if I choose a theme and upgrade via /start
@dsas, I couldn't reproduce the issue. Could you confirm if you followed some different steps compared to the following video? Or maybe you can also see the issue in my video and I misunderstood something? Screen.Recording.2023-11-30.at.16.47.33.mov(you will just see an extra refresh on the checkout page that I did for the credits) And I didn't record, but after going through the WC setup wizard, I was redirected to the congrats page. Is this the page you saw directly after the checkout? |
@renatho I can't reproduce the issue either, and I didn't record what I was doing. Perhaps I got a step wrong, or it was related to some trunk changes somehow |
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.
Ah wait, I found the issue again. After the checkout I'm not being redirected to the theme, but to a 'Congrats' page.
Screen.Recording.2023-12-01.at.12.11.53.mov
It looks like this is a problem with the wpcalypso.wordpress.com environment. It happens when I use wpcalypso.wordpress.com directly, or when I test this PR with the calypso live link. It doesn't happen when I'm testing this PR locally, or if I'm just on WordPress.com.
To confirm, I tested it in a different PR not related to these changes: #84175, and I could also see the same issue there. So it's confirmed that it's some issue because of the test environment. Thank you everyone for the reviews! I'll wait until Monday to deploy it to see if there's any other feedback, and to avoid the deployment on Friday. :) |
I opened #84767 to look at the test environment issue |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/9876186 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @renatho for including a screenshot in the description! This is really helpful for our translators. |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/9876186 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @renatho for including a screenshot in the description! This is really helpful for our translators. |
* Refactor WooCommerceBundledBadge component to be generic receiving the details through props * Update Woo icon to simplify styles * Refactor sass code * Add container for the icon * Move WooCommerce badge settings to a settings file * Add selector to get theme software set * Make WooCommerce theme bundle generic, in order to allow other bundles * Return slugs instead of names * Refactor occurrences of is_bundled_with_woo_commerce to make it generic for any bundle * Remove TODOs since it will have multiple occurrences It will be documented and discussed in the PR. * Refactor messages to be generic using bundle settings * Fix missing variable * Update badge icon to a component * Remove todo comment The reference for this name appears in many places, so I'm keeping at for now to avoid any accidental issue. * Fix design picker badge * Add a separate text for upsell description * Add setting for bundled badge color * Update property name to match other properties casing * Move variables to the scope where it's used * Update icon and color settings to be generic * Make bundle modal generic * Decrease padding around svg With this the image matches a little better the current state of the image in the modal * Add comment to document field * Add translator comments * Transform new selector to typescript * Import only FunctionComponent type Co-authored-by: daledupreez <dale@automattic.com> * Update sass file to not use name concating The purpose is to be easier to find the classes in a search operation. * Move bundle settings to a hook So it can re-render when translations change. * Remove separation of the static and dynamic part The benefit isn't worth the extra complexity. * Improve vertical alignment of the icon * Remove not used check * Fix feature check to check based on the software set --------- Co-authored-by: daledupreez <dale@automattic.com>
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/9876186 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @renatho for including a screenshot in the description! This is really helpful for our translators. |
Translation for this Pull Request has now been finished. |
Related to Automattic/themes#7498
Proposed Changes
client/my-sites/theme/bundle-settings.tsx
.I also added the "[Status] String Freeze" label to this PR, so we make sure we don't break the translations of strings that are already in the site but had their structure changed.Make bundled theme generic (pre checkout) #84483 (comment)Testing Instructions
Themes
Design Picker and checkout
Screenshots
Themes
Design Picker
Pre-merge Checklist
About the first item, I didn't test exhaustively the browser support because it shouldn't change anything for the browser.