-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
prepublish-panel.tsx
76 lines (71 loc) · 2.3 KB
/
prepublish-panel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createElement } from '@wordpress/element';
import { Button } from '@wordpress/components';
import { useDispatch } from '@wordpress/data';
import { recordEvent } from '@woocommerce/tracks';
import { useEntityProp } from '@wordpress/core-data';
/**
* Internal dependencies
*/
import { PublishButton } from '../header/publish-button';
import { PrepublishPanelProps } from './types';
import { store as productEditorUiStore } from '../../store/product-editor-ui';
import { TRACKS_SOURCE } from '../../constants';
import { VisibilitySection } from './visibility-section';
import { ScheduleSection } from './schedule-section';
import { ShowPrepublishChecksSection } from './show-prepublish-checks-section';
export function PrepublishPanel( {
productType = 'product',
title = __( 'Are you ready to publish this product?', 'woocommerce' ),
description = __(
'Double-check your settings before sharing this product with customers.',
'woocommerce'
),
}: PrepublishPanelProps ) {
const [ editedDate, , date ] = useEntityProp< string >(
'postType',
productType,
'date_created'
);
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 (
<div className="woocommerce-product-publish-panel">
<div className="woocommerce-product-publish-panel__header">
<PublishButton productType={ productType } />
<Button
variant={ 'secondary' }
onClick={ () => {
recordEvent( 'product_prepublish_panel', {
source: TRACKS_SOURCE,
action: 'cancel',
} );
closePrepublishPanel();
} }
>
{ __( 'Cancel', 'woocommerce' ) }
</Button>
</div>
<div className="woocommerce-product-publish-panel__title">
<h4>{ title }</h4>
<span>{ description }</span>
</div>
<div className="woocommerce-product-publish-panel__content">
<VisibilitySection productType={ productType } />
<ScheduleSection postType={ productType } />
</div>
<div className="woocommerce-product-publish-panel__footer">
<ShowPrepublishChecksSection />
</div>
</div>
);
}