1
0
Fork 0
mirror of synced 2024-09-30 17:18:14 +13:00

Fix table selection (#11050)

This commit is contained in:
Gerard Burns 2023-06-28 12:14:23 +01:00 committed by GitHub
parent 1b2781b7f8
commit 099eee5f8c
6 changed files with 30 additions and 78 deletions

View file

@ -6,6 +6,7 @@
Layout,
ModalContent,
} from "@budibase/bbui"
import Spinner from "components/common/Spinner.svelte"
import { IntegrationTypes } from "constants/backend"
import { createTableSelectionStore } from "./tableSelectionStore"
@ -19,9 +20,10 @@
$: tableType = isSheets ? "sheets" : "tables"
$: title = `Choose your ${tableType}`
$: confirmText = $store.hasSelected
? `Fetch ${tableType}`
: "Continue without fetching"
$: confirmText =
$store.loading || $store.hasSelected
? `Fetch ${tableType}`
: "Continue without fetching"
$: description = isSheets
? "Select which spreadsheets you want to connect."
@ -39,7 +41,9 @@
disabled={$store.loading}
>
{#if $store.loading}
<p>loading...</p>
<div class="loading">
<Spinner size="20" />
</div>
{:else}
<Layout noPadding no>
<Body size="S">{description}</Body>
@ -60,3 +64,10 @@
</Layout>
{/if}
</ModalContent>
<style>
.loading {
display: flex;
justify-content: center;
}
</style>

View file

@ -32,10 +32,10 @@ export const createTableSelectionStore = (integration, datasource) => {
} else {
notifications.error("Error fetching tables.")
}
}
// Prevent modal closing
return false
// Prevent modal closing
return false
}
}
const combined = derived(

View file

@ -1,21 +0,0 @@
<script>
import { Menu, Icon, MenuSection, MenuItem } from "@budibase/bbui"
export let heading
export let tables
export let selected = false
export let select
</script>
<Menu>
<MenuSection {heading}>
{#each tables as table}
<MenuItem noClose icon="Table" on:click={() => select(table)}>
{table.name}
{#if selected}
<Icon size="S" name="Checkmark" />
{/if}
</MenuItem>
{/each}
</MenuSection>
</Menu>

View file

@ -5,7 +5,7 @@
import GoogleAuthPrompt from "./GoogleAuthPrompt.svelte"
import { get } from "svelte/store"
import TableImportSelection from "./TableImportSelection/index.svelte"
import TableImportSelection from "components/backend/Datasources/TableImportSelection/index.svelte"
import DatasourceConfigEditor from "components/backend/Datasources/ConfigEditor/index.svelte"
import { datasources } from "stores/backend"
import { createOnGoogleAuthStore } from "./stores/onGoogleAuth.js"

View file

@ -1,66 +1,29 @@
<script>
import { Body, Button, notifications, Modal, Toggle } from "@budibase/bbui"
import { datasources, tables } from "stores/backend"
import { Button, Modal } from "@budibase/bbui"
import { integrations, tables } from "stores/backend"
import CreateExternalTableModal from "./CreateExternalTableModal.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import ValuesList from "components/common/ValuesList.svelte"
import TableImportSelection from "components/backend/Datasources/TableImportSelection/index.svelte"
import { integrationForDatasource } from "stores/selectors"
export let datasource
let createExternalTableModal
let confirmDialog
let specificTables = null
let requireSpecificTables = false
$: integration = integrationForDatasource($integrations, datasource)
async function updateDatasourceSchema() {
try {
await datasources.updateSchema(datasource, specificTables)
notifications.success(`Datasource ${name} tables updated successfully`)
await tables.fetch()
} catch (error) {
notifications.error(
`Error updating datasource schema ${
error?.message ? `: ${error.message}` : ""
}`
)
}
}
let createExternalTableModal
let tableSelectionModal
</script>
<Modal bind:this={createExternalTableModal}>
<CreateExternalTableModal {datasource} />
</Modal>
<ConfirmDialog
bind:this={confirmDialog}
okText="Fetch tables"
onOk={updateDatasourceSchema}
onCancel={() => confirmDialog.hide()}
warning={false}
title="Confirm table fetch"
>
<Toggle
bind:value={requireSpecificTables}
on:change={e => {
requireSpecificTables = e.detail
specificTables = null
}}
thin
text="Fetch listed tables only (one per line)"
/>
{#if requireSpecificTables}
<ValuesList label="" bind:values={specificTables} />
{/if}
<br />
<Body>
If you have fetched tables from this database before, this action may
overwrite any changes you made after your initial fetch.
</Body>
</ConfirmDialog>
<Modal bind:this={tableSelectionModal}>
<TableImportSelection {datasource} {integration} onComplete={tables.fetch} />
</Modal>
<div class="buttons">
<Button cta on:click={createExternalTableModal.show}>Create new table</Button>
<Button secondary on:click={confirmDialog.show}>Fetch tables</Button>
<Button secondary on:click={tableSelectionModal.show}>Fetch tables</Button>
</div>
<style>

View file

@ -26,7 +26,6 @@
$integrations[datasource.source].relationships === false
? ["Tables", "Queries"]
: ["Tables", "Relationships", "Queries"]
// TODO what is this for?
selectedPanel = panelOptions.includes(selectedPanel)
? selectedPanel
: "Tables"