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/ActionButton"; import "../../elements/forms/ModalForm"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { PAGE_SIZE } from "../../constants"; import { EventsApi, NotificationTransport } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/forms/DeleteForm"; import "./TransportForm"; @customElement("ak-event-transport-list") export class TransportListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return t`Notification Transports`; } pageDescription(): string { return t`Define how notifications are sent to users, like Email or Webhook.`; } pageIcon(): string { return "pf-icon pf-icon-export"; } @property() order = "name"; apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsTransportsList({ ordering: this.order, page: page, pageSize: PAGE_SIZE, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Name`, "name"), new TableColumn(t`Mode`, "mode"), new TableColumn(""), ]; } row(item: NotificationTransport): TemplateResult[] { return [ html`${item.name}`, html`${item.modeVerbose}`, html` { return new EventsApi(DEFAULT_CONFIG).eventsTransportsTestCreate({ uuid: item.pk || "", }); }}> ${t`Test`} ${t`Update`} ${t`Update Notification Transport`} { return new EventsApi(DEFAULT_CONFIG).eventsTransportsUsedByList({ uuid: item.pk }); }} .delete=${() => { return new EventsApi(DEFAULT_CONFIG).eventsTransportsDestroy({ uuid: item.pk }); }}> `, ]; } renderToolbar(): TemplateResult { return html` ${t`Create`} ${t`Create Notification Transport`} ${super.renderToolbar()} `; } }