mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-08 15:58:45 +01:00
feat: move connections to folders from context menu, related to #773
This commit is contained in:
parent
65ec4c5da6
commit
9aef287a98
@ -15,6 +15,43 @@
|
|||||||
:size="18"
|
:size="18"
|
||||||
/> {{ t('connection.disconnect') }}</span>
|
/> {{ t('connection.disconnect') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="!contextConnection.isFolder" class="context-element">
|
||||||
|
<span class="d-flex">
|
||||||
|
<BaseIcon
|
||||||
|
class="text-light mt-1 mr-1"
|
||||||
|
icon-name="mdiFolderMove"
|
||||||
|
:size="18"
|
||||||
|
/> {{ t('general.moveTo') }}</span>
|
||||||
|
<BaseIcon
|
||||||
|
class="text-light ml-1"
|
||||||
|
icon-name="mdiChevronRight"
|
||||||
|
:size="18"
|
||||||
|
/>
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div class="context-element" @click.stop="moveToFolder(null)">
|
||||||
|
<span class="d-flex">
|
||||||
|
<BaseIcon
|
||||||
|
class="text-light mt-1 mr-1"
|
||||||
|
icon-name="mdiFolderPlus"
|
||||||
|
:size="18"
|
||||||
|
/> {{ t('application.newFolder') }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="folder in parsedFolders"
|
||||||
|
:key="folder.uid"
|
||||||
|
class="context-element"
|
||||||
|
@click.stop="moveToFolder(folder.uid)"
|
||||||
|
>
|
||||||
|
<span class="d-flex">
|
||||||
|
<BaseIcon
|
||||||
|
class="text-light mt-1 mr-1"
|
||||||
|
icon-name="mdiFolder"
|
||||||
|
:size="18"
|
||||||
|
:style="`color: ${folder.color}!important`"
|
||||||
|
/> {{ folder.name || t('general.folder') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="context-element" @click.stop="showAppearanceModal">
|
<div class="context-element" @click.stop="showAppearanceModal">
|
||||||
<span class="d-flex">
|
<span class="d-flex">
|
||||||
<BaseIcon
|
<BaseIcon
|
||||||
@ -79,6 +116,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
import { computed, Prop, ref } from 'vue';
|
import { computed, Prop, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
@ -98,9 +136,12 @@ const {
|
|||||||
getConnectionByUid,
|
getConnectionByUid,
|
||||||
getConnectionName,
|
getConnectionName,
|
||||||
addConnection,
|
addConnection,
|
||||||
deleteConnection
|
deleteConnection,
|
||||||
|
addFolder
|
||||||
} = connectionsStore;
|
} = connectionsStore;
|
||||||
|
|
||||||
|
const { getFolders: folders } = storeToRefs(connectionsStore);
|
||||||
|
|
||||||
const workspacesStore = useWorkspacesStore();
|
const workspacesStore = useWorkspacesStore();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -121,6 +162,7 @@ const isConnectionEdit = ref(false);
|
|||||||
|
|
||||||
const connectionName = computed(() => props.contextConnection.name || getConnectionName(props.contextConnection.uid) || t('general.folder', 1));
|
const connectionName = computed(() => props.contextConnection.name || getConnectionName(props.contextConnection.uid) || t('general.folder', 1));
|
||||||
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
|
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
|
||||||
|
const parsedFolders = computed(() => folders.value.filter(f => !f.connections.includes(props.contextConnection.uid)));
|
||||||
|
|
||||||
const confirmDeleteConnection = () => {
|
const confirmDeleteConnection = () => {
|
||||||
if (isConnected.value)
|
if (isConnected.value)
|
||||||
@ -129,6 +171,16 @@ const confirmDeleteConnection = () => {
|
|||||||
closeContext();
|
closeContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const moveToFolder = (folderUid?: string) => {
|
||||||
|
if (!folderUid) {
|
||||||
|
addFolder({
|
||||||
|
connections: [props.contextConnection.uid]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
closeContext();
|
||||||
|
};
|
||||||
|
|
||||||
const duplicateConnection = () => {
|
const duplicateConnection = () => {
|
||||||
let connectionCopy = getConnectionByUid(props.contextConnection.uid);
|
let connectionCopy = getConnectionByUid(props.contextConnection.uid);
|
||||||
connectionCopy = {
|
connectionCopy = {
|
||||||
|
@ -101,7 +101,13 @@ const props = defineProps({
|
|||||||
selectedField: Object
|
selectedField: Object
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['close-context', 'duplicate-selected', 'delete-selected', 'add-new-index', 'add-to-index']);
|
const emit = defineEmits([
|
||||||
|
'close-context',
|
||||||
|
'duplicate-selected',
|
||||||
|
'delete-selected',
|
||||||
|
'add-new-index',
|
||||||
|
'add-to-index'
|
||||||
|
]);
|
||||||
|
|
||||||
const hasPrimary = computed(() => props.indexes.some(index => index.type === 'PRIMARY'));
|
const hasPrimary = computed(() => props.indexes.some(index => index.type === 'PRIMARY'));
|
||||||
|
|
||||||
|
@ -150,7 +150,13 @@ const props = defineProps({
|
|||||||
mode: String
|
mode: String
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['add-new-index', 'add-to-index', 'rename-field', 'duplicate-field', 'remove-field']);
|
const emit = defineEmits([
|
||||||
|
'add-new-index',
|
||||||
|
'add-to-index',
|
||||||
|
'rename-field',
|
||||||
|
'duplicate-field',
|
||||||
|
'remove-field'
|
||||||
|
]);
|
||||||
|
|
||||||
const workspacesStore = useWorkspacesStore();
|
const workspacesStore = useWorkspacesStore();
|
||||||
const consoleStore = useConsoleStore();
|
const consoleStore = useConsoleStore();
|
||||||
|
@ -79,7 +79,8 @@ export const enUS = {
|
|||||||
search: 'Search',
|
search: 'Search',
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
archive: 'Archive', // verb
|
archive: 'Archive', // verb
|
||||||
undo: 'Undo'
|
undo: 'Undo',
|
||||||
|
moveTo: 'Move to'
|
||||||
},
|
},
|
||||||
connection: { // Database connection
|
connection: { // Database connection
|
||||||
connection: 'Connection',
|
connection: 'Connection',
|
||||||
@ -363,6 +364,7 @@ export const enUS = {
|
|||||||
editFolder: 'Edit folder',
|
editFolder: 'Edit folder',
|
||||||
folderName: 'Folder name',
|
folderName: 'Folder name',
|
||||||
deleteFolder: 'Delete folder',
|
deleteFolder: 'Delete folder',
|
||||||
|
newFolder: 'New folder',
|
||||||
editConnectionAppearance: 'Edit connection appearance',
|
editConnectionAppearance: 'Edit connection appearance',
|
||||||
defaultCopyType: 'Default copy type',
|
defaultCopyType: 'Default copy type',
|
||||||
showTableSize: 'Show table size in sidebar',
|
showTableSize: 'Show table size in sidebar',
|
||||||
|
@ -90,8 +90,12 @@ export const useConnectionsStore = defineStore('connections', {
|
|||||||
});
|
});
|
||||||
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
||||||
},
|
},
|
||||||
addFolder (params: {after: string; connections: [string, string]}) {
|
addFolder (params: {after?: string; connections: [string, string?]}) {
|
||||||
const index = this.connectionsOrder.findIndex((conn: SidebarElement) => conn.uid === params.after);
|
const index = params.after
|
||||||
|
? this.connectionsOrder.findIndex((conn: SidebarElement) => conn.uid === params.after)
|
||||||
|
: this.connectionsOrder.length;
|
||||||
|
|
||||||
|
this.removeFromFolders(params.connections);
|
||||||
|
|
||||||
this.connectionsOrder.splice(index, 0, {
|
this.connectionsOrder.splice(index, 0, {
|
||||||
isFolder: true,
|
isFolder: true,
|
||||||
@ -102,6 +106,15 @@ export const useConnectionsStore = defineStore('connections', {
|
|||||||
});
|
});
|
||||||
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
||||||
},
|
},
|
||||||
|
removeFromFolders (...connections: string[]) { // Removes connections from folders
|
||||||
|
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).map(el => {
|
||||||
|
if (el.isFolder)
|
||||||
|
el.connections = el.connections.filter(uid => !connections.includes(uid));
|
||||||
|
return el;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.clearEmptyFolders();
|
||||||
|
},
|
||||||
addToFolder (params: {folder: string; connection: string}) {
|
addToFolder (params: {folder: string; connection: string}) {
|
||||||
this.connectionsOrder = this.connectionsOrder.map((conn: SidebarElement) => {
|
this.connectionsOrder = this.connectionsOrder.map((conn: SidebarElement) => {
|
||||||
if (conn.uid === params.folder)
|
if (conn.uid === params.folder)
|
||||||
@ -113,11 +126,7 @@ export const useConnectionsStore = defineStore('connections', {
|
|||||||
this.clearEmptyFolders();
|
this.clearEmptyFolders();
|
||||||
},
|
},
|
||||||
deleteConnection (connection: SidebarElement | ConnectionParams) {
|
deleteConnection (connection: SidebarElement | ConnectionParams) {
|
||||||
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).map(el => { // Removes connection from folders
|
this.removeFromFolders(connection.uid);
|
||||||
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);
|
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.lastConnections = (this.lastConnections as SidebarElement[]).filter(el => el.uid !== connection.uid);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ export interface Workspace {
|
|||||||
uid: string;
|
uid: string;
|
||||||
client?: ClientCode;
|
client?: ClientCode;
|
||||||
database?: string;
|
database?: string;
|
||||||
connectionStatus: 'connected' | 'disconnected' | 'failed';
|
connectionStatus: 'connected' | 'connecting' | 'disconnected' | 'failed';
|
||||||
selectedTab: string;
|
selectedTab: string;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
tabs: WorkspaceTab[];
|
tabs: WorkspaceTab[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user