Fix Bug 69012

No validation of required fields on SSO settings page
This commit is contained in:
Viktor Fomin 2024-08-19 14:21:24 +03:00
parent 9453205261
commit 2e734ff666
2 changed files with 31 additions and 12 deletions

View File

@ -41,13 +41,11 @@ const SubmitResetButtons = (props) => {
resetForm,
confirmationResetModal,
isSubmitLoading,
hasErrors,
hasChanges,
isLoadingXml,
enableSso,
isSSOAvailable,
closeResetModal,
confirmReset,
isDisabledSaveButton,
} = props;
return (
@ -62,9 +60,7 @@ const SubmitResetButtons = (props) => {
displaySettings={true}
hasScroll={true}
isSaving={isSubmitLoading}
saveButtonDisabled={
!enableSso || hasErrors || !hasChanges || isLoadingXml
}
saveButtonDisabled={isDisabledSaveButton}
disableRestoreToDefault={
isSubmitLoading || isLoadingXml || !isSSOAvailable
}
@ -90,12 +86,10 @@ export default inject(({ ssoStore, currentQuotaStore }) => {
resetForm,
confirmationResetModal,
isSubmitLoading,
hasErrors,
hasChanges,
isLoadingXml,
enableSso,
closeResetModal,
confirmReset,
isDisabledSaveButton,
} = ssoStore;
const { isSSOAvailable } = currentQuotaStore;
@ -106,12 +100,10 @@ export default inject(({ ssoStore, currentQuotaStore }) => {
resetForm,
confirmationResetModal,
isSubmitLoading,
hasErrors,
hasChanges,
isLoadingXml,
enableSso,
isSSOAvailable,
closeResetModal,
confirmReset,
isDisabledSaveButton,
};
})(observer(SubmitResetButtons));

View File

@ -946,6 +946,33 @@ class SsoFormStore {
);
}
get isDisabledSaveButton() {
return (
!this.enableSso ||
this.hasErrors ||
!this.hasChanges ||
this.isLoadingXml ||
this.isRequiredFieldsEmpty
);
}
get isRequiredFieldsEmpty() {
return (
this.entityId.trim().length === 0 ||
(this.ssoBinding === BINDING_POST &&
this.ssoUrlPost.trim().length === 0) ||
(this.sloBinding === BINDING_POST &&
this.sloUrlPost.trim().length === 0) ||
(this.ssoBinding === BINDING_REDIRECT &&
this.ssoUrlRedirect.trim().length === 0) ||
(this.sloBinding === BINDING_REDIRECT &&
this.sloUrlRedirect.trim().length === 0) ||
this.firstName.trim().length === 0 ||
this.lastName.trim().length === 0 ||
this.email.trim().length === 0
);
}
scrollToField = () => {
for (let key in this) {
if (key.includes("HasError") && this[key] !== false) {