fix: empty workspace deleting connections in some conditions

This commit is contained in:
Fabio Di Stasio 2023-09-11 18:02:19 +02:00
parent 785bc40ad0
commit 0de5ef8a98
3 changed files with 10 additions and 5 deletions

View File

@ -55,7 +55,6 @@
<script setup lang="ts">
import { uidGen } from 'common/libs/uidGen';
import { storeToRefs } from 'pinia';
import { computed, Prop, ref } from 'vue';
import { useI18n } from 'vue-i18n';
@ -78,10 +77,8 @@ const {
} = connectionsStore;
const workspacesStore = useWorkspacesStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const {
selectWorkspace,
removeConnected: disconnectWorkspace,
getWorkspace
} = workspacesStore;
@ -101,8 +98,8 @@ const connectionName = computed(() => props.contextConnection.name || getConnect
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
const confirmDeleteConnection = () => {
if (selectedWorkspace.value === props.contextConnection.uid)
selectWorkspace(null);
if (isConnected.value)
disconnectWorkspace(props.contextConnection.uid);
deleteConnection(props.contextConnection);
closeContext();
};

View File

@ -3,6 +3,8 @@ import { uidGen } from 'common/libs/uidGen';
import * as crypto from 'crypto';
import * as Store from 'electron-store';
import { defineStore } from 'pinia';
import { useWorkspacesStore } from '@/stores/workspaces';
const key = localStorage.getItem('key');
export interface SidebarElement {
@ -105,10 +107,12 @@ export const useConnectionsStore = defineStore('connections', {
return el;
});
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).filter(el => el.uid !== connection.uid);
this.lastConnections = (this.lastConnections as SidebarElement[]).filter(el => el.uid !== connection.uid);
this.connections = (this.connections as SidebarElement[]).filter(el => el.uid !== connection.uid);
persistentStore.set('connections', this.connections);
this.clearEmptyFolders();
useWorkspacesStore().removeWorkspace(connection.uid);
},
editConnection (connection: ConnectionParams) {
const editedConnections = (this.connections as ConnectionParams[]).map(conn => {

View File

@ -424,6 +424,10 @@ export const useWorkspacesStore = defineStore('workspaces', {
this.workspaces.push(workspace);
},
removeWorkspace (uid: string) {
this.workspaces = this.workspaces.filter((w: Workspace) => w.uid !== uid);
if (uid === this.selectedWorkspace) this.selectedWorkspace = 'NEW';
},
changeBreadcrumbs (payload: Breadcrumb) {
const breadcrumbsObj: Breadcrumb = {
schema: null,