import { t } from "@lingui/macro"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { AKResponse } from "../../api/Client"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./OutpostHealth"; import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/Dropdown"; import "../../elements/forms/DeleteForm"; import "../../elements/forms/ModalForm"; import "./ServiceConnectionKubernetesForm"; import "./ServiceConnectionDockerForm"; import { until } from "lit-html/directives/until"; import { PAGE_SIZE } from "../../constants"; import { OutpostsApi, ServiceConnection } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/forms/ProxyForm"; import { ifDefined } from "lit-html/directives/if-defined"; import { PFColor } from "../../elements/Label"; @customElement("ak-outpost-service-connection-list") export class OutpostServiceConnectionListPage extends TablePage { pageTitle(): string { return "Outpost Service-Connections"; } pageDescription(): string | undefined { return "Outpost Service-Connections define how authentik connects to external platforms to manage and deploy Outposts."; } pageIcon(): string { return "pf-icon pf-icon-integration"; } searchEnabled(): boolean { return true; } apiEndpoint(page: number): Promise> { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllList({ 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(t`Local`, "local"), new TableColumn(t`State`), new TableColumn(""), ]; } @property() order = "name"; row(item: ServiceConnection): TemplateResult[] { return [ html`${item.name}`, html`${item.verboseName}`, html`${item.local ? t`Yes` : t`No`}`, html`${until( new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllState({ uuid: item.pk || "" }).then((state) => { if (state.healthy) { return html``; } return html``; }), html``)}`, html` ${t`Update`} ${t`Update ${item.verboseName}`} { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDelete({ uuid: item.pk || "" }); }}> `, ]; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()}`; } }