Merge pull request #1306 from Budibase/fix/errouneous-navigation-when-deleting-tables

Fixes navigation issues when deleting tables/datasources
This commit is contained in:
Kevin Åberg Kultalahti 2021-03-19 15:14:46 +01:00 committed by GitHub
commit 2ae0e7e01e
3 changed files with 16 additions and 3 deletions

View File

@ -105,7 +105,9 @@ export const getBackendUiStore = () => {
state.datasources = state.datasources.filter(
existing => existing._id !== datasource._id
)
state.selectedDatasourceId = null
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
)
state.selectedTable = {}
if (table._id === state.selectedTable._id) {
state.selectedTable = {}
}
return state
})
},

View File

@ -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>

View File

@ -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()
}