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/SourceListPage.ts
Jens Langhammer 263bcae050 web/admin: improve empty state
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

# Conflicts:
#	web/src/elements/table/TablePage.ts
#	web/src/pages/applications/ApplicationListPage.ts
2022-05-19 10:21:46 +02:00

121 lines
3.9 KiB
TypeScript

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 { Source, SourcesApi } from "@goauthentik/api";
import { AKResponse } from "../../api/Client";
import { DEFAULT_CONFIG } from "../../api/Config";
import { uiConfig } from "../../common/config";
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 "./SourceWizard";
import "./ldap/LDAPSourceForm";
import "./oauth/OAuthSourceForm";
import "./plex/PlexSourceForm";
import "./saml/SAMLSourceForm";
@customElement("ak-source-list")
export class SourceListPage extends TablePage<Source> {
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<AKResponse<Source>> {
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`<ak-forms-delete-bulk
objectLabel=${t`Source(s)`}
.objects=${this.selectedElements}
.usedBy=${(item: Source) => {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllUsedByList({
slug: item.slug,
});
}}
.delete=${(item: Source) => {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllDestroy({
slug: item.slug,
});
}}
>
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`}
</button>
</ak-forms-delete-bulk>`;
}
row(item: Source): TemplateResult[] {
if (item.component === "") {
return this.rowInbuilt(item);
}
return [
html`<a href="#/core/sources/${item.slug}">
<div>${item.name}</div>
${item.enabled ? html`` : html`<small>${t`Disabled`}</small>`}
</a>`,
html`${item.verboseName}`,
html` <ak-forms-modal>
<span slot="submit"> ${t`Update`} </span>
<span slot="header"> ${t`Update ${item.verboseName}`} </span>
<ak-proxy-form
slot="form"
.args=${{
instancePk: item.slug,
}}
type=${ifDefined(item.component)}
>
</ak-proxy-form>
<button slot="trigger" class="pf-c-button pf-m-plain">
<i class="fas fa-edit"></i>
</button>
</ak-forms-modal>`,
];
}
rowInbuilt(item: Source): TemplateResult[] {
return [
html`<span>
<div>${item.name}</div>
<small>${t`Built-in`}</small>
</span>`,
html`${t`Built-in`}`,
html``,
];
}
renderObjectCreate(): TemplateResult {
return html`<ak-source-wizard> </ak-source-wizard> `;
}
}