Navigation fixes for duplicate and delete query
This commit is contained in:
parent
6f53b25116
commit
e45ee07192
|
@ -137,7 +137,7 @@
|
||||||
selected={$queries.selected === query._id}
|
selected={$queries.selected === query._id}
|
||||||
on:click={() => onClickQuery(query)}
|
on:click={() => onClickQuery(query)}
|
||||||
>
|
>
|
||||||
<EditQueryPopover {query} />
|
<EditQueryPopover {query} {onClickQuery} />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -5,22 +5,29 @@
|
||||||
import { datasources, queries } from "stores/backend"
|
import { datasources, queries } from "stores/backend"
|
||||||
|
|
||||||
export let query
|
export let query
|
||||||
|
export let onClickQuery
|
||||||
|
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
|
|
||||||
async function deleteQuery() {
|
async function deleteQuery() {
|
||||||
const wasSelectedQuery = $queries.selected
|
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)
|
await queries.delete(query)
|
||||||
if (wasSelectedQuery === query._id) {
|
await datasources.fetch()
|
||||||
$goto(`./datasource/${selectedDatasource}`)
|
|
||||||
|
if (navigateToDatasource) {
|
||||||
|
await datasources.select(query.datasourceId)
|
||||||
|
$goto(`./datasource/${query.datasourceId}`)
|
||||||
}
|
}
|
||||||
notifications.success("Query deleted")
|
notifications.success("Query deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
async function duplicateQuery() {
|
async function duplicateQuery() {
|
||||||
try {
|
try {
|
||||||
await queries.duplicate(query)
|
const newQuery = await queries.duplicate(query)
|
||||||
|
onClickQuery(newQuery)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notifications.error(e.message)
|
notifications.error(e.message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ export function createQueriesStore() {
|
||||||
list.map(q => q.name)
|
list.map(q => q.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
actions.save(datasourceId, newQuery)
|
return actions.save(datasourceId, newQuery)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue