Skip to content

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

chore: update

ecmadao797f3617b093
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index c482f0527a..8c66604779 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -943,6 +943,8 @@
"connecting-database-to-project": "Connecting database...",
"connection-info": "Connection info",
"connection-options": "Connection Options",
+ "delete-active-confirmation": "Instance \"{{name}}\" is active. Bytebase will archive it first, then permanently delete it. This action cannot be undone. Type the instance ID \"{{id}}\" to confirm.",
+ "delete-confirmation": "This will permanently delete instance \"{{name}}\". This action cannot be undone. Type the instance ID \"{{id}}\" to confirm.",
"connection-recovery": {
"auth": {
"description": "Verify the username, password, token, or IAM authentication settings, then test the connection again.",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 069c4310b6..2f1460e307 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -943,6 +943,8 @@
"connecting-database-to-project": "Conectando base de datos...",
"connection-info": "Información de conexión",
"connection-options": "Opciones de conexión",
+ "delete-active-confirmation": "La instancia \"{{name}}\" está activa. Bytebase la archivará primero y luego la eliminará permanentemente. Esta acción no se puede deshacer. Escribe el ID de la instancia \"{{id}}\" para confirmar.",
+ "delete-confirmation": "Esto eliminará permanentemente la instancia \"{{name}}\". Esta acción no se puede deshacer. Escribe el ID de la instancia \"{{id}}\" para confirmar.",
"connection-recovery": {
"auth": {
"description": "Verifica el usuario, la contraseña, el token o la configuración de autenticación IAM y vuelve a probar la conexión.",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 00813266ba..b3d132c262 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -943,6 +943,8 @@
"connecting-database-to-project": "データベースを接続中...",
"connection-info": "接続情報",
"connection-options": "接続オプション",
+ "delete-active-confirmation": "インスタンス「{{name}}」はアクティブです。Bytebase はまずアーカイブしてから完全に削除します。この操作は元に戻せません。確認するにはインスタンス ID「{{id}}」を入力してください。",
+ "delete-confirmation": "インスタンス「{{name}}」を完全に削除します。この操作は元に戻せません。確認するにはインスタンス ID「{{id}}」を入力してください。",
"connection-recovery": {
"auth": {
"description": "ユーザー名、パスワード、トークン、または IAM 認証設定を確認してから、もう一度接続をテストしてください。",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 96b7dfa779..595108f2f7 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -943,6 +943,8 @@
"connecting-database-to-project": "Đang kết nối cơ sở dữ liệu...",
"connection-info": "Thông tin kết nối",
"connection-options": "Tùy chọn kết nối",
+ "delete-active-confirmation": "Instance \"{{name}}\" đang hoạt động. Bytebase sẽ lưu trữ instance này trước, sau đó xóa vĩnh viễn. Không thể hoàn tác hành động này. Nhập ID instance \"{{id}}\" để xác nhận.",
+ "delete-confirmation": "Thao tác này sẽ xóa vĩnh viễn instance \"{{name}}\". Không thể hoàn tác hành động này. Nhập ID instance \"{{id}}\" để xác nhận.",
"connection-recovery": {
"auth": {
"description": "Kiểm tra tên người dùng, mật khẩu, token hoặc cấu hình xác thực IAM, rồi kiểm tra kết nối lại.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index a3a08613e6..4112dd10f5 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -943,6 +943,8 @@
"connecting-database-to-project": "正在连接数据库...",
"connection-info": "连接信息",
"connection-options": "连接选项",
+ "delete-active-confirmation": "实例“{{name}}”当前处于活动状态。Bytebase 将先归档该实例,然后永久删除它。此操作无法撤销。请输入实例 ID “{{id}}” 以确认。",
+ "delete-confirmation": "这将永久删除实例“{{name}}”。此操作无法撤销。请输入实例 ID “{{id}}” 以确认。",
"connection-recovery": {
"auth": {
"description": "请检查用户名、密码、令牌或 IAM 认证配置,然后重新测试连接。",
diff --git a/frontend/src/react/components/ProjectTable.test.tsx b/frontend/src/react/components/ProjectTable.test.tsx
index 43e16bd611..05e98f23a7 100644
--- a/frontend/src/react/components/ProjectTable.test.tsx
+++ b/frontend/src/react/components/ProjectTable.test.tsx
@@ -2,6 +2,7 @@ import type { MouseEventHandler, ReactNode } from "react";
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { State } from "@/types/proto-es/v1/common_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { ProjectTable } from "./ProjectTable";
@@ -164,4 +165,30 @@ describe("ProjectTable", () => {
expect(onRowClick.mock.calls[0][0]).toBe(project);
expect(onRowClick.mock.calls[0][1].metaKey).toBe(true);
});
+
+ test("renders a state column when requested", () => {
+ act(() => {
+ root.render(
+ <ProjectTable
+ projectList={[
+ { ...project, state: State.ACTIVE },
+ {
+ name: "projects/archived",
+ title: "Archived Project",
+ labels: {},
+ state: State.DELETED,
+ } as Project,
+ ]}
+ showState
+ />
+ );
+ });
+
+ const headers = [...container.querySelectorAll("thead th")].map(
+ (th) => th.textContent
+ );
+ expect(headers).toContain("common.state");
+ expect(container.textContent).toContain("common.active");
+ expect(container.textContent).toContain("common.archived");
+ });
});
diff --git a/frontend/src/react/components/ProjectTable.tsx b/frontend/src/react/components/ProjectTable.tsx
index 570b09b458..0b3789eaa8 100644
--- a/frontend/src/react/components/ProjectTable.tsx
+++ b/frontend/src/react/components/ProjectTable.tsx
@@ -53,6 +53,8 @@ export interface ProjectTableProps {
readonly showSelection?: boolean;
/** Mirrors Vue's `:show-labels`. Defaults to true. */
readonly showLabels?: boolean;
+ /** Adds a dedicated state column. */
+ readonly showState?: boolean;
/**
* Mirrors Vue's `:show-actions`. When set, the trailing column renders
* `renderActions(project)` (typically the project action dropdown).
@@ -97,6 +99,7 @@ export function ProjectTable({
emptyContent,
showSelection = false,
showLabels = true,
+ showState = false,
showActions = false,
renderActions,
selectedProjectNames = [],
@@ -131,6 +134,7 @@ export function ProjectTable({
1 + // id
1 + // title
(showLabels ? 1 : 0) +
+ (showState ? 1 : 0) +
(showActions ? 1 : 0);
// Use refs so per-row handlers stay stable across selection changes.
@@ -213,6 +217,9 @@ export function ProjectTable({
{t("common.labels")}
</TableHead>
) : null}
+ {showState ? (
+ <TableHead className="min-w-[120px]">{t("common.state")}</TableHead>
+ ) : null}
{showActions ? <TableHead className="w-[50px]" /> : null}
</TableRow>
</TableHeader>
@@ -248,6 +255,7 @@ export function ProjectTable({
showSelection={showSelection}
showLeadingCheck={showLeadingCheck}
showLabels={showLabels}
+ showState={showState}
showActions={showActions}
keyword={keyword}
onToggleRow={handleToggleRow}
@@ -268,6 +276,7 @@ interface ProjectRowViewProps {
showSelection: boolean;
showLeadingCheck: boolean;
showLabels: boolean;
+ showState: boolean;
showActions: boolean;
keyword: string;
onToggleRow: (name: string) => void;
@@ -282,6 +291,7 @@ const ProjectRowView = memo(function ProjectRowView({
showSelection,
showLeadingCheck,
showLabels,
+ showState,
showActions,
keyword,
onToggleRow,
@@ -342,7 +352,7 @@ const ProjectRowView = memo(function ProjectRowView({
>
{titleContent}
</ProjectLabel>
- {project.state === State.DELETED ? (
+ {!showState && project.state === State.DELETED ? (
<Badge variant="warning" className="text-xs shrink-0">
{t("common.archived")}
</Badge>
@@ -354,6 +364,11 @@ const ProjectRowView = memo(function ProjectRowView({
<LabelsCell labels={project.labels ?? {}} />
</TableCell>
) : null}
+ {showState ? (
+ <TableCell>
+ <ResourceStateBadge state={project.state} />
+ </TableCell>
+ ) : null}
{showActions ? (
<TableCell className="w-[50px]" onClick={(e) => e.stopPropagation()}>
<div className="flex justify-end">{renderActions(project)}</div>
@@ -363,6 +378,22 @@ const ProjectRowView = memo(function ProjectRowView({
);
});
+function ResourceStateBadge({ state }: { state: State }) {
+ const { t } = useTranslation();
+ if (state === State.DELETED) {
+ return (
+ <Badge variant="warning" className="text-xs">
+ {t("common.archived")}
+ </Badge>
+ );
+ }
+ return (
+ <Badge variant="success" className="text-xs">
+ {t("common.active")}
+ </Badge>
+ );
+}
+
/**
* Mirrors Vue's `LabelsCell` — show up to N labels inline, "..." for
* the rest, and a tooltip on hover that lists all of them.
diff --git a/frontend/src/react/components/instance/InstanceActionDropdown.test.tsx b/frontend/src/react/components/instance/InstanceActionDropdown.test.tsx
index 97108d8135..34d429628d 100644
--- a/frontend/src/react/components/instance/InstanceActionDropdown.test.tsx
+++ b/frontend/src/react/components/instance/InstanceActionDropdown.test.tsx
@@ -112,7 +112,7 @@ describe("InstanceActionDropdown", () => {
act(() => menu.root.unmount());
});
- test("opens the archived instance list after archiving", async () => {
+ test("opens the default instance list after archiving", async () => {
const confirmSpy = vi.spyOn(window, "confirm").mockReturnValue(true);
mocks.archiveInstance.mockResolvedValue(undefined);
const menu = await renderMenu(State.ACTIVE);
@@ -128,7 +128,6 @@ describe("InstanceActionDropdown", () => {
expect(mocks.archiveInstance).toHaveBeenCalled();
expect(mocks.routerReplace).toHaveBeenCalledWith({
name: "workspace.instance",
- query: { q: "state:DELETED" },
});
confirmSpy.mockRestore();
diff --git a/frontend/src/react/components/instance/InstanceActionDropdown.tsx b/frontend/src/react/components/instance/InstanceActionDropdown.tsx
index ec95a597fe..f2c3b0a6a3 100644
--- a/frontend/src/react/components/instance/InstanceActionDropdown.tsx
+++ b/frontend/src/react/components/instance/InstanceActionDropdown.tsx
@@ -48,10 +48,7 @@ export function InstanceActionDropdown({
0: instance.title,
}),
});
- router.replace({
- name: INSTANCE_ROUTE_DASHBOARD,
- query: { q: "state:DELETED" },
- });
+ router.replace({ name: INSTANCE_ROUTE_DASHBOARD });
}, [instance, t]);
const handleRestore = useCallback(async () => {
diff --git a/frontend/src/react/components/instance/InstanceFormContext.test.tsx b/frontend/src/react/components/instance/InstanceFormContext.test.tsx
index 65f1561fa4..a08a859452 100644
--- a/frontend/src/react/components/instance/InstanceFormContext.test.tsx
+++ b/frontend/src/react/components/instance/InstanceFormContext.test.tsx
@@ -3,7 +3,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 { Engine } from "@/types/proto-es/v1/common_pb";
+import { Engine, State } from "@/types/proto-es/v1/common_pb";
import {
DataSourceSchema,
DataSourceType,
@@ -132,6 +132,8 @@ const Probe = () => {
data-title={ctx.basicInfo.title}
data-host={ctx.adminDataSource.host}
data-environment={ctx.basicInfo.environment}
+ data-value-changed={String(ctx.valueChanged)}
+ data-is-editing={String(ctx.isEditing)}
/>
);
};
@@ -158,6 +160,7 @@ const renderIntoContainer = () => {
describe("InstanceFormProvider", () => {
beforeEach(() => {
mockEnvironmentList = [];
+ vi.useRealTimers();
});
test("selects the first environment by default when creating an instance", async () => {
@@ -211,6 +214,54 @@ describe("InstanceFormProvider", () => {
harness.unmount();
});
+ test("does not mark an archived instance as changed after restore", async () => {
+ vi.useFakeTimers();
+ const archivedInstance = create(InstanceSchema, {
+ name: "instances/prod",
+ state: State.DELETED,
+ title: "Production",
+ engine: Engine.POSTGRES,
+ environment: "environments/prod",
+ dataSources: [
+ create(DataSourceSchema, {
+ id: "admin",
+ type: DataSourceType.ADMIN,
+ host: "prod.example.com",
+ port: "5432",
+ }),
+ ],
+ });
+ const restoredInstance = create(InstanceSchema, {
+ ...archivedInstance,
+ state: State.ACTIVE,
+ });
+ const harness = renderIntoContainer();
+
+ await harness.render(
+ <InstanceFormProvider instance={archivedInstance}>
+ <Probe />
+ </InstanceFormProvider>
+ );
+ await act(async () => {
+ vi.advanceTimersByTime(350);
+ });
+ await harness.render(
+ <InstanceFormProvider instance={restoredInstance}>
+ <Probe />
+ </InstanceFormProvider>
+ );
+ await act(async () => {
+ vi.advanceTimersByTime(350);
+ });
+
+ const probe = harness.container.firstElementChild as HTMLElement;
+ expect(probe.dataset.valueChanged).toBe("false");
+ expect(probe.dataset.isEditing).toBe("false");
+
+ harness.unmount();
+ vi.useRealTimers();
+ });
+
// Regression test for BYT-9696: setting missingFeature (e.g. saving a
// read-only connection on an unlicensed instance) must surface the
// FeatureModal paywall instead of failing silently.
diff --git a/frontend/src/react/components/instance/InstanceFormContext.tsx b/frontend/src/react/components/instance/InstanceFormContext.tsx
index 189a6c5c48..4d1b088f3f 100644
--- a/frontend/src/react/components/instance/InstanceFormContext.tsx
+++ b/frontend/src/react/components/instance/InstanceFormContext.tsx
@@ -164,15 +164,23 @@ export function InstanceFormProvider({
const [labelErrors, setLabelErrors] = useState<string[]>([]);
const [showConnectionOptionsEvent, setShowConnectionOptionsEvent] =
useState(0);
- const syncedInstanceNameRef = useRef(instance?.name);
+ const syncedInstanceRef = useRef({
+ name: instance?.name,
+ state: instance?.state,
+ });
const isCreating = instance === undefined;
useEffect(() => {
- if (syncedInstanceNameRef.current === instance?.name) {
+ const previous = syncedInstanceRef.current;
+ const next = {
+ name: instance?.name,
+ state: instance?.state,
+ };
+ if (previous.name === next.name && previous.state === next.state) {
return;
}
- syncedInstanceNameRef.current = instance?.name;
+ syncedInstanceRef.current = next;
const nextBasicInfo = extractBasicInfo(instance);
const nextDataSourceEditState = extractDataSourceEditState(instance);
setBasicInfo(nextBasicInfo);
diff --git a/frontend/src/react/pages/settings/InstancesPage.tsx b/frontend/src/react/pages/settings/InstancesPage.tsx
index 5b0ba7e2ac..a004758ef1 100644
--- a/frontend/src/react/pages/settings/InstancesPage.tsx
+++ b/frontend/src/react/pages/settings/InstancesPage.tsx
@@ -33,6 +33,7 @@ import {
AlertDialogDescription,
AlertDialogTitle,
} from "@/react/components/ui/alert-dialog";
+import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
import {
@@ -73,7 +74,6 @@ import {
} from "@/react/hooks/useSessionPageSize";
import {
createAdvancedSearchParser,
- legacyStateSearchParams,
serializeAdvancedSearch,
useURLSearchParam,
} from "@/react/hooks/useURLSearchParam";
@@ -101,6 +101,10 @@ import {
hostPortOfInstanceV1,
supportedEngineV1List,
} from "@/utils";
+import {
+ defaultActiveStateSearchParams,
+ getResourceStateFilter,
+} from "./resourceStateFilter";
const ASSIGN_LICENSE_QUERY = "assignLicense";
const ASSIGN_LICENSE_INSTANCES_QUERY = "instances";
@@ -440,7 +444,7 @@ export function InstancesPage() {
const route = useCurrentRoute();
const defaultSearchParams = useMemo<SearchParams>(
- () => legacyStateSearchParams(route.query.state),
+ () => defaultActiveStateSearchParams(route.query.state),
[route.query.state]
);
const [searchParams, setSearchParams] = useURLSearchParam<SearchParams>({
@@ -541,12 +545,7 @@ export function InstancesPage() {
const searchText = searchParams.query;
const stateFilterVal = getValueFromScopes(searchParams, "state");
- const selectedState =
- stateFilterVal === "DELETED"
- ? State.DELETED
- : stateFilterVal === "ALL"
- ? undefined
- : State.ACTIVE;
+ const selectedState = getResourceStateFilter(stateFilterVal);
const envVal = getValueFromScopes(searchParams, "environment");
const selectedEnvironment = envVal
@@ -920,6 +919,23 @@ export function InstancesPage() {
<EnvironmentLabel environmentName={instance.environment ?? ""} />
),
},
+ {
+ key: "state",
+ title: t("common.state"),
+ defaultWidth: 120,
+ minWidth: 100,
+ resizable: true,
+ render: (instance) =>
+ instance.state === State.DELETED ? (
+ <Badge variant="warning" className="text-xs">
+ {t("common.archived")}
+ </Badge>
+ ) : (
+ <Badge variant="success" className="text-xs">
+ {t("common.active")}
+ </Badge>
+ ),
+ },
{
key: "address",
title: t("common.address"),
diff --git a/frontend/src/react/pages/settings/ProjectsPage.tsx b/frontend/src/react/pages/settings/ProjectsPage.tsx
index 81c21ba3ad..65016dd157 100644
--- a/frontend/src/react/pages/settings/ProjectsPage.tsx
+++ b/frontend/src/react/pages/settings/ProjectsPage.tsx
@@ -40,7 +40,6 @@ import {
} from "@/react/hooks/useSessionPageSize";
import {
createAdvancedSearchParser,
- legacyStateSearchParams,
serializeAdvancedSearch,
useURLSearchParam,
} from "@/react/hooks/useURLSearchParam";
@@ -58,6 +57,10 @@ import {
hasProjectPermissionV2,
hasWorkspacePermissionV2,
} from "@/utils";
+import {
+ defaultActiveStateSearchParams,
+ getResourceStateFilter,
+} from "./resourceStateFilter";
const parseProjectSearch = createAdvancedSearchParser(["state", "label"]);
@@ -244,7 +247,7 @@ export function ProjectsPage() {
const route = useCurrentRoute();
const defaultSearchParams = useMemo<SearchParams>(
- () => legacyStateSearchParams(route.query.state),
+ () => defaultActiveStateSearchParams(route.query.state),
[route.query.state]
);
const [searchParams, setSearchParams] = useURLSearchParam<SearchParams>({
@@ -297,12 +300,7 @@ export function ProjectsPage() {
// Derived values from searchParams
const searchText = searchParams.query;
- const stateFilter = useMemo(() => {
- const val = getValueFromScopes(searchParams, "state");
- if (val === "DELETED") return "DELETED" as const;
- if (val === "ALL") return "ALL" as const;
- return "ACTIVE" as const;
- }, [searchParams]);
+ const stateFilter = getValueFromScopes(searchParams, "state");
const selectedLabels = useMemo(
() =>
searchParams.scopes.filter((s) => s.id === "label").map((s) => s.value),
@@ -355,11 +353,7 @@ export function ProjectsPage() {
[sortKey, sortOrder]
);
- const selectedState = useMemo(() => {
- if (stateFilter === "DELETED") return State.DELETED;
- if (stateFilter === "ALL") return undefined;
- return State.ACTIVE;
- }, [stateFilter]);
+ const selectedState = getResourceStateFilter(stateFilter);
const fetchProjects = useCallback(
async (isRefresh: boolean) => {
@@ -635,6 +629,7 @@ export function ProjectsPage() {
loading={loading}
showSelection={canDelete}
showLabels
+ showState
showActions
renderActions={(project) => (
<ProjectActionDropdown
diff --git a/frontend/src/react/pages/settings/resourceStateFilter.test.ts b/frontend/src/react/pages/settings/resourceStateFilter.test.ts
new file mode 100644
index 0000000000..56808a6111
--- /dev/null
+++ b/frontend/src/react/pages/settings/resourceStateFilter.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, test } from "vitest";
+import { State } from "@/types/proto-es/v1/common_pb";
+import {
+ defaultActiveStateSearchParams,
+ getResourceStateFilter,
+} from "./resourceStateFilter";
+
+describe("defaultActiveStateSearchParams", () => {
+ test("uses active state as the default filter", () => {
+ expect(defaultActiveStateSearchParams(undefined)).toEqual({
+ query: "",
+ scopes: [{ id: "state", value: "ACTIVE" }],
+ });
+ });
+
+ test("preserves legacy archived and all state query values", () => {
+ expect(defaultActiveStateSearchParams("archived").scopes).toEqual([
+ { id: "state", value: "DELETED" },
+ ]);
+ expect(defaultActiveStateSearchParams("all").scopes).toEqual([
+ { id: "state", value: "ALL" },
+ ]);
+ });
+});
+
+describe("getResourceStateFilter", () => {
+ test("maps an explicit active state to active resources", () => {
+ expect(getResourceStateFilter("ACTIVE")).toBe(State.ACTIVE);
+ });
+
+ test("maps an explicit deleted state to archived resources", () => {
+ expect(getResourceStateFilter("DELETED")).toBe(State.DELETED);
+ });
+
+ test("maps all or no state scope to all resources", () => {
+ expect(getResourceStateFilter("ALL")).toBeUndefined();
+ expect(getResourceStateFilter(undefined)).toBeUndefined();
+ });
+});
diff --git a/frontend/src/react/pages/settings/resourceStateFilter.ts b/frontend/src/react/pages/settings/resourceStateFilter.ts
new file mode 100644
index 0000000000..afdbaaebc4
--- /dev/null
+++ b/frontend/src/react/pages/settings/resourceStateFilter.ts
@@ -0,0 +1,25 @@
+import type { SearchParams } from "@/react/components/AdvancedSearch";
+import { legacyStateSearchParams } from "@/react/hooks/useURLSearchParam";
+import { State } from "@/types/proto-es/v1/common_pb";
+
+export const defaultActiveStateSearchParams = (
+ state: unknown
+): SearchParams => {
+ const legacy = legacyStateSearchParams(state);
+ if (legacy.scopes.length > 0) {
+ return legacy;
+ }
+ return { query: "", scopes: [{ id: "state", value: "ACTIVE" }] };
+};
+
+export const getResourceStateFilter = (
+ stateFilterValue: string | undefined
+): State | undefined => {
+ if (stateFilterValue === "ACTIVE") {
+ return State.ACTIVE;
+ }
+ if (stateFilterValue === "DELETED") {
+ return State.DELETED;
+ }
+ return undefined;
+};