-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to skip PublishSidebar on publishing #9760
Changes from all commits
b7cc241
e3f0c24
85edadc
0488595
14ea423
f4c237e
1a00c13
c659529
e888220
b3e9fa8
f78a332
3e2877f
dbd6090
ea5dc6a
afae18d
2f45e20
7bfc2a5
c65ea7c
18036e2
c37b6a8
d1c69c5
1be0b54
79ced01
78ebeec
87b372d
acffe70
37900cc
6637b7e
d7c7151
b50ca1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* WordPress Dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { MenuItem } from '@wordpress/components'; | ||
import { compose } from '@wordpress/compose'; | ||
import { withSelect, withDispatch } from '@wordpress/data'; | ||
|
||
const PublishSidebarToggle = function( { onToggle, isEnabled } ) { | ||
return ( | ||
<MenuItem | ||
className={ 'edit-post__pre-publish-checks' } | ||
icon={ isEnabled && 'yes' } | ||
isSelected={ isEnabled } | ||
role="menuitemcheckbox" | ||
onClick={ onToggle } | ||
> | ||
{ __( 'Enable Pre-publish Checks' ) } | ||
</MenuItem> | ||
); | ||
}; | ||
|
||
export default compose( [ | ||
withSelect( ( select ) => ( { | ||
isEnabled: select( 'core/editor' ).isPublishSidebarEnabled(), | ||
} ) ), | ||
withDispatch( ( dispatch, ownProps ) => ( { | ||
onToggle() { | ||
const { disablePublishSidebar, enablePublishSidebar } = dispatch( 'core/editor' ); | ||
if ( ownProps.isEnabled ) { | ||
disablePublishSidebar(); | ||
} else { | ||
enablePublishSidebar(); | ||
} | ||
ownProps.onToggle(); | ||
}, | ||
} ) ), | ||
] )( PublishSidebarToggle ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -763,3 +763,25 @@ export function unregisterToken( name ) { | |
name, | ||
}; | ||
} | ||
|
||
/** | ||
* Returns an action object used in signalling that the user has enabled the publish sidebar. | ||
* | ||
* @return {Object} Action object | ||
*/ | ||
export function enablePublishSidebar() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally added the enable/disable logic to the An alternative approach could have been to keep the logic in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there another alternative to consider where the publish panel makes more sense in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish we'd taken a more generalized approach akin to |
||
return { | ||
type: 'ENABLE_PUBLISH_SIDEBAR', | ||
}; | ||
} | ||
|
||
/** | ||
* Returns an action object used in signalling that the user has disabled the publish sidebar. | ||
* | ||
* @return {Object} Action object | ||
*/ | ||
export function disablePublishSidebar() { | ||
return { | ||
type: 'DISABLE_PUBLISH_SIDEBAR', | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1580,9 +1580,28 @@ describe( 'state', () => { | |
|
||
expect( state ).toEqual( { | ||
insertUsage: {}, | ||
isPublishSidebarEnabled: true, | ||
} ); | ||
} ); | ||
|
||
it( 'should disable the publish sidebar', () => { | ||
const original = deepFreeze( preferences( undefined, { } ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#spacing Need to find if possible to enforce by ESLint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const state = preferences( original, { | ||
type: 'DISABLE_PUBLISH_SIDEBAR', | ||
} ); | ||
|
||
expect( state.isPublishSidebarEnabled ).toBe( false ); | ||
} ); | ||
|
||
it( 'should enable the publish sidebar', () => { | ||
const original = deepFreeze( preferences( { isPublishSidebarEnabled: false }, { } ) ); | ||
const state = preferences( original, { | ||
type: 'ENABLE_PUBLISH_SIDEBAR', | ||
} ); | ||
|
||
expect( state.isPublishSidebarEnabled ).toBe( true ); | ||
} ); | ||
|
||
it( 'should record recently used blocks', () => { | ||
const state = preferences( deepFreeze( { insertUsage: {} } ), { | ||
type: 'INSERT_BLOCKS', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting the word "this" inside this text might help contextualise this more.
might help users understand it more. If it doesn't look too cramped I say go with that, but if it's already a tight space feel free to leave it as-is.