From 75aa52a650942d9713522d7f2e2abafa3cb95a3e Mon Sep 17 00:00:00 2001 From: Caleb Date: Sat, 2 Sep 2017 19:24:37 -0600 Subject: [PATCH 1/3] Disable Save button when entry has not been changed. --- src/components/EntryEditor/EntryEditor.js | 3 +++ src/components/EntryEditor/EntryEditorToolbar.js | 4 +++- src/containers/EntryPage.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/EntryEditor/EntryEditor.js b/src/components/EntryEditor/EntryEditor.js index 5413d12d..b0ceacf4 100644 --- a/src/components/EntryEditor/EntryEditor.js +++ b/src/components/EntryEditor/EntryEditor.js @@ -47,6 +47,7 @@ class EntryEditor extends Component { fieldsErrors, getAsset, onChange, + hasChanged, showDelete, onDelete, onValidate, @@ -131,6 +132,7 @@ class EntryEditor extends Component { onCancelEdit={onCancelEdit} onDelete={onDelete} showDelete={showDelete} + hasChanged={hasChanged} /> @@ -149,6 +151,7 @@ EntryEditor.propTypes = { onChange: PropTypes.func.isRequired, onValidate: PropTypes.func.isRequired, onPersist: PropTypes.func.isRequired, + hasChanged: PropTypes.bool.isRequired, showDelete: PropTypes.bool.isRequired, onDelete: PropTypes.func.isRequired, onRemoveAsset: PropTypes.func.isRequired, diff --git a/src/components/EntryEditor/EntryEditorToolbar.js b/src/components/EntryEditor/EntryEditorToolbar.js index da5847e9..204bad6e 100644 --- a/src/components/EntryEditor/EntryEditorToolbar.js +++ b/src/components/EntryEditor/EntryEditorToolbar.js @@ -5,11 +5,12 @@ const EntryEditorToolbar = ( { isPersisting, onPersist, + hasChanged, showDelete, onDelete, onCancelEdit, }) => { - const disabled = isPersisting; + const disabled = !hasChanged || isPersisting; return (
@@ -151,7 +151,7 @@ EntryEditor.propTypes = { onChange: PropTypes.func.isRequired, onValidate: PropTypes.func.isRequired, onPersist: PropTypes.func.isRequired, - hasChanged: PropTypes.bool.isRequired, + enableSave: PropTypes.bool.isRequired, showDelete: PropTypes.bool.isRequired, onDelete: PropTypes.func.isRequired, onRemoveAsset: PropTypes.func.isRequired, diff --git a/src/components/EntryEditor/EntryEditorToolbar.js b/src/components/EntryEditor/EntryEditorToolbar.js index 204bad6e..022e78ac 100644 --- a/src/components/EntryEditor/EntryEditorToolbar.js +++ b/src/components/EntryEditor/EntryEditorToolbar.js @@ -5,12 +5,12 @@ const EntryEditorToolbar = ( { isPersisting, onPersist, - hasChanged, + enableSave, showDelete, onDelete, onCancelEdit, }) => { - const disabled = !hasChanged || isPersisting; + const disabled = !enableSave || isPersisting; return (
"`; -exports[`EntryEditorToolbar should have both buttons enabled initially 1`] = `"
"`; +exports[`EntryEditorToolbar should enable the Save button 1`] = `"
"`; + +exports[`EntryEditorToolbar should have the Save button disabled initally, and the Cancel button enabled 1`] = `"
"`;