Skip to content

Commit

Permalink
feat: move connections out of folder from context menu, related to #773
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Mar 24, 2024
1 parent 9aef287 commit 62e3115
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
33 changes: 30 additions & 3 deletions src/renderer/components/SettingBarContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/> {{ t('application.newFolder') }}</span>
</div>
<div
v-for="folder in parsedFolders"
v-for="folder in filteredFolders"
:key="folder.uid"
class="context-element"
@click.stop="moveToFolder(folder.uid)"
Expand All @@ -50,6 +50,19 @@
:style="`color: ${folder.color}!important`"
/> {{ folder.name || t('general.folder') }}</span>
</div>

<div
v-if="isInFolder"
class="context-element"
@click="outOfFolder"
>
<span class="d-flex">
<BaseIcon
class="text-light mt-1 mr-1"
icon-name="mdiFolderOff"
:size="18"
/> {{ t('application.outOfFolder') }}</span>
</div>
</div>
</div>
<div class="context-element" @click.stop="showAppearanceModal">
Expand Down Expand Up @@ -137,7 +150,9 @@ const {
getConnectionName,
addConnection,
deleteConnection,
addFolder
addFolder,
addToFolder,
removeFromFolders
} = connectionsStore;
const { getFolders: folders } = storeToRefs(connectionsStore);
Expand All @@ -162,7 +177,8 @@ const isConnectionEdit = ref(false);
const connectionName = computed(() => props.contextConnection.name || getConnectionName(props.contextConnection.uid) || t('general.folder', 1));
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
const parsedFolders = computed(() => folders.value.filter(f => !f.connections.includes(props.contextConnection.uid)));
const filteredFolders = computed(() => folders.value.filter(f => !f.connections.includes(props.contextConnection.uid)));
const isInFolder = computed(() => folders.value.some(f => f.connections.includes(props.contextConnection.uid)));
const confirmDeleteConnection = () => {
if (isConnected.value)
Expand All @@ -177,7 +193,18 @@ const moveToFolder = (folderUid?: string) => {
connections: [props.contextConnection.uid]
});
}
else {
addToFolder({
folder: folderUid,
connection: props.contextConnection.uid
});
}
closeContext();
};
const outOfFolder = () => {
removeFromFolders(props.contextConnection.uid);
closeContext();
};
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export const enUS = {
folderName: 'Folder name',
deleteFolder: 'Delete folder',
newFolder: 'New folder',
outOfFolder: 'Out of folder',
editConnectionAppearance: 'Edit connection appearance',
defaultCopyType: 'Default copy type',
showTableSize: 'Show table size in sidebar',
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/stores/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const useConnectionsStore = defineStore('connections', {
? this.connectionsOrder.findIndex((conn: SidebarElement) => conn.uid === params.after)
: this.connectionsOrder.length;

this.removeFromFolders(params.connections);
this.removeFromFolders(...params.connections);

this.connectionsOrder.splice(index, 0, {
isFolder: true,
Expand All @@ -116,6 +116,8 @@ export const useConnectionsStore = defineStore('connections', {
this.clearEmptyFolders();
},
addToFolder (params: {folder: string; connection: string}) {
this.removeFromFolders(params.connection);

this.connectionsOrder = this.connectionsOrder.map((conn: SidebarElement) => {
if (conn.uid === params.folder)
conn.connections.push(params.connection);
Expand Down

0 comments on commit 62e3115

Please sign in to comment.