moves integrations part of backendstore to separate store
This commit is contained in:
parent
58aefcec04
commit
17802795d0
|
@ -7,7 +7,6 @@ const INITIAL_BACKEND_UI_STATE = {
|
|||
views: [],
|
||||
datasources: [],
|
||||
queries: [],
|
||||
integrations: {},
|
||||
selectedDatabase: {},
|
||||
selectedTable: {},
|
||||
draftTable: {},
|
||||
|
@ -20,17 +19,15 @@ export const getBackendUiStore = () => {
|
|||
reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }),
|
||||
database: {
|
||||
select: async db => {
|
||||
const [tables, queries, integrations] = await Promise.all([
|
||||
const [tables, queries] = await Promise.all([
|
||||
api.get(`/api/tables`).then(r => r.json()),
|
||||
api.get(`/api/queries`).then(r => r.json()),
|
||||
api.get("/api/integrations").then(r => r.json()),
|
||||
])
|
||||
|
||||
store.update(state => {
|
||||
state.selectedDatabase = db
|
||||
state.tables = tables
|
||||
state.queries = queries
|
||||
state.integrations = integrations
|
||||
return state
|
||||
})
|
||||
},
|
||||
|
@ -242,25 +239,6 @@ export const getBackendUiStore = () => {
|
|||
})
|
||||
},
|
||||
},
|
||||
permissions: {
|
||||
fetchLevels: async () => {
|
||||
const response = await api.get("/api/permission/levels")
|
||||
const json = await response.json()
|
||||
return json
|
||||
},
|
||||
forResource: async resourceId => {
|
||||
const response = await api.get(`/api/permission/${resourceId}`)
|
||||
const json = await response.json()
|
||||
return json
|
||||
},
|
||||
save: async ({ role, resource, level }) => {
|
||||
const response = await api.post(
|
||||
`/api/permission/${role}/${resource}/${level}`
|
||||
)
|
||||
const json = await response.json()
|
||||
return json
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return store
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export { permissions } from "./permissions"
|
||||
export { roles } from "./roles"
|
||||
export { datasources } from "./datasources"
|
||||
export { integrations } from "./integrations"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
import { writable } from "svelte/store"
|
||||
|
||||
export const integrations = writable({})
|
|
@ -10,7 +10,7 @@ import {
|
|||
selectedAccessRole,
|
||||
} from "builderStore"
|
||||
// Backendstores
|
||||
import {datasources} from 'builderStore/store/backend/'
|
||||
import { datasources, integrations } from 'builderStore/store/backend/'
|
||||
|
||||
import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
|
||||
import api from "../api"
|
||||
|
@ -62,10 +62,12 @@ export const getFrontendStore = () => {
|
|||
await hostingStore.actions.fetch()
|
||||
|
||||
// Initialise backend stores
|
||||
const [sources] = await Promise.all([
|
||||
const [_datasources, _integrations] = await Promise.all([
|
||||
api.get(`/api/datasources`).then(r => r.json()),
|
||||
api.get("/api/integrations").then(r => r.json())
|
||||
])
|
||||
datasources.set({sources, selected: null})
|
||||
datasources.set({sources: _datasources, selected: null})
|
||||
integrations.set(_integrations)
|
||||
|
||||
await backendUiStore.actions.database.select(application.instance)
|
||||
},
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
} from "@budibase/bbui"
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import { store, backendUiStore, currentAsset } from "builderStore"
|
||||
import { datasources } from 'builderStore/store/backend/'
|
||||
import { datasources, integrations } from 'builderStore/store/backend/'
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
|
||||
import IntegrationQueryEditor from "components/integration/index.svelte"
|
||||
|
@ -85,7 +85,7 @@
|
|||
const source = $datasources.sources.find(
|
||||
ds => ds._id === query.datasourceId
|
||||
).source
|
||||
return $backendUiStore.integrations[source].query[query.queryVerb]
|
||||
return $integrations[source].query[query.queryVerb]
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { Select, Label, Spacer } from "@budibase/bbui"
|
||||
import { store, backendUiStore, currentAsset } from "builderStore"
|
||||
import { datasources } from 'builderStore/store/backend/'
|
||||
import { datasources, integrations } from 'builderStore/store/backend/'
|
||||
import { getBindableProperties } from "builderStore/dataBinding"
|
||||
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
|
||||
import IntegrationQueryEditor from "components/integration/index.svelte"
|
||||
|
@ -21,7 +21,7 @@
|
|||
const source = $datasources.sources.find(
|
||||
ds => ds._id === query.datasourceId
|
||||
).source
|
||||
return $backendUiStore.integrations[source].query[query.queryVerb]
|
||||
return $integrations[source].query[query.queryVerb]
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte"
|
||||
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { datasources } from 'builderStore/store/backend/'
|
||||
import { datasources, integrations } from 'builderStore/store/backend/'
|
||||
|
||||
const PREVIEW_HEADINGS = [
|
||||
{
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
$: datasourceType = datasource?.source
|
||||
|
||||
$: integrationInfo = $backendUiStore.integrations[datasourceType]
|
||||
$: integrationInfo = $integrations[datasourceType]
|
||||
$: queryConfig = integrationInfo?.query
|
||||
|
||||
$: shouldShowQueryConfig = queryConfig && query.queryVerb
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { goto, beforeUrlChange } from "@sveltech/routify"
|
||||
import { Button, Heading, Body, Spacer } from "@budibase/bbui"
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { datasources } from 'builderStore/store/backend/'
|
||||
import { datasources, integrations } from 'builderStore/store/backend/'
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
|
||||
import ICONS from "components/backend/DatasourceNavigator/icons"
|
||||
|
@ -12,7 +12,7 @@
|
|||
$: datasource = $datasources.sources.find(
|
||||
ds => ds._id === $datasources.selected
|
||||
)
|
||||
$: integration = datasource && $backendUiStore.integrations[datasource.source]
|
||||
$: integration = datasource && $integrations[datasource.source]
|
||||
|
||||
async function saveDatasource() {
|
||||
// Create datasource
|
||||
|
|
Loading…
Reference in New Issue