import { t } from "@lingui/macro";
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { until } from "lit/directives/until";
import { Source, SourcesApi } from "@goauthentik/api";
import { AKResponse } from "../../api/Client";
import { DEFAULT_CONFIG } from "../../api/Config";
import { PAGE_SIZE } from "../../constants";
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`Sources`;
}
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";
apiEndpoint(page: number): Promise> {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllList({
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
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()}`;
}
}