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`
  • -