Ensure datasources are refreshed when loading the create screen modal

This commit is contained in:
Dean 2022-04-08 09:05:56 +01:00
parent 75be5cff35
commit 8bb0f147e5
1 changed files with 26 additions and 6 deletions

View File

@ -1,11 +1,18 @@
<script>
import { store, selectedAccessRole } from "builderStore"
import { ModalContent, Layout, Select, Divider } from "@budibase/bbui"
import {
ModalContent,
Layout,
Select,
Divider,
notifications,
} from "@budibase/bbui"
import { tables, datasources, roles } from "stores/backend"
import getTemplates from "builderStore/store/screenTemplates"
import ICONS from "../../backend/DatasourceNavigator/icons"
import { IntegrationNames } from "constants"
import analytics, { Events } from "analytics"
import { onMount } from "svelte"
export let onCancel
export let onConfirm
@ -40,12 +47,25 @@
})
}
$: filteredSources = $datasources.list.reduce((acc, datasource) => {
if (datasource.source !== IntegrationNames.REST && datasource["entities"]) {
acc.push(datasource)
$: filteredSources = Array.isArray($datasources.list)
? $datasources.list.reduce((acc, datasource) => {
if (
datasource.source !== IntegrationNames.REST &&
datasource["entities"]
) {
acc.push(datasource)
}
return acc
}, [])
: []
onMount(async () => {
try {
await datasources.fetch()
} catch (error) {
notifications.error("Error fetching datasources")
}
return acc
}, [])
})
</script>
<ModalContent