-
-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add <PageTitle /> component * Use useEffect to override hard-coded value * Ensure page titles are tracked across the site * Adjust unit tests * Playwright test updates * Tweak tests * Update InvenTreeTable.tsx Revert unused change
- Loading branch information
1 parent
113b9e9
commit 7b50f3b
Showing
14 changed files
with
149 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useEffect, useMemo } from 'react'; | ||
import { useGlobalSettingsState } from '../../states/SettingsState'; | ||
|
||
/** | ||
* Component to set the page title | ||
*/ | ||
export default function PageTitle({ | ||
title, | ||
subtitle | ||
}: { | ||
title?: string; | ||
subtitle?: string; | ||
}) { | ||
const globalSettings = useGlobalSettingsState(); | ||
|
||
const pageTitle = useMemo(() => { | ||
const instanceName = globalSettings.getSetting( | ||
'INVENTREE_INSTANCE', | ||
'InvenTree' | ||
); | ||
const useInstanceName = globalSettings.isSet( | ||
'INVENTREE_INSTANCE_TITLE', | ||
false | ||
); | ||
|
||
let data = ''; | ||
|
||
if (title) { | ||
data += title; | ||
} | ||
|
||
if (subtitle) { | ||
data += ` - ${subtitle}`; | ||
} | ||
|
||
if (useInstanceName) { | ||
data = `${instanceName} | ${data}`; | ||
} | ||
|
||
if (!data) { | ||
// Backup: No title provided | ||
data = instanceName; | ||
} | ||
|
||
return data; | ||
}, [title, subtitle, globalSettings]); | ||
|
||
useEffect(() => { | ||
document.title = pageTitle; | ||
}, [pageTitle]); | ||
|
||
return <title>{pageTitle}</title>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.