Skip to content

Commit

Permalink
NCL-8659 Disable SCM edit page submit button when no fields changed
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikk0123 committed Apr 23, 2024
1 parent be3ff75 commit f5ad600
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const ScmRepositoryCreateEditPage = ({ isEditPage = false }: IScmReposito
// edit page - patch method
const serviceContainerEditPagePatch = useServiceContainer(scmRepositoryApi.patchScmRepository);

const { register, setFieldValues, getFieldState, getFieldErrors, handleSubmit, isSubmitDisabled } = useForm();
const { register, setFieldValues, getFieldState, getFieldErrors, handleSubmit, isSubmitDisabled, hasFormChanged } = useForm();

useTitle(
generatePageTitle({
Expand Down Expand Up @@ -230,7 +230,11 @@ export const ScmRepositoryCreateEditPage = ({ isEditPage = false }: IScmReposito
/>
</FormGroup>
<ActionGroup>
<Button variant="primary" isDisabled={isSubmitDisabled} onClick={handleSubmit(isEditPage ? submitEdit : submitCreate)}>
<Button
variant="primary"
isDisabled={isSubmitDisabled || !hasFormChanged}
onClick={handleSubmit(isEditPage ? submitEdit : submitCreate)}
>
{isEditPage ? ButtonTitles.update : ButtonTitles.create} {EntityTitles.scmRepository}
</Button>
{scmCreatingFinished?.id && (
Expand Down

0 comments on commit f5ad600

Please sign in to comment.