From 7018ff47b65184614db3d62a05b34e020a30641f Mon Sep 17 00:00:00 2001
From: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Fri, 21 Jul 2023 08:22:49 +0200
Subject: [PATCH] Add manual path to upgrade Products block
(https://github.com/woocommerce/woocommerce-blocks/pull/10268)
* Add option to manually update Products block to Product Collection
* Disable manual upgrade of Products yet
* Manual update flag doesn't have to be dependant on auto update
* Removed commented out console info logs
* Disable option to upgrade Products block
* Change the way to bold text in Upgrade Notices so it's translatable
* Change the way UpgradeNotice is rendered conditionally
---
.../inspector-controls/upgrade-notice.tsx | 34 +++++++-------
.../js/blocks/product-query/constants.ts | 3 +-
.../product-query/inspector-controls.tsx | 15 ++++---
.../inspector-controls/upgrade-notice.tsx | 45 +++++++++++++++++++
...on-from-products-to-product-collection.tsx | 4 +-
5 files changed, 75 insertions(+), 26 deletions(-)
create mode 100644 plugins/woocommerce-blocks/assets/js/blocks/product-query/inspector-controls/upgrade-notice.tsx
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/inspector-controls/upgrade-notice.tsx b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/inspector-controls/upgrade-notice.tsx
index 6885497b241..d9fe5b9607e 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-collection/inspector-controls/upgrade-notice.tsx
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-collection/inspector-controls/upgrade-notice.tsx
@@ -4,34 +4,34 @@
import { __ } from '@wordpress/i18n';
import { Notice, Button } from '@wordpress/components';
import { BlockEditProps } from '@wordpress/blocks';
+import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { ProductCollectionAttributes } from '../types';
-const FormattedNotice = ( { notice }: { notice: string } ) => {
- const strongText = 'Product Collection';
- const [ before, after ] = notice.split( strongText );
-
- return (
- <>
- { before }
- { strongText }
- { after }
- >
- );
-};
-
const UpgradeNotice = (
props: BlockEditProps< ProductCollectionAttributes > & {
revertMigration: () => void;
}
) => {
const { displayUpgradeNotice } = props.attributes;
- const notice = __(
- 'Products (Beta) block was upgraded to Product Collection, an updated version with new features and simplified settings.',
- 'woo-gutenberg-products-block'
+ const notice = createInterpolateElement(
+ __(
+ 'Products (Beta) block was upgraded to , an updated version with new features and simplified settings.',
+ 'woo-gutenberg-products-block'
+ ),
+ {
+ strongText: (
+
+ { __(
+ `Product Collection`,
+ 'woo-gutenberg-products-block'
+ ) }
+
+ ),
+ }
);
const buttonLabel = __(
@@ -53,7 +53,7 @@ const UpgradeNotice = (
return displayUpgradeNotice ? (
-
+ <>{ notice } >