Prevent flashes
This commit is contained in:
parent
4a1a87d12d
commit
2381bbd80c
|
@ -22,6 +22,7 @@
|
||||||
import { TableNames } from "constants"
|
import { TableNames } from "constants"
|
||||||
import { userSelectedResourceMap } from "builderStore"
|
import { userSelectedResourceMap } from "builderStore"
|
||||||
import { enrichDatasources } from "./datasourceUtils"
|
import { enrichDatasources } from "./datasourceUtils"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
export let searchTerm
|
export let searchTerm
|
||||||
let toggledDatasources = {}
|
let toggledDatasources = {}
|
||||||
|
@ -62,6 +63,12 @@
|
||||||
$: showAppUsersTable =
|
$: showAppUsersTable =
|
||||||
!searchTerm ||
|
!searchTerm ||
|
||||||
appUsersTableName.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1
|
appUsersTableName.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if ($tables.selected) {
|
||||||
|
toggledDatasources[$tables.selected.sourceId] = true
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database?._id}
|
{#if $database?._id}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { TableNames } from "constants"
|
|
||||||
|
|
||||||
const showDatasourceOpen = ({
|
const showDatasourceOpen = ({
|
||||||
selected,
|
selected,
|
||||||
containsSelected,
|
containsSelected,
|
||||||
|
@ -28,7 +26,7 @@ const containsActiveEntity = (
|
||||||
datasource,
|
datasource,
|
||||||
params,
|
params,
|
||||||
isActive,
|
isActive,
|
||||||
tables,
|
selectedTableId,
|
||||||
queries,
|
queries,
|
||||||
views,
|
views,
|
||||||
viewsV2
|
viewsV2
|
||||||
|
@ -71,8 +69,7 @@ const containsActiveEntity = (
|
||||||
|
|
||||||
// Check for a matching table
|
// Check for a matching table
|
||||||
if (params.tableId) {
|
if (params.tableId) {
|
||||||
const selectedTable = tables.selected?._id
|
return options.find(x => x._id === selectedTableId) != null
|
||||||
return options.find(x => x._id === selectedTable) != null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for a matching view
|
// Check for a matching view
|
||||||
|
@ -93,7 +90,7 @@ export const enrichDatasources = (
|
||||||
datasources,
|
datasources,
|
||||||
params,
|
params,
|
||||||
isActive,
|
isActive,
|
||||||
tables,
|
selectedTableId,
|
||||||
queries,
|
queries,
|
||||||
views,
|
views,
|
||||||
viewsV2,
|
viewsV2,
|
||||||
|
@ -103,6 +100,7 @@ export const enrichDatasources = (
|
||||||
if (!datasources?.list?.length) {
|
if (!datasources?.list?.length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const onlySource = datasources.list.length === 1
|
const onlySource = datasources.list.length === 1
|
||||||
return datasources.list.map(datasource => {
|
return datasources.list.map(datasource => {
|
||||||
const selected =
|
const selected =
|
||||||
|
@ -112,18 +110,19 @@ export const enrichDatasources = (
|
||||||
datasource,
|
datasource,
|
||||||
params,
|
params,
|
||||||
isActive,
|
isActive,
|
||||||
tables,
|
selectedTableId,
|
||||||
queries,
|
queries,
|
||||||
views,
|
views,
|
||||||
viewsV2
|
viewsV2
|
||||||
)
|
)
|
||||||
|
|
||||||
const dsTables = tables.list.filter(
|
const entities = Array.isArray(datasource.entities)
|
||||||
|
? datasource.entities
|
||||||
|
: Object.values(datasource.entities)
|
||||||
|
const dsTables = entities.filter(
|
||||||
table =>
|
table =>
|
||||||
table.sourceId === datasource._id &&
|
!searchTerm ||
|
||||||
table._id !== TableNames.USERS &&
|
table.name?.toLowerCase()?.indexOf(searchTerm.toLowerCase()) > -1
|
||||||
(!searchTerm ||
|
|
||||||
table.name?.toLowerCase()?.indexOf(searchTerm.toLowerCase()) > -1)
|
|
||||||
)
|
)
|
||||||
const dsQueries = queries.list.filter(
|
const dsQueries = queries.list.filter(
|
||||||
query =>
|
query =>
|
||||||
|
@ -140,7 +139,7 @@ export const enrichDatasources = (
|
||||||
onlyOneSource: onlySource,
|
onlyOneSource: onlySource,
|
||||||
})
|
})
|
||||||
|
|
||||||
const show = !searchTerm || dsQueries.length || dsTables.length
|
const show = !searchTerm || dsQueries.length || dsTables.length || false
|
||||||
return {
|
return {
|
||||||
...datasource,
|
...datasource,
|
||||||
selected,
|
selected,
|
||||||
|
|
Loading…
Reference in New Issue