This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/pages/providers/ProviderViewPage.ts
Jens Langhammer 225099b1a1 web/admin: fix error when viewing ldap provider
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
2021-05-05 21:57:13 +02:00

55 lines
2.1 KiB
TypeScript

import { customElement, html, LitElement, property, TemplateResult } from "lit-element";
import "../../elements/buttons/SpinnerButton";
import "../../elements/EmptyState";
import "../../elements/PageHeader";
import "./saml/SAMLProviderViewPage";
import "./oauth2/OAuth2ProviderViewPage";
import "./proxy/ProxyProviderViewPage";
import "./ldap/LDAPProviderViewPage";
import { Provider, ProvidersApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { ifDefined } from "lit-html/directives/if-defined";
@customElement("ak-provider-view")
export class ProviderViewPage extends LitElement {
@property({type: Number})
set providerID(value: number) {
new ProvidersApi(DEFAULT_CONFIG).providersAllRead({
id: value,
}).then((prov) => (this.provider = prov));
}
@property({ attribute: false })
provider?: Provider;
renderProvider(): TemplateResult {
if (!this.provider) {
return html`<ak-empty-state ?loading=${true} ?fullHeight=${true}></ak-empty-state>`;
}
switch (this.provider?.component) {
case "ak-provider-saml-form":
return html`<ak-provider-saml-view providerID=${ifDefined(this.provider.pk)}></ak-provider-saml-view>`;
case "ak-provider-oauth2-form":
return html`<ak-provider-oauth2-view providerID=${ifDefined(this.provider.pk)}></ak-provider-oauth2-view>`;
case "ak-provider-proxy-form":
return html`<ak-provider-proxy-view providerID=${ifDefined(this.provider.pk)}></ak-provider-proxy-view>`;
case "ak-provider-ldap-form":
return html`<ak-provider-ldap-view providerID=${ifDefined(this.provider.pk)}></ak-provider-ldap-view>`;
default:
return html`<p>Invalid provider type ${this.provider?.component}</p>`;
}
}
render(): TemplateResult {
return html`<ak-page-header
icon="pf-icon pf-icon-integration"
header=${ifDefined(this.provider?.name)}
description=${ifDefined(this.provider?.verboseName)}>
</ak-page-header>
${this.renderProvider()}`;
}
}