Navigation fixes for duplicate and delete query

This commit is contained in:
Rory Powell 2022-01-05 13:27:15 -05:00
parent 8210ed7ee4
commit 22407446ee
3 changed files with 13 additions and 6 deletions

View File

@ -137,7 +137,7 @@
selected={$queries.selected === query._id}
on:click={() => onClickQuery(query)}
>
<EditQueryPopover {query} />
<EditQueryPopover {query} {onClickQuery} />
</NavItem>
{/each}
{/if}

View File

@ -5,22 +5,29 @@
import { datasources, queries } from "stores/backend"
export let query
export let onClickQuery
let confirmDeleteDialog
async function deleteQuery() {
const wasSelectedQuery = $queries.selected
const selectedDatasource = $datasources.selected
// need to calculate this before the query is deleted
const navigateToDatasource = wasSelectedQuery === query._id
await queries.delete(query)
if (wasSelectedQuery === query._id) {
$goto(`./datasource/${selectedDatasource}`)
await datasources.fetch()
if (navigateToDatasource) {
await datasources.select(query.datasourceId)
$goto(`./datasource/${query.datasourceId}`)
}
notifications.success("Query deleted")
}
async function duplicateQuery() {
try {
await queries.duplicate(query)
const newQuery = await queries.duplicate(query)
onClickQuery(newQuery)
} catch (e) {
notifications.error(e.message)
}

View File

@ -134,7 +134,7 @@ export function createQueriesStore() {
list.map(q => q.name)
)
actions.save(datasourceId, newQuery)
return actions.save(datasourceId, newQuery)
},
}