🐛 fix(sidebar): 隐藏达梦等数据源不支持的数据库管理入口

- 新增数据库级 DDL 能力判定,统一收敛新建库、重命名库、删库菜单显示
- 修正 Sidebar V1/V2 右键菜单,避免达梦和 Oracle-like 数据源暴露误导入口
- 补充能力与菜单回归测试,覆盖达梦、Oracle 和 OceanBase Oracle 协议

Refs #496
This commit is contained in:
Syngnat
2026-05-27 20:13:19 +08:00
parent e069ddf8fa
commit fac826b335
5 changed files with 122 additions and 11 deletions

View File

@@ -99,12 +99,55 @@ export type DataSourceCapabilities = {
supportsQueryEditor: boolean;
supportsSqlQueryExport: boolean;
supportsCopyInsert: boolean;
supportsCreateDatabase: boolean;
supportsRenameDatabase: boolean;
supportsDropDatabase: boolean;
forceReadOnlyQueryResult: boolean;
preferManualTotalCount: boolean;
supportsApproximateTableCount: boolean;
supportsApproximateTotalPages: boolean;
};
const CREATE_DATABASE_TYPES = new Set([
'mysql',
'mariadb',
'oceanbase',
'diros',
'starrocks',
'postgres',
'kingbase',
'highgo',
'vastbase',
'opengauss',
'sqlserver',
'tdengine',
'clickhouse',
]);
const RENAME_DATABASE_TYPES = new Set([
'diros',
'postgres',
'kingbase',
'highgo',
'vastbase',
'opengauss',
]);
const DROP_DATABASE_TYPES = new Set([
'mysql',
'mariadb',
'oceanbase',
'diros',
'starrocks',
'postgres',
'kingbase',
'highgo',
'vastbase',
'opengauss',
'tdengine',
'clickhouse',
]);
export const getDataSourceCapabilities = (config: ConnectionLike): DataSourceCapabilities => {
const type = resolveDataSourceType(config);
return {
@@ -112,6 +155,9 @@ export const getDataSourceCapabilities = (config: ConnectionLike): DataSourceCap
supportsQueryEditor: !QUERY_EDITOR_DISABLED_TYPES.has(type),
supportsSqlQueryExport: SQL_QUERY_EXPORT_TYPES.has(type),
supportsCopyInsert: COPY_INSERT_TYPES.has(type),
supportsCreateDatabase: CREATE_DATABASE_TYPES.has(type),
supportsRenameDatabase: RENAME_DATABASE_TYPES.has(type),
supportsDropDatabase: DROP_DATABASE_TYPES.has(type),
forceReadOnlyQueryResult: FORCE_READ_ONLY_QUERY_TYPES.has(type),
preferManualTotalCount: MANUAL_TOTAL_COUNT_TYPES.has(type),
supportsApproximateTableCount: APPROXIMATE_TABLE_COUNT_TYPES.has(type),