1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

refactor: changes to implement folders

This commit is contained in:
2022-11-21 20:19:02 +01:00
parent 83f9b12be0
commit 5a028a4ea2
6 changed files with 279 additions and 225 deletions

View File

@ -3,20 +3,6 @@
:context-event="contextEvent"
@close-context="$emit('close-context')"
>
<div
v-if="isPinned"
class="context-element"
@click="unpin"
>
<span class="d-flex"><i class="mdi mdi-18px mdi-pin-off text-light pr-1" /> {{ t('word.unpin') }}</span>
</div>
<div
v-else
class="context-element"
@click="pin"
>
<span class="d-flex"><i class="mdi mdi-18px mdi-pin mdi-rotate-45 text-light pr-1" /> {{ t('word.pin') }}</span>
</div>
<div
v-if="isConnected"
class="context-element"
@ -24,7 +10,11 @@
>
<span class="d-flex"><i class="mdi mdi-18px mdi-power text-light pr-1" /> {{ t('word.disconnect') }}</span>
</div>
<div class="context-element" @click="duplicateConnection">
<div
v-if="!contextConnection.isFolder"
class="context-element"
@click="duplicateConnection"
>
<span class="d-flex"><i class="mdi mdi-18px mdi-content-duplicate text-light pr-1" /> {{ t('word.duplicate') }}</span>
</div>
<div class="context-element" @click="showConfirmModal">
@ -38,7 +28,7 @@
>
<template #header>
<div class="d-flex">
<i class="mdi mdi-24px mdi-server-remove mr-1" /> {{ t('message.deleteConnection') }}
<i class="mdi mdi-24px mdi-server-remove mr-1" /> {{ t(contextConnection.isFolder ? 'message.deleteFolder' : 'message.deleteConnection') }}
</div>
</template>
<template #body>
@ -55,26 +45,22 @@ import { computed, Prop, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { uidGen } from 'common/libs/uidGen';
import { useI18n } from 'vue-i18n';
import { useConnectionsStore } from '@/stores/connections';
import { SidebarElement, useConnectionsStore } from '@/stores/connections';
import { useWorkspacesStore } from '@/stores/workspaces';
import BaseContextMenu from '@/components/BaseContextMenu.vue';
import ConfirmModal from '@/components/BaseConfirmModal.vue';
import { ConnectionParams } from 'common/interfaces/antares';
const { t } = useI18n();
const connectionsStore = useConnectionsStore();
const {
getConnectionByUid,
getConnectionName,
addConnection,
deleteConnection,
pinConnection,
unpinConnection
deleteConnection
} = connectionsStore;
const { pinnedConnections } = storeToRefs(connectionsStore);
const workspacesStore = useWorkspacesStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
@ -86,16 +72,15 @@ const {
const props = defineProps({
contextEvent: MouseEvent,
contextConnection: Object as Prop<ConnectionParams>
contextConnection: Object as Prop<SidebarElement>
});
const emit = defineEmits(['close-context']);
const isConfirmModal = ref(false);
const connectionName = computed(() => getConnectionName(props.contextConnection.uid));
const isConnected = computed(() => getWorkspace(props.contextConnection.uid).connectionStatus === 'connected');
const isPinned = computed(() => pinnedConnections.value.has(props.contextConnection.uid));
const connectionName = computed(() => props.contextConnection.name || getConnectionName(props.contextConnection.uid) || t('word.folder', 1));
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
const confirmDeleteConnection = () => {
if (selectedWorkspace.value === props.contextConnection.uid)
@ -105,7 +90,7 @@ const confirmDeleteConnection = () => {
};
const duplicateConnection = () => {
let connectionCopy = Object.assign({}, props.contextConnection);
let connectionCopy = getConnectionByUid(props.contextConnection.uid);
connectionCopy = {
...connectionCopy,
uid: uidGen('C'),
@ -125,16 +110,6 @@ const hideConfirmModal = () => {
closeContext();
};
const pin = () => {
pinConnection(props.contextConnection.uid);
closeContext();
};
const unpin = () => {
unpinConnection(props.contextConnection.uid);
closeContext();
};
const disconnect = () => {
disconnectWorkspace(props.contextConnection.uid);
closeContext();