mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Allow typing whitespaces on Settings > Integrations > SSO > End users form (#41817)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40715 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] QA'd all new/changed functionality manually https://github.com/user-attachments/assets/98d6cc51-06b5-4120-86de-65d3f6dbf359 --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
02e8d474e2
commit
5c4445e1dc
3 changed files with 20 additions and 6 deletions
1
changes/40715-allow-whitespace-end-users-form
Normal file
1
changes/40715-allow-whitespace-end-users-form
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Allow typing whitespace on Settings > Integrations > SSO > End users form.
|
||||
|
|
@ -23,6 +23,7 @@ import {
|
|||
IFormErrorsIdp,
|
||||
isEmptyFormData,
|
||||
isMissingAnyRequiredField,
|
||||
trimFormDataIdp,
|
||||
validateFormDataIdp,
|
||||
} from "./helpers";
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ const EndUserAuthSection = ({
|
|||
|
||||
const onInputChange = useCallback(
|
||||
({ name, value }: { name: keyof IFormDataIdp; value: string }) => {
|
||||
const newData = { ...formData, [name]: value?.trim() || "" };
|
||||
const newData = { ...formData, [name]: value };
|
||||
setFormData(newData);
|
||||
setDirty(true);
|
||||
|
||||
|
|
@ -81,13 +82,18 @@ const EndUserAuthSection = ({
|
|||
);
|
||||
|
||||
const onBlur = useCallback(() => {
|
||||
setFormErrors(validateFormDataIdp(formData));
|
||||
}, [formData]);
|
||||
const trimmed = trimFormDataIdp(formData);
|
||||
setFormData(trimmed);
|
||||
setFormErrors(validateFormDataIdp(trimmed));
|
||||
}, [formData, setFormData]);
|
||||
|
||||
const onSubmit = useCallback(
|
||||
async (e: React.FormEvent<SubmitEvent>) => {
|
||||
e.preventDefault();
|
||||
const newErrors = validateFormDataIdp(formData);
|
||||
const trimmed = trimFormDataIdp(formData);
|
||||
setFormData(trimmed);
|
||||
|
||||
const newErrors = validateFormDataIdp(trimmed);
|
||||
if (newErrors) {
|
||||
setFormErrors(newErrors);
|
||||
return;
|
||||
|
|
@ -97,7 +103,7 @@ const EndUserAuthSection = ({
|
|||
await configAPI.update({
|
||||
mdm: {
|
||||
end_user_authentication: {
|
||||
...formData,
|
||||
...trimmed,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -119,7 +125,7 @@ const EndUserAuthSection = ({
|
|||
renderFlash("error", "Couldn't update. Please try again.");
|
||||
}
|
||||
},
|
||||
[formData, renderFlash, setDirty]
|
||||
[formData, setFormData, renderFlash, setDirty]
|
||||
);
|
||||
|
||||
const renderContent = () => {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ const validators = {
|
|||
metadata: errorMetadata,
|
||||
} as const;
|
||||
|
||||
export const trimFormDataIdp = (data: IFormDataIdp): IFormDataIdp => ({
|
||||
idp_name: data.idp_name.trim(),
|
||||
entity_id: data.entity_id.trim(),
|
||||
metadata_url: data.metadata_url.trim(),
|
||||
metadata: data.metadata.trim(),
|
||||
});
|
||||
|
||||
export type IFormErrorsIdp = Partial<Record<keyof IFormDataIdp, string>>;
|
||||
|
||||
export const validateFormDataIdp = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue