From cc60baa3d188526df93c4b4711befdebe4d22816 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 6 Jun 2023 17:40:14 +0100 Subject: [PATCH] Some fixes for BBUI and updating postgres table name fetching to get uniques. --- .../src/FancyForm/FancyCheckboxGroup.svelte | 12 ++- packages/bbui/src/ListBox/Checkbox.svelte | 62 ------------ packages/bbui/src/ListBox/ListBox.svelte | 99 ------------------- packages/bbui/src/index.js | 1 - .../builder/src/builderStore/datasource.js | 8 +- .../modals/DatasourceConfigModal.svelte | 8 +- .../server/src/api/controllers/datasource.ts | 2 +- packages/server/src/integrations/postgres.ts | 3 +- 8 files changed, 23 insertions(+), 172 deletions(-) delete mode 100644 packages/bbui/src/ListBox/Checkbox.svelte delete mode 100644 packages/bbui/src/ListBox/ListBox.svelte diff --git a/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte b/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte index 58cf00db58..be37994616 100644 --- a/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte +++ b/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte @@ -1,17 +1,19 @@ - - - - diff --git a/packages/bbui/src/ListBox/ListBox.svelte b/packages/bbui/src/ListBox/ListBox.svelte deleted file mode 100644 index 04b563160e..0000000000 --- a/packages/bbui/src/ListBox/ListBox.svelte +++ /dev/null @@ -1,99 +0,0 @@ - - -
- {#if options && Array.isArray(options)} - {#if showSelectAll} -
- -
- {/if} - {#each options as option} -
- -
- {/each} - {/if} -
- - diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index f1b2e58870..d26b938dd5 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -78,7 +78,6 @@ export { default as IconSideNavItem } from "./IconSideNav/IconSideNavItem.svelte export { default as Slider } from "./Form/Slider.svelte" export { default as Accordion } from "./Accordion/Accordion.svelte" export { default as File } from "./Form/File.svelte" -export { default as ListBox } from "./ListBox/ListBox.svelte" // Renderers export { default as BoldRenderer } from "./Table/BoldRenderer.svelte" diff --git a/packages/builder/src/builderStore/datasource.js b/packages/builder/src/builderStore/datasource.js index 6509216a5b..10f1facb1c 100644 --- a/packages/builder/src/builderStore/datasource.js +++ b/packages/builder/src/builderStore/datasource.js @@ -41,6 +41,10 @@ export async function createRestDatasource(integration) { export async function validateDatasourceConfig(config) { const datasource = prepareData(config) - const resp = await API.validateDatasource(datasource) - return resp + return await API.validateDatasource(datasource) +} + +export async function getDatasourceInfo(config) { + const datasource = prepareData(config) + return await API.fetchInfoForDatasource(datasource) } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte index 481dd29856..626c61ea5f 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte @@ -13,6 +13,7 @@ import { saveDatasource as save, validateDatasourceConfig, + getDatasourceInfo, } from "builderStore/datasource" import { DatasourceFeature } from "@budibase/types" @@ -22,7 +23,10 @@ let datasource = cloneDeep(integration) let isValid = false let fetchTableStep = false + let selectedTables = [] + let tableList = [] + $: console.log(selectedTables) $: name = IntegrationNames[datasource?.type] || datasource?.name || datasource?.type $: datasourcePlus = datasource?.plus @@ -78,6 +82,8 @@ } if (datasourcePlus) { notifications.success("Connected to datasource successfully.") + const info = await getDatasourceInfo(datasource) + tableList = info.tableNames fetchTableStep = true return false } else { @@ -110,7 +116,7 @@ /> {:else}
- +
{/if} diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 75b33083fb..4660d05b1e 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -174,7 +174,7 @@ export async function information( } const tableNames = await connector.getTableNames() ctx.body = { - tableNames, + tableNames: tableNames.sort(), } } diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index 47295716e6..33ecf45982 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -322,7 +322,8 @@ class PostgresIntegration extends Sql implements DatasourcePlus { await this.openConnection() const columnsResponse: { rows: PostgresColumn[] } = await this.client.query(this.COLUMNS_SQL) - return columnsResponse.rows.map(row => row.table_name) + const names = columnsResponse.rows.map(row => row.table_name) + return [...new Set(names)] } finally { await this.closeConnection() }