Modify pre-publish texts after scheduling product (#44652)
* Modify prepublish texts after scheduling product * Add changelog
This commit is contained in:
parent
e8a403b406
commit
587ba79350
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
[Product editor block]: Modify pre-publish sidebar title after scheduling a product #44651
|
|
@ -6,6 +6,7 @@ import { createElement } from '@wordpress/element';
|
||||||
import { Button } from '@wordpress/components';
|
import { Button } from '@wordpress/components';
|
||||||
import { useDispatch, useSelect } from '@wordpress/data';
|
import { useDispatch, useSelect } from '@wordpress/data';
|
||||||
import { recordEvent } from '@woocommerce/tracks';
|
import { recordEvent } from '@woocommerce/tracks';
|
||||||
|
import { useEntityProp } from '@wordpress/core-data';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -20,12 +21,18 @@ import { ScheduleSection } from './schedule-section';
|
||||||
export function PrepublishPanel( {
|
export function PrepublishPanel( {
|
||||||
productId,
|
productId,
|
||||||
productType = 'product',
|
productType = 'product',
|
||||||
title = __( 'Are you ready to add this product?', 'woocommerce' ),
|
title = __( 'Are you ready to publish this product?', 'woocommerce' ),
|
||||||
description = __(
|
description = __(
|
||||||
'Double-check your settings before sharing this product with customers.',
|
'Double-check your settings before sharing this product with customers.',
|
||||||
'woocommerce'
|
'woocommerce'
|
||||||
),
|
),
|
||||||
}: PrepublishPanelProps ) {
|
}: PrepublishPanelProps ) {
|
||||||
|
const [ editedDate, , date ] = useEntityProp< string >(
|
||||||
|
'postType',
|
||||||
|
productType,
|
||||||
|
'date_created'
|
||||||
|
);
|
||||||
|
|
||||||
const lastPersistedProduct = useSelect(
|
const lastPersistedProduct = useSelect(
|
||||||
( select ) => {
|
( select ) => {
|
||||||
const { getEntityRecord } = select( 'core' );
|
const { getEntityRecord } = select( 'core' );
|
||||||
|
@ -36,6 +43,14 @@ export function PrepublishPanel( {
|
||||||
|
|
||||||
const { closePrepublishPanel } = useDispatch( productEditorUiStore );
|
const { closePrepublishPanel } = useDispatch( productEditorUiStore );
|
||||||
|
|
||||||
|
if ( editedDate !== date ) {
|
||||||
|
title = __( 'Are you ready to schedule this product?', 'woocommerce' );
|
||||||
|
description = __(
|
||||||
|
'Your product will be published at the specified date and time.',
|
||||||
|
'woocommerce'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="woocommerce-product-publish-panel">
|
<div className="woocommerce-product-publish-panel">
|
||||||
<div className="woocommerce-product-publish-panel__header">
|
<div className="woocommerce-product-publish-panel__header">
|
||||||
|
|
|
@ -122,7 +122,7 @@ export function ScheduleSection( { postType }: ScheduleSectionProps ) {
|
||||||
initialOpen={ false }
|
initialOpen={ false }
|
||||||
// @ts-expect-error title does currently support this value
|
// @ts-expect-error title does currently support this value
|
||||||
title={ [
|
title={ [
|
||||||
__( 'Add:', 'woocommerce' ),
|
__( 'Publish:', 'woocommerce' ),
|
||||||
<span className="editor-post-publish-panel__link" key="label">
|
<span className="editor-post-publish-panel__link" key="label">
|
||||||
{ getScheduleLabel(
|
{ getScheduleLabel(
|
||||||
editedDate === date ? undefined : editedDate
|
editedDate === date ? undefined : editedDate
|
||||||
|
|
Loading…
Reference in New Issue