Skip to content

Commit

Permalink
feat: disable 'Save' button when there are no changes (#5595)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradystroud authored Aug 3, 2021
1 parent 9f22bcd commit 4b566a7
Show file tree
Hide file tree
Showing 5 changed files with 641 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
.emotion-2[disabled] {
background-color: #eff0f4;
color: #798291;
cursor: default;
}
.emotion-5 {
Expand Down Expand Up @@ -255,6 +256,7 @@ exports[`GitGatewayAuthenticationPage should render with no identity error 1`] =
.emotion-2[disabled] {
background-color: #eff0f4;
color: #798291;
cursor: default;
}
.emotion-5 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ const DeleteButton = styled(ToolbarButton)`

const SaveButton = styled(ToolbarButton)`
${buttons.lightBlue};
&[disabled] {
${buttons.disabled};
}
`;

const PublishedToolbarButton = styled(DropdownButton)`
Expand Down Expand Up @@ -583,7 +586,11 @@ export class EditorToolbar extends React.Component {
(!hasUnpublishedChanges && !isModification && t('editor.editorToolbar.deletePublishedEntry'));

return [
<SaveButton key="save-button" onClick={() => hasChanged && onPersist()}>
<SaveButton
disabled={!hasChanged}
key="save-button"
onClick={() => hasChanged && onPersist()}
>
{isPersisting ? t('editor.editorToolbar.saving') : t('editor.editorToolbar.save')}
</SaveButton>,
(!showDelete || useOpenAuthoring) && !hasUnpublishedChanges && !isModification ? null : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,10 @@ describe('EditorToolbar', () => {
expect(asFragment()).toMatchSnapshot();
});
});

it(`should render normal save button`, () => {
const { asFragment } = render(<EditorToolbar {...props} hasChanged={true} />);
expect(asFragment()).toMatchSnapshot();
});
});
});
Loading

0 comments on commit 4b566a7

Please sign in to comment.