Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

feat(structure): remove dynamic yes/no labels from editor checkboxes

lxk9557e324bdd011c
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index 6eafe38615..62c31ec604 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -5669,7 +5669,7 @@ watch(
<th
v-for="(columnLabel, i) in colLabels"
:key="columnLabel.key"
- :class="[structureHeaderCellClass, 'bg-background select-none', { 'text-center': columnLabel.key === 'primaryKey' }]"
+ :class="[structureHeaderCellClass, 'bg-background select-none', { 'text-center': columnLabel.key === 'primaryKey' || columnLabel.key === 'nullable' }]"
:data-column-selected="columnLabel.key === 'actions' ? undefined : selectedStructureColumnKeys.has(columnLabel.key)"
:style="{
width: visibleColWidths[i] + 'px',
@@ -5881,11 +5881,8 @@ watch(
</Select>
</div>
</td>
- <td v-if="columnEditorControls.nullable" :class="[structureCellClass, structureColumnSelectionClass('nullable')]">
- <label class="flex items-center gap-1.5">
- <input v-model="column.isNullable" type="checkbox" :class="structureCheckboxClass" :disabled="isColumnNullableDisabled(column)" />
- <span>{{ column.isNullable ? t("structureEditor.yes") : t("structureEditor.no") }}</span>
- </label>
+ <td v-if="columnEditorControls.nullable" :class="[structureCellClass, 'text-center', structureColumnSelectionClass('nullable')]">
+ <input v-model="column.isNullable" type="checkbox" :class="structureCheckboxClass" :disabled="isColumnNullableDisabled(column)" :aria-label="t('structureEditor.nullable')" />
</td>
<td v-if="columnEditorControls.primaryKey" :class="[structureCellClass, 'text-center', structureColumnSelectionClass('primaryKey')]">
<input
@@ -5893,6 +5890,7 @@ watch(
type="checkbox"
:class="structureCheckboxClass"
:disabled="isPrimaryKeyDisabled(column)"
+ :aria-label="t('structureEditor.primaryKey')"
@change="
() => {
if (column.isPrimaryKey) column.isNullable = false;
@@ -6183,7 +6181,7 @@ watch(
<th
v-for="(label, i) in indexColLabels"
:key="i"
- :class="structureHeaderCellClass"
+ :class="[structureHeaderCellClass, { 'text-center': i === 2 || i === 7 }]"
:style="{
width: indexColWidths[i] + 'px',
minWidth: indexColWidths[i] + 'px',
@@ -6231,18 +6229,16 @@ watch(
</StructureIndexColumnPicker>
<span v-else class="font-mono text-[length:var(--structure-font-size)] text-muted-foreground">{{ toColumnNames(index.columns) }}</span>
</td>
- <td :class="structureCellClass">
- <label class="flex items-center gap-1.5">
- <input
- :checked="index.isUnique"
- type="checkbox"
- :class="structureCheckboxClass"
- :disabled="!canEditIndexDraft(index) || !!indexColumnsIssue(index, index.columns, index.indexType, true)"
- data-index-unique
- @change="onIndexUniqueChange(index, ($event.target as HTMLInputElement).checked)"
- />
- <span>{{ index.isUnique ? t("structureEditor.yes") : t("structureEditor.no") }}</span>
- </label>
+ <td :class="[structureCellClass, 'text-center']">
+ <input
+ :checked="index.isUnique"
+ type="checkbox"
+ :class="structureCheckboxClass"
+ :disabled="!canEditIndexDraft(index) || !!indexColumnsIssue(index, index.columns, index.indexType, true)"
+ data-index-unique
+ :aria-label="t('structureEditor.unique')"
+ @change="onIndexUniqueChange(index, ($event.target as HTMLInputElement).checked)"
+ />
</td>
<td :class="structureCellClass">
<Select v-if="indexTypeOptions.length > 0" :model-value="index.indexType || 'BTREE'" :disabled="!canEditIndexDraft(index)" data-index-type @update:model-value="(value: unknown) => onIndexTypeChange(index, value)">
@@ -6276,10 +6272,9 @@ watch(
<td :class="structureCellClass">
<Input v-model="index.comment" :class="[structureControlClass, indexSearchFieldClass(index, index.comment)]" :disabled="!canEditIndexComment(index)" />
</td>
- <td :class="structureCellClass">
- <label v-if="structureCapabilities.indexConcurrent" class="flex items-center gap-1.5" :title="concurrentIndexCellTitle(index)">
- <input v-model="index.concurrently" type="checkbox" :class="structureCheckboxClass" :disabled="!canEditIndexConcurrent(index)" />
- <span>{{ index.concurrently ? t("structureEditor.yes") : t("structureEditor.no") }}</span>
+ <td :class="[structureCellClass, 'text-center']">
+ <label v-if="structureCapabilities.indexConcurrent" class="inline-flex items-center justify-center" :title="concurrentIndexCellTitle(index)">
+ <input v-model="index.concurrently" type="checkbox" :class="structureCheckboxClass" :disabled="!canEditIndexConcurrent(index)" :aria-label="t('structureEditor.concurrent')" />
</label>
<span v-else class="text-[length:var(--structure-font-size)] text-muted-foreground">—</span>
</td>
diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts
index 63caf096b8..2c48b88c49 100644
--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts
+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts
@@ -745,6 +745,32 @@ describe("TableStructureEditor column index actions", () => {
await vi.waitFor(() => expect(root.textContent).toContain("structureEditor.spatialIndexNullable"));
expect(mocks.executeBatch).not.toHaveBeenCalled();
});
+
+ it("renders checkboxes without dynamic yes/no toggle text (#8148)", async () => {
+ loadMetadata();
+ const root = await mountStructureEditor();
+ await openSubmenu(fieldRow(root, "email"), "structureEditor.createColumnIndex");
+ menuButton("structureEditor.createNormalIndex").click();
+ await expectIndexName(root, "idx_email");
+
+ const unique = indexRow(root).querySelector<HTMLInputElement>("[data-index-unique]")!;
+ const uniqueCell = unique.closest("td")!;
+ expect(uniqueCell.textContent?.trim()).toBe("");
+
+ unique.checked = true;
+ unique.dispatchEvent(new Event("change"));
+ await settle();
+ expect(uniqueCell.textContent?.trim()).toBe("");
+
+ const nullable = fieldRow(root, "location").querySelector<HTMLInputElement>('input[aria-label="structureEditor.nullable"]')!;
+ const nullableCell = nullable.closest("td")!;
+ expect(nullableCell.textContent?.trim()).toBe("");
+
+ nullable.checked = true;
+ nullable.dispatchEvent(new Event("change"));
+ await settle();
+ expect(nullableCell.textContent?.trim()).toBe("");
+ });
});
afterEach(() => {