25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(objects): show invalid indicator and validity badge for routines/views
lxk95587e3c0634a04
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vueindex b7c1faa817..67165ce905 100644--- a/apps/desktop/src/components/objects/ObjectBrowser.vue+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue@@ -13,6 +13,7 @@ import {Braces,Check,CheckSquare,+ CircleX,Clock,Clipboard,Code2,@@ -1117,6 +1118,7 @@ const tableOverviewRows = computed(() => {{ label: t("common.table"), value: sidePanelRow.value?.name ?? "" },{ label: t("common.schema"), value: sidePanelRow.value?.schema || selectedSchema.value || props.database },{ label: t("common.database"), value: props.database },+ ...(sidePanelRow.value?.valid != null ? [{ label: t("objects.validity"), value: t(sidePanelRow.value.valid ? "objects.validStatus" : "objects.invalidStatus") }] : []),{ label: t("structureEditor.comment"), value: tableOverviewComment.value ?? "" },{ label: t("grid.tableInfoEstimatedRows"), value: formatObjectBrowserCount(stats?.estimated_rows) },{ label: t("grid.tableInfoTotalSize"), value: formatObjectBrowserBytes(stats?.total_bytes) },@@ -4106,7 +4108,10 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {<ChevronRight v-else class="h-3.5 w-3.5" /></button><span v-else-if="item.partitionParentId" class="h-5 w-5 shrink-0" />- <component :is="iconFor(item)" class="h-3.5 w-3.5 shrink-0" :class="iconClass(item.type)" />+ <span class="relative flex h-3.5 w-3.5 shrink-0" :class="{ 'overflow-visible': item.valid === false }">+ <component :is="iconFor(item)" class="h-3.5 w-3.5 shrink-0" :class="iconClass(item.type)" />+ <CircleX v-if="item.valid === false" data-invalid-object-indicator="true" class="pointer-events-none absolute -right-1 -bottom-1 h-2.5 w-2.5 rounded-full bg-background text-destructive stroke-[3]" aria-hidden="true" />+ </span><span class="truncate text-[13px] font-medium text-foreground" :title="item.displayName">{{ item.displayName }}</span><span v-if="item.partitionCount" class="shrink-0 rounded border bg-muted/40 px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground">{{ t("objects.partitions", { count: item.partitionCount }) }}@@ -4114,7 +4119,7 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {</div><div class="flex min-w-0 items-center gap-1.5 truncate text-xs text-muted-foreground"><span class="truncate">{{ typeLabel(item) }}</span>- <span v-if="item.type === 'VIEW' && item.valid != null" class="shrink-0 rounded border px-1 py-px text-[10px] font-medium" :class="item.valid ? 'border-emerald-500/30 text-emerald-600' : 'border-destructive/30 text-destructive'">+ <span v-if="item.valid != null" class="shrink-0 rounded border px-1 py-px text-[10px] font-medium" :class="item.valid ? 'border-emerald-500/30 text-emerald-600' : 'border-destructive/30 text-destructive'">{{ t(item.valid ? "objects.validStatus" : "objects.invalidStatus") }}</span></div>@@ -4157,13 +4162,14 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {<CheckSquare v-if="selectedTableIds.has(item.id)" class="h-3.5 w-3.5 text-primary" /><Square v-else class="h-3.5 w-3.5" /></button>- <div class="flex h-11 w-11 shrink-0 items-center justify-center rounded-full shadow-sm" :class="iconBgClass(item.type)">+ <div class="relative flex h-11 w-11 shrink-0 items-center justify-center rounded-full shadow-sm" :class="[iconBgClass(item.type), { 'overflow-visible': item.valid === false }]"><component :is="iconFor(item)" class="h-6 w-6" :class="iconClass(item.type)" />+ <CircleX v-if="item.valid === false" data-invalid-object-indicator="true" class="pointer-events-none absolute -right-0.5 -bottom-0.5 h-4 w-4 rounded-full bg-background text-destructive stroke-[3]" aria-hidden="true" /></div><span class="w-full truncate text-sm font-medium leading-tight text-foreground">{{ item.displayName }}</span><div class="flex items-center gap-1.5"><span class="text-xs text-muted-foreground">{{ typeLabel(item) }}</span>- <span v-if="item.type === 'VIEW' && item.valid != null" class="rounded border px-1 py-px text-[10px] font-medium" :class="item.valid ? 'border-emerald-500/30 text-emerald-600' : 'border-destructive/30 text-destructive'">+ <span v-if="item.valid != null" class="rounded border px-1 py-px text-[10px] font-medium" :class="item.valid ? 'border-emerald-500/30 text-emerald-600' : 'border-destructive/30 text-destructive'">{{ t(item.valid ? "objects.validStatus" : "objects.invalidStatus") }}</span><span v-if="showObjectRowStats && item.estimatedRows != null && item.estimatedRows > 0" class="object-browser-stat-badge object-browser-stat-badge-rows rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-primary">{{@@ -4410,6 +4416,9 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {<div class="flex h-8 shrink-0 items-center gap-2 border-b bg-muted/20 px-3"><Code2 class="h-3.5 w-3.5 text-muted-foreground" /><span class="min-w-0 flex-1 truncate text-xs font-medium">{{ sourceTitle(sourceRow) }}</span>+ <span v-if="sourceRow?.valid != null" class="shrink-0 rounded border px-1 py-px text-[10px] font-medium" :class="sourceRow.valid ? 'border-emerald-500/30 text-emerald-600' : 'border-destructive/30 text-destructive'">+ {{ t(sourceRow.valid ? "objects.validStatus" : "objects.invalidStatus") }}+ </span><Button v-if="sourceEditing" variant="ghost" size="sm" class="h-6 px-2 text-xs" :disabled="sourceSaving || !sourceDraft.trim()" @click="saveSource"><Loader2 v-if="sourceSaving" class="mr-1 h-3 w-3 animate-spin" />{{ t("objects.saveSource") }}diff --git a/apps/desktop/src/components/objects/__tests__/ObjectBrowser.validityStatus.component.spec.ts b/apps/desktop/src/components/objects/__tests__/ObjectBrowser.validityStatus.component.spec.tsnew file mode 100644index 0000000000..569c8096df--- /dev/null+++ b/apps/desktop/src/components/objects/__tests__/ObjectBrowser.validityStatus.component.spec.ts@@ -0,0 +1,209 @@+// @vitest-environment happy-dom++import { createApp, defineComponent, h, nextTick, ref, type App } from "vue";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import ObjectBrowser from "@/components/objects/ObjectBrowser.vue";+import { invalidateObjectBrowserRowsCache } from "@/lib/table/objectBrowserRowsCache";+import type { ConnectionConfig, ObjectBrowserViewMode, ObjectInfo } from "@/types/database";++const mocks = vi.hoisted(() => ({+ listObjects: vi.fn(),+ listSchemas: vi.fn(),+ getObjectSource: vi.fn(),+ ensureConnected: vi.fn(),+ viewMode: "list" as ObjectBrowserViewMode,+}));++vi.mock("@/lib/backend/api", () => ({+ listObjects: (...args: unknown[]) => mocks.listObjects(...args),+ listSchemas: (...args: unknown[]) => mocks.listSchemas(...args),+ getObjectSource: (...args: unknown[]) => mocks.getObjectSource(...args),+ listObjectStatistics: vi.fn().mockResolvedValue([]),+}));+vi.mock("@/stores/connectionStore", () => ({+ useConnectionStore: () => ({+ getConfig: () => connection,+ ensureConnected: mocks.ensureConnected,+ orderByPinnedTreeNodes: (rows: unknown[]) => rows,+ }),+}));+vi.mock("@/stores/queryStore", () => ({ useQueryStore: () => ({}) }));+vi.mock("@/stores/settingsStore", () => ({+ useSettingsStore: () => ({+ editorSettings: {+ shortcuts: { refreshData: "F5" },+ objectBrowserViewMode: mocks.viewMode,+ objectBrowserShowCheckbox: false,+ sidebarActivation: "double",+ },+ }),+}));+vi.mock("vue-i18n", () => ({+ useI18n: () => ({+ t: (key: string) => {+ if (key === "objects.validStatus") return "VALID";+ if (key === "objects.invalidStatus") return "INVALID";+ if (key === "objects.source") return "Source";+ return key;+ },+ locale: ref("en-US"),+ }),+}));+vi.mock("@/i18n", () => ({ default: { install: () => undefined } }));+vi.mock("@/composables/useSqlHighlighter", () => ({ useSqlHighlighter: () => ({ highlight: (sql: string) => sql }) }));+vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: vi.fn() }) }));+vi.mock("vue-virtual-scroller", () => ({+ RecycleScroller: defineComponent({+ props: { items: { type: Array, default: () => [] } },+ setup(props, { slots }) {+ return () =>+ h(+ "div",+ props.items.map((item) => slots.default?.({ item })),+ );+ },+ }),+}));+vi.mock("@/components/ui/searchable-select", () => ({ SearchableSelect: { render: () => null } }));+vi.mock("@/components/ui/ToolbarOverflowMenu.vue", () => ({ default: { render: () => null } }));+vi.mock("@/components/editor/QueryEditor.vue", () => ({ default: { render: () => null } }));+vi.mock("@/components/editor/DangerConfirmDialog.vue", () => ({ default: { render: () => null } }));+vi.mock("@/components/objects/ProcedureExecutionDialog.vue", () => ({ default: { render: () => null } }));+vi.mock("@/components/objects/CustomTypeInfoPanel.vue", () => ({ default: { render: () => null } }));+vi.mock("@/components/export/XlsxHeaderDialog.vue", () => ({ default: { render: () => null } }));++const connection = {+ id: "validity-connection",+ name: "Dameng",+ db_type: "dameng",+ database: "DAMENG",+ driver_profile: null,+ url_params: null,+ transport_layers: [],+} as unknown as ConnectionConfig;++const mockObjects: ObjectInfo[] = [+ { name: "valid_view", object_type: "VIEW", schema: "APP", valid: true },+ { name: "invalid_view", object_type: "VIEW", schema: "APP", valid: false },+ { name: "valid_proc", object_type: "PROCEDURE", schema: "APP", valid: true },+ { name: "invalid_proc", object_type: "PROCEDURE", schema: "APP", valid: false },+ { name: "invalid_func", object_type: "FUNCTION", schema: "APP", valid: false },+ { name: "invalid_pkg", object_type: "PACKAGE", schema: "APP", valid: false },+ { name: "plain_table", object_type: "TABLE", schema: "APP", valid: null },+];++const mountedApps: Array<{ app: App; host: HTMLElement }> = [];+const gridStyle = document.createElement("style");+gridStyle.textContent = ".object-browser-grid-wrapper { padding: 8px; }";++beforeEach(() => {+ document.head.append(gridStyle);+ vi.clearAllMocks();+ mocks.viewMode = "list";+ mocks.listSchemas.mockResolvedValue(["APP"]);+ mocks.listObjects.mockResolvedValue(mockObjects);+ mocks.getObjectSource.mockResolvedValue("CREATE OR REPLACE PROCEDURE invalid_proc AS BEGIN NULL; END;");+});++afterEach(() => {+ for (const { app, host } of mountedApps.splice(0)) {+ app.unmount();+ host.remove();+ }+ invalidateObjectBrowserRowsCache({});+ gridStyle.remove();+});++async function mountBrowser() {+ const host = document.createElement("div");+ document.body.append(host);+ const app = createApp({+ setup: () => () => h(ObjectBrowser, { connection, database: "DAMENG", schema: "APP", selectedObjectFilter: "all" }),+ });+ mountedApps.push({ app, host });+ app.mount(host);+ await vi.waitFor(() => expect(host.querySelector('[title="valid_view"]')).not.toBeNull());+ return host;+}++function findObjectContainer(host: HTMLElement, name: string): HTMLElement {+ const rowOrCard = host.querySelector(`[title="${name}"]`)?.closest<HTMLElement>(".cursor-default");+ expect(rowOrCard, `expected row/card for ${name}`).toBeTruthy();+ return rowOrCard!;+}++describe("ObjectBrowser validity indicators", () => {+ it("renders red invalid indicator icon and status badges for invalid views, procedures, and functions in list view", async () => {+ mocks.viewMode = "list";+ const host = await mountBrowser();++ // Invalid objects have indicator icon+ const invalidView = findObjectContainer(host, "invalid_view");+ expect(invalidView.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidView.textContent).toContain("INVALID");++ const invalidProc = findObjectContainer(host, "invalid_proc");+ expect(invalidProc.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidProc.textContent).toContain("INVALID");++ const invalidFunc = findObjectContainer(host, "invalid_func");+ expect(invalidFunc.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidFunc.textContent).toContain("INVALID");++ const invalidPkg = findObjectContainer(host, "invalid_pkg");+ expect(invalidPkg.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidPkg.textContent).toContain("INVALID");++ // Valid objects do not have indicator icon, but have VALID badge+ const validView = findObjectContainer(host, "valid_view");+ expect(validView.querySelector('[data-invalid-object-indicator="true"]')).toBeNull();+ expect(validView.textContent).toContain("VALID");++ const validProc = findObjectContainer(host, "valid_proc");+ expect(validProc.querySelector('[data-invalid-object-indicator="true"]')).toBeNull();+ expect(validProc.textContent).toContain("VALID");++ // Null validity object has neither+ const plainTable = findObjectContainer(host, "plain_table");+ expect(plainTable.querySelector('[data-invalid-object-indicator="true"]')).toBeNull();+ expect(plainTable.textContent).not.toContain("INVALID");+ expect(plainTable.textContent).not.toContain("VALID");+ });++ it("renders red invalid indicator icon and status badges in grid view", async () => {+ mocks.viewMode = "grid";+ const host = await mountBrowser();++ const invalidView = findObjectContainer(host, "invalid_view");+ expect(invalidView.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidView.textContent).toContain("INVALID");++ const invalidProc = findObjectContainer(host, "invalid_proc");+ expect(invalidProc.querySelector('[data-invalid-object-indicator="true"]')).not.toBeNull();+ expect(invalidProc.textContent).toContain("INVALID");++ const validProc = findObjectContainer(host, "valid_proc");+ expect(validProc.querySelector('[data-invalid-object-indicator="true"]')).toBeNull();+ expect(validProc.textContent).toContain("VALID");++ const plainTable = findObjectContainer(host, "plain_table");+ expect(plainTable.querySelector('[data-invalid-object-indicator="true"]')).toBeNull();+ expect(plainTable.textContent).not.toContain("INVALID");+ expect(plainTable.textContent).not.toContain("VALID");+ });++ it("shows invalid status badge in side panel header when an invalid routine is selected", async () => {+ mocks.viewMode = "list";+ const host = await mountBrowser();++ const invalidProc = findObjectContainer(host, "invalid_proc");+ invalidProc.click();+ await nextTick();++ await vi.waitFor(() => {+ const header = host.querySelector(".border-b.bg-muted\\/20");+ expect(header).not.toBeNull();+ expect(header?.textContent).toContain("INVALID");+ });+ });+});diff --git a/apps/desktop/src/lib/__tests__/table/objectBrowserRows.spec.ts b/apps/desktop/src/lib/__tests__/table/objectBrowserRows.spec.tsindex 662fa5a27c..c095c46706 100644--- a/apps/desktop/src/lib/__tests__/table/objectBrowserRows.spec.ts+++ b/apps/desktop/src/lib/__tests__/table/objectBrowserRows.spec.ts@@ -39,6 +39,21 @@ describe("buildObjectBrowserRows", () => {expect(rows.map((row) => row.valid)).toEqual([true, false, null]);});++ it("preserves routine and package validity in browser rows", () => {+ const rows = buildObjectBrowserRows({+ objects: [+ { name: "valid_proc", object_type: "PROCEDURE", valid: true },+ { name: "invalid_proc", object_type: "PROCEDURE", valid: false },+ { name: "invalid_func", object_type: "FUNCTION", valid: false },+ { name: "invalid_pkg", object_type: "PACKAGE", valid: false },+ ],+ database: "app",+ fallbackSchema: "app",+ });++ expect(rows.map((row) => row.valid)).toEqual([true, false, false, false]);+ });});describe("Object Browser pinned ordering", () => {diff --git a/apps/desktop/src/lib/table/objectBrowserRows.ts b/apps/desktop/src/lib/table/objectBrowserRows.tsindex f6638b919a..bf04d74d28 100644--- a/apps/desktop/src/lib/table/objectBrowserRows.ts+++ b/apps/desktop/src/lib/table/objectBrowserRows.ts@@ -89,6 +89,7 @@ function objectBrowserRowObjectInfo(row: ObjectBrowserRow, schema?: string): Objname: row.name,object_type: row.type,schema,+ valid: row.valid,signature: row.signature || undefined,parent_schema: row.partitionParentSchema,parent_name: row.partitionParentName,