import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { until } from "lit/directives/until.js"; import { Source, SourcesApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; import "../../elements/forms/ProxyForm"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./ldap/LDAPSourceForm"; import "./oauth/OAuthSourceForm"; import "./plex/PlexSourceForm"; import "./saml/SAMLSourceForm"; @customElement("ak-source-list") export class SourceListPage extends TablePage { pageTitle(): string { return t`Federation & Social login`; } pageDescription(): string | undefined { return t`Sources of identities, which can either be synced into authentik's database, or can be used by users to authenticate and enroll themselves.`; } pageIcon(): string { return "pf-icon pf-icon-middleware"; } searchEnabled(): boolean { return true; } checkbox = true; @property() order = "name"; async apiEndpoint(page: number): Promise> { return new SourcesApi(DEFAULT_CONFIG).sourcesAllList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } columns(): TableColumn[] { return [new TableColumn(t`Name`, "name"), new TableColumn(t`Type`), new TableColumn("")]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new SourcesApi(DEFAULT_CONFIG).sourcesAllUsedByList({ slug: item.slug, }); }} .delete=${(item: Source) => { return new SourcesApi(DEFAULT_CONFIG).sourcesAllDestroy({ slug: item.slug, }); }} > `; } row(item: Source): TemplateResult[] { if (item.component === "") { return this.rowInbuilt(item); } return [ html`
${item.name}
${item.enabled ? html`` : html`${t`Disabled`}`}
`, html`${item.verboseName}`, html` ${t`Update`} ${t`Update ${item.verboseName}`} `, ]; } rowInbuilt(item: Source): TemplateResult[] { return [ html`
${item.name}
${t`Built-in`}
`, html`${t`Built-in`}`, html``, ]; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()}`; } }