Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(frontend): standardize document title format across all routes (#19347)

boojack6ac8a7b17644
diff --git a/frontend/src/components/Release/ReleaseDetail/ReleaseDetail.vue b/frontend/src/components/Release/ReleaseDetail/ReleaseDetail.vue
index 054bb535bd..7c5967ea5f 100644
--- a/frontend/src/components/Release/ReleaseDetail/ReleaseDetail.vue
+++ b/frontend/src/components/Release/ReleaseDetail/ReleaseDetail.vue
@@ -29,10 +29,14 @@
<script lang="ts" setup>
import { computed, reactive, watch } from "vue";
+import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { Drawer, DrawerContent } from "@/components/v2";
import { PROJECT_V1_ROUTE_RELEASE_DETAIL } from "@/router/dashboard/projectV1";
+import { useProjectByName } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import type { Release_File } from "@/types/proto-es/v1/release_service_pb";
+import { setDocumentTitle } from "@/utils";
import BasicInfo from "./BasicInfo.vue";
import { provideReleaseDetailContext } from "./context";
import NavBar from "./NavBar";
@@ -43,23 +47,26 @@ interface LocalState {
selectedReleaseFile?: Release_File;
}
+const { t } = useI18n();
const route = useRoute();
const { release } = provideReleaseDetailContext();
const state = reactive<LocalState>({});
-const documentTitle = computed(() => {
- if (route.name !== PROJECT_V1_ROUTE_RELEASE_DETAIL) {
- return undefined;
- }
+const projectId = computed(() => {
const parts = release.value.name.split("/");
- return parts[parts.length - 1] || release.value.name;
+ const idx = parts.indexOf("projects");
+ return idx >= 0 ? parts[idx + 1] : "";
});
+const projectResourceName = computed(
+ () => `${projectNamePrefix}${projectId.value}`
+);
+const { project } = useProjectByName(projectResourceName);
watch(
- documentTitle,
- (title) => {
- if (title) {
- document.title = title;
+ [() => route.name, () => project.value.title],
+ () => {
+ if (route.name === PROJECT_V1_ROUTE_RELEASE_DETAIL) {
+ setDocumentTitle(t("release.releases"), project.value.title);
}
},
{ immediate: true }
diff --git a/frontend/src/composables/useLanguage.ts b/frontend/src/composables/useLanguage.ts
index 27a2dcc2d0..585ef74c75 100644
--- a/frontend/src/composables/useLanguage.ts
+++ b/frontend/src/composables/useLanguage.ts
@@ -1,7 +1,11 @@
import { useLocalStorage } from "@vueuse/core";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import { emitStorageChangedEvent, STORAGE_KEY_LANGUAGE } from "@/utils";
+import {
+ emitStorageChangedEvent,
+ STORAGE_KEY_LANGUAGE,
+ setDocumentTitle,
+} from "@/utils";
/**
* Language hook for i18n
@@ -18,8 +22,7 @@ const useLanguage = () => {
emitStorageChangedEvent();
if (currentRoute.value.meta.title) {
- const title = currentRoute.value.meta.title(currentRoute.value);
- document.title = title || "Bytebase";
+ setDocumentTitle(currentRoute.value.meta.title(currentRoute.value));
}
};
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index 827f0323b4..dd81f7b5fa 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -34,8 +34,8 @@
<script lang="tsx" setup>
import { type ConnectError } from "@connectrpc/connect";
import { NSpin } from "naive-ui";
-import { computed, watchEffect } from "vue";
-import { useRouter } from "vue-router";
+import { computed, watch, watchEffect } from "vue";
+import { useRoute, useRouter } from "vue-router";
import { BBAttention } from "@/bbkit";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
import IAMRemindModal from "@/components/IAMRemindModal.vue";
@@ -55,7 +55,7 @@ import {
import { projectNamePrefix } from "@/store/modules/v1/common";
import { DEFAULT_PROJECT_NAME, UNKNOWN_PROJECT_NAME } from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
-import { hasProjectPermissionV2 } from "@/utils";
+import { hasProjectPermissionV2, setDocumentTitle } from "@/utils";
const props = defineProps<{
projectId: string;
@@ -116,4 +116,19 @@ const allowEdit = computed(() => {
return hasProjectPermissionV2(project.value, "bb.projects.update");
});
+
+const route = useRoute();
+watch(
+ [() => route.meta.title, () => project.value.title, initialized],
+ () => {
+ if (!initialized.value) return;
+ const pageTitle = route.meta.title ? route.meta.title(route) : undefined;
+ if (pageTitle) {
+ setDocumentTitle(pageTitle, project.value.title);
+ } else {
+ setDocumentTitle(project.value.title);
+ }
+ },
+ { immediate: true }
+);
</script>
diff --git a/frontend/src/layouts/SettingLayout.vue b/frontend/src/layouts/SettingLayout.vue
index fb8d55550d..a9cdc71171 100644
--- a/frontend/src/layouts/SettingLayout.vue
+++ b/frontend/src/layouts/SettingLayout.vue
@@ -5,10 +5,26 @@
</template>
<script lang="ts" setup>
-import { computed } from "vue";
-import { hasWorkspacePermissionV2 } from "@/utils";
+import { computed, watch } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRoute } from "vue-router";
+import { hasWorkspacePermissionV2, setDocumentTitle } from "@/utils";
+
+const { t } = useI18n();
+const route = useRoute();
const allowEdit = computed((): boolean => {
return hasWorkspacePermissionV2("bb.settings.set");
});
+
+watch(
+ () => route.meta.title,
+ () => {
+ const pageTitle = route.meta.title ? route.meta.title(route) : undefined;
+ if (pageTitle) {
+ setDocumentTitle(pageTitle, t("common.settings"));
+ }
+ },
+ { immediate: true }
+);
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 77f38d173e..0362f1f61f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -272,7 +272,9 @@
"unknown": "Unknown"
},
"error-page": {
- "go-back-home": "Go back home"
+ "forbidden": "Forbidden",
+ "go-back-home": "Go back home",
+ "not-found": "Not Found"
},
"refresh-remind": {
"title": "Outdated version detected",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 4edae68561..5b79c69d87 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -272,7 +272,9 @@
"delete-resource-description": "Once you delete \"{name}\", there is no going back. Please be certain."
},
"error-page": {
- "go-back-home": "Volver al inicio"
+ "forbidden": "Prohibido",
+ "go-back-home": "Volver al inicio",
+ "not-found": "No encontrado"
},
"refresh-remind": {
"title": "Versión obsoleta detectada",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d47738e47c..c86226c096 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -272,7 +272,9 @@
"delete-resource-description": "Once you delete \"{name}\", there is no going back. Please be certain."
},
"error-page": {
- "go-back-home": "ホームページに戻る"
+ "forbidden": "アクセス禁止",
+ "go-back-home": "ホームページに戻る",
+ "not-found": "ページが見つかりません"
},
"refresh-remind": {
"title": "古いバージョンが検出されました",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 93ebd44040..2b6d68f9a8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -272,7 +272,9 @@
"delete-resource-description": "Once you delete \"{name}\", there is no going back. Please be certain."
},
"error-page": {
- "go-back-home": "Về trang chủ"
+ "forbidden": "Bị cấm",
+ "go-back-home": "Về trang chủ",
+ "not-found": "Không tìm thấy"
},
"refresh-remind": {
"title": "Đã phát hiện phiên bản lỗi thời",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 1da804a2c1..4135ebfde9 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -272,7 +272,9 @@
"delete-resource-description": "删除「{name}」后将无法恢复,请确认。"
},
"error-page": {
- "go-back-home": "回到主页"
+ "forbidden": "禁止访问",
+ "go-back-home": "回到主页",
+ "not-found": "页面未找到"
},
"refresh-remind": {
"title": "检测到过时版本",
diff --git a/frontend/src/router/auth.ts b/frontend/src/router/auth.ts
index a67450e367..3c87113dc8 100644
--- a/frontend/src/router/auth.ts
+++ b/frontend/src/router/auth.ts
@@ -73,7 +73,7 @@ const authRoutes: RouteRecordRaw[] = [
{
path: "idp-init",
name: AUTH_IDP_INIT_MODULE,
- meta: { title: () => "Initializing SSO" },
+ meta: { title: () => t("common.loading") },
component: () => import("@/views/IdPInitiatedSSO.vue"),
},
],
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index ffaa256c43..13d961919d 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -44,6 +44,9 @@ const workspaceRoutes: RouteRecordRaw[] = [
{
path: "landing",
name: WORKSPACE_ROUTE_LANDING,
+ meta: {
+ title: () => t("common.home"),
+ },
components: {
content: () => import("@/views/DashboardLanding.vue"),
leftSidebar: () => import("@/views/DashboardSidebar.vue"),
@@ -112,6 +115,9 @@ const workspaceRoutes: RouteRecordRaw[] = [
{
path: "403",
name: WORKSPACE_ROUTE_403,
+ meta: {
+ title: () => t("error-page.forbidden"),
+ },
components: {
content: () => import("@/views/Page403.vue"),
leftSidebar: () => import("@/views/DashboardSidebar.vue"),
@@ -124,6 +130,9 @@ const workspaceRoutes: RouteRecordRaw[] = [
{
path: "404",
name: WORKSPACE_ROUTE_404,
+ meta: {
+ title: () => t("error-page.not-found"),
+ },
components: {
content: () => import("@/views/Page404.vue"),
leftSidebar: () => import("@/views/DashboardSidebar.vue"),
@@ -137,6 +146,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
path: "sql-review",
meta: {
title: () => t("sql-review.title"),
+ overrideDocumentTitle: true,
},
components: {
content: () => import("@/layouts/SettingLayout.vue"),
@@ -190,6 +200,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
meta: {
title: () => t("settings.sidebar.sso"),
requiredPermissionList: () => ["bb.identityProviders.get"],
+ overrideDocumentTitle: true,
},
components: {
content: () => import("@/layouts/SettingLayout.vue"),
@@ -215,6 +226,9 @@ const workspaceRoutes: RouteRecordRaw[] = [
},
{
path: "",
+ meta: {
+ overrideDocumentTitle: true,
+ },
components: {
content: () => import("@/layouts/SettingLayout.vue"),
leftSidebar: () => import("@/views/DashboardSidebar.vue"),
@@ -342,6 +356,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
path: "integration",
meta: {
title: () => t("settings.sidebar.integration"),
+ overrideDocumentTitle: true,
},
components: {
content: () => import("@/layouts/SettingLayout.vue"),
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index d3b5b7d3ab..1b51f633b2 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1,5 +1,5 @@
-import { useTitle } from "@vueuse/core";
-import { nextTick, ref } from "vue";
+import { nextTick } from "vue";
+import { setDocumentTitle } from "@/utils";
import {
createRouter,
createWebHistory,
@@ -265,17 +265,17 @@ router.beforeEach((to, from, next) => {
});
});
-const DEFAULT_DOCUMENT_TITLE = "Bytebase";
-const title = ref(DEFAULT_DOCUMENT_TITLE);
-useTitle(title);
-
router.afterEach((to /*, from */) => {
- // Needs to use nextTick otherwise title will still be the one from the previous route.
+ // Skip routes where a layout component manages the document title:
+ // - ProjectV1Layout handles project-scoped routes (have projectId param)
+ // - SettingLayout handles settings routes (marked with overrideDocumentTitle)
+ if (to.params.projectId || to.meta.overrideDocumentTitle) return;
+
nextTick(() => {
if (to.meta.title) {
- document.title = to.meta.title(to);
+ setDocumentTitle(to.meta.title(to));
} else {
- document.title = DEFAULT_DOCUMENT_TITLE;
+ setDocumentTitle();
}
});
});
diff --git a/frontend/src/router/sqlEditor.ts b/frontend/src/router/sqlEditor.ts
index 617054f792..fda91d1e2a 100644
--- a/frontend/src/router/sqlEditor.ts
+++ b/frontend/src/router/sqlEditor.ts
@@ -1,5 +1,6 @@
import type { RouteRecordRaw } from "vue-router";
import SQLEditorLayout from "@/layouts/SQLEditorLayout.vue";
+import { t } from "@/plugins/i18n";
export const SQL_EDITOR_HOME_MODULE = "sql-editor.home";
export const SQL_EDITOR_PROJECT_MODULE = "sql-editor.project";
@@ -23,31 +24,31 @@ const sqlEditorRoutes: RouteRecordRaw[] = [
{
path: "",
name: SQL_EDITOR_HOME_MODULE,
- meta: { title: () => "Bytebase SQL Editor" },
+ meta: { title: () => t("sql-editor.self") },
component: () => import("../views/sql-editor/SQLEditorPage.vue"),
},
{
path: "projects/:project",
name: SQL_EDITOR_PROJECT_MODULE,
- meta: { title: () => "Bytebase SQL Editor" },
+ meta: { title: () => t("sql-editor.self") },
component: () => import("../views/sql-editor/SQLEditorPage.vue"),
},
{
path: "projects/:project/instances/:instance/databases/:database",
name: SQL_EDITOR_DATABASE_MODULE,
- meta: { title: () => "Bytebase SQL Editor" },
+ meta: { title: () => t("sql-editor.self") },
component: () => import("../views/sql-editor/SQLEditorPage.vue"),
},
{
path: "projects/:project/instances/:instance",
name: SQL_EDITOR_INSTANCE_MODULE,
- meta: { title: () => "Bytebase SQL Editor" },
+ meta: { title: () => t("sql-editor.self") },
component: () => import("../views/sql-editor/SQLEditorPage.vue"),
},
{
path: "projects/:project/sheets/:sheet",
name: SQL_EDITOR_WORKSHEET_MODULE,
- meta: { title: () => "Bytebase SQL Editor" },
+ meta: { title: () => t("sql-editor.self") },
component: () => import("../views/sql-editor/SQLEditorPage.vue"),
},
],
diff --git a/frontend/src/shims-vue-router.d.ts b/frontend/src/shims-vue-router.d.ts
index edfde69433..76ecd75a7f 100644
--- a/frontend/src/shims-vue-router.d.ts
+++ b/frontend/src/shims-vue-router.d.ts
@@ -6,5 +6,8 @@ declare module "vue-router" {
interface RouteMeta {
title?: (route: RouteLocationNormalized) => string;
requiredPermissionList?: () => Permission[];
+ // When true, a layout component (e.g. ProjectV1Layout, SettingLayout)
+ // manages document.title for this route, so the router afterEach skips it.
+ overrideDocumentTitle?: boolean;
}
}
diff --git a/frontend/src/utils/document-title.ts b/frontend/src/utils/document-title.ts
new file mode 100644
index 0000000000..d458587262
--- /dev/null
+++ b/frontend/src/utils/document-title.ts
@@ -0,0 +1,18 @@
+export const DOCUMENT_TITLE_SEPARATOR = " - ";
+export const DOCUMENT_TITLE_SUFFIX = "Bytebase";
+
+export function buildDocumentTitle(...segments: string[]): string {
+ const filtered = segments.filter((s) => s.length > 0);
+ if (filtered.length === 0) {
+ return DOCUMENT_TITLE_SUFFIX;
+ }
+ return (
+ filtered.join(DOCUMENT_TITLE_SEPARATOR) +
+ DOCUMENT_TITLE_SEPARATOR +
+ DOCUMENT_TITLE_SUFFIX
+ );
+}
+
+export function setDocumentTitle(...segments: string[]): void {
+ document.title = buildDocumentTitle(...segments);
+}
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 0dedbf2fc7..f986ae03e1 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -28,3 +28,4 @@ export * from "./expr";
export * from "./accessGrant";
export * from "./storage-keys";
export * from "./storage-migrate";
+export * from "./document-title";
diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
index 0e7e264e84..53360f78e2 100644
--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
@@ -217,7 +217,6 @@
</template>
<script lang="ts" setup>
-import { useTitle } from "@vueuse/core";
import { ArrowRightLeftIcon } from "lucide-vue-next";
import { NButton, NTabPane, NTabs } from "naive-ui";
import { computed, reactive, watch, watchEffect } from "vue";
@@ -261,6 +260,7 @@ import {
getInstanceResource,
instanceV1HasAlterSchema,
PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE,
+ setDocumentTitle,
} from "@/utils";
import { extractReleaseUID } from "@/utils/v1/release";
@@ -365,7 +365,14 @@ const environment = computed(() => {
return getDatabaseEnvironment(database.value);
});
-useTitle(
- computed(() => extractDatabaseResourceName(database.value.name).databaseName)
+watch(
+ [() => database.value.name, () => project.value.title],
+ () => {
+ const dbName = extractDatabaseResourceName(
+ database.value.name
+ ).databaseName;
+ setDocumentTitle(dbName, project.value.title);
+ },
+ { immediate: true }
);
</script>
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index a044ddaa77..c835eb3f09 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -79,7 +79,6 @@
</template>
<script lang="tsx" setup>
-import { useTitle } from "@vueuse/core";
import { cloneDeep } from "lodash-es";
import { NTabPane, NTabs } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
@@ -124,6 +123,7 @@ import {
getValuesFromSearchParams,
instanceV1HasCreateDatabase,
instanceV1Name,
+ setDocumentTitle,
} from "@/utils";
const instanceHashList = ["overview", "databases", "users"] as const;
@@ -267,7 +267,13 @@ const createDatabase = () => {
state.showCreateDatabaseModal = true;
};
-useTitle(computed(() => instance.value.title));
+watch(
+ () => instance.value.title,
+ (title) => {
+ setDocumentTitle(title);
+ },
+ { immediate: true }
+);
const selectedDatabases = computed((): Database[] => {
return state.selectedDatabaseNameList
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 0938a3fb2f..6bd258516c 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -213,7 +213,6 @@
import { create } from "@bufbuild/protobuf";
import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";
import type { ConnectError } from "@connectrpc/connect";
-import { useTitle } from "@vueuse/core";
import { cloneDeep, isEqual } from "lodash-es";
import { EllipsisIcon } from "lucide-vue-next";
import type { DropdownOption } from "naive-ui";
@@ -226,6 +225,7 @@ import {
onUnmounted,
reactive,
ref,
+ watch,
} from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
@@ -271,7 +271,12 @@ import {
UpdateUserRequestSchema,
UserType,
} from "@/types/proto-es/v1/user_service_pb";
-import { displayRoleTitle, hasWorkspacePermissionV2, sortRoles } from "@/utils";
+import {
+ displayRoleTitle,
+ hasWorkspacePermissionV2,
+ setDocumentTitle,
+ sortRoles,
+} from "@/utils";
import { migrateUserStorage } from "@/utils/storage-migrate";
interface LocalState {
@@ -564,5 +569,11 @@ const dropDownOptions = computed((): DropdownOption[] => [
},
]);
-useTitle(computed(() => user.value.title));
+watch(
+ () => user.value.title,
+ (title) => {
+ setDocumentTitle(title);
+ },
+ { immediate: true }
+);
</script>
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index 00ac388ef2..3a0dbe0152 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -173,7 +173,6 @@
</template>
<script lang="tsx" setup>
-import { useTitle } from "@vueuse/core";
import { NButton, NDivider, NTag } from "naive-ui";
import {
computed,
@@ -205,7 +204,11 @@ import {
} from "@/types";
import type { Engine } from "@/types/proto-es/v1/common_pb";
import { SQLReviewRule_Type } from "@/types/proto-es/v1/review_config_service_pb";
-import { hasWorkspacePermissionV2, sqlReviewNameFromSlug } from "@/utils";
+import {
+ hasWorkspacePermissionV2,
+ setDocumentTitle,
+ sqlReviewNameFromSlug,
+} from "@/utils";
const props = defineProps<{
sqlReviewPolicySlug: string;
@@ -402,7 +405,13 @@ const onRemove = () => {
});
};
-useTitle(computed(() => reviewPolicy.value.name));
+watch(
+ () => reviewPolicy.value.name,
+ (name) => {
+ setDocumentTitle(name);
+ },
+ { immediate: true }
+);
</script>
<style lang="postcss" scoped>
diff --git a/frontend/src/views/project/IssueLayout.vue b/frontend/src/views/project/IssueLayout.vue
index e1fd74c302..9ff9d15962 100644
--- a/frontend/src/views/project/IssueLayout.vue
+++ b/frontend/src/views/project/IssueLayout.vue
@@ -22,9 +22,8 @@
</template>
<script lang="tsx" setup>
-import { useTitle } from "@vueuse/core";
import { NSpin } from "naive-ui";
-import { computed, ref, toRef } from "vue";
+import { computed, ref, toRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
import {
@@ -36,6 +35,9 @@ import { HeaderSection } from "@/components/Plan/components";
import { provideSidebarContext } from "@/components/Plan/logic/sidebar";
import { useNavigationGuard } from "@/components/Plan/logic/useNavigationGuard";
import PollerProvider from "@/components/Plan/PollerProvider.vue";
+import { useProjectByName } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { setDocumentTitle } from "@/utils";
const props = defineProps<{
projectId: string;
@@ -83,23 +85,29 @@ providePlanContext({
provideSidebarContext(containerRef);
-const documentTitle = computed(() => {
- if (isCreating.value) {
- return t("plan.new-plan");
- } else {
- if (ready.value) {
- if (issue.value) {
- return issue.value.title;
- }
- if (plan.value) {
- return plan.value.title;
+const projectName = computed(() => `${projectNamePrefix}${props.projectId}`);
+const { project } = useProjectByName(projectName);
+
+watch(
+ [
+ isCreating,
+ ready,
+ () => issue.value?.title,
+ () => plan.value?.title,
+ () => project.value.title,
+ ],
+ () => {
+ if (isCreating.value) {
+ setDocumentTitle(t("plan.new-plan"), project.value.title);
+ } else if (ready.value) {
+ const entityTitle = issue.value?.title || plan.value?.title;
+ if (entityTitle) {
+ setDocumentTitle(entityTitle, project.value.title);
}
}
- }
- return t("common.loading");
-});
-
-useTitle(documentTitle);
+ },
+ { immediate: true }
+);
// Set up navigation guards to check for unsaved changes
const handleRouteNavigation = async (
diff --git a/frontend/src/views/project/RolloutLayout.vue b/frontend/src/views/project/RolloutLayout.vue
index 0543786b22..d6bfe70cbd 100644
--- a/frontend/src/views/project/RolloutLayout.vue
+++ b/frontend/src/views/project/RolloutLayout.vue
@@ -27,9 +27,8 @@
</template>
<script lang="ts" setup>
-import { useTitle } from "@vueuse/core";
import { NSpin } from "naive-ui";
-import { computed, ref, toRef, watchEffect } from "vue";
+import { computed, ref, toRef, watch, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import {
providePlanContext,
@@ -40,8 +39,10 @@ import RefreshIndicator from "@/components/Plan/components/RefreshIndicator.vue"
import { provideSidebarContext } from "@/components/Plan/logic/sidebar";
import PollerProvider from "@/components/Plan/PollerProvider.vue";
import RolloutBreadcrumb from "@/components/RolloutV1/components/Rollout/RolloutBreadcrumb.vue";
-import { usePolicyV1Store } from "@/store";
+import { usePolicyV1Store, useProjectByName } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
+import { setDocumentTitle } from "@/utils";
const props = defineProps<{
projectId: string;
@@ -96,12 +97,17 @@ providePlanContext({
provideSidebarContext(containerRef);
-useTitle(
- computed(() => {
- if (ready.value && plan.value?.title) {
- return plan.value.title;
+const projectName = computed(() => `${projectNamePrefix}${props.projectId}`);
+const { project } = useProjectByName(projectName);
+
+watch(
+ [ready, () => plan.value?.title, () => project.value.title],
+ () => {
+ if (ready.value) {
+ const planTitle = plan.value?.title || t("common.rollout");
+ setDocumentTitle(planTitle, project.value.title);
}
- return ready.value ? t("common.rollout") : t("common.loading");
- })
+ },
+ { immediate: true }
);
</script>