Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(frontend): add project or product context to page titles (#9037)

Andrew Huang132411149f8f
diff --git a/frontend/public/locales/en/translations.json b/frontend/public/locales/en/translations.json
index c18eb106ae..9b7d121692 100644
--- a/frontend/public/locales/en/translations.json
+++ b/frontend/public/locales/en/translations.json
@@ -65,6 +65,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "A project with this name already exists.",
"email": "Email",
"password": "Password",
diff --git a/frontend/public/locales/es/translations.json b/frontend/public/locales/es/translations.json
index e0342a9bc9..c538838374 100644
--- a/frontend/public/locales/es/translations.json
+++ b/frontend/public/locales/es/translations.json
@@ -40,6 +40,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "Ya existe un proyecto con este nombre.",
"email": "Correo electrónico",
"password": "Contraseña",
diff --git a/frontend/public/locales/fr/translations.json b/frontend/public/locales/fr/translations.json
index 7d59957a7a..3424e29f9c 100644
--- a/frontend/public/locales/fr/translations.json
+++ b/frontend/public/locales/fr/translations.json
@@ -40,6 +40,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "Un projet avec ce nom existe déjà.",
"email": "Email",
"password": "Mot de passe",
diff --git a/frontend/public/locales/ko/translations.json b/frontend/public/locales/ko/translations.json
index ad35d8b918..18c8510ca3 100644
--- a/frontend/public/locales/ko/translations.json
+++ b/frontend/public/locales/ko/translations.json
@@ -29,6 +29,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "동일한 이름을 가진 프로젝트가 이미 존재해요.",
"email": "메일",
"password": "비밀번호",
diff --git a/frontend/public/locales/pt-BR/translations.json b/frontend/public/locales/pt-BR/translations.json
index 6e84c2a9ae..debb4f864c 100644
--- a/frontend/public/locales/pt-BR/translations.json
+++ b/frontend/public/locales/pt-BR/translations.json
@@ -40,6 +40,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "Já exite um projeto com este nome.",
"email": "Email",
"password": "Senha",
diff --git a/frontend/public/locales/tr/translations.json b/frontend/public/locales/tr/translations.json
index 1da283a835..3e7f75e488 100644
--- a/frontend/public/locales/tr/translations.json
+++ b/frontend/public/locales/tr/translations.json
@@ -40,6 +40,7 @@
},
"common": {
"head-title": "{{title}} | Infisical",
+ "head-title-scoped": "{{title}} · {{scope}} | Infisical",
"error_project-already-exists": "Bu isimle bir proje zaten mevcut.",
"email": "Email",
"password": "Şifre",
diff --git a/frontend/src/components/PageTitle.tsx b/frontend/src/components/PageTitle.tsx
index b765d881bf..522be272a3 100644
--- a/frontend/src/components/PageTitle.tsx
+++ b/frontend/src/components/PageTitle.tsx
@@ -1,7 +1,52 @@
import { useTranslation } from "react-i18next";
+import { useQuery } from "@tanstack/react-query";
+import { useRouterState } from "@tanstack/react-router";
+
+import { getProjectTitle } from "@app/helpers/project";
+import { projectKeys } from "@app/hooks/api";
+import { fetchProjectById } from "@app/hooks/api/projects/queries";
+import { useImplicitProduct } from "@app/hooks/useImplicitProduct";
export const PageTitle = ({ title }: { title: string }) => {
const { t, ready } = useTranslation(undefined, { useSuspense: false });
+ // Read from the router state rather than useParams, which throws in the router's pending
+ // component because it renders outside any route match.
+ const projectId = useRouterState({
+ select: (state) => {
+ const params = state.matches[state.matches.length - 1]?.params;
+ return params && "projectId" in params ? params.projectId : "";
+ }
+ });
+ const implicitProduct = useImplicitProduct();
+
+ // Only reads the project the route layout already loaded, so a title never sends a request of its own.
+ const { data: project } = useQuery({
+ queryKey: projectKeys.getProjectById(projectId),
+ queryFn: () => fetchProjectById(projectId),
+ enabled: false
+ });
+
+ // Products with one project per organization never name it, so the product stands in for it,
+ // unless the page title already names the product.
+ const productName = implicitProduct ? getProjectTitle(implicitProduct) : undefined;
+ const scope =
+ project?.name ?? (productName && !title.includes(productName) ? productName : undefined);
+
+ if (scope && scope !== title) {
+ // Locale files are served immutable for 30 days, so a cached copy can predate this key. The
+ // default stays a template so the scope is interpolated, never parsed as one.
+ return (
+ <title>
+ {ready
+ ? t("common.head-title-scoped", {
+ title,
+ scope,
+ defaultValue: "{{title}} · {{scope}} | Infisical"
+ })
+ : `${title} · ${scope} | Infisical`}
+ </title>
+ );
+ }
return <title>{ready ? t("common.head-title", { title }) : `${title} | Infisical`}</title>;
};
diff --git a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
index 2073739c02..cc55f2a595 100644
--- a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
@@ -307,18 +307,21 @@ export const ProjectTypePage = () => {
if (projectType === ProjectType.CertificateManager) {
return (
- <CertManagerNotConfiguredModal
- isOpen={isCertManagerSetupOpen}
- onOpenChange={(open) => {
- setIsCertManagerSetupOpen(open);
- if (!open) {
- navigate({
- to: "/organizations/$orgId/projects",
- params: { orgId }
- });
- }
- }}
- />
+ <>
+ <PageTitle title={getProjectTitle(projectType)} />
+ <CertManagerNotConfiguredModal
+ isOpen={isCertManagerSetupOpen}
+ onOpenChange={(open) => {
+ setIsCertManagerSetupOpen(open);
+ if (!open) {
+ navigate({
+ to: "/organizations/$orgId/projects",
+ params: { orgId }
+ });
+ }
+ }}
+ />
+ </>
);
}