diff --git a/web/src/locales/en.po b/web/src/locales/en.po index 9a4fb765d..b8fb7589d 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -1979,7 +1979,6 @@ msgstr "Loading" #: src/pages/groups/GroupForm.ts #: src/pages/outposts/OutpostForm.ts #: src/pages/outposts/OutpostForm.ts -#: src/pages/outposts/OutpostForm.ts #: src/pages/outposts/ServiceConnectionDockerForm.ts #: src/pages/outposts/ServiceConnectionDockerForm.ts #: src/pages/policies/PolicyBindingForm.ts @@ -4397,6 +4396,10 @@ msgstr "X509 Subject" msgid "Yes" msgstr "Yes" +#: src/pages/outposts/OutpostForm.ts +msgid "You can only select providers that match the type of the outpost." +msgstr "You can only select providers that match the type of the outpost." + #: src/interfaces/Interface.ts msgid "You're currently impersonating {0}." msgstr "You're currently impersonating {0}." diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 9d4819b5a..a415b2a3e 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -2019,7 +2019,6 @@ msgstr "" #: #: #: -#: msgid "Loading..." msgstr "" @@ -4383,6 +4382,10 @@ msgstr "" msgid "Yes" msgstr "" +#: +msgid "You can only select providers that match the type of the outpost." +msgstr "" + #: msgid "You're currently impersonating {0}." msgstr "" diff --git a/web/src/pages/outposts/OutpostForm.ts b/web/src/pages/outposts/OutpostForm.ts index d45247dbc..38d27771a 100644 --- a/web/src/pages/outposts/OutpostForm.ts +++ b/web/src/pages/outposts/OutpostForm.ts @@ -1,6 +1,6 @@ import { Outpost, OutpostsApi, OutpostTypeEnum, ProvidersApi } from "authentik-api"; import { t } from "@lingui/macro"; -import { customElement } from "lit-element"; +import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { until } from "lit-html/directives/until"; @@ -13,9 +13,15 @@ import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-outpost-form") export class OutpostForm extends ModelForm { + @property() + type!: OutpostTypeEnum; + loadInstance(pk: string): Promise { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesRetrieve({ uuid: pk + }).then(o => { + this.type = o.type || OutpostTypeEnum.Proxy; + return o; }); } @@ -40,6 +46,33 @@ export class OutpostForm extends ModelForm { } }; + renderProviders(): Promise { + switch (this.type) { + case OutpostTypeEnum.Proxy: + return new ProvidersApi(DEFAULT_CONFIG).providersProxyList({ + ordering: "pk" + }).then(providers => { + return providers.results.map(provider => { + const selected = Array.from(this.instance?.providers || []).some(sp => { + return sp == provider.pk; + }); + return html``; + }); + }); + case OutpostTypeEnum.Ldap: + return new ProvidersApi(DEFAULT_CONFIG).providersLdapList({ + ordering: "pk" + }).then(providers => { + return providers.results.map(provider => { + const selected = Array.from(this.instance?.providers || []).some(sp => { + return sp == provider.pk; + }); + return html``; + }); + }); + } + } + renderForm(): TemplateResult { return html`
{ label=${t`Type`} ?required=${true} name="type"> - { + const target = ev.target as HTMLSelectElement; + this.type = target.selectedOptions[0].value as OutpostTypeEnum; + }}> @@ -82,27 +118,9 @@ export class OutpostForm extends ModelForm { ?required=${true} name="providers"> +

${t`You can only select providers that match the type of the outpost.`}

${t`Hold control/command to select multiple items.`}