Skip to content

Commit

Permalink
Merge pull request #1330 from williamw04/AdminDiscardButton-1326
Browse files Browse the repository at this point in the history
Admin discard button 1326
  • Loading branch information
huss authored Aug 12, 2024
2 parents 661d8b8 + eb3b904 commit 8a54247
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/client/app/components/admin/PreferencesComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default function PreferencesComponent() {
setLocalAdminPref({ ...localAdminPref, [key]: value });
};

const discardChanges = () => {
setLocalAdminPref(cloneDeep(adminPreferences));
};

return (
<div className='d-flex flex-column '>
<UnsavedWarningComponent
Expand Down Expand Up @@ -316,24 +320,32 @@ export default function PreferencesComponent() {
onChange={e => makeLocalChanges('defaultHelpUrl', e.target.value)}
/>
</div>

<Button
type='submit'
onClick={() =>
submitPreferences(localAdminPref)
.unwrap()
.then(() => {
showSuccessNotification(translate('updated.preferences'));
})
.catch(() => {
showErrorNotification(translate('failed.to.submit.changes'));
})
}
disabled={!hasChanges}
className='align-self-end mt-3'
>
{translate('submit')}
</Button>
<div className='d-flex justify-content-end mt-3'>
<Button
type='button'
onClick={discardChanges}
disabled={!hasChanges}
style={{ marginRight: '20px' }}
>
{translate('discard.changes')}
</Button>
<Button
type='submit'
onClick={() =>
submitPreferences(localAdminPref)
.unwrap()
.then(() => {
showSuccessNotification(translate('updated.preferences'));
})
.catch(() => {
showErrorNotification(translate('failed.to.submit.changes'));
})
}
disabled={!hasChanges}
>
{translate('submit')}
</Button>
</div>
</div >
);
}
Expand Down

0 comments on commit 8a54247

Please sign in to comment.