From ed48787b0c2701978d7265edcbec949d47e550d9 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:16:59 +0530 Subject: [PATCH] fix(nc-gui): remove source from base source list if connection is deleted --- .../workspace/integrations/ConnectionsTab.vue | 23 ++++++++++++++++++- packages/nc-gui/store/workspace.ts | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue b/packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue index 6980bbc198..e34dd72337 100644 --- a/packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue +++ b/packages/nc-gui/components/workspace/integrations/ConnectionsTab.vue @@ -22,6 +22,8 @@ const { $api, $e } = useNuxtApp() const { allCollaborators } = storeToRefs(useWorkspace()) +const { bases } = storeToRefs(useBases()) + const isDeleteIntegrationModalOpen = ref(false) const toBeDeletedIntegration = ref< | (IntegrationType & { @@ -139,7 +141,26 @@ const openDeleteIntegration = async (source: IntegrationType) => { } 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 () => { diff --git a/packages/nc-gui/store/workspace.ts b/packages/nc-gui/store/workspace.ts index 29d55b2656..6989e06d34 100644 --- a/packages/nc-gui/store/workspace.ts +++ b/packages/nc-gui/store/workspace.ts @@ -20,6 +20,8 @@ export const useWorkspace = defineStore('workspaceStore', () => { const collaborators = ref() + const allCollaborators = ref() + const router = useRouter() const route = router.currentRoute @@ -296,6 +298,7 @@ export const useWorkspace = defineStore('workspaceStore', () => { removeCollaborator, updateCollaborator, collaborators, + allCollaborators, isInvitingCollaborators, isCollaboratorsLoading, addToFavourite, @@ -323,7 +326,6 @@ export const useWorkspace = defineStore('workspaceStore', () => { auditLogsQuery, audits, auditPaginationData, - loadAudits, isIntegrationsPageOpened, navigateToIntegrations,