From 31fc4d1cb9096415dce6bb8babea18e1e1ec5fc7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 13 Jun 2021 22:55:41 +0200 Subject: [PATCH] web: migrate banner to sidebar Signed-off-by: Jens Langhammer --- web/src/elements/Banner.ts | 27 ------------- web/src/elements/sidebar/Sidebar.ts | 1 - web/src/elements/sidebar/SidebarItem.ts | 25 ++++++++++-- .../identification/IdentificationStage.ts | 2 +- web/src/interfaces/AdminInterface.ts | 39 ++++++++----------- web/src/locales/en.po | 24 ++---------- web/src/locales/pseudo-LOCALE.po | 18 +-------- 7 files changed, 44 insertions(+), 92 deletions(-) delete mode 100644 web/src/elements/Banner.ts diff --git a/web/src/elements/Banner.ts b/web/src/elements/Banner.ts deleted file mode 100644 index 0c8d651ec..000000000 --- a/web/src/elements/Banner.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { customElement, CSSResult, html, LitElement, property, TemplateResult } from "lit-element"; -import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css"; -import PFBanner from "@patternfly/patternfly/components/Banner/banner.css"; -import AKGlobal from "../authentik.css"; - -@customElement("ak-banner") -export class Banner extends LitElement { - - @property() - level = "pf-m-warning"; - - static get styles(): CSSResult[] { - return [PFBase, PFBanner, PFFlex, AKGlobal]; - } - - render(): TemplateResult { - return html`
-
-
- -
-
-
`; - } - -} diff --git a/web/src/elements/sidebar/Sidebar.ts b/web/src/elements/sidebar/Sidebar.ts index b1e03cc05..5d2f6e076 100644 --- a/web/src/elements/sidebar/Sidebar.ts +++ b/web/src/elements/sidebar/Sidebar.ts @@ -19,7 +19,6 @@ export class Sidebar extends LitElement { css` :host { z-index: 100; - box-shadow: none !important; } .pf-c-nav__link.pf-m-current::after, .pf-c-nav__link.pf-m-current:hover::after, diff --git a/web/src/elements/sidebar/SidebarItem.ts b/web/src/elements/sidebar/SidebarItem.ts index 27d4b6ee1..701575395 100644 --- a/web/src/elements/sidebar/SidebarItem.ts +++ b/web/src/elements/sidebar/SidebarItem.ts @@ -21,6 +21,13 @@ export class SidebarItem extends LitElement { z-index: 100; box-shadow: none !important; } + :host([highlight]) .pf-c-nav__item { + background-color: var(--ak-accent); + margin: 16px; + } + :host([highlight]) .pf-c-nav__item .pf-c-nav__link { + padding-left: 0.5rem; + } .pf-c-nav__link.pf-m-current::after, .pf-c-nav__link.pf-m-current:hover::after, .pf-c-nav__item.pf-m-current:not(.pf-m-expanded) .pf-c-nav__link::after { @@ -75,6 +82,12 @@ export class SidebarItem extends LitElement { @property({ type: Boolean }) isActive = false; + @property({ type: Boolean }) + isAbsoluteLink?: boolean; + + @property({ type: Boolean }) + highlight?: boolean; + parent?: SidebarItem; get childItems(): SidebarItem[] { @@ -159,9 +172,15 @@ export class SidebarItem extends LitElement { `; } return html`
  • - - - + ${this.path ? html` + + + + ` : html` + + + + `}
  • `; } } diff --git a/web/src/flows/stages/identification/IdentificationStage.ts b/web/src/flows/stages/identification/IdentificationStage.ts index 873547905..ff0cb674a 100644 --- a/web/src/flows/stages/identification/IdentificationStage.ts +++ b/web/src/flows/stages/identification/IdentificationStage.ts @@ -21,7 +21,7 @@ export const PasswordManagerPrefill: { totp: undefined, }; -declare module "Intl" { +declare module Intl { class ListFormat { constructor(locale: string, args: { [key: string]: string }); public format: (items: string[]) => string; diff --git a/web/src/interfaces/AdminInterface.ts b/web/src/interfaces/AdminInterface.ts index 01cfc233f..f70300088 100644 --- a/web/src/interfaces/AdminInterface.ts +++ b/web/src/interfaces/AdminInterface.ts @@ -13,7 +13,6 @@ import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css"; import "../elements/router/RouterOutlet"; import "../elements/messages/MessageContainer"; import "../elements/notifications/NotificationDrawer"; -import "../elements/Banner"; import "../elements/sidebar/Sidebar"; import { until } from "lit-html/directives/until"; import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, VERSION } from "../constants"; @@ -54,28 +53,6 @@ export class AdminInterface extends LitElement { render(): TemplateResult { return html` - ${until(new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve().then(version => { - if (version.versionCurrent !== VERSION) { - return html` - ${t`A newer version of the frontend is available.`} - - `; - } - return html``; - }))} - ${until(me().then((u) => { - if (u.original) { - return html` - ${t`You're currently impersonating ${u.user.username}.`} - - ${t`Stop impersonation`} - - `; - } - return html``; - }))}
    ${this.renderSidebarItems()} @@ -104,6 +81,22 @@ export class AdminInterface extends LitElement { return me().then(u => u.user.isSuperuser || false); }; return html` + ${until(new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve().then(version => { + if (version.versionCurrent !== VERSION) { + return html` + ${t`A newer version of the frontend is available.`} + `; + } + return html``; + }))} + ${until(me().then((u) => { + if (u.original) { + return html` + ${t`You're currently impersonating ${u.user.username}. Click to stop.`} + `; + } + return html``; + }))} ${t`Library`} diff --git a/web/src/locales/en.po b/web/src/locales/en.po index c073250bc..51b0aa61d 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -32,7 +32,7 @@ msgstr "6 digits, widely compatible" msgid "8 digits, not compatible with apps like Google Authenticator" msgstr "8 digits, not compatible with apps like Google Authenticator" -#: src/interfaces/Interface.ts +#: src/interfaces/AdminInterface.ts msgid "A newer version of the frontend is available." msgstr "A newer version of the frontend is available." @@ -1286,14 +1286,6 @@ msgstr "Email address" msgid "Email info:" msgstr "Email info:" -#: src/flows/stages/identification/IdentificationStage.ts -msgid "Email or username" -msgstr "Email or username" - -#: src/flows/stages/identification/IdentificationStage.ts -msgid "Email, UPN or username" -msgstr "Email, UPN or username" - #: src/pages/stages/prompt/PromptForm.ts msgid "Email: Text field with Email type." msgstr "Email: Text field with Email type." @@ -2935,10 +2927,6 @@ msgstr "Regular expressions for which authentication is not required. Each new l msgid "Related" msgstr "Related" -#: src/interfaces/Interface.ts -msgid "Reload" -msgstr "Reload" - #: src/pages/stages/user_logout/UserLogoutStageForm.ts msgid "Remove the user from the current session." msgstr "Remove the user from the current session." @@ -3416,10 +3404,6 @@ msgstr "Status: Disabled" msgid "Status: Enabled" msgstr "Status: Enabled" -#: src/interfaces/Interface.ts -msgid "Stop impersonation" -msgstr "Stop impersonation" - #: src/pages/events/EventInfo.ts #: src/pages/stages/email/EmailStageForm.ts msgid "Subject" @@ -4529,9 +4513,9 @@ msgstr "Yes" msgid "You can only select providers that match the type of the outpost." msgstr "You can only select providers that match the type of the outpost." -#: src/interfaces/Interface.ts -msgid "You're currently impersonating {0}." -msgstr "You're currently impersonating {0}." +#: src/interfaces/AdminInterface.ts +msgid "You're currently impersonating {0}. Click to stop." +msgstr "You're currently impersonating {0}. Click to stop." #: src/pages/stages/password/PasswordStageForm.ts msgid "authentik Builtin Database" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 13ef7b8ba..6df2b473c 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -1278,14 +1278,6 @@ msgstr "" msgid "Email info:" msgstr "" -#: -msgid "Email or username" -msgstr "" - -#: -msgid "Email, UPN or username" -msgstr "" - #: msgid "Email: Text field with Email type." msgstr "" @@ -2927,10 +2919,6 @@ msgstr "" msgid "Related" msgstr "" -#: -msgid "Reload" -msgstr "" - #: msgid "Remove the user from the current session." msgstr "" @@ -3408,10 +3396,6 @@ msgstr "" msgid "Status: Enabled" msgstr "" -#: -msgid "Stop impersonation" -msgstr "" - #: #: msgid "Subject" @@ -4516,7 +4500,7 @@ msgid "You can only select providers that match the type of the outpost." msgstr "" #: -msgid "You're currently impersonating {0}." +msgid "You're currently impersonating {0}. Click to stop." msgstr "" #: