Disable Save button when entry has not been changed.

This commit is contained in:
Caleb 2017-09-02 19:24:37 -06:00
parent afa5a9af2c
commit 75aa52a650
3 changed files with 7 additions and 1 deletions

View File

@ -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}
/>
</div>
</div>
@ -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,

View File

@ -5,11 +5,12 @@ const EntryEditorToolbar = (
{
isPersisting,
onPersist,
hasChanged,
showDelete,
onDelete,
onCancelEdit,
}) => {
const disabled = isPersisting;
const disabled = !hasChanged || isPersisting;
return (
<div>
<Button
@ -37,6 +38,7 @@ const EntryEditorToolbar = (
EntryEditorToolbar.propTypes = {
isPersisting: PropTypes.bool,
onPersist: PropTypes.func.isRequired,
hasChanged: PropTypes.bool.isRequired,
showDelete: PropTypes.bool.isRequired,
onDelete: PropTypes.func.isRequired,
onCancelEdit: PropTypes.func.isRequired,

View File

@ -151,6 +151,7 @@ class EntryPage extends React.Component {
onPersist={this.handlePersistEntry}
onDelete={this.handleDeleteEntry}
showDelete={this.props.showDelete}
hasChanged={entryDraft.get('hasChanged')}
onCancelEdit={this.handleCloseEntry}
/>
);