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,
}
},
viewV2: view => ({
viewV2: (view, datasources) => {
const datasource = datasources
.filter(f => f.entities)
.flatMap(d => d.entities)
.find(ds => ds._id === view.tableId)
return {
...view,
label: view.name,
type: "viewV2",
}),
datasourceName: datasource?.name,
}
},
}
export const tableSelect = {

View File

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