PluginProbe
Edit Flow / 0.9
Edit Flow v0.9
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
edit-flow / blocks / src / custom-status / block.js

block.js in Edit Flow 0.9, at blocks/src/custom-status/block.js

69 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import './editor.scss';
2 import './style.scss';
3
4 let { __ } = wp.i18n;
5 let { PluginPostStatusInfo } = wp.editPost;
6 let { registerPlugin } = wp.plugins;
7 let { withSelect, withDispatch } = wp.data;
8 let { compose } = wp.compose;
9 let { SelectControl } = wp.components;
10
11 /**
12 * Map Custom Statuses as options for SelectControl
13 */
14 let statuses = window.EditFlowCustomStatuses.map( s => ({ label: s.name, value: s.slug }) );
15
16 let getStatusLabel = slug => statuses.find( s => s.value === slug ).label;
17
18 // Hack :(
19 // @see https://github.com/WordPress/gutenberg/issues/3144
20 let sideEffectL10nManipulation = status => {
21 let node = document.querySelector('.editor-post-save-draft');
22 if ( node ) {
23 document.querySelector('.editor-post-save-draft').innerText = `${__( 'Save' ) } ${status}`
24 }
25 }
26
27 /**
28 * Custom status component
29 * @param object props
30 */
31 let EditFlowCustomPostStati = ( { onUpdate, status } ) => (
32 <PluginPostStatusInfo
33 className={ `edit-flow-extended-post-status edit-flow-extended-post-status-${status}` }
34 >
35 <h4>{ status !== 'publish' ? __( 'Extended Post Status', 'edit-flow' ) : __( 'Extended Post Status Disabled.', 'edit-flow' ) }</h4>
36
37 { status !== 'publish' ? <SelectControl
38 label=""
39 value={ status }
40 options={ statuses }
41 onChange={ onUpdate }
42 /> : null }
43
44 <small className="edit-flow-extended-post-status-note">
45 { status !== 'publish' ? __( `Note: this will override all status settings above.`, 'edit-flow' ) : __( 'To select a custom status, please unpublish the content first.', 'edit-flow' ) }
46 </small>
47 </PluginPostStatusInfo>
48 );
49
50 let plugin = compose(
51 withSelect((select) => ({
52 status: select('core/editor').getEditedPostAttribute('status'),
53 })),
54 withDispatch((dispatch) => ({
55 onUpdate(status) {
56 dispatch('core/editor').editPost( { status } );
57 sideEffectL10nManipulation( getStatusLabel( status ) );
58 }
59 }))
60 )(EditFlowCustomPostStati);
61
62 /**
63 * Kick it off
64 */
65 registerPlugin( 'edit-flow-custom-status', {
66 icon: 'edit-flow',
67 render: plugin
68 } );
69