From a9336d0983484debfe32e366aa9cdd5b99b39a6a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 4 Apr 2021 23:19:08 +0200 Subject: [PATCH] web: allow for non-path elements in hash, store current tab page in hash Signed-off-by: Jens Langhammer --- web/package-lock.json | 27 ----- web/package.json | 5 +- web/src/constants.ts | 1 + web/src/elements/Tabs.ts | 21 +++- web/src/elements/router/RouterOutlet.ts | 26 ++++- web/src/elements/sidebar/Sidebar.ts | 5 +- web/src/locales/en.po | 114 +++++++++----------- web/src/locales/pseudo-LOCALE.po | 114 +++++++++----------- web/src/pages/policies/PolicyBindingForm.ts | 4 +- web/src/pages/stages/StageListPage.ts | 2 +- 10 files changed, 151 insertions(+), 168 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 1692f62ed..7339f63c4 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -5304,33 +5304,6 @@ } } }, - "rollup-plugin-external-globals": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-external-globals/-/rollup-plugin-external-globals-0.6.1.tgz", - "integrity": "sha512-mlp3KNa5sE4Sp9UUR2rjBrxjG79OyZAh/QC18RHIjM+iYkbBwNXSo8DHRMZWtzJTrH8GxQ+SJvCTN3i14uMXIA==", - "requires": { - "@rollup/pluginutils": "^4.0.0", - "estree-walker": "^2.0.1", - "is-reference": "^1.2.1", - "magic-string": "^0.25.7" - }, - "dependencies": { - "@rollup/pluginutils": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.0.tgz", - "integrity": "sha512-TrBhfJkFxA+ER+ew2U2/fHbebhLT/l/2pRk0hfj9KusXUuRXd2v0R58AfaZK9VXDQ4TogOSEmICVrQAA3zFnHQ==", - "requires": { - "estree-walker": "^2.0.1", - "picomatch": "^2.2.2" - } - }, - "estree-walker": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.1.tgz", - "integrity": "sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==" - } - } - }, "rollup-plugin-minify-html-literals": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/rollup-plugin-minify-html-literals/-/rollup-plugin-minify-html-literals-1.2.6.tgz", diff --git a/web/package.json b/web/package.json index 1c4898d42..bfc3cfb5b 100644 --- a/web/package.json +++ b/web/package.json @@ -12,7 +12,10 @@ }, "lingui": { "sourceLocale": "en", - "locales": ["en", "pseudo-LOCALE"], + "locales": [ + "en", + "pseudo-LOCALE" + ], "pseudoLocale": "pseudo-LOCALE", "fallbackLocales": { "pseudo-LOCALE": "en" diff --git a/web/src/constants.ts b/web/src/constants.ts index e21c53ad4..f111e34d1 100644 --- a/web/src/constants.ts +++ b/web/src/constants.ts @@ -10,3 +10,4 @@ export const EVENT_NOTIFICATION_TOGGLE = "ak-notification-toggle"; export const EVENT_SIDEBAR_TOGGLE = "ak-sidebar-toggle"; export const EVENT_API_DRAWER_REFRESH = "ak-api-drawer-refresh"; export const TITLE_SUFFIX = "authentik"; +export const ROUTE_SEPARATOR = ";"; diff --git a/web/src/elements/Tabs.ts b/web/src/elements/Tabs.ts index a417603cf..a7895b455 100644 --- a/web/src/elements/Tabs.ts +++ b/web/src/elements/Tabs.ts @@ -3,7 +3,7 @@ import { ifDefined } from "lit-html/directives/if-defined"; import PFTabs from "@patternfly/patternfly/components/Tabs/tabs.css"; import PFGlobal from "@patternfly/patternfly/patternfly-base.css"; import AKGlobal from "../authentik.css"; -import { CURRENT_CLASS } from "../constants"; +import { CURRENT_CLASS, ROUTE_SEPARATOR } from "../constants"; import { t } from "@lingui/macro"; @customElement("ak-tabs") @@ -50,10 +50,17 @@ export class Tabs extends LitElement { super.disconnectedCallback(); } + onClick(slot?: string): void { + this.currentPage = slot; + const currentUrl = window.location.hash.slice(1, Infinity).split(ROUTE_SEPARATOR)[0]; + const newUrl = `#${currentUrl};${slot}`; + window.location.hash = newUrl; + } + renderTab(page: Element): TemplateResult { const slot = page.attributes.getNamedItem("slot")?.value; return html`
  • -