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