Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable 'Save' button when there are no changes #5595

Merged
merged 16 commits into from
Aug 3, 2021
Merged
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