mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-18 11:29:26 +03:00
17da90df6c
* web: Clarify required marker when using screen reader. * web: Mark helper text as input descriptor. * web: Use next domain when in development. * web: Clean up constants. Fix attribute mapping. * web: use previous function name. * web: Fix sort. * web: Use constant. * web: Use prefix. * web: keep using current release for notes.
132 lines
4.6 KiB
TypeScript
132 lines
4.6 KiB
TypeScript
import "#admin/sources/SourceWizard";
|
|
import "#admin/sources/kerberos/KerberosSourceForm";
|
|
import "#admin/sources/ldap/LDAPSourceForm";
|
|
import "#admin/sources/oauth/OAuthSourceForm";
|
|
import "#admin/sources/plex/PlexSourceForm";
|
|
import "#admin/sources/saml/SAMLSourceForm";
|
|
import "#elements/forms/DeleteBulkForm";
|
|
import "#elements/forms/ModalForm";
|
|
import "#elements/forms/ProxyForm";
|
|
import "@patternfly/elements/pf-tooltip/pf-tooltip.js";
|
|
|
|
import { DEFAULT_CONFIG } from "#common/api/config";
|
|
|
|
import { PFColor } from "#elements/Label";
|
|
import { PaginatedResponse, TableColumn } from "#elements/table/Table";
|
|
import { TablePage } from "#elements/table/TablePage";
|
|
import { SlottedTemplateResult } from "#elements/types";
|
|
|
|
import { Source, SourcesApi } from "@goauthentik/api";
|
|
|
|
import { msg, str } from "@lit/localize";
|
|
import { html, nothing, TemplateResult } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
|
@customElement("ak-source-list")
|
|
export class SourceListPage extends TablePage<Source> {
|
|
public pageTitle = msg("Federation and Social login");
|
|
public pageDescription = msg(
|
|
"Sources of identities, which can either be synced into authentik's database, or can be used by users to authenticate and enroll themselves.",
|
|
);
|
|
public pageIcon = "pf-icon pf-icon-middleware";
|
|
protected override searchEnabled = true;
|
|
|
|
checkbox = true;
|
|
clearOnRefresh = true;
|
|
|
|
@property()
|
|
order = "name";
|
|
|
|
async apiEndpoint(): Promise<PaginatedResponse<Source>> {
|
|
return new SourcesApi(DEFAULT_CONFIG).sourcesAllList(await this.defaultEndpointConfig());
|
|
}
|
|
|
|
protected columns: TableColumn[] = [
|
|
// ---
|
|
[msg("Name"), "name"],
|
|
[msg("Type")],
|
|
["", null, msg("Row Actions")],
|
|
];
|
|
|
|
renderToolbarSelected(): TemplateResult {
|
|
const disabled =
|
|
this.selectedElements.length < 1 ||
|
|
this.selectedElements.some((item) => item.component === "");
|
|
const nonBuiltInSources = this.selectedElements.filter((item) => item.component !== "");
|
|
return html`<ak-forms-delete-bulk
|
|
objectLabel=${msg("Source(s)")}
|
|
.objects=${nonBuiltInSources}
|
|
.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">
|
|
${msg("Delete")}
|
|
</button>
|
|
</ak-forms-delete-bulk>`;
|
|
}
|
|
|
|
row(item: Source): SlottedTemplateResult[] {
|
|
if (item.component === "") {
|
|
return this.rowInbuilt(item);
|
|
}
|
|
return [
|
|
html`<a href="#/core/sources/${item.slug}">
|
|
<div>${item.name}</div>
|
|
${item.enabled
|
|
? nothing
|
|
: html`<ak-label color=${PFColor.Orange} compact>
|
|
${msg("Disabled")}</ak-label
|
|
>`}
|
|
</a>`,
|
|
html`${item.verboseName}`,
|
|
html` <ak-forms-modal>
|
|
<span slot="submit">${msg("Update")}</span>
|
|
<span slot="header">${msg(str`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">
|
|
<pf-tooltip position="top" content=${msg("Edit")}>
|
|
<i class="fas fa-edit" aria-hidden="true"></i>
|
|
</pf-tooltip>
|
|
</button>
|
|
</ak-forms-modal>`,
|
|
];
|
|
}
|
|
|
|
rowInbuilt(item: Source): SlottedTemplateResult[] {
|
|
return [
|
|
html`<div>
|
|
<div>${item.name}</div>
|
|
<ak-label color=${PFColor.Grey} compact> ${msg("Built-in")}</ak-label>
|
|
</div>`,
|
|
html`${msg("Built-in")}`,
|
|
nothing,
|
|
];
|
|
}
|
|
|
|
renderObjectCreate(): TemplateResult {
|
|
return html`<ak-source-wizard> </ak-source-wizard> `;
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-source-list": SourceListPage;
|
|
}
|
|
}
|