import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteForm"; import "../../elements/forms/ModalForm"; import "../../elements/forms/ProxyForm"; import "../../elements/forms/ConfirmationForm"; 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 { ifDefined } from "lit-html/directives/if-defined"; import "./dummy/DummyPolicyForm"; import "./event_matcher/EventMatcherPolicyForm"; import "./expression/ExpressionPolicyForm"; import "./expiry/ExpiryPolicyForm"; import "./hibp/HaveIBeenPwnedPolicyForm"; import "./password/PasswordPolicyForm"; import "./reputation/ReputationPolicyForm"; @customElement("ak-policy-list") export class PolicyListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return t`Policies`; } pageDescription(): string { return t`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(t`Name`, "name"), new TableColumn(t`Type`), new TableColumn(""), ]; } row(item: Policy): TemplateResult[] { return [ html`
${item.name}
${(item.boundTo || 0) > 0 ? html` ${t`Assigned to ${item.boundTo} objects.`} `: html` ${t`Warning: Policy is not assigned.`}`}
`, html`${item.verboseName}`, html` ${t`Update`} ${t`Update ${item.verboseName}`} ${t`Test`} ${t`Test Policy`} { return new PoliciesApi(DEFAULT_CONFIG).policiesAllDestroy({ policyUuid: item.pk || "" }); }}> `, ]; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()} { return new PoliciesApi(DEFAULT_CONFIG).policiesAllCacheClearCreate(); }}> ${t`Clear Policy cache`}

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

`; } }