import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteForm"; import "../../elements/forms/ModalForm"; import "./PolicyTestForm"; import { TableColumn } from "../../elements/table/Table"; import { until } from "lit-html/directives/until"; import { PAGE_SIZE } from "../../constants"; import { PoliciesApi, Policy } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; import { AdminURLManager } from "../../api/legacy"; @customElement("ak-policy-list") export class PolicyListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return gettext("Policies"); } pageDescription(): string { return gettext("Allow users to use Applications based on properties, enforce Password Criteria and selectively apply Stages."); } pageIcon(): string { return "pf-icon pf-icon-infrastructure"; } @property() order = "name"; apiEndpoint(page: number): Promise> { return new PoliciesApi(DEFAULT_CONFIG).policiesAllList({ ordering: this.order, page: page, pageSize: PAGE_SIZE, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn("Name", "name"), new TableColumn("Type"), new TableColumn(""), ]; } row(item: Policy): TemplateResult[] { return [ html`
${item.name}
${(item.boundTo || 0) > 0 ? html` ${gettext(`Assigned to ${item.boundTo} objects.`)} `: html` ${gettext("Warning: Policy is not assigned.")}`}
`, html`${item.verboseName}`, html` ${gettext("Edit")}
${gettext("Test")} ${gettext("Test Policy")} { return new PoliciesApi(DEFAULT_CONFIG).policiesAllDelete({ policyUuid: item.pk || "" }); }}> `, ]; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()}`; } }