Merge pull request #1306 from Budibase/fix/errouneous-navigation-when-deleting-tables
Fixes navigation issues when deleting tables/datasources
This commit is contained in:
commit
2ae0e7e01e
|
@ -105,7 +105,9 @@ export const getBackendUiStore = () => {
|
|||
state.datasources = state.datasources.filter(
|
||||
existing => existing._id !== datasource._id
|
||||
)
|
||||
if (datasource._id === state.selectedDatasourceId) {
|
||||
state.selectedDatasourceId = null
|
||||
}
|
||||
return state
|
||||
})
|
||||
},
|
||||
|
@ -233,7 +235,9 @@ export const getBackendUiStore = () => {
|
|||
state.tables = state.tables.filter(
|
||||
existing => existing._id !== table._id
|
||||
)
|
||||
if (table._id === state.selectedTable._id) {
|
||||
state.selectedTable = {}
|
||||
}
|
||||
return state
|
||||
})
|
||||
},
|
||||
|
|
|
@ -22,9 +22,13 @@
|
|||
}
|
||||
|
||||
async function deleteDatasource() {
|
||||
const wasSelectedSource = $backendUiStore.selectedDatasourceId
|
||||
await backendUiStore.actions.datasources.delete(datasource)
|
||||
notifier.success("Datasource deleted")
|
||||
$goto("./datasource")
|
||||
// navigate to first index page if the source you are deleting is selected
|
||||
if (wasSelectedSource === datasource._id) {
|
||||
$goto('./datasource')
|
||||
}
|
||||
hideEditor()
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import { goto } from "@sveltech/routify"
|
||||
import { backendUiStore, store, allScreens } from "builderStore"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import { DropdownMenu, Button, Input } from "@budibase/bbui"
|
||||
|
@ -36,10 +37,14 @@
|
|||
}
|
||||
|
||||
async function deleteTable() {
|
||||
const wasSelectedTable = $backendUiStore.selectedTable
|
||||
await backendUiStore.actions.tables.delete(table)
|
||||
store.actions.screens.delete(templateScreens)
|
||||
await backendUiStore.actions.tables.fetch()
|
||||
notifier.success("Table deleted")
|
||||
if (wasSelectedTable._id === table._id) {
|
||||
$goto('./table')
|
||||
}
|
||||
hideEditor()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue