Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions apps/desktop/src/components/structure/TableStructureEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -5881,18 +5881,16 @@ 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
v-model="column.isPrimaryKey"
type="checkbox"
:class="structureCheckboxClass"
:disabled="isPrimaryKeyDisabled(column)"
:aria-label="t('structureEditor.primaryKey')"
@change="
() => {
if (column.isPrimaryKey) column.isNullable = false;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)">
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Loading