Fix/disable table comment for unsupported db (#518)
* fix(structure-editor): disable table comment input for databases that don't support comments (e.g. SQLite) ## 背景说明 SQLite 不支持表注释(COMMENT),但表注释输入框始终可编辑。用户修改注释后,SQL 预览显示暂无变更且应用变更按钮不可用,造成困惑的 UX。 ## 修改内容 - 新增 isTableCommentDisabled 计算属性,基于 structureCapabilities.comment 控制禁用状态 - 表注释 Input 添加 :disabled 绑定,禁用时输入框变灰不可编辑 - 禁用时在输入框右侧显示 Info 图标,hover 显示 Tooltip 说明 - 三语言(zh-CN / en / es)新增 tableCommentUnsupported 翻译 ## 影响范围 - SQLite、DuckDB 及未知数据库类型:输入框被禁用 + Tooltip 提示 - MySQL、PostgreSQL、ClickHouse 等支持注释的数据库:完全不受影响 - 后端 generate_comment_ddl 已有对等过滤(仅 Postgres/Oracle/ClickHouse 生成 COMMENT SQL) ## 测试 - 建议补充:dbType 为 sqlite 时 isTableCommentDisabled 为 true 的单元测试 * test(structure-editor): add tests for table comment disabled state and unsupported DB capabilities
This commit is contained in:
1 parent
5e6d94afff
commit
310cc22b37
6 files changed
+29
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Database,
|
||||
Info,
|
||||
KeyRound,
|
||||
Loader2,
|
||||
Maximize2,
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { SearchableSelect } from "@/components/ui/searchable-select";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
@@ -134,6 +136,7 @@ function onIndexColResize(e: MouseEvent, col: number) {
|
||||
const connection = computed(() => (props.connectionId ? store.getConfig(props.connectionId) : undefined));
|
||||
const databaseType = computed(() => connection.value?.db_type);
|
||||
const structureCapabilities = computed(() => getTableStructureCapabilities(databaseType.value));
|
||||
const isTableCommentDisabled = computed(() => !structureCapabilities.value.comment);
|
||||
const dataTypeOptions = computed(() => DATA_TYPE_OPTIONS[databaseType.value ?? ""] ?? []);
|
||||
|
||||
const indexTypesByDb: Record<string, string[]> = {
|
||||
@@ -509,7 +512,14 @@ watch(
|
||||
v-model="tableComment"
|
||||
:placeholder="t('structureEditor.tableCommentPlaceholder')"
|
||||
class="h-6 max-w-[320px] text-[11px]"
|
||||
:disabled="isTableCommentDisabled"
|
||||
/>
|
||||
<Tooltip v-if="isTableCommentDisabled">
|
||||
<TooltipTrigger as-child>
|
||||
<Info class="h-4 w-4 shrink-0 text-muted-foreground" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{{ t("structureEditor.tableCommentUnsupported") }}</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground">
|
||||
|
||||
Reference in new issue
Block a user