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 40c8c0fab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
)
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
})
},

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