fix(databases): correct enum icon and hide indexed checkbox for relationships

The create-index column selector matched icons by type only, so enum
columns (type: string, format: enum) fell through to the first
string-typed option and showed the email icon. The columns table also
showed an "Indexed" checkbox for relationship columns, which can't be
indexed.
This commit is contained in:
harsh mahajan committed 2026-07-10 11:28:39 +05:30
1 parent d305af6bd8
commit ca5f703f57
2 files changed
+26 -18

No files matched your search

@@ -57,7 +57,11 @@
.map((field) => ({
value: field.key,
label: field.key,
leadingIcon: baseColumnOptions.find((option) => option.type === field.type)?.icon
leadingIcon: baseColumnOptions.find(
(option) =>
option.type === field.type &&
option.format === ('format' in field ? field.format : undefined)
)?.icon
}))
);
@@ -515,26 +515,30 @@
{columnType.toLowerCase()}
</Spreadsheet.Cell>
<Spreadsheet.Cell column="indexed" {root} isEditable={false}>
<!-- $id is always indexed internally -->
{@const isActuallyIndexed =
isId || $indexes.some((index) => index.columns.includes(column.key))}
{#if !isRelationship(column)}
<!-- $id is always indexed internally -->
{@const isActuallyIndexed =
isId ||
$indexes.some((index) => index.columns.includes(column.key))}
<!-- $id is always indexed internally -->
{@const checked = isId || isActuallyIndexed || !!columnIndexMap[column.key]}
<!-- $id is always indexed internally -->
{@const checked =
isId || isActuallyIndexed || !!columnIndexMap[column.key]}
<Selector.Checkbox
size="s"
{checked}
disabled={isActuallyIndexed}
on:change={(e) => {
if (!isActuallyIndexed) {
if (e.detail) {
columnIndexMap[column.key] = true;
$showCreateIndexSheet.show = true;
$showCreateIndexSheet.column = column.key;
<Selector.Checkbox
size="s"
{checked}
disabled={isActuallyIndexed}
on:change={(e) => {
if (!isActuallyIndexed) {
if (e.detail) {
columnIndexMap[column.key] = true;
$showCreateIndexSheet.show = true;
$showCreateIndexSheet.column = column.key;
}
}
}
}} />
}} />
{/if}
</Spreadsheet.Cell>
<Spreadsheet.Cell column="default" {root} isEditable={false}>
{@const _default = column.required