better UI feedback

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

View File

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

View File

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

View File

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

View File

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