Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web/admin: fix document title for admin interface #9362

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions web/src/elements/PageHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider";
import "@patternfly/elements/pf-tooltip/pf-tooltip.js";

import { msg } from "@lit/localize";
import { CSSResult, PropertyValues, TemplateResult, css, html } from "lit";
import { CSSResult, TemplateResult, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";

import PFButton from "@patternfly/patternfly/components/Button/button.css";
Expand Down Expand Up @@ -107,21 +107,23 @@ export class PageHeader extends WithBrandConfig(AKElement) {
});
}

setTitle(value: string) {
setTitle(header?: string) {
const currentIf = currentInterface();
const title = this.brand?.brandingTitle || TITLE_DEFAULT;
document.title =
currentIf === "admin"
? `${msg("Admin")} - ${title}`
: value !== ""
? `${value} - ${title}`
: title;
let title = this.brand?.brandingTitle || TITLE_DEFAULT;
if (currentIf === "admin") {
title = `${msg("Admin")} - ${title}`;
}
// Prepend the header to the title
if (header !== undefined && header !== "") {
title = `${header} - ${title}`;
}
document.title = title;
}

willUpdate(changedProperties: PropertyValues<this>) {
if (changedProperties.has("header") && this.header) {
this.setTitle(this.header);
}
willUpdate() {
// Always update title, even if there's no header value set,
// as in that case we still need to return to the generic title
this.setTitle(this.header);
}

renderIcon(): TemplateResult {
Expand Down
Loading