Skip to content

Commit

Permalink
Block Template: Implement "all/insert" locking levels
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 3, 2017
1 parent 1398753 commit b413329
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
*/
import { connect } from 'react-redux';
import classnames from 'classnames';
import { get, partial, reduce, size, flow } from 'lodash';
import { get, partial, reduce, size } from 'lodash';

/**
* WordPress dependencies
*/
import { Component, compose, createElement } from '@wordpress/element';
import { keycodes } from '@wordpress/utils';
import { getBlockType, BlockEdit, getBlockDefaultClassname, createBlock, hasBlockSupport } from '@wordpress/blocks';
import { withFilters } from '@wordpress/components';
import { withFilters, withContext } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { withContext } from '@wordpress/components';

/**
* Internal dependencies
Expand Down Expand Up @@ -517,14 +516,14 @@ const mapDispatchToProps = ( dispatch, ownProps ) => ( {
},
} );

export default flow(
export default compose(
withFilters( 'Editor.BlockItem' ),
connect( mapStateToProps, mapDispatchToProps ),
withContext( 'editor' )( ( settings ) => {
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
)( BlockListBlock );
2 changes: 1 addition & 1 deletion editor/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default flow(
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: templateLock === 'all',
};
} ),
)( BlockMover );
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default flow(
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
)( BlockDeleteButton );
2 changes: 1 addition & 1 deletion editor/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default flow(
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
)( BlockSwitcher );
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default flow(
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
)( EditorGlobalKeyboardShortcuts );
2 changes: 1 addition & 1 deletion editor/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default flowRight( [

return {
hasSupportedBlocks: true === blockTypes || ! isEmpty( blockTypes ),
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
] )( Inserter );
2 changes: 1 addition & 1 deletion editor/edit-post/modes/visual-editor/inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default flow(
const { templateLock } = settings;

return {
isLocked: true === templateLock,
isLocked: !! templateLock,
};
} ),
)( VisualEditorInserter );
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
$post_type_object = get_post_type_object( $post_to_edit['type'] );
if ( ! empty( $post_type_object->template ) ) {
$editor_settings['template'] = $post_type_object->template;
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) && $post_type_object->template_lock;
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
}

$script = '( function() {';
Expand Down

0 comments on commit b413329

Please sign in to comment.