Skip to content

Commit

Permalink
web: fix error handling bug in ui
Browse files Browse the repository at this point in the history
# What

When I converted all of the Provider forms over to a unified structure, the RAC form
stood out as one that couldn't be directly converted, so two copies were retained.
The error handling was updated to a new format, but this one bit of older handling
was missed.

For now, we're going back to using `Record<string, string>` for errors, to stay as
close to the `./admin/providers/` style of handling.

# Testing

This error prevented the RAC Provider form from loading in the wizard. Seeing that it works in the
wizard should be sufficient.
  • Loading branch information
kensternberg-authentik committed Jan 11, 2025
1 parent 50d2f69 commit b03e5c4
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ApplicationWizardProviderForm<T extends OneOfProvider> extends AKEl
wizard!: ApplicationWizardState;

@property({ type: Object, attribute: false })
errors: Map<string | number | symbol, string> = new Map();
errors: Record<string | number | symbol, string> = {};

@query("form#providerform")
form!: HTMLFormElement;
Expand All @@ -41,13 +41,13 @@ export class ApplicationWizardProviderForm<T extends OneOfProvider> extends AKEl
}

get valid() {
this.errors = new Map();
this.errors = {};
return this.form.checkValidity();
}

errorMessages(name: string) {
return this.errors.has(name)
? [this.errors.get(name)]
return name in this.errors
? [this.errors[name]]
: (this.wizard.errors?.provider?.[name] ??
this.wizard.errors?.provider?.[camelToSnake(name)] ??
[]);
Expand All @@ -56,7 +56,7 @@ export class ApplicationWizardProviderForm<T extends OneOfProvider> extends AKEl
isValid(name: keyof T) {
return !(
(this.wizard.errors?.provider?.[name as string] ?? []).length > 0 ||
this.errors.has(name)
this.errors?.[name] !== undefined
);
}
}

0 comments on commit b03e5c4

Please sign in to comment.