Browse Source

fix(nc-gui): remove source from base source list if connection is deleted

pull/9265/head
Ramesh Mane 3 months ago
parent
commit
ed48787b0c
  1. 23
      packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue
  2. 4
      packages/nc-gui/store/workspace.ts

23
packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue

@ -22,6 +22,8 @@ const { $api, $e } = useNuxtApp()
const { allCollaborators } = storeToRefs(useWorkspace()) const { allCollaborators } = storeToRefs(useWorkspace())
const { bases } = storeToRefs(useBases())
const isDeleteIntegrationModalOpen = ref(false) const isDeleteIntegrationModalOpen = ref(false)
const toBeDeletedIntegration = ref< const toBeDeletedIntegration = ref<
| (IntegrationType & { | (IntegrationType & {
@ -139,7 +141,26 @@ const openDeleteIntegration = async (source: IntegrationType) => {
} }
const onDeleteConfirm = async () => { const onDeleteConfirm = async () => {
await deleteIntegration(toBeDeletedIntegration.value, true) const isDeleted = await deleteIntegration(toBeDeletedIntegration.value, true)
if (isDeleted) {
for (const source of toBeDeletedIntegration.value?.sources || []) {
if (!source.base_id || !source.id || (source.base_id && !bases.value.get(source.base_id))) {
continue
}
const base = bases.value.get(source.base_id)
if (!Array.isArray(base?.sources)) {
continue
}
bases.value.set(source.base_id, {
...(base || {}),
sources: [...base.sources.filter((s) => s.id !== source.id)],
})
}
}
} }
const loadOrgUsers = async () => { const loadOrgUsers = async () => {

4
packages/nc-gui/store/workspace.ts

@ -20,6 +20,8 @@ export const useWorkspace = defineStore('workspaceStore', () => {
const collaborators = ref<any[] | null>() const collaborators = ref<any[] | null>()
const allCollaborators = ref<any[] | null>()
const router = useRouter() const router = useRouter()
const route = router.currentRoute const route = router.currentRoute
@ -296,6 +298,7 @@ export const useWorkspace = defineStore('workspaceStore', () => {
removeCollaborator, removeCollaborator,
updateCollaborator, updateCollaborator,
collaborators, collaborators,
allCollaborators,
isInvitingCollaborators, isInvitingCollaborators,
isCollaboratorsLoading, isCollaboratorsLoading,
addToFavourite, addToFavourite,
@ -323,7 +326,6 @@ export const useWorkspace = defineStore('workspaceStore', () => {
auditLogsQuery, auditLogsQuery,
audits, audits,
auditPaginationData, auditPaginationData,
loadAudits, loadAudits,
isIntegrationsPageOpened, isIntegrationsPageOpened,
navigateToIntegrations, navigateToIntegrations,

Loading…
Cancel
Save