better UI feedback

This commit is contained in:
Martin McKeaveney 2021-01-04 10:39:17 +00:00
parent b4b4941003
commit d27a264c96
4 changed files with 14 additions and 10 deletions

View File

@ -60,9 +60,9 @@ export const getBackendUiStore = () => {
}) })
return json return json
}, },
select: async datasource => { select: async datasourceId => {
store.update(state => { store.update(state => {
state.selectedDatasourceId = datasource._id state.selectedDatasourceId = datasourceId
return state return state
}) })
}, },

View File

@ -9,6 +9,7 @@
ModalContent, ModalContent,
TextArea, TextArea,
} from "@budibase/bbui" } from "@budibase/bbui"
import { notifier } from "builderStore/store/notifications"
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import api from "builderStore/api" import api from "builderStore/api"
import EditIntegrationConfig from "../modals/EditIntegrationConfig.svelte" import EditIntegrationConfig from "../modals/EditIntegrationConfig.svelte"
@ -23,17 +24,20 @@
async function saveQuery() { async function saveQuery() {
try { try {
await backendUiStore.actions.datasources.saveQuery(datasource._id, query) await backendUiStore.actions.datasources.saveQuery(datasource._id, query)
notifier.success(`Query created successfully.`)
} catch (err) { } catch (err) {
console.error(err) console.error(err)
// TODO: notifier notifier.danger(`Error creating query. ${err.message}`)
} }
} }
$: console.log(query)
</script> </script>
<div> <div>
<Button text small on:click={modal.show}> <Button text small on:click={modal.show}>
<Icon name="filter" /> <Icon name="filter" />
Create Query {query ? 'Edit' : 'Create'} Query
</Button> </Button>
</div> </div>
<Modal bind:this={modal}> <Modal bind:this={modal}>

View File

@ -15,7 +15,7 @@
function selectDatasource(datasource) { function selectDatasource(datasource) {
// You can't actually select a datasource, just edit it // You can't actually select a datasource, just edit it
backendUiStore.actions.datasources.select(datasource) backendUiStore.actions.datasources.select(datasource._id)
$goto(`./datasource/${datasource._id}`) $goto(`./datasource/${datasource._id}`)
} }
@ -23,6 +23,7 @@
if ($backendUiStore.selectedQueryId === queryId) { if ($backendUiStore.selectedQueryId === queryId) {
return return
} }
backendUiStore.actions.datasources.select(datasourceId)
backendUiStore.actions.queries.select(queryId) backendUiStore.actions.queries.select(queryId)
$goto(`./datasource/${datasourceId}/${queryId}`) $goto(`./datasource/${datasourceId}/${queryId}`)
} }
@ -54,7 +55,7 @@
indentLevel={1} indentLevel={1}
icon="ri-eye-line" icon="ri-eye-line"
text={datasource.queries[queryId].name} text={datasource.queries[queryId].name}
selected={selectedView === queryId} selected={$backendUiStore.selectedQueryId === queryId}
on:click={() => onClickQuery(datasource._id, queryId)}> on:click={() => onClickQuery(datasource._id, queryId)}>
<!-- <EditViewPopover <!-- <EditViewPopover
view={{ name: viewName, ...table.views[viewName] }} /> --> view={{ name: viewName, ...table.views[viewName] }} /> -->

View File

@ -3,14 +3,13 @@
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte" import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte"
$: datasourceId = $params.selectedDatasource
// TODO: refactor // TODO: refactor
$: datasource = $backendUiStore.datasources.find( $: datasource = $backendUiStore.datasources.find(
ds => ds._id === $params.selectedDatasource ds => ds._id === $params.selectedDatasource
) )
$: query = datasource.queries[$params.query] $: query = datasource && datasource.queries[$params.query]
</script> </script>
{#if $backendUiStore.selectedDatabase._id && query} {#if $backendUiStore.selectedDatabase._id && datasource}
<ExternalDataSourceTable {query} {datasourceId} /> <ExternalDataSourceTable {query} datasourceId={datasource._id} />
{/if} {/if}