import "@goauthentik/admin/events/RuleForm"; import "@goauthentik/admin/policies/BoundPoliciesList"; import "@goauthentik/admin/rbac/ObjectPermissionModal"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { severityToLabel } from "@goauthentik/common/labels"; import "@goauthentik/components/ak-status-label"; import "@goauthentik/elements/buttons/SpinnerButton"; import "@goauthentik/elements/forms/DeleteBulkForm"; import "@goauthentik/elements/forms/ModalForm"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { TableColumn } from "@goauthentik/elements/table/Table"; import { TablePage } from "@goauthentik/elements/table/TablePage"; import "@patternfly/elements/pf-tooltip/pf-tooltip.js"; import { msg } from "@lit/localize"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { EventsApi, NotificationRule, RbacPermissionsAssignedByUsersListModelEnum, } from "@goauthentik/api"; @customElement("ak-event-rule-list") export class RuleListPage extends TablePage { expandable = true; checkbox = true; clearOnRefresh = true; searchEnabled(): boolean { return true; } pageTitle(): string { return msg("Notification Rules"); } pageDescription(): string { return msg( "Send notifications whenever a specific Event is created and matched by policies.", ); } pageIcon(): string { return "pf-icon pf-icon-attention-bell"; } @property() order = "name"; async apiEndpoint(): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsRulesList(await this.defaultEndpointConfig()); } columns(): TableColumn[] { return [ new TableColumn(msg("Enabled")), new TableColumn(msg("Name"), "name"), new TableColumn(msg("Severity"), "severity"), new TableColumn(msg("Sent to group"), "group"), new TableColumn(msg("Actions")), ]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new EventsApi(DEFAULT_CONFIG).eventsRulesUsedByList({ pbmUuid: item.pk, }); }} .delete=${(item: NotificationRule) => { return new EventsApi(DEFAULT_CONFIG).eventsRulesDestroy({ pbmUuid: item.pk, }); }} > `; } row(item: NotificationRule): TemplateResult[] { const enabled = !!item.destinationGroupObj || item.destinationEventUser; return [ html``, html`${item.name}`, html`${severityToLabel(item.severity)}`, html`${item.destinationGroupObj ? html`${item.destinationGroupObj.name}` : msg("-")}`, html` ${msg("Update")} ${msg("Update Notification Rule")} `, ]; } renderObjectCreate(): TemplateResult { return html` ${msg("Create")} ${msg("Create Notification Rule")} `; } renderExpanded(item: NotificationRule): TemplateResult { return html`

${msg( `These bindings control upon which events this rule triggers. Bindings to groups/users are checked against the user of the event.`, )}

`; } } declare global { interface HTMLElementTagNameMap { "ak-event-rule-list": RuleListPage; } }