From 30b4c2467fb465456b56731f22bbdcb0cfd9026d Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 30 Dec 2020 11:46:37 +0000 Subject: [PATCH] codemirror --- packages/builder/package.json | 1 + .../builder/src/builderStore/store/backend.js | 14 +++++++ .../modals/CreateDatasourceModal.svelte | 6 ++- .../src/components/integration/Editor.svelte | 34 ++++++++++++++++ .../components/integration/SqlEditor.svelte | 0 .../src/components/integration/codemirror.js | 7 ++++ .../src/components/integration/index.svelte | 5 ++- .../[selectedDatasource]/[query]/index.svelte | 2 +- packages/builder/yarn.lock | 40 ++++++++++++++----- 9 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 packages/builder/src/components/integration/Editor.svelte delete mode 100644 packages/builder/src/components/integration/SqlEditor.svelte create mode 100644 packages/builder/src/components/integration/codemirror.js diff --git a/packages/builder/package.json b/packages/builder/package.json index 6c023efd29..b4a382f7ac 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -71,6 +71,7 @@ "@sentry/browser": "5.19.1", "@svelteschool/svelte-forms": "^0.7.0", "britecharts": "^2.16.0", + "codemirror": "^5.59.0", "d3-selection": "^1.4.1", "deepmerge": "^4.2.2", "fast-sort": "^2.2.0", diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index a1e3cfffdb..4e6767fa70 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -81,6 +81,20 @@ export const getBackendUiStore = () => { } state.datasources = state.datasources + state.selectedDatasourceId = json._id + return state + }) + return json + }, + delete: async datasource => { + await api.delete( + `/api/datasources/${datasource._id}/${datasource._rev}` + ) + store.update(state => { + state.datasources = state.datasources.filter( + existing => existing._id !== datasource._id + ) + state.selectedDatasourceId = null return state }) }, diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index 21c297c8a9..ef458c1953 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -27,7 +27,7 @@ const { type, ...config } = integration // Create datasource - await backendUiStore.actions.datasources.save({ + const response = await backendUiStore.actions.datasources.save({ name, source: type, config @@ -35,8 +35,10 @@ notifier.success(`Datasource ${name} created successfully.`) analytics.captureEvent("Datasource Created", { name }) + console.log(response) + // Navigate to new datasource - $goto(`./datasource/${datasource._id}`) + $goto(`./datasource/${response._id}`) } diff --git a/packages/builder/src/components/integration/Editor.svelte b/packages/builder/src/components/integration/Editor.svelte new file mode 100644 index 0000000000..f2bce2f222 --- /dev/null +++ b/packages/builder/src/components/integration/Editor.svelte @@ -0,0 +1,34 @@ + + +