feat(nacos): allow pinning namespaces

This commit is contained in:
二丫讲梵 2026-06-25 17:39:46 +08:00 committed by GitHub
parent 42541d1146
commit bc4e71c628
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View File

@ -66,7 +66,7 @@ import type { ColumnInfo, ConnectionConfig, DatabaseType, TreeNode, TreeNodeType
import * as api from "@/lib/api";
import { uuid } from "@/lib/utils";
import { resolveDefaultDatabase } from "@/lib/defaultDatabase";
import { canTreeNodeShowExpander, treeItemPaddingLeft, usesFullWidthTreeLabel } from "@/lib/sidebarTreeItemLayout";
import { canTreeNodePin, canTreeNodeShowExpander, treeItemPaddingLeft, usesFullWidthTreeLabel } from "@/lib/sidebarTreeItemLayout";
import { buildTableSelectSql } from "@/lib/tableSelectSql";
import { buildTableDeleteTemplate, buildTableInsertTemplate, buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/tableSqlTemplates";
import { connectionFilePath, defaultSqliteBackupFileName, isMemorySqlitePath, sqliteBackupSourcePath } from "@/lib/connectionFile";
@ -302,8 +302,6 @@ function getIconInfo(node: TreeNode): { icon: any; colorClass: string } | null {
}
const groupTypes: Set<TreeNodeType> = new Set(["group-columns", "group-indexes", "group-fkeys", "group-triggers", "group-tables", "group-views", "group-materialized-views", "group-procedures", "group-functions", "group-sequences", "group-packages", "group-partitions"]);
const pinnableTypes: Set<TreeNodeType> = new Set(["connection-group", "database", "linked-server", "linked-server-catalog", "linked-server-schema", "schema", "table", "view", "materialized_view", "redis-db", "mongo-db", "mongo-collection", "vector-collection", "elasticsearch-index"]);
function isGroupLabel(node: TreeNode): boolean {
return groupTypes.has(node.type);
}
@ -3048,7 +3046,7 @@ const canExpand = computed(() =>
childCount: props.node.children?.length ?? 0,
}),
);
const canPin = computed(() => pinnableTypes.has(props.node.type));
const canPin = computed(() => canTreeNodePin(props.node.type));
const canOpenSqlFileExecution = computed(() => {
return supportsSqlFileExecution(rawDatabaseType());
});

View File

@ -6,6 +6,24 @@ const fullWidthLabelTypes: Set<TreeNodeType> = new Set(["table", "view", "materi
const emptyContainerTypes: Set<TreeNodeType> = new Set(["saved-sql-root", "saved-sql-folder"]);
const pinnableTypes: Set<TreeNodeType> = new Set([
"connection-group",
"database",
"linked-server",
"linked-server-catalog",
"linked-server-schema",
"schema",
"table",
"view",
"materialized_view",
"redis-db",
"mongo-db",
"mongo-collection",
"vector-collection",
"elasticsearch-index",
"nacos-namespace",
]);
export function treeItemPaddingLeft(depth: number): string {
return `${depth * 16 + 8}px`;
}
@ -23,3 +41,7 @@ export function canTreeNodeShowExpander({ type, childCount }: { type: TreeNodeTy
if (childCount === 0 && emptyContainerTypes.has(type)) return false;
return true;
}
export function canTreeNodePin(type: TreeNodeType): boolean {
return pinnableTypes.has(type);
}

View File

@ -1,6 +1,6 @@
import { test } from "vitest";
import assert from "node:assert/strict";
import { canTreeNodeShowExpander } from "../../apps/desktop/src/lib/sidebarTreeItemLayout.ts";
import { canTreeNodePin, canTreeNodeShowExpander } from "../../apps/desktop/src/lib/sidebarTreeItemLayout.ts";
test("mongodb collection rows can show an expander for metadata groups", () => {
assert.equal(canTreeNodeShowExpander({ type: "mongo-collection", childCount: 0 }), true);
@ -9,3 +9,7 @@ test("mongodb collection rows can show an expander for metadata groups", () => {
test("ZooKeeper root rows do not show an empty expander", () => {
assert.equal(canTreeNodeShowExpander({ type: "zookeeper-root", childCount: 0 }), false);
});
test("Nacos namespace rows can show the pin action", () => {
assert.equal(canTreeNodePin("nacos-namespace"), true);
});