diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index bc29e3ece3..fb01bd5f95 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -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 diff --git a/packages/builder/src/builderStore/store/backend/index.js b/packages/builder/src/builderStore/store/backend/index.js index c2ae7f463c..8cdbffbe4a 100644 --- a/packages/builder/src/builderStore/store/backend/index.js +++ b/packages/builder/src/builderStore/store/backend/index.js @@ -1,3 +1,4 @@ export { permissions } from "./permissions" export { roles } from "./roles" export { datasources } from "./datasources" +export { integrations } from "./integrations" diff --git a/packages/builder/src/builderStore/store/backend/integrations.js b/packages/builder/src/builderStore/store/backend/integrations.js new file mode 100644 index 0000000000..d1df818248 --- /dev/null +++ b/packages/builder/src/builderStore/store/backend/integrations.js @@ -0,0 +1,3 @@ +import { writable } from "svelte/store" + +export const integrations = writable({}) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index a43382f3dd..f4977db705 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -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) }, diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DatasourceSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DatasourceSelect.svelte index 1e1ce41cba..24422150fc 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DatasourceSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DatasourceSelect.svelte @@ -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] } diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/ExecuteQuery.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/ExecuteQuery.svelte index 53f5d8b51b..2187f384e9 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/ExecuteQuery.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/ExecuteQuery.svelte @@ -1,7 +1,7 @@ diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 869697f109..2019e8bd0c 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -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 diff --git a/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/index.svelte b/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/index.svelte index 23a08522f8..8bf2f48dc0 100644 --- a/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/index.svelte +++ b/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/index.svelte @@ -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