mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* First stab at new page layouts behind feature toggle * Simplifying PageHeader * Progress on a new model that can more easily support new and old page layouts * Progress * rename folder * Progress * Minor change * fixes * Fixing tests * Make breadcrumbs work * Add tests for old Page component * Adding tests for new Page component and behavior * fixing page header test * Fixed test * AppChrome outside route * Renaming folder * Minor fix * Updated * Fixing StoragePage * Fix for banners Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
33 lines
773 B
TypeScript
33 lines
773 B
TypeScript
import { useEffect } from 'react';
|
|
|
|
import { NavModel, NavModelItem } from '@grafana/data';
|
|
|
|
import { Branding } from '../Branding/Branding';
|
|
|
|
export function usePageTitle(navModel?: NavModel, pageNav?: NavModelItem) {
|
|
useEffect(() => {
|
|
const parts: string[] = [];
|
|
|
|
if (pageNav) {
|
|
if (pageNav.children) {
|
|
const activePage = pageNav.children.find((x) => x.active);
|
|
if (activePage) {
|
|
parts.push(activePage.text);
|
|
}
|
|
}
|
|
parts.push(pageNav.text);
|
|
}
|
|
|
|
if (navModel) {
|
|
if (navModel.node !== navModel.main) {
|
|
parts.push(navModel.node.text);
|
|
}
|
|
parts.push(navModel.main.text);
|
|
}
|
|
|
|
parts.push(Branding.AppTitle);
|
|
|
|
document.title = parts.join(' - ');
|
|
}, [navModel, pageNav]);
|
|
}
|