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, fieldsErrors,
getAsset, getAsset,
onChange, onChange,
hasChanged,
showDelete, showDelete,
onDelete, onDelete,
onValidate, onValidate,
@ -131,6 +132,7 @@ class EntryEditor extends Component {
onCancelEdit={onCancelEdit} onCancelEdit={onCancelEdit}
onDelete={onDelete} onDelete={onDelete}
showDelete={showDelete} showDelete={showDelete}
hasChanged={hasChanged}
/> />
</div> </div>
</div> </div>
@ -149,6 +151,7 @@ EntryEditor.propTypes = {
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
onValidate: PropTypes.func.isRequired, onValidate: PropTypes.func.isRequired,
onPersist: PropTypes.func.isRequired, onPersist: PropTypes.func.isRequired,
hasChanged: PropTypes.bool.isRequired,
showDelete: PropTypes.bool.isRequired, showDelete: PropTypes.bool.isRequired,
onDelete: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired,
onRemoveAsset: PropTypes.func.isRequired, onRemoveAsset: PropTypes.func.isRequired,

View File

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

View File

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