Skip to content

Commit

Permalink
fix: empty workspace deleting connections in some conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Sep 11, 2023
1 parent 785bc40 commit 0de5ef8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/renderer/components/SettingBarContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -78,10 +77,8 @@ const {
} = connectionsStore;
const workspacesStore = useWorkspacesStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const {
selectWorkspace,
removeConnected: disconnectWorkspace,
getWorkspace
} = workspacesStore;
Expand All @@ -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();
};
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/stores/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 => {
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/stores/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0de5ef8

Please sign in to comment.