Skip to content

Commit

Permalink
fix: deletion of connections inside folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Nov 28, 2022
1 parent 4fe9dfc commit b06bafe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
28 changes: 14 additions & 14 deletions src/renderer/components/ModalConnectionAppearence.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const icons = [
{ name: 'account-group', code: 'mdi-account-group-outline' },
{ name: 'cloud', code: 'mdi-cloud-outline' },
{ name: 'key-chain', code: 'mdi-key-chain-variant' },
{ name: 'filmstrip', code: 'mdi-filmstrip' },
{ name: 'lightning-bolt', code: 'mdi-lightning-bolt' },
{ name: 'map-marker', code: 'mdi-map-marker-radius-outline' },
{ name: 'api', code: 'mdi-api' },
{ name: 'chart-line', code: 'mdi-chart-line' },
Expand All @@ -99,20 +99,22 @@ const icons = [
{ name: 'cart', code: 'mdi-cart-variant' },
{ name: 'bank', code: 'mdi-bank-outline' },
{ name: 'receipt', code: 'mdi-receipt-text-outline' },
{ name: 'heart', code: 'mdi-heart-outline' },
{ name: 'raspberry-pi', code: 'mdi-raspberry-pi' },
{ name: 'book', code: 'mdi-book-outline' },
{ name: 'anchor', code: 'mdi-anchor' },
{ name: 'leaf', code: 'mdi-leaf' },
{ name: 'music', code: 'mdi-music' },
{ name: 'camera', code: 'mdi-camera-outline' },
{ name: 'cash-register', code: 'mdi-cash-register' },
{ name: 'food', code: 'mdi-food-outline' },
{ name: 'web', code: 'mdi-web' },
{ name: 'multimedia', code: 'mdi-multimedia' },
{ name: 'qr-code', code: 'mdi-qrcode' },
{ name: 'flask', code: 'mdi-flask-outline' },
{ name: 'memory', code: 'mdi-memory' },
{ name: 'cube', code: 'mdi-cube-outline' },
{ name: 'weather', code: 'mdi-weather-partly-snowy-rainy' },
{ name: 'controller', code: 'mdi-controller' },
{ name: 'home-group', code: 'mdi-home-group' },
// Vehicles
{ name: 'truck', code: 'mdi-truck-outline' },
{ name: 'car', code: 'mdi-car' },
{ name: 'motorbike', code: 'mdi-motorbike' },
{ name: 'motorbike', code: 'mdi-atv' },
{ name: 'train', code: 'mdi-train' },
{ name: 'airplane', code: 'mdi-airplane' },
{ name: 'ferry', code: 'mdi-ferry' },
Expand All @@ -123,11 +125,9 @@ const icons = [
{ name: 'aws', code: 'mdi-aws' },
{ name: 'google-cloud', code: 'mdi-google-cloud' },
{ name: 'microsoft-azure', code: 'mdi-microsoft-azure' },
{ name: 'debian', code: 'mdi-debian' },
{ name: 'ubuntu', code: 'mdi-ubuntu' },
{ name: 'arch', code: 'mdi-arch' },
{ name: 'redhat', code: 'mdi-redhat' },
{ name: 'fedora', code: 'mdi-fedora' },
{ name: 'linux', code: 'mdi-linux' },
{ name: 'microsoft-windows', code: 'mdi-microsoft-windows' },
{ name: 'apple', code: 'mdi-apple' },
{ name: 'android', code: 'mdi-android' }
];
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ModalFolderAppearence.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const colorPalette = [
{ name: 'emerald', hex: '#038835' },
{ name: 'mint', hex: '#48CFAD' },
{ name: 'aqua', hex: '#4FC1E9' },
{ name: 'roya-lblue', hex: '#4169E1' },
{ name: 'royal-lblue', hex: '#4169E1' },
{ name: 'blue-jeans', hex: '#5D9CEC' },
{ name: 'stone', hex: '#59788E' },
{ name: 'lavander', hex: '#AC92EC' },
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/SettingBarConnections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
<SettingBarConnectionsFolder
v-else-if="element.isFolder"
:key="element.uid"
:key="`${element.uid}-${element.connections.length}`"
:folder="element"
:covered-element="coveredElement"
:dragged-element="draggedElement"
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/SettingBarConnectionsFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
>
<i
class="folder-element-icon dbi"
:class="[getConnectionOrderByUid(element).icon ? `mdi ${getConnectionOrderByUid(element).icon}`: `dbi-${getConnectionOrderByUid(element).client}`, getStatusBadge(element)]"
:class="[getConnectionOrderByUid(element)?.icon ? `mdi ${getConnectionOrderByUid(element).icon}`: `dbi-${getConnectionOrderByUid(element)?.client}`, getStatusBadge(element)]"
/>
<small v-if="isOpen" class="folder-element-name">{{ getConnectionOrderByUid(element).name || getConnectionName(element) }}</small>
<small v-if="isOpen" class="folder-element-name">{{ getConnectionOrderByUid(element)?.name || getConnectionName(element) }}</small>
</div>
</template>
</Draggable>
Expand Down
10 changes: 4 additions & 6 deletions src/renderer/stores/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,12 @@ export const useConnectionsStore = defineStore('connections', {
persistentStore.set('connectionsOrder', this.connectionsOrder);
},
deleteConnection (connection: SidebarElement | ConnectionParams) {
this.connections = (this.connections as SidebarElement[]).filter(el => el.uid !== connection.uid);
persistentStore.set('connections', this.connections);

this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).filter(el => el.uid !== connection.uid);
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).map(el => { // Removes connection from folders
if (el.isFolder && el.connections.includes(connection.uid))
el.connections = el.connections.filter(uid => uid !== connection.uid);

return el;
});
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).filter(el => el.uid !== connection.uid);

// Clear empty folders
const emptyFolders = (this.connectionsOrder as SidebarElement[]).reduce<string[]>((acc, curr) => {
Expand All @@ -130,8 +126,10 @@ export const useConnectionsStore = defineStore('connections', {
}, []);

this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).filter(el => !emptyFolders.includes(el.uid));

persistentStore.set('connectionsOrder', this.connectionsOrder);

this.connections = (this.connections as SidebarElement[]).filter(el => el.uid !== connection.uid);
persistentStore.set('connections', this.connections);
},
editConnection (connection: ConnectionParams) {
const editedConnections = (this.connections as ConnectionParams[]).map(conn => {
Expand Down

0 comments on commit b06bafe

Please sign in to comment.