Display datasource name in views
This commit is contained in:
parent
aa9603a1f2
commit
1609f42ed2
|
@ -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 = {
|
||||||
|
|
|
@ -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,
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue