web/admin: fix broken outpost form
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		| @ -1,21 +1,21 @@ | |||||||
| import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||||||
| import { docLink } from "@goauthentik/common/global"; | import { docLink } from "@goauthentik/common/global"; | ||||||
| import { first, groupBy } from "@goauthentik/common/utils"; | import { groupBy } from "@goauthentik/common/utils"; | ||||||
| import "@goauthentik/elements/CodeMirror"; | import "@goauthentik/elements/CodeMirror"; | ||||||
| import "@goauthentik/elements/forms/HorizontalFormElement"; | import "@goauthentik/elements/forms/HorizontalFormElement"; | ||||||
| import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; | import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; | ||||||
| import "@goauthentik/elements/forms/SearchSelect"; | import "@goauthentik/elements/forms/SearchSelect"; | ||||||
|  | import YAML from "yaml"; | ||||||
|  |  | ||||||
| import { t } from "@lingui/macro"; | import { t } from "@lingui/macro"; | ||||||
|  |  | ||||||
| import { TemplateResult, html } from "lit"; | import { TemplateResult, html } from "lit"; | ||||||
| import { customElement, property, state } from "lit/decorators.js"; | import { customElement, property } from "lit/decorators.js"; | ||||||
| import { ifDefined } from "lit/directives/if-defined.js"; | import { ifDefined } from "lit/directives/if-defined.js"; | ||||||
| import { until } from "lit/directives/until.js"; | import { until } from "lit/directives/until.js"; | ||||||
|  |  | ||||||
| import { | import { | ||||||
|     Outpost, |     Outpost, | ||||||
|     OutpostDefaultConfig, |  | ||||||
|     OutpostTypeEnum, |     OutpostTypeEnum, | ||||||
|     OutpostsApi, |     OutpostsApi, | ||||||
|     OutpostsServiceConnectionsAllListRequest, |     OutpostsServiceConnectionsAllListRequest, | ||||||
| @ -36,15 +36,9 @@ export class OutpostForm extends ModelForm<Outpost, string> { | |||||||
|             uuid: pk, |             uuid: pk, | ||||||
|         }); |         }); | ||||||
|         this.type = o.type || OutpostTypeEnum.Proxy; |         this.type = o.type || OutpostTypeEnum.Proxy; | ||||||
|         this.defaultConfig = await new OutpostsApi( |  | ||||||
|             DEFAULT_CONFIG, |  | ||||||
|         ).outpostsInstancesDefaultSettingsRetrieve(); |  | ||||||
|         return o; |         return o; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @state() |  | ||||||
|     defaultConfig?: OutpostDefaultConfig; |  | ||||||
|  |  | ||||||
|     getSuccessMessage(): string { |     getSuccessMessage(): string { | ||||||
|         if (this.instance) { |         if (this.instance) { | ||||||
|             return t`Successfully updated outpost.`; |             return t`Successfully updated outpost.`; | ||||||
| @ -208,9 +202,20 @@ export class OutpostForm extends ModelForm<Outpost, string> { | |||||||
|                 </p> |                 </p> | ||||||
|             </ak-form-element-horizontal> |             </ak-form-element-horizontal> | ||||||
|             <ak-form-element-horizontal label=${t`Configuration`} name="config"> |             <ak-form-element-horizontal label=${t`Configuration`} name="config"> | ||||||
|  |                 <!-- @ts-ignore --> | ||||||
|                 <ak-codemirror |                 <ak-codemirror | ||||||
|                     mode="yaml" |                     mode="yaml" | ||||||
|                     value="${first(this.instance?.config, this.defaultConfig)}" |                     value="${until( | ||||||
|  |                         new OutpostsApi(DEFAULT_CONFIG) | ||||||
|  |                             .outpostsInstancesDefaultSettingsRetrieve() | ||||||
|  |                             .then((config) => { | ||||||
|  |                                 let fc = config.config; | ||||||
|  |                                 if (this.instance) { | ||||||
|  |                                     fc = this.instance.config; | ||||||
|  |                                 } | ||||||
|  |                                 return YAML.stringify(fc); | ||||||
|  |                             }), | ||||||
|  |                     )}" | ||||||
|                 ></ak-codemirror> |                 ></ak-codemirror> | ||||||
|                 <p class="pf-c-form__helper-text"> |                 <p class="pf-c-form__helper-text"> | ||||||
|                     ${t`Set custom attributes using YAML or JSON.`} |                     ${t`Set custom attributes using YAML or JSON.`} | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer