Skip to content

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

fix: multiple fe issues (#20774)

ecmadao490f26d06ef0
diff --git a/frontend/src/locales/dynamic/en-US.json b/frontend/src/locales/dynamic/en-US.json
index 529f926103..d971ad9840 100644
--- a/frontend/src/locales/dynamic/en-US.json
+++ b/frontend/src/locales/dynamic/en-US.json
@@ -189,6 +189,10 @@
"desc": "Secure database connections with SSL/TLS encryption.",
"title": "SSL connection"
},
+ "FEATURE_JIT": {
+ "desc": "Allow users to request temporary database access with approval.",
+ "title": "Just-In-Time access"
+ },
"FEATURE_MULTI_DATABASE_BATCH_CHANGES": {
"desc": "Apply the same change to multiple databases across different tenants or partitions.",
"title": "Multi-database batch changes"
diff --git a/frontend/src/locales/dynamic/es-ES.json b/frontend/src/locales/dynamic/es-ES.json
index aef78b8c38..8ea285317a 100644
--- a/frontend/src/locales/dynamic/es-ES.json
+++ b/frontend/src/locales/dynamic/es-ES.json
@@ -189,6 +189,10 @@
"desc": "Conexiones seguras a bases de datos con cifrado SSL/TLS.",
"title": "Conexión SSL"
},
+ "FEATURE_JIT": {
+ "desc": "Permite a los usuarios solicitar acceso temporal a la base de datos con aprobación.",
+ "title": "Acceso Just-In-Time"
+ },
"FEATURE_MULTI_DATABASE_BATCH_CHANGES": {
"desc": "Aplique el mismo cambio a múltiples bases de datos en diferentes inquilinos o particiones.",
"title": "Cambios por lotes en múltiples bases de datos"
diff --git a/frontend/src/locales/dynamic/ja-JP.json b/frontend/src/locales/dynamic/ja-JP.json
index ff85149ba2..82bf76dcac 100644
--- a/frontend/src/locales/dynamic/ja-JP.json
+++ b/frontend/src/locales/dynamic/ja-JP.json
@@ -189,6 +189,10 @@
"desc": "SSL/TLS暗号化による安全なデータベース接続。",
"title": "SSL接続"
},
+ "FEATURE_JIT": {
+ "desc": "ユーザーが承認付きで一時的なデータベースアクセスをリクエストできます。",
+ "title": "Just-In-Timeアクセス"
+ },
"FEATURE_MULTI_DATABASE_BATCH_CHANGES": {
"desc": "異なるテナントやパーティション間で複数のデータベースに同じ変更を適用します。",
"title": "複数データベースバッチ変更"
diff --git a/frontend/src/locales/dynamic/vi-VN.json b/frontend/src/locales/dynamic/vi-VN.json
index dca5af5796..d1b942271f 100644
--- a/frontend/src/locales/dynamic/vi-VN.json
+++ b/frontend/src/locales/dynamic/vi-VN.json
@@ -189,6 +189,10 @@
"desc": "Kết nối cơ sở dữ liệu an toàn với mã hóa SSL/TLS.",
"title": "Kết nối SSL"
},
+ "FEATURE_JIT": {
+ "desc": "Cho phép người dùng yêu cầu quyền truy cập cơ sở dữ liệu tạm thời kèm phê duyệt.",
+ "title": "Truy cập Just-In-Time"
+ },
"FEATURE_MULTI_DATABASE_BATCH_CHANGES": {
"desc": "Áp dụng cùng một thay đổi cho nhiều cơ sở dữ liệu trên các tenant hoặc phân vùng khác nhau.",
"title": "Thay đổi hàng loạt nhiều cơ sở dữ liệu"
diff --git a/frontend/src/locales/dynamic/zh-CN.json b/frontend/src/locales/dynamic/zh-CN.json
index 09794a54d1..1c377dadd3 100644
--- a/frontend/src/locales/dynamic/zh-CN.json
+++ b/frontend/src/locales/dynamic/zh-CN.json
@@ -189,6 +189,10 @@
"desc": "使用 SSL/TLS 加密的安全数据库连接。",
"title": "SSL 连接"
},
+ "FEATURE_JIT": {
+ "desc": "允许用户通过审批请求临时数据库访问权限。",
+ "title": "即时访问"
+ },
"FEATURE_MULTI_DATABASE_BATCH_CHANGES": {
"desc": "将相同的更改应用于跨不同租户或分区的多个数据库。",
"title": "多数据库批量变更"
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 44db744b65..ffac8a799b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1896,7 +1896,7 @@
"visit-database": "Visit Databases",
"visit-environment": "Visit Environments",
"visit-instance": "Visit Instances",
- "visit-member": "Visit Member | Members",
+ "visit-member": "Visit Members",
"visit-project": "Visit Projects"
},
"refresh-remind": {},
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index b00e64b013..b04f44eb79 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1896,7 +1896,7 @@
"visit-database": "Visitar Bases de datos",
"visit-environment": "Visitar Entornos",
"visit-instance": "Visitar Instancias",
- "visit-member": "Visitar Miembro | Miembros",
+ "visit-member": "Visitar Miembros",
"visit-project": "Visitar Proyectos"
},
"refresh-remind": {},
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 35170caf69..9b10c1fe4d 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1896,7 +1896,7 @@
"visit-database": "データベースにアクセスする",
"visit-environment": "環境にアクセスする",
"visit-instance": "インスタンスにアクセスする",
- "visit-member": "メンバー | メンバーにアクセスする",
+ "visit-member": "メンバーにアクセスする",
"visit-project": "プロジェクトにアクセスする"
},
"refresh-remind": {},
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 47d3e42c9e..c9d538e26e 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1896,7 +1896,7 @@
"visit-database": "Truy cập Cơ sở dữ liệu",
"visit-environment": "Truy cập Môi trường",
"visit-instance": "Truy cập Phiên bản",
- "visit-member": "Truy cập Thành viên | Thành viên",
+ "visit-member": "Truy cập Thành viên",
"visit-project": "Truy cập Dự án"
},
"refresh-remind": {},
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 5ae3568695..be65a1a46f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1896,7 +1896,7 @@
"visit-database": "访问数据库",
"visit-environment": "访问环境",
"visit-instance": "访问实例",
- "visit-member": "访问成员 | 成员",
+ "visit-member": "访问成员",
"visit-project": "访问项目"
},
"refresh-remind": {},
diff --git a/frontend/src/react/components/FeatureAttention.test.tsx b/frontend/src/react/components/FeatureAttention.test.tsx
index 16589be545..98820eabc1 100644
--- a/frontend/src/react/components/FeatureAttention.test.tsx
+++ b/frontend/src/react/components/FeatureAttention.test.tsx
@@ -2,6 +2,7 @@ import type { ReactElement } from "react";
import { act } from "react";
import { createRoot } from "react-dom/client";
import { beforeEach, describe, expect, test, vi } from "vitest";
+import dynamicEn from "@/locales/dynamic/en-US.json";
import { ENTERPRISE_INQUIRE_LINK } from "@/types/common";
import {
PlanFeature,
@@ -26,6 +27,19 @@ const mocks = vi.hoisted(() => ({
let FeatureAttention: typeof import("./FeatureAttention").FeatureAttention;
+const translateFromDynamicEn = (key: string) => {
+ const segments = key.startsWith("dynamic.")
+ ? key.slice("dynamic.".length).split(".")
+ : key.split(".");
+ const value = segments.reduce<unknown>((node, segment) => {
+ if (!node || typeof node !== "object") {
+ return undefined;
+ }
+ return (node as Record<string, unknown>)[segment];
+ }, dynamicEn);
+ return typeof value === "string" ? value : key;
+};
+
vi.mock("react-i18next", () => ({
useTranslation: mocks.useTranslation,
}));
@@ -115,6 +129,27 @@ beforeEach(async () => {
});
describe("FeatureAttention", () => {
+ test("renders the JIT feature title and description from dynamic i18n", () => {
+ mocks.useTranslation.mockReturnValue({
+ t: (key: string) => translateFromDynamicEn(key),
+ });
+ const { container, render, unmount } = renderIntoContainer(
+ <FeatureAttention feature={PlanFeature.FEATURE_JIT} />
+ );
+
+ render();
+
+ expect(container.textContent).toContain("Just-In-Time access");
+ expect(container.textContent).toContain(
+ "Allow users to request temporary database access with approval."
+ );
+ expect(container.textContent).not.toContain(
+ "dynamic.subscription.features.FEATURE_JIT"
+ );
+
+ unmount();
+ });
+
test("renders warning state as an alert and opens the inquiry link", () => {
const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
const { container, render, unmount } = renderIntoContainer(
diff --git a/frontend/src/react/components/FeatureAttention.tsx b/frontend/src/react/components/FeatureAttention.tsx
index 15d6503ba4..42cad54f69 100644
--- a/frontend/src/react/components/FeatureAttention.tsx
+++ b/frontend/src/react/components/FeatureAttention.tsx
@@ -131,7 +131,7 @@ export function FeatureAttention({
{actionText && (
<div className="mt-3 flex justify-end">
<Button
- appearance="outline"
+ appearance="solid"
size="sm"
className="shrink-0 whitespace-nowrap"
onClick={onAction}
diff --git a/frontend/src/react/components/Quickstart.test.tsx b/frontend/src/react/components/Quickstart.test.tsx
new file mode 100644
index 0000000000..0c28e95c7c
--- /dev/null
+++ b/frontend/src/react/components/Quickstart.test.tsx
@@ -0,0 +1,130 @@
+import type { ReactElement, ReactNode } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ getIntroStateByKey: vi.fn(
+ (key: string) => key !== "hidden" && key !== "member.visit"
+ ),
+ getOrFetchProjectByName: vi.fn(async () => ({ name: "" })),
+ hasWorkspacePermissionV2: vi.fn((_permission: string) => true),
+ loadProjectIamPolicy: vi.fn(async () => undefined),
+ saveIntroStateByKey: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
+ useTranslation: () => ({
+ t: (key: string) => key,
+ }),
+}));
+
+vi.mock("@/react/components/RouterLink", () => ({
+ RouterLink: ({
+ children,
+ to,
+ ...props
+ }: {
+ children: ReactNode;
+ to: { name?: string };
+ }) => (
+ <a data-route-name={to.name} {...props}>
+ {children}
+ </a>
+ ),
+}));
+
+vi.mock("@/react/stores/app", () => {
+ const state = {
+ quickStartEnabled: () => true,
+ getIntroStateByKey: mocks.getIntroStateByKey,
+ loadProjectIamPolicy: mocks.loadProjectIamPolicy,
+ };
+ const useAppStore = (selector?: (s: typeof state) => unknown) =>
+ selector ? selector(state) : state;
+ useAppStore.getState = () => ({
+ ...state,
+ getOrFetchProjectByName: mocks.getOrFetchProjectByName,
+ fetchIssueByName: vi.fn(),
+ getOrFetchWorksheetByName: vi.fn(),
+ saveIntroStateByKey: mocks.saveIntroStateByKey,
+ });
+ return { useAppStore };
+});
+
+vi.mock("@/store", () => ({
+ pushNotification: vi.fn(),
+}));
+
+vi.mock("@/utils", () => ({
+ extractProjectResourceName: (name: string) => name,
+ hasProjectPermissionV2: () => true,
+ hasWorkspacePermissionV2: mocks.hasWorkspacePermissionV2,
+}));
+
+vi.mock("@/types", () => ({
+ isValidProjectName: () => false,
+ UNKNOWN_PROJECT_NAME: "projects/-",
+}));
+
+import { Quickstart } from "./Quickstart";
+
+let container: HTMLDivElement;
+let root: ReturnType<typeof createRoot>;
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.getIntroStateByKey.mockImplementation(
+ (key: string) => key !== "hidden" && key !== "member.visit"
+ );
+ mocks.hasWorkspacePermissionV2.mockReturnValue(true);
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => {
+ root.unmount();
+ });
+ document.body.removeChild(container);
+});
+
+const render = async (element: ReactElement) => {
+ await act(async () => {
+ root.render(element);
+ await Promise.resolve();
+ });
+};
+
+describe("Quickstart", () => {
+ it("links the member visit item to the Members page", async () => {
+ await render(<Quickstart />);
+
+ const memberLink = Array.from(container.querySelectorAll("a")).find((a) =>
+ a.textContent?.includes("quick-start.visit-member")
+ );
+
+ expect(memberLink?.getAttribute("data-route-name")).toBe(
+ "workspace.members"
+ );
+ });
+
+ it("shows the member visit item when user can access workspace IAM policy", async () => {
+ mocks.hasWorkspacePermissionV2.mockImplementation(
+ (permission) => permission === "bb.workspaces.getIamPolicy"
+ );
+
+ await render(<Quickstart />);
+
+ expect(container.textContent).toContain("quick-start.visit-member");
+ expect(mocks.hasWorkspacePermissionV2).not.toHaveBeenCalledWith(
+ "bb.users.list"
+ );
+ });
+});
diff --git a/frontend/src/react/components/Quickstart.tsx b/frontend/src/react/components/Quickstart.tsx
index 99c8a2b8da..aeea161e50 100644
--- a/frontend/src/react/components/Quickstart.tsx
+++ b/frontend/src/react/components/Quickstart.tsx
@@ -11,7 +11,7 @@ import {
PROJECT_V1_ROUTE_DASHBOARD,
PROJECT_V1_ROUTE_ISSUE_DETAIL,
SQL_EDITOR_WORKSHEET_MODULE,
- WORKSPACE_ROUTE_USERS,
+ WORKSPACE_ROUTE_MEMBERS,
} from "@/react/router/handles";
import { useAppStore } from "@/react/stores/app";
import { pushNotification } from "@/store";
@@ -212,9 +212,9 @@ export function Quickstart() {
},
{
name: t("quick-start.visit-member"),
- link: { name: WORKSPACE_ROUTE_USERS },
+ link: { name: WORKSPACE_ROUTE_MEMBERS },
done: memberVisited,
- requiredPermissions: ["bb.workspaces.getIamPolicy", "bb.users.list"],
+ requiredPermissions: ["bb.workspaces.getIamPolicy"],
},
];
return all.filter((item) => {
diff --git a/frontend/src/react/components/header/ProfileMenuTrigger.test.tsx b/frontend/src/react/components/header/ProfileMenuTrigger.test.tsx
index ed44cdf909..37952eeac0 100644
--- a/frontend/src/react/components/header/ProfileMenuTrigger.test.tsx
+++ b/frontend/src/react/components/header/ProfileMenuTrigger.test.tsx
@@ -59,8 +59,16 @@ vi.mock("@/react/components/ui/dropdown-menu", () => ({
DropdownMenuTrigger: ({ children }: { children: ReactElement }) => (
<div>{children}</div>
),
- DropdownMenuContent: ({ children }: { children: ReactElement[] }) => (
- <div>{children}</div>
+ DropdownMenuContent: ({
+ children,
+ className,
+ }: {
+ children: ReactElement[];
+ className?: string;
+ }) => (
+ <div data-testid="profile-menu-content" className={className}>
+ {children}
+ </div>
),
DropdownMenuItem: ({
children,
@@ -167,6 +175,22 @@ beforeEach(async () => {
});
describe("ProfileMenuTrigger", () => {
+ test("expands the profile menu content instead of scrolling it", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <ProfileMenuTrigger size="medium" link />
+ );
+
+ render();
+
+ const content = container.querySelector(
+ "[data-testid='profile-menu-content']"
+ );
+ expect(content?.className).toContain("max-h-none");
+ expect(content?.className).toContain("overflow-visible");
+
+ unmount();
+ });
+
test("supports locale changes, workspace toggle, and logout", () => {
const { container, render, unmount } = renderIntoContainer(
<ProfileMenuTrigger size="medium" link />
diff --git a/frontend/src/react/components/header/ProfileMenuTrigger.tsx b/frontend/src/react/components/header/ProfileMenuTrigger.tsx
index d6d3beb2e7..dc9e2e578b 100644
--- a/frontend/src/react/components/header/ProfileMenuTrigger.tsx
+++ b/frontend/src/react/components/header/ProfileMenuTrigger.tsx
@@ -137,7 +137,7 @@ export function ProfileMenuTrigger({
/>
</DropdownMenuTrigger>
- <DropdownMenuContent className="w-56 p-0">
+ <DropdownMenuContent className="w-56 max-h-none overflow-visible p-0">
<DropdownMenuItem
className="block w-full px-4 py-3"
onClick={handleProfileNavigate}
diff --git a/frontend/src/react/components/sql-editor/HistoryPane.tsx b/frontend/src/react/components/sql-editor/HistoryPane.tsx
index 09077beed1..7f43807273 100644
--- a/frontend/src/react/components/sql-editor/HistoryPane.tsx
+++ b/frontend/src/react/components/sql-editor/HistoryPane.tsx
@@ -142,18 +142,6 @@ export function HistoryPane() {
}
};
- const handleCopy = async (statement: string) => {
- if (await writeTextToClipboard(statement)) {
- useAppStore.getState().notify({
- module: "bytebase",
- style: "SUCCESS",
- title: t("sql-editor.url-copied-to-clipboard"),
- });
- } else {
- // clipboard not available
- }
- };
-
// Builds a shareable deep link to a query history. Opening it loads the
// statement into a new draft tab — see `SQLEditorRouteShell`.
const buildHistoryLink = (history: QueryHistory) => {
@@ -170,12 +158,12 @@ export function HistoryPane() {
).href;
};
- const handleCopyLink = async (history: QueryHistory) => {
- if (await writeTextToClipboard(buildHistoryLink(history))) {
+ const handleCopy = async (content: string, notification: string) => {
+ if (await writeTextToClipboard(content)) {
useAppStore.getState().notify({
module: "bytebase",
style: "SUCCESS",
- title: t("sql-editor.url-copied-to-clipboard"),
+ title: notification,
});
} else {
// clipboard not available
@@ -226,7 +214,10 @@ export function HistoryPane() {
data-copy-link-btn
onClick={(e) => {
e.stopPropagation();
- void handleCopyLink(history);
+ void handleCopy(
+ buildHistoryLink(history),
+ t("sql-editor.url-copied-to-clipboard")
+ );
}}
aria-label={t("sql-editor.copy-history-link")}
>
@@ -239,7 +230,7 @@ export function HistoryPane() {
data-copy-btn
onClick={(e) => {
e.stopPropagation();
- void handleCopy(history.statement);
+ void handleCopy(history.statement, t("common.copied"));
}}
aria-label={t("common.copy")}
>
diff --git a/frontend/src/react/components/sql-editor/ResultView/DetailPanel.test.tsx b/frontend/src/react/components/sql-editor/ResultView/DetailPanel.test.tsx
index e305658359..73453629cf 100644
--- a/frontend/src/react/components/sql-editor/ResultView/DetailPanel.test.tsx
+++ b/frontend/src/react/components/sql-editor/ResultView/DetailPanel.test.tsx
@@ -154,18 +154,26 @@ const flushAsyncRender = async () => {
const waitForAssertion = async (assertion: () => void) => {
let lastError: unknown;
- for (let i = 0; i < 20; i++) {
+ const deadline = Date.now() + 5000;
+ while (Date.now() < deadline) {
await flushAsyncRender();
try {
assertion();
return;
} catch (err) {
lastError = err;
+ await new Promise((resolve) => window.setTimeout(resolve, 10));
}
}
throw lastError;
};
+const getDetailSearchControl = (input: HTMLInputElement) => {
+ const searchControl = input.closest("[data-testid='detail-search-control']");
+ expect(searchControl).toBeInstanceOf(HTMLDivElement);
+ return searchControl as HTMLDivElement;
+};
+
const getDetailContentRegion = (expectedText = "longbridge") => {
const candidates = Array.from(document.body.querySelectorAll("div"));
const contentRegion = candidates.find(
@@ -396,12 +404,13 @@ describe("DetailPanel", () => {
"input[aria-label='sql-editor.result-detail.search']"
) as HTMLInputElement | null;
expect(input).toBeInstanceOf(HTMLInputElement);
+ const searchControl = getDetailSearchControl(input!);
act(() => {
setInputValue(input!, "needle");
});
await waitForAssertion(() => {
- expect(document.body.textContent).toContain("1 / 2");
+ expect(searchControl.textContent).toContain("1 / 2");
});
scrolledContent.length = 0;
diff --git a/frontend/src/react/pages/auth/SetupPage.test.tsx b/frontend/src/react/pages/auth/SetupPage.test.tsx
index d8e476072c..7a46eca7e6 100644
--- a/frontend/src/react/pages/auth/SetupPage.test.tsx
+++ b/frontend/src/react/pages/auth/SetupPage.test.tsx
@@ -11,14 +11,16 @@ import { beforeEach, describe, expect, test, vi } from "vitest";
const mocks = vi.hoisted(() => ({
routerIsReady: vi.fn(async () => {}),
routerPush: vi.fn(),
+ fetchServerInfo: vi.fn(async () => {}),
listRoles: vi.fn(async () => {}),
fetchIamPolicy: vi.fn(async () => {}),
- getOrFetchProjectByName: vi.fn(async () => {
+ getOrFetchProjectByName: vi.fn(async (): Promise<{ name: string }> => {
throw new ConnectError("not found", Code.NotFound);
}),
createProject: vi.fn(),
setupSample: vi.fn(),
updateWorkspaceProfile: vi.fn(),
+ resetQuickstartProgress: vi.fn(),
}));
vi.mock("@/react/router", async (importOriginal) => ({
@@ -33,6 +35,7 @@ vi.mock("@/react/stores/app", () => {
const state = {
enableOnboarding: () => true,
appFeatures: { "bb.feature.database-change-mode": 0 },
+ fetchServerInfo: mocks.fetchServerInfo,
loadWorkspaceProfile: vi.fn(async () => undefined),
listRoles: mocks.listRoles,
fetchWorkspaceIamPolicy: mocks.fetchIamPolicy,
@@ -40,6 +43,7 @@ vi.mock("@/react/stores/app", () => {
createProject: mocks.createProject,
setupSample: mocks.setupSample,
updateWorkspaceProfile: mocks.updateWorkspaceProfile,
+ resetQuickstartProgress: mocks.resetQuickstartProgress,
};
return {
useAppStore: Object.assign(
@@ -130,6 +134,114 @@ beforeEach(async () => {
});
describe("SetupPage", () => {
+ test("finishes setup by navigating to the workspace landing page", async () => {
+ const { container, render, unmount } = renderIntoContainer(<SetupPage />);
+ render();
+ await flushPromises();
+
+ const buttonByText = (text: string) =>
+ Array.from(container.querySelectorAll<HTMLButtonElement>("button")).find(
+ (button) => button.textContent === text
+ );
+
+ act(() => {
+ buttonByText("→")?.click();
+ });
+ await flushPromises();
+
+ act(() => {
+ buttonByText("→")?.click();
+ });
+ await flushPromises();
+
+ act(() => {
+ buttonByText("common.confirm")?.click();
+ });
+ await flushPromises();
+
+ expect(mocks.routerPush).toHaveBeenLastCalledWith({
+ name: "workspace.landing",
+ });
+ expect(mocks.resetQuickstartProgress).toHaveBeenCalledTimes(1);
+
+ unmount();
+ });
+
+ test("aligns the built-in sample radio with its title and styles the description", async () => {
+ const { container, render, unmount } = renderIntoContainer(<SetupPage />);
+ render();
+ await flushPromises();
+
+ const nextButton = () =>
+ Array.from(container.querySelectorAll<HTMLButtonElement>("button")).find(
+ (button) => button.textContent === "→"
+ );
+
+ act(() => {
+ nextButton()?.click();
+ });
+ await flushPromises();
+
+ const title = Array.from(container.querySelectorAll("div")).find(
+ (element) => element.textContent === "setup.data.built-in"
+ );
+ const description = Array.from(container.querySelectorAll("div")).find(
+ (element) => element.textContent === "setup.data.built-in-desc"
+ );
+ const option = title?.closest("label");
+ const radio = option?.querySelector("[role='radio']");
+
+ expect(option?.className).toContain("items-start");
+ expect(radio?.className).toContain("mt-0.5");
+ expect(title?.className).toContain("font-medium");
+ expect(description?.className).toContain("text-control");
+
+ unmount();
+ });
+
+ test("aligns default landing page radios with their titles and styles descriptions", async () => {
+ const { container, render, unmount } = renderIntoContainer(<SetupPage />);
+ render();
+ await flushPromises();
+
+ const nextButton = () =>
+ Array.from(container.querySelectorAll<HTMLButtonElement>("button")).find(
+ (button) => button.textContent === "→"
+ );
+
+ act(() => {
+ nextButton()?.click();
+ });
+ await flushPromises();
+
+ act(() => {
+ nextButton()?.click();
+ });
+ await flushPromises();
+
+ const workspaceTitle = Array.from(container.querySelectorAll("div")).find(
+ (element) =>
+ element.textContent ===
+ "settings.general.workspace.default-landing-page.workspace.self"
+ );
+ const workspaceDescription = Array.from(
+ container.querySelectorAll("div")
+ ).find(
+ (element) =>
+ element.textContent ===
+ "settings.general.workspace.default-landing-page.workspace.description"
+ );
+ const option = workspaceTitle?.closest("label");
+ const radio = option?.querySelector("[role='radio']");
+
+ expect(option?.className).toContain("items-start");
+ expect(radio?.className).toContain("mt-0.5");
+ expect(workspaceTitle?.className).toContain("font-medium");
+ expect(workspaceDescription?.className).toContain("text-control");
+
+ unmount();
+ });
+
test("allows advancing with a new project resource id", async () => {
const { container, render, unmount } = renderIntoContainer(<SetupPage />);
render();
@@ -155,6 +267,34 @@ describe("SetupPage", () => {
unmount();
});
+ test("allows advancing when project lookup resolves to the unknown placeholder", async () => {
+ mocks.getOrFetchProjectByName.mockResolvedValueOnce({
+ name: "projects/-1",
+ });
+
+ const { container, render, unmount } = renderIntoContainer(<SetupPage />);
+ render();
+ await flushPromises();
+
+ const nextButton = () =>
+ Array.from(container.querySelectorAll<HTMLButtonElement>("button")).find(
+ (button) => button.textContent === "→"
+ );
+
+ act(() => {
+ nextButton()?.click();
+ });
+ await flushPromises();
+
+ expect(mocks.getOrFetchProjectByName).toHaveBeenCalledWith(
+ "projects/new-project",
+ true
+ );
+ expect(nextButton()?.disabled).toBe(false);
+
+ unmount();
+ });
+
test("blocks advancing when project lookup fails for reasons other than NotFound", async () => {
mocks.getOrFetchProjectByName.mockRejectedValueOnce(
new ConnectError("backend unavailable", Code.Unavailable)
diff --git a/frontend/src/react/pages/auth/SetupPage.tsx b/frontend/src/react/pages/auth/SetupPage.tsx
index add5201563..b446f2043f 100644
--- a/frontend/src/react/pages/auth/SetupPage.tsx
+++ b/frontend/src/react/pages/auth/SetupPage.tsx
@@ -15,9 +15,13 @@ import { Input } from "@/react/components/ui/input";
import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { useAppFeature } from "@/react/hooks/useAppState";
import { router } from "@/react/router";
-import { SQL_EDITOR_HOME_MODULE } from "@/react/router/handles";
+import {
+ SQL_EDITOR_HOME_MODULE,
+ WORKSPACE_ROUTE_LANDING,
+} from "@/react/router/handles";
import { useAppStore } from "@/react/stores/app";
import { projectNamePrefix } from "@/store/modules/v1/common";
+import { isValidProjectName } from "@/types";
import { DatabaseChangeMode } from "@/types/proto-es/v1/setting_service_pb";
import { extractGrpcErrorMessage, getErrorCode } from "@/utils/connect";
@@ -37,7 +41,7 @@ const homePath = (mode?: DatabaseChangeMode) => {
if (mode === DatabaseChangeMode.EDITOR) {
return { name: SQL_EDITOR_HOME_MODULE };
}
- return "/";
+ return { name: WORKSPACE_ROUTE_LANDING };
};
export function SetupPage() {
@@ -147,6 +151,7 @@ function SetupWizard() {
paths: ["value.workspace_profile.database_change_mode"],
}),
});
+ useAppStore.getState().resetQuickstartProgress();
router.push(homePath(mode));
} finally {
setLoading(false);
@@ -156,12 +161,15 @@ function SetupWizard() {
const validateProjectResourceID = useCallback(
async (id: string) => {
try {
- await useAppStore
+ const project = await useAppStore
.getState()
.getOrFetchProjectByName(
`${projectNamePrefix}${id}`,
true /* silent */
);
+ if (!isValidProjectName(project.name)) {
+ return [];
+ }
return [
{
type: "error" as const,
@@ -272,10 +280,16 @@ function SetupWizard() {
)}
</div>
<div>
- <RadioGroupItem value="builtin-sample">
+ <RadioGroupItem
+ value="builtin-sample"
+ className="items-start"
+ radioClassName="mt-0.5"
+ >
<div className="flex flex-col gap-1">
<div className="font-medium">{t("setup.data.built-in")}</div>
- <div>{t("setup.data.built-in-desc")}</div>
+ <div className="text-control">
+ {t("setup.data.built-in-desc")}
+ </div>
</div>
</RadioGroupItem>
</div>
@@ -293,28 +307,36 @@ function SetupWizard() {
onValueChange={(v) => setMode(Number(v) as DatabaseChangeMode)}
className="flex-col items-start gap-y-6"
>
- <RadioGroupItem value={String(DatabaseChangeMode.PIPELINE)}>
+ <RadioGroupItem
+ value={String(DatabaseChangeMode.PIPELINE)}
+ className="items-start"
+ radioClassName="mt-0.5"
+ >
<div className="flex flex-col gap-1">
- <div className="textinfo">
+ <div className="font-medium">
{t(
"settings.general.workspace.default-landing-page.workspace.self"
)}
</div>
- <div className="textinfolabel">
+ <div className="text-control">
{t(
"settings.general.workspace.default-landing-page.workspace.description"
)}
</div>
</div>
</RadioGroupItem>
- <RadioGroupItem value={String(DatabaseChangeMode.EDITOR)}>
+ <RadioGroupItem
+ value={String(DatabaseChangeMode.EDITOR)}
+ className="items-start"
+ radioClassName="mt-0.5"
+ >
<div className="flex flex-col gap-1">
- <div className="textinfo">
+ <div className="font-medium">
{t(
"settings.general.workspace.default-landing-page.sql-editor.self"
)}
</div>
- <div className="textinfolabel">
+ <div className="text-control">
{t(
"settings.general.workspace.default-landing-page.sql-editor.description"
)}
diff --git a/frontend/src/react/pages/settings/MembersPage.test.tsx b/frontend/src/react/pages/settings/MembersPage.test.tsx
index 5d80ba8ea5..33c4470032 100644
--- a/frontend/src/react/pages/settings/MembersPage.test.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.test.tsx
@@ -11,8 +11,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
).IS_REACT_ACT_ENVIRONMENT = true;
-const { mockPushNotification, mockUpdateProjectIamPolicy } = vi.hoisted(() => ({
+const {
+ mockGetIntroStateByKey,
+ mockPushNotification,
+ mockSaveIntroStateByKey,
+ mockUpdateProjectIamPolicy,
+} = vi.hoisted(() => ({
+ mockGetIntroStateByKey: vi.fn(),
mockPushNotification: vi.fn(),
+ mockSaveIntroStateByKey: vi.fn(),
mockUpdateProjectIamPolicy: vi.fn(),
}));
@@ -314,6 +321,8 @@ vi.mock("@/react/stores/app", () => {
getOrFetchSettingByName: vi.fn(),
getSettingByName: () => undefined,
getWorkspaceProfile: () => ({}),
+ getIntroStateByKey: mockGetIntroStateByKey,
+ saveIntroStateByKey: mockSaveIntroStateByKey,
});
const useAppStore = (selector?: (state: unknown) => unknown) =>
selector ? selector(buildState()) : buildState();
@@ -342,6 +351,7 @@ let root: ReturnType<typeof createRoot>;
beforeEach(() => {
vi.clearAllMocks();
+ mockGetIntroStateByKey.mockReturnValue(false);
projectIamPolicy.bindings = [];
container = document.createElement("div");
document.body.appendChild(container);
@@ -370,6 +380,16 @@ async function flush(): Promise<void> {
}
describe("MembersPage project role grant drawer", () => {
+ it("marks the member quick-start item visited on mount", async () => {
+ await renderPage();
+
+ expect(mockGetIntroStateByKey).toHaveBeenCalledWith("member.visit");
+ expect(mockSaveIntroStateByKey).toHaveBeenCalledWith({
+ key: "member.visit",
+ newState: true,
+ });
+ });
+
it("uses the graphical expression editor for database CEL scope", async () => {
await renderPage();
diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsx
index 11444f3afc..8e52b86677 100644
--- a/frontend/src/react/pages/settings/MembersPage.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.tsx
@@ -2069,6 +2069,16 @@ export function MembersPage({ projectId }: { projectId?: string }) {
>();
const [showRequestRoleDialog, setShowRequestRoleDialog] = useState(false);
+ useEffect(() => {
+ const store = useAppStore.getState();
+ if (!store.getIntroStateByKey("member.visit")) {
+ store.saveIntroStateByKey({
+ key: "member.visit",
+ newState: true,
+ });
+ }
+ }, []);
+
const hasRequestRoleFeature = useAppStore((s) =>
s.hasFeature(PlanFeature.FEATURE_REQUEST_ROLE_WORKFLOW)
);
diff --git a/frontend/src/react/stores/app/index.test.ts b/frontend/src/react/stores/app/index.test.ts
index 7d8f43623f..ec6bbeb005 100644
--- a/frontend/src/react/stores/app/index.test.ts
+++ b/frontend/src/react/stores/app/index.test.ts
@@ -1964,7 +1964,7 @@ describe("useAppStore", () => {
JSON.parse(localStorage.getItem(storageKeyRecentVisit("", user.email))!)
).toEqual(["/projects/a?tab=2"]);
expect(
- JSON.parse(localStorage.getItem(storageKeyIntroState(user.email))!)
+ JSON.parse(localStorage.getItem(storageKeyIntroState("", user.email))!)
).toMatchObject({
hidden: false,
"project.visit": false,
@@ -2022,6 +2022,82 @@ describe("useAppStore", () => {
).toEqual(["/projects/b"]);
});
+ test("scopes recent projects from server workspace before user workspace hydrates", () => {
+ const store = createAppStore();
+ store.setState({
+ serverInfo: createProto(ActuatorInfoSchema, {
+ saas: true,
+ workspace: "workspaces/from-server",
+ }),
+ });
+ store.setState({ currentUser: { ...user, workspace: "" } });
+
+ store.getState().setRecentProject(projectA.name);
+
+ expect(
+ JSON.parse(
+ localStorage.getItem(
+ storageKeyRecentProjects("workspaces/from-server", user.email)
+ )!
+ )
+ ).toEqual([projectA.name]);
+ expect(
+ localStorage.getItem(storageKeyRecentProjects("", user.email))
+ ).toBeNull();
+ });
+
+ test("scopes intro state by workspace in SaaS mode", () => {
+ const store = createAppStore();
+ store.setState({
+ serverInfo: createProto(ActuatorInfoSchema, { saas: true }),
+ });
+ store.setState({ currentUser: { ...user, workspace: "workspaces/a" } });
+ store
+ .getState()
+ .saveIntroStateByKey({ key: "project.visit", newState: true });
+
+ store.setState({ currentUser: { ...user, workspace: "workspaces/b" } });
+ expect(store.getState().getIntroStateByKey("project.visit")).toBe(false);
+ store
+ .getState()
+ .saveIntroStateByKey({ key: "database.visit", newState: true });
+
+ expect(
+ JSON.parse(
+ localStorage.getItem(storageKeyIntroState("workspaces/a", user.email))!
+ )
+ ).toEqual({ "project.visit": true });
+ expect(
+ JSON.parse(
+ localStorage.getItem(storageKeyIntroState("workspaces/b", user.email))!
+ )
+ ).toEqual({ "database.visit": true });
+ });
+
+ test("keeps intro state workspace-agnostic in self-host mode", () => {
+ const store = createAppStore();
+ store.setState({
+ serverInfo: createProto(ActuatorInfoSchema, {
+ saas: false,
+ workspace: "workspaces/default",
+ }),
+ });
+ store.setState({ currentUser: user });
+ localStorage.setItem(
+ storageKeyIntroState("", user.email),
+ JSON.stringify({ "project.visit": true })
+ );
+
+ expect(store.getState().getIntroStateByKey("project.visit")).toBe(true);
+ store
+ .getState()
+ .saveIntroStateByKey({ key: "database.visit", newState: true });
+
+ expect(
+ JSON.parse(localStorage.getItem(storageKeyIntroState("", user.email))!)
+ ).toEqual({ "project.visit": true, "database.visit": true });
+ });
+
test("caches database metadata and reuses inflight request", async () => {
const {
DatabaseMetadataSchema,
diff --git a/frontend/src/react/stores/app/preferences.ts b/frontend/src/react/stores/app/preferences.ts
index ee40cfbf0a..5b43c02b88 100644
--- a/frontend/src/react/stores/app/preferences.ts
+++ b/frontend/src/react/stores/app/preferences.ts
@@ -74,7 +74,7 @@ export const createPreferencesSlice: AppSliceCreator<PreferencesSlice> = (
resetQuickstartProgress: () => {
const email = getCurrentUserEmail(get);
if (!email) return;
- const key = storageKeyIntroState(email);
+ const key = storageKeyIntroState(getWorkspaceCacheScope(get), email);
const previous = readJson<Record<string, boolean>>(key, {});
const next = {
...previous,
@@ -86,13 +86,14 @@ export const createPreferencesSlice: AppSliceCreator<PreferencesSlice> = (
},
// Mirrors the Pinia `useUIStateStore.getIntroStateByKey`. Reads the per-user
- // localStorage map; `introStateVersion` (read by callers' selectors) is what
- // makes a subsequent `saveIntroStateByKey` re-trigger the read.
+ // localStorage map scoped to the current workspace;
+ // `introStateVersion` (read by callers' selectors) is what makes a
+ // subsequent `saveIntroStateByKey` re-trigger the read.
getIntroStateByKey: (key) => {
const email = getCurrentUserEmail(get);
if (!email) return false;
const map = readJson<Record<string, boolean>>(
- storageKeyIntroState(email),
+ storageKeyIntroState(getWorkspaceCacheScope(get), email),
{}
);
return map[key] ?? false;
@@ -103,7 +104,7 @@ export const createPreferencesSlice: AppSliceCreator<PreferencesSlice> = (
saveIntroStateByKey: ({ key, newState }) => {
const email = getCurrentUserEmail(get);
if (!email) return;
- const storageKey = storageKeyIntroState(email);
+ const storageKey = storageKeyIntroState(getWorkspaceCacheScope(get), email);
const previous = readJson<Record<string, boolean>>(storageKey, {});
writeJson(storageKey, { ...previous, [key]: newState });
set((state) => ({ introStateVersion: state.introStateVersion + 1 }));
diff --git a/frontend/src/react/stores/app/utils.ts b/frontend/src/react/stores/app/utils.ts
index 1bd02192ea..41db08ff35 100644
--- a/frontend/src/react/stores/app/utils.ts
+++ b/frontend/src/react/stores/app/utils.ts
@@ -30,11 +30,17 @@ export function getCurrentUserEmail(get: () => AppStoreState): string {
// Workspace segment for localStorage cache keys — "" for self-host (keys stay
// shared/unchanged), the workspace name for SaaS (keys are workspace-isolated).
+// Fall back to serverInfo while the current user is still hydrating.
export function getWorkspaceCacheScope(
get: () => AppStoreState,
- workspaceName = get().currentUser?.workspace ?? ""
+ workspaceName?: string
): string {
- return workspaceCacheScope(get().isSaaSMode(), workspaceName);
+ const scope =
+ workspaceName ||
+ get().currentUser?.workspace ||
+ get().serverInfo?.workspace ||
+ "";
+ return workspaceCacheScope(get().isSaaSMode(), scope);
}
export function readJson<T>(key: string, fallback: T): T {
diff --git a/frontend/src/utils/storage-keys.ts b/frontend/src/utils/storage-keys.ts
index 97c3093f7f..6dc6182c4d 100644
--- a/frontend/src/utils/storage-keys.ts
+++ b/frontend/src/utils/storage-keys.ts
@@ -55,8 +55,8 @@ export const storageKeyLastActivity = (email: string) =>
`bb.last-activity.${email}`;
export const storageKeyCollapseState = (email: string) =>
`bb.collapse-state.${email}`;
-export const storageKeyIntroState = (email: string) =>
- `bb.intro-state.${email}`;
+export const storageKeyIntroState = (scope: string, email: string) =>
+ withScope("bb.intro-state", scope, email);
// Workspace-scoped: value keys embed project resource names.
export const storageKeyIamRemind = (scope: string, email: string) =>
withScope("bb.iam-remind", scope, email);