From 5571aa32b6e5431770d90d19ffb9e9194d0d59ac Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 1 Aug 2021 11:47:22 +0200 Subject: [PATCH] web/admin: add UI to copy invitation link Signed-off-by: Jens Langhammer --- web/src/locales/en.po | 9 +++ web/src/locales/pseudo-LOCALE.po | 9 +++ .../stages/invitation/InvitationListLink.ts | 67 +++++++++++++++++++ .../stages/invitation/InvitationListPage.ts | 15 +++++ 4 files changed, 100 insertions(+) create mode 100644 web/src/pages/stages/invitation/InvitationListLink.ts diff --git a/web/src/locales/en.po b/web/src/locales/en.po index bae3fff3a..06403de74 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -2086,6 +2086,10 @@ msgstr "Link to a user with identical email address. Can have security implicati msgid "Link to a user with identical username address. Can have security implications when a username is used with another source." msgstr "Link to a user with identical username address. Can have security implications when a username is used with another source." +#: src/pages/stages/invitation/InvitationListLink.ts +msgid "Link to use the invitation." +msgstr "Link to use the invitation." + #: src/pages/sources/oauth/OAuthSourceForm.ts #: src/pages/sources/plex/PlexSourceForm.ts msgid "Link users on unique identifier" @@ -2174,6 +2178,7 @@ msgstr "Loading" #: src/pages/stages/identification/IdentificationStageForm.ts #: src/pages/stages/identification/IdentificationStageForm.ts #: src/pages/stages/identification/IdentificationStageForm.ts +#: src/pages/stages/invitation/InvitationListLink.ts #: src/pages/stages/password/PasswordStageForm.ts #: src/pages/stages/prompt/PromptStageForm.ts #: src/pages/stages/prompt/PromptStageForm.ts @@ -3274,6 +3279,10 @@ msgstr "Select a provider that this application should use. Alternatively, creat msgid "Select all rows" msgstr "Select all rows" +#: src/pages/stages/invitation/InvitationListLink.ts +msgid "Select an enrollment flow" +msgstr "Select an enrollment flow" + #: src/flows/stages/authenticator_validate/AuthenticatorValidateStage.ts msgid "Select an identification method." msgstr "Select an identification method." diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index fa2a647c7..de85dab3d 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -2078,6 +2078,10 @@ msgstr "" msgid "Link to a user with identical username address. Can have security implications when a username is used with another source." msgstr "" +#: src/pages/stages/invitation/InvitationListLink.ts +msgid "Link to use the invitation." +msgstr "" + #: src/pages/sources/oauth/OAuthSourceForm.ts #: src/pages/sources/plex/PlexSourceForm.ts msgid "Link users on unique identifier" @@ -2166,6 +2170,7 @@ msgstr "" #: src/pages/stages/identification/IdentificationStageForm.ts #: src/pages/stages/identification/IdentificationStageForm.ts #: src/pages/stages/identification/IdentificationStageForm.ts +#: src/pages/stages/invitation/InvitationListLink.ts #: src/pages/stages/password/PasswordStageForm.ts #: src/pages/stages/prompt/PromptStageForm.ts #: src/pages/stages/prompt/PromptStageForm.ts @@ -3266,6 +3271,10 @@ msgstr "" msgid "Select all rows" msgstr "" +#: src/pages/stages/invitation/InvitationListLink.ts +msgid "Select an enrollment flow" +msgstr "" + #: src/flows/stages/authenticator_validate/AuthenticatorValidateStage.ts msgid "Select an identification method." msgstr "" diff --git a/web/src/pages/stages/invitation/InvitationListLink.ts b/web/src/pages/stages/invitation/InvitationListLink.ts new file mode 100644 index 000000000..052549bd4 --- /dev/null +++ b/web/src/pages/stages/invitation/InvitationListLink.ts @@ -0,0 +1,67 @@ +import { t } from "@lingui/macro"; +import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; +import { until } from "lit-html/directives/until"; +import PFForm from "@patternfly/patternfly/components/Form/form.css"; +import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css"; +import AKGlobal from "../../../authentik.css"; +import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css"; +import { FlowsApi, FlowsInstancesListDesignationEnum } from "authentik-api"; +import { DEFAULT_CONFIG } from "../../../api/Config"; +import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; + +@customElement("ak-stage-invitation-list-link") +export class InvitationListLink extends LitElement { + + @property() + invitation?: string + + @property() + selectedFlow?: string; + + static get styles(): CSSResult[] { + return [PFBase, PFForm, PFFormControl, PFFlex, PFDescriptionList, AKGlobal]; + } + + renderLink(): string { + return `${window.location.protocol}//${window.location.host}/if/flow/${this.selectedFlow}/?token=${this.invitation}`; + } + + render(): TemplateResult { + return html`
+
+
+ ${t`Select an enrollment flow`} +
+
+
+ +
+
+
+
+
+ ${t`Link to use the invitation.`} +
+
+
+ +
+
+
+
`; + } + +} diff --git a/web/src/pages/stages/invitation/InvitationListPage.ts b/web/src/pages/stages/invitation/InvitationListPage.ts index ed351e4b0..08dbb6917 100644 --- a/web/src/pages/stages/invitation/InvitationListPage.ts +++ b/web/src/pages/stages/invitation/InvitationListPage.ts @@ -8,6 +8,7 @@ import "../../../elements/buttons/SpinnerButton"; import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/ModalForm"; import "./InvitationForm"; +import "./InvitationListLink"; import { TableColumn } from "../../../elements/table/Table"; import { PAGE_SIZE } from "../../../constants"; import { Invitation, StagesApi } from "authentik-api"; @@ -15,6 +16,8 @@ import { DEFAULT_CONFIG } from "../../../api/Config"; @customElement("ak-stage-invitation-list") export class InvitationListPage extends TablePage { + expandable = true; + searchEnabled(): boolean { return true; } @@ -75,6 +78,18 @@ export class InvitationListPage extends TablePage { ]; } + renderExpanded(item: Invitation): TemplateResult { + return html` + +
+ +
+ + + + `; + } + renderToolbar(): TemplateResult { return html`