Modify notice for legacy local attributes (#41646)
* Modify notice for legacy local attributes * Rename variable * Add changelogs * Rename local_attributes_notice_dismissed_ids
This commit is contained in:
parent
2fc7057e16
commit
4a0db06321
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Modify notice for legacy local attributes #41646
|
|
@ -28,13 +28,14 @@ export type UserPreferences = {
|
|||
variable_product_tour_shown?: string;
|
||||
variable_product_block_tour_shown?: string;
|
||||
variations_report_columns?: string;
|
||||
product_block_variable_options_notice_dismissed?: string;
|
||||
local_attributes_notice_dismissed_ids?: number[];
|
||||
variable_items_without_price_notice_dismissed?: Record< number, string >;
|
||||
};
|
||||
|
||||
export type WoocommerceMeta = UserPreferences & {
|
||||
task_list_tracked_started_tasks?: string;
|
||||
variable_items_without_price_notice_dismissed?: string;
|
||||
local_attributes_notice_dismissed_ids?: string;
|
||||
};
|
||||
|
||||
export type WCUser<
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Modify notice for legacy local attributes #41646
|
|
@ -16,6 +16,7 @@ import {
|
|||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { Link } from '@woocommerce/components';
|
||||
import { getAdminLink } from '@woocommerce/settings';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore No types for this exist yet.
|
||||
// eslint-disable-next-line @woocommerce/dependency-group
|
||||
|
@ -31,13 +32,13 @@ import { ProductEditorBlockEditProps } from '../../../types';
|
|||
|
||||
export function Edit( {
|
||||
attributes: blockAttributes,
|
||||
context,
|
||||
}: ProductEditorBlockEditProps< BlockAttributes > ) {
|
||||
const blockProps = useWooBlockProps( blockAttributes );
|
||||
const { generateProductVariations } = useProductVariationsHelper();
|
||||
const {
|
||||
updateUserPreferences,
|
||||
product_block_variable_options_notice_dismissed:
|
||||
hasDismissedVariableOptionsNotice,
|
||||
local_attributes_notice_dismissed_ids: dismissedNoticesIds = [],
|
||||
} = useUserPreferences();
|
||||
|
||||
const [ entityAttributes, setEntityAttributes ] = useEntityProp<
|
||||
|
@ -51,6 +52,9 @@ export function Edit( {
|
|||
'default_attributes'
|
||||
);
|
||||
|
||||
const { postType } = context;
|
||||
const productId = useEntityId( 'postType', postType );
|
||||
|
||||
const { attributes, handleChange } = useProductAttributes( {
|
||||
allAttributes: entityAttributes,
|
||||
isVariationAttributes: true,
|
||||
|
@ -68,7 +72,7 @@ export function Edit( {
|
|||
let notice: string | React.ReactElement = '';
|
||||
if (
|
||||
localAttributeNames.length > 0 &&
|
||||
hasDismissedVariableOptionsNotice !== 'yes'
|
||||
! dismissedNoticesIds?.includes( productId )
|
||||
) {
|
||||
notice = createInterpolateElement(
|
||||
__(
|
||||
|
@ -87,7 +91,9 @@ export function Edit( {
|
|||
),
|
||||
globalAttributeLink: (
|
||||
<Link
|
||||
href="https://woo.com/document/variable-product/#add-attributes-to-use-for-variations"
|
||||
href={ getAdminLink(
|
||||
'edit.php?post_type=product&page=product_attributes'
|
||||
) }
|
||||
type="external"
|
||||
target="_blank"
|
||||
/>
|
||||
|
@ -122,7 +128,10 @@ export function Edit( {
|
|||
useRemoveConfirmationModal={ true }
|
||||
onNoticeDismiss={ () =>
|
||||
updateUserPreferences( {
|
||||
product_block_variable_options_notice_dismissed: 'yes',
|
||||
local_attributes_notice_dismissed_ids: [
|
||||
...dismissedNoticesIds,
|
||||
productId,
|
||||
],
|
||||
} )
|
||||
}
|
||||
onAddAnother={ () => {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Modify notice for legacy local attributes #41646
|
|
@ -175,7 +175,7 @@ class Init {
|
|||
$user_data_fields,
|
||||
array(
|
||||
'variable_product_block_tour_shown',
|
||||
'product_block_variable_options_notice_dismissed',
|
||||
'local_attributes_notice_dismissed_ids',
|
||||
'variable_items_without_price_notice_dismissed',
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue