-
Notifications
You must be signed in to change notification settings - Fork 143
Added personalization to purchase extension task #4849
Conversation
This commit adds personalization to purchase extension task
This commit removes an unnecessary naming fix
jeffstieler
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.
This tests well - nicely done. There are some issues with the way strings are being built and translated that need to be addressed.
client/task-list/tasks.js
Outdated
| key: 'purchase', | ||
| title: __( 'Purchase & install extensions', 'woocommerce-admin' ), | ||
| title: sprintf( | ||
| __( '%s', 'woocommerce-admin' ), |
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.
This is effectively an untranslatable string.
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.
Nice catch! I corrected it in the commit 7e8426d
client/task-list/tasks.js
Outdated
|
|
||
| const purchaseAndInstallText = | ||
| uniqueItemsList.length === 1 | ||
| ? `Purchase & install ${ uniqueItemsList[ 0 ].name } ${ uniqueItemsList[ 0 ].type }` |
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.
This needs to be translatable - e.g. __( 'Purchase & install %s theme', 'woocommerce-admin' ). We should probably restrict the dynamic part of the string to just the Extension or Theme 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.
Thank you @jeffstieler, this is also corrected in the commit 7e8426d
client/task-list/tasks.js
Outdated
| const purchaseAndInstallText = | ||
| uniqueItemsList.length === 1 | ||
| ? `Purchase & install ${ uniqueItemsList[ 0 ].name } ${ uniqueItemsList[ 0 ].type }` | ||
| : 'Purchase & install extensions'; |
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.
This needs to be wrapped in an i18n call.
| ); | ||
|
|
||
| const uniqueItemsList = [ | ||
| ...new Set( [ |
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.
Interesting trick!
client/dashboard/utils.js
Outdated
| * @param {Array} installedPlugins Installed plugins. | ||
| * @return {Array} Objects with grouped product names and types. | ||
| */ | ||
| export function getGroupedOnboardingProducts( profileItems, installedPlugins ) { |
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.
Total nitpick on naming: technically this isn't grouping the products, it's labeling/categorizing them.
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.
Thank you for the suggestion, I changed it in the commit e160630
| if ( product.label ) { | ||
| cleanedProduct = { type: 'extension', name: product.label }; | ||
| } else { | ||
| cleanedProduct = { type: 'theme', name: product.title }; |
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've left other comments about translation - if these type values still end up in strings to display (which I don't think they should) they need to be passed through the i18n functions as raw strings here.
The method 'getGroupedOnboardingProducts' was given a more accurate name.
|
Thank you for your review @jeffstieler, I addressed the suggested changes. Could you give this PR another look? |
client/task-list/tasks.js
Outdated
| ? __( 'theme', 'woocommerce-admin' ) | ||
| : __( 'extension', 'woocommerce-admin' ); | ||
| purchaseAndInstallText = sprintf( | ||
| __( 'Purchase & install %s %s', 'woocommerce-admin' ), |
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.
If we're leaving two placeholders in the string they need to be positional - either a named replacement using interpolation or numerically indexed. Also we'd need to leave a note for the translators.
I'd personally prefer an alternative - this could turn into 2 translatable strings using the itemType logic above. Something like:
const purchaseAndInstallFormat = 'theme' === itemType ? __( 'Purchase & install %s theme, 'woocommerce-admin' ) : __( 'Purchase & install %s extension, 'woocommerce-admin' );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.
Thank you for your suggestion @jeffstieler. The modification was added in the commit c6e734d
jeffstieler
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.
Code looks good and tests well. Nice work!
Fixes #4578
This PR adds personalization to the
Purchase extensiontask list item.It should:
Accessibility
prefers-reduced-motionScreenshots
Detailed test instructions:
Extensions
/wp-admin/admin.php?page=wc-admin&path=%2Fprofiler&step=product-types).DashboardorHomescreen (URL:/wp-admin/admin.php?page=wc-admin).Purchase and install [extension_name] extensionshould be visible in the task list.Themes
DashboardorHomescreen (URL:/wp-admin/admin.php?page=wc-admin).Purchase and install [theme_name] themeshould be visible in the task list.More than one item
Purchase & install extensionsshould be visible.Changelog Note:
Dev: Added personalization to purchase extension task