web: fix save & reset behavior on System ➲ Settings page. (#8528)

This commit is contained in:
Ken Sternberg
2024-02-15 09:08:55 -08:00
committed by GitHub
parent 4c5730a222
commit 07b6356b38
2 changed files with 48 additions and 40 deletions

View File

@ -22,25 +22,36 @@ import { AdminApi, Settings, SettingsRequest } from "@goauthentik/api";
@customElement("ak-admin-settings-form")
export class AdminSettingsForm extends Form<SettingsRequest> {
@property({ attribute: false })
set settings(value: Settings) {
//
// Custom property accessors in Lit 2 require a manual call to requestUpdate(). See:
// https://lit.dev/docs/v2/components/properties/#accessors-custom
//
set settings(value: Settings | undefined) {
this._settings = value;
this.requestUpdate();
}
@property({ type: Object })
get settings() {
return this._settings;
}
private _settings?: Settings;
static get styles(): CSSResult[] {
return super.styles.concat(PFList);
}
getSuccessMessage(): string {
return msg("Successfully updated settings.");
}
async send(data: SettingsRequest): Promise<Settings> {
return new AdminApi(DEFAULT_CONFIG).adminSettingsUpdate({
const result = await new AdminApi(DEFAULT_CONFIG).adminSettingsUpdate({
settingsRequest: data,
});
}
static get styles(): CSSResult[] {
return super.styles.concat(PFList);
this.dispatchEvent(new CustomEvent("ak-admin-setting-changed"));
return result;
}
renderForm(): TemplateResult {