import { gettext } from "django"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; import { Provider } from "../../api/Providers"; import { OAuth2Provider, OAuth2SetupURLs } from "../../api/providers/OAuth2"; import { COMMON_STYLES } from "../../common/styles"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/CodeMirror"; import "../../elements/Tabs"; import { Page } from "../../elements/Page"; import { convertToTitle } from "../../utils"; @customElement("ak-provider-oauth2-view") export class OAuth2ProviderViewPage extends Page { pageTitle(): string { return gettext(`OAuth Provider ${this.provider?.name}`); } pageDescription(): string | undefined { return; } pageIcon(): string { return "pf-icon pf-icon-integration"; } @property({type: Number}) set providerID(value: number) { OAuth2Provider.get(value).then((app) => this.provider = app); OAuth2Provider.getLaunchURls(value).then((urls) => this.providerUrls = urls); } @property({ attribute: false }) provider?: OAuth2Provider; @property({ attribute: false }) providerUrls?: OAuth2SetupURLs; static get styles(): CSSResult[] { return COMMON_STYLES; } constructor() { super(); this.addEventListener("ak-refresh", () => { if (!this.provider?.pk) return; this.providerID = this.provider?.pk; }); } renderContent(): TemplateResult { if (!this.provider) { return html``; } return html`
${gettext("Name")}
${this.provider.name}
${gettext("Assigned to application")}
${this.provider.assigned_application_slug ? html` ${this.provider.assigned_application_name} `: html`-` }
${gettext("Client type")}
${convertToTitle(this.provider.client_type)}
${gettext("Client ID")}
${this.provider.client_id}
${gettext("Redirect URIs")}
${this.provider.redirect_uris}

`; } }