Display datasource name in views

This commit is contained in:
Adria Navarro 2025-01-21 13:41:30 +01:00
parent aa9603a1f2
commit 1609f42ed2
2 changed files with 30 additions and 13 deletions

View File

@ -9,11 +9,18 @@ export const datasourceSelect = {
datasourceName: datasource?.name, datasourceName: datasource?.name,
} }
}, },
viewV2: view => ({ viewV2: (view, datasources) => {
...view, const datasource = datasources
label: view.name, .filter(f => f.entities)
type: "viewV2", .flatMap(d => d.entities)
}), .find(ds => ds._id === view.tableId)
return {
...view,
label: view.name,
type: "viewV2",
datasourceName: datasource?.name,
}
},
} }
export const tableSelect = { export const tableSelect = {

View File

@ -43,10 +43,12 @@ interface DerivedBuilderState {
tables: { tables: {
label: string label: string
resourceId: string resourceId: string
datasourceName: string
}[] }[]
viewsV2: { viewsV2: {
label: string label: string
resourceId: string resourceId: string
datasourceName: string
}[] }[]
} }
} }
@ -64,10 +66,14 @@ export class BuilderStore extends DerivedBudiStore<
([$tables, $datasources, $viewsV2]) => ({ ([$tables, $datasources, $viewsV2]) => ({
formatedDatasourceNames: { formatedDatasourceNames: {
tables: $tables.list tables: $tables.list
.map(table => ({ .map(table => {
...format.table(table, $datasources.list), const formatted = format.table(table, $datasources.list)
resourceId: table._id!, return {
})) label: formatted.label,
datasourceName: formatted.datasourceName,
resourceId: table._id!,
}
})
.sort((a, b) => { .sort((a, b) => {
// sort tables alphabetically, grouped by datasource // sort tables alphabetically, grouped by datasource
const dsA = a.datasourceName ?? "" const dsA = a.datasourceName ?? ""
@ -79,10 +85,14 @@ export class BuilderStore extends DerivedBudiStore<
} }
return a.label.localeCompare(b.label) return a.label.localeCompare(b.label)
}), }),
viewsV2: $viewsV2.list.map(view => ({ viewsV2: $viewsV2.list.map(view => {
...format.viewV2(view), const formatted = format.viewV2(view, $datasources.list)
resourceId: view.id, return {
})), label: formatted.label,
datasourceName: formatted.datasourceName,
resourceId: view.id,
}
}),
}, },
}) })
) )