Fixes #113 Add ability to disable editor preview for a collection
This commit is contained in:
parent
7aa77baea9
commit
881c0b0958
@ -30,6 +30,8 @@ collections: # A list of collections the CMS should be able to edit
|
||||
|
||||
- name: "settings"
|
||||
label: "Settings"
|
||||
editor:
|
||||
preview: false
|
||||
files:
|
||||
- name: "general"
|
||||
label: "Site Settings"
|
||||
|
@ -53,9 +53,15 @@ class EntryEditor extends Component {
|
||||
const controlClassName = `${ styles.controlPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
||||
const previewClassName = `${ styles.previewPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
||||
|
||||
const collectionPreviewEnabled = collection.getIn(['editor', 'preview'], true);
|
||||
|
||||
const togglePreviewButton = (
|
||||
<Button className={styles.previewToggle} onClick={this.handleTogglePreview}>Toggle Preview</Button>
|
||||
);
|
||||
|
||||
const editor = (
|
||||
<div className={controlClassName}>
|
||||
<Button className={styles.previewToggle} onClick={this.handleTogglePreview}>Toggle Preview</Button>
|
||||
{ collectionPreviewEnabled ? togglePreviewButton : null }
|
||||
<ControlPane
|
||||
collection={collection}
|
||||
entry={entry}
|
||||
@ -97,7 +103,7 @@ class EntryEditor extends Component {
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
{ this.state.previewVisible ? editorWithPreview : editor }
|
||||
{ collectionPreviewEnabled && this.state.previewVisible ? editorWithPreview : editor }
|
||||
<div className={styles.footer}>
|
||||
<Toolbar
|
||||
isPersisting={entry.get('isPersisting')}
|
||||
@ -125,5 +131,4 @@ EntryEditor.propTypes = {
|
||||
onCancelEdit: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
||||
export default EntryEditor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user