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/sources/SourceViewPage.ts
Jens Langhammer 6f7fb4c919 web/elements: add PageHeader element to replace page
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
2021-04-10 17:09:40 +02:00

62 lines
2 KiB
TypeScript

import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { Source, SourcesApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/buttons/SpinnerButton";
import "../../elements/EmptyState";
import "../../elements/PageHeader";
import "./ldap/LDAPSourceViewPage";
import "./oauth/OAuthSourceViewPage";
import "./saml/SAMLSourceViewPage";
import { ifDefined } from "lit-html/directives/if-defined";
@customElement("ak-source-view")
export class SourceViewPage extends LitElement {
@property({ type: String })
set sourceSlug(slug: string) {
new SourcesApi(DEFAULT_CONFIG).sourcesAllRead({
slug: slug
}).then((source) => {
this.source = source;
});
}
@property({ attribute: false })
source?: Source;
static get styles(): CSSResult[] {
return [css`
* {
height: 100%;
}
`];
}
renderSource(): TemplateResult {
if (!this.source) {
return html`<ak-empty-state ?loading=${true} ?fullHeight=${true}></ak-empty-state>`;
}
switch (this.source?.component) {
case "ak-source-ldap-form":
return html`<ak-source-ldap-view sourceSlug=${this.source.slug}></ak-source-ldap-view>`;
case "ak-source-oauth-form":
return html`<ak-source-oauth-view sourceSlug=${this.source.slug}></ak-source-oauth-view>`;
case "ak-source-saml-form":
return html`<ak-source-saml-view sourceSlug=${this.source.slug}></ak-source-saml-view>`;
default:
return html`<p>Invalid source type ${this.source.component}</p>`;
}
}
render(): TemplateResult {
return html`<ak-page-header
icon="pf-icon pf-icon-middleware"
header=${ifDefined(this.source?.name)}
description=${ifDefined(this.source?.verboseName)}>
</ak-page-header>
${this.renderSource()}`;
}
}