From 881c0b0958af202e51eb457019c5141d63cc8e81 Mon Sep 17 00:00:00 2001 From: Joseph Earl Date: Thu, 13 Apr 2017 00:56:15 +0100 Subject: [PATCH] Fixes #113 Add ability to disable editor preview for a collection --- example/config.yml | 2 ++ src/components/EntryEditor/EntryEditor.js | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/example/config.yml b/example/config.yml index 8cd21fb0..8bbad3d4 100644 --- a/example/config.yml +++ b/example/config.yml @@ -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" diff --git a/src/components/EntryEditor/EntryEditor.js b/src/components/EntryEditor/EntryEditor.js index 17091961..34e46641 100644 --- a/src/components/EntryEditor/EntryEditor.js +++ b/src/components/EntryEditor/EntryEditor.js @@ -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 = ( + + ); + const editor = (
- + { collectionPreviewEnabled ? togglePreviewButton : null } - { this.state.previewVisible ? editorWithPreview : editor } + { collectionPreviewEnabled && this.state.previewVisible ? editorWithPreview : editor }