2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-10-28 07:48:51 +00:00
|
|
|
import { TemplateResult, html } from "lit";
|
2021-11-04 21:34:48 +00:00
|
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
|
import { until } from "lit/directives/until.js";
|
2021-02-19 16:49:34 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { OutpostsApi, ServiceConnection } from "@goauthentik/api";
|
|
|
|
|
|
|
|
import { AKResponse } from "../../api/Client";
|
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-10-14 10:48:52 +00:00
|
|
|
import { uiConfig } from "../../common/config";
|
2021-09-21 09:31:37 +00:00
|
|
|
import { PFColor } from "../../elements/Label";
|
2021-02-19 16:49:34 +00:00
|
|
|
import "../../elements/buttons/Dropdown";
|
2021-09-21 09:31:37 +00:00
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-08-12 20:03:13 +00:00
|
|
|
import "../../elements/forms/DeleteBulkForm";
|
2021-03-31 20:40:48 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
|
|
|
import "../../elements/forms/ProxyForm";
|
2021-09-21 09:31:37 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
import "./OutpostHealth";
|
|
|
|
import "./ServiceConnectionDockerForm";
|
|
|
|
import "./ServiceConnectionKubernetesForm";
|
2021-02-19 16:49:34 +00:00
|
|
|
|
|
|
|
@customElement("ak-outpost-service-connection-list")
|
2021-03-08 10:14:00 +00:00
|
|
|
export class OutpostServiceConnectionListPage extends TablePage<ServiceConnection> {
|
2021-02-19 16:49:34 +00:00
|
|
|
pageTitle(): string {
|
2021-08-03 22:18:15 +00:00
|
|
|
return "Outpost integrations";
|
2021-02-19 16:49:34 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
2021-08-03 22:18:15 +00:00
|
|
|
return "Outpost integrations define how authentik connects to external platforms to manage and deploy Outposts.";
|
2021-02-19 16:49:34 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return "pf-icon pf-icon-integration";
|
|
|
|
}
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
checkbox = true;
|
|
|
|
|
2021-10-14 10:48:52 +00:00
|
|
|
async apiEndpoint(page: number): Promise<AKResponse<ServiceConnection>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllList({
|
2021-02-19 16:49:34 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-10-14 10:48:52 +00:00
|
|
|
pageSize: (await uiConfig()).pagination.perPage,
|
2021-02-19 16:49:34 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
2021-03-08 10:14:00 +00:00
|
|
|
|
2021-02-19 16:49:34 +00:00
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
2021-04-04 14:56:16 +00:00
|
|
|
new TableColumn(t`Name`, "name"),
|
2021-04-04 14:22:29 +00:00
|
|
|
new TableColumn(t`Type`),
|
2021-04-04 14:56:16 +00:00
|
|
|
new TableColumn(t`Local`, "local"),
|
2021-04-04 14:22:29 +00:00
|
|
|
new TableColumn(t`State`),
|
2021-08-05 10:30:43 +00:00
|
|
|
new TableColumn(t`Actions`),
|
2021-02-19 16:49:34 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
row(item: ServiceConnection): TemplateResult[] {
|
2021-02-19 16:49:34 +00:00
|
|
|
return [
|
|
|
|
html`${item.name}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.verboseName}`,
|
2021-04-03 17:59:22 +00:00
|
|
|
html`${item.local ? t`Yes` : t`No`}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${until(
|
2021-08-03 15:52:21 +00:00
|
|
|
new OutpostsApi(DEFAULT_CONFIG)
|
|
|
|
.outpostsServiceConnectionsAllStateRetrieve({
|
|
|
|
uuid: item.pk || "",
|
|
|
|
})
|
|
|
|
.then((state) => {
|
|
|
|
if (state.healthy) {
|
|
|
|
return html`<ak-label
|
|
|
|
color=${PFColor.Green}
|
|
|
|
text=${ifDefined(state.version)}
|
|
|
|
></ak-label>`;
|
|
|
|
}
|
|
|
|
return html`<ak-label
|
|
|
|
color=${PFColor.Red}
|
|
|
|
text=${t`Unhealthy`}
|
|
|
|
></ak-label>`;
|
|
|
|
}),
|
|
|
|
html`<ak-spinner></ak-spinner>`,
|
|
|
|
)}`,
|
|
|
|
html` <ak-forms-modal>
|
2021-08-05 10:30:43 +00:00
|
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
|
|
<span slot="header"> ${t`Update ${item.verboseName}`} </span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
|
|
|
.args=${{
|
|
|
|
instancePk: item.pk,
|
2021-08-03 15:52:21 +00:00
|
|
|
}}
|
2021-08-05 10:30:43 +00:00
|
|
|
type=${ifDefined(item.component)}
|
2021-08-03 15:52:21 +00:00
|
|
|
>
|
2021-08-05 10:30:43 +00:00
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
|
|
|
<i class="fas fa-edit"></i>
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>`,
|
2021-02-19 16:49:34 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
renderToolbarSelected(): TemplateResult {
|
2021-08-12 20:03:13 +00:00
|
|
|
const disabled = this.selectedElements.length < 1;
|
|
|
|
return html`<ak-forms-delete-bulk
|
|
|
|
objectLabel=${t`Outpost integration(s)`}
|
|
|
|
.objects=${this.selectedElements}
|
|
|
|
.usedBy=${(item: ServiceConnection) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllUsedByList({
|
|
|
|
uuid: item.pk,
|
|
|
|
});
|
|
|
|
}}
|
2021-08-12 20:03:13 +00:00
|
|
|
.delete=${(item: ServiceConnection) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDestroy({
|
|
|
|
uuid: item.pk,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
|
|
${t`Delete`}
|
|
|
|
</button>
|
2021-08-12 20:03:13 +00:00
|
|
|
</ak-forms-delete-bulk>`;
|
2021-08-05 10:30:43 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 16:49:34 +00:00
|
|
|
renderToolbar(): TemplateResult {
|
2021-08-03 15:52:21 +00:00
|
|
|
return html` <ak-dropdown class="pf-c-dropdown">
|
|
|
|
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
|
|
|
|
<span class="pf-c-dropdown__toggle-text">${t`Create`}</span>
|
|
|
|
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
<ul class="pf-c-dropdown__menu" hidden>
|
|
|
|
${until(
|
|
|
|
new OutpostsApi(DEFAULT_CONFIG)
|
|
|
|
.outpostsServiceConnectionsAllTypesList()
|
|
|
|
.then((types) => {
|
|
|
|
return types.map((type) => {
|
|
|
|
return html`<li>
|
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit"> ${t`Create`} </span>
|
|
|
|
<span slot="header"> ${t`Create ${type.name}`} </span>
|
|
|
|
<ak-proxy-form slot="form" type=${type.component}>
|
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
|
|
|
${type.name}<br />
|
|
|
|
<small>${type.description}</small>
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
|
|
|
</li>`;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
html`<ak-spinner></ak-spinner>`,
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</ak-dropdown>
|
|
|
|
${super.renderToolbar()}`;
|
2021-02-19 16:49:34 +00:00
|
|
|
}
|
|
|
|
}
|