From 0d3705685e10018a0ab4ab46fa7e20e3ac213880 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 4 Nov 2021 21:00:42 +0100 Subject: [PATCH] web/admin: show warning on invitation list when no stage exists or is bound closes #1720 Signed-off-by: Jens Langhammer --- .../stages/invitation/InvitationListPage.ts | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/web/src/pages/stages/invitation/InvitationListPage.ts b/web/src/pages/stages/invitation/InvitationListPage.ts index ce139eac9..3719aa63c 100644 --- a/web/src/pages/stages/invitation/InvitationListPage.ts +++ b/web/src/pages/stages/invitation/InvitationListPage.ts @@ -1,7 +1,10 @@ import { t } from "@lingui/macro"; -import { TemplateResult, html } from "lit"; -import { customElement, property } from "lit/decorators"; +import { CSSResult, TemplateResult, html } from "lit"; +import { customElement, property, state } from "lit/decorators"; +import { ifDefined } from "lit/directives/if-defined"; + +import PFBanner from "@patternfly/patternfly/components/Banner/banner.css"; import { Invitation, StagesApi } from "@goauthentik/api"; @@ -34,12 +37,24 @@ export class InvitationListPage extends TablePage { return "pf-icon pf-icon-migration"; } + static get styles(): CSSResult[] { + return super.styles.concat(PFBanner); + } + checkbox = true; @property() order = "expires"; + @state() + invitationStageExists = false; + async apiEndpoint(page: number): Promise> { + const stages = await new StagesApi(DEFAULT_CONFIG).stagesInvitationStagesList({ + noFlows: false, + }); + this.invitationStageExists = stages.pagination.count > 0; + this.expandable = this.invitationStageExists; return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsList({ ordering: this.order, page: page, @@ -110,4 +125,23 @@ export class InvitationListPage extends TablePage { ${super.renderToolbar()} `; } + + render(): TemplateResult { + return html` + + ${this.invitationStageExists + ? html`` + : html` +
+ ${t`Warning: No invitation stage is bound to any flow. Invitations will not work as expected.`} +
+ `} +
+
${this.renderTable()}
+
`; + } }