import { AKResponse } from "@goauthentik/web/api/Client"; import { AndNext, DEFAULT_CONFIG } from "@goauthentik/web/api/Config"; import { uiConfig } from "@goauthentik/web/common/config"; import "@goauthentik/web/elements/buttons/SpinnerButton"; import "@goauthentik/web/elements/forms/ConfirmationForm"; import "@goauthentik/web/elements/forms/DeleteBulkForm"; import "@goauthentik/web/elements/forms/ModalForm"; import { TableColumn } from "@goauthentik/web/elements/table/Table"; import { TablePage } from "@goauthentik/web/elements/table/TablePage"; import "@goauthentik/web/pages/flows/FlowForm"; import "@goauthentik/web/pages/flows/FlowImportForm"; import { DesignationToLabel } from "@goauthentik/web/pages/flows/utils"; import { groupBy } from "@goauthentik/web/utils"; import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { Flow, FlowsApi } from "@goauthentik/api"; @customElement("ak-flow-list") export class FlowListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return t`Flows`; } pageDescription(): string { return t`Flows describe a chain of Stages to authenticate, enroll or recover a user. Stages are chosen based on policies applied to them.`; } pageIcon(): string { return "pf-icon pf-icon-process-automation"; } checkbox = true; @property() order = "slug"; async apiEndpoint(page: number): Promise> { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } groupBy(items: Flow[]): [string, Flow[]][] { return groupBy(items, (flow) => { if (!flow.designation) { return ""; } return DesignationToLabel(flow.designation); }); } columns(): TableColumn[] { return [ new TableColumn(t`Identifier`, "slug"), new TableColumn(t`Name`, "name"), new TableColumn(t`Stages`), new TableColumn(t`Policies`), new TableColumn(t`Actions`), ]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesUsedByList({ slug: item.slug, }); }} .delete=${(item: Flow) => { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesDestroy({ slug: item.slug, }); }} > `; } row(item: Flow): TemplateResult[] { return [ html`
${item.slug}
${item.title}
`, html`${item.name}`, html`${Array.from(item.stages || []).length}`, html`${Array.from(item.policies || []).length}`, html` ${t`Update`} ${t`Update Flow`} `, ]; } renderObjectCreate(): TemplateResult { return html` ${t`Create`} ${t`Create Flow`} ${t`Import`} ${t`Import Flow`} `; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()} { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesCacheClearCreate(); }} > ${t`Clear Flow cache`}

${t`Are you sure you want to clear the flow cache? This will cause all flows to be re-evaluated on their next usage.`}

`; } }