Fixes #113 Add ability to disable editor preview for a collection

This commit is contained in:
Joseph Earl 2017-04-13 00:56:15 +01:00
parent 7aa77baea9
commit 881c0b0958
2 changed files with 10 additions and 3 deletions

View File

@ -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"

View File

@ -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;