diff --git a/src/renderer/components/SettingBarContext.vue b/src/renderer/components/SettingBarContext.vue
index bcecb942..8ddc98b2 100644
--- a/src/renderer/components/SettingBarContext.vue
+++ b/src/renderer/components/SettingBarContext.vue
@@ -3,6 +3,27 @@
:context-event="contextEvent"
@close-context="$emit('close-context')"
>
+
+ {{ $t('word.unpin') }}
+
+
+ {{ $t('word.pin') }}
+
+
+ {{ $t('word.disconnect') }}
+
{{ $t('word.duplicate') }}
@@ -39,15 +60,26 @@ import BaseContextMenu from '@/components/BaseContextMenu.vue';
import ConfirmModal from '@/components/BaseConfirmModal.vue';
import { ConnectionParams } from 'common/interfaces/antares';
+const connectionsStore = useConnectionsStore();
+
const {
getConnectionName,
addConnection,
- deleteConnection
-} = useConnectionsStore();
+ deleteConnection,
+ pinConnection,
+ unpinConnection
+} = connectionsStore;
+
+const { pinnedConnections } = storeToRefs(connectionsStore);
+
const workspacesStore = useWorkspacesStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
-const { selectWorkspace } = workspacesStore;
+const {
+ selectWorkspace,
+ removeConnected: disconnectWorkspace,
+ getWorkspace
+} = workspacesStore;
const props = defineProps({
contextEvent: MouseEvent,
@@ -59,6 +91,8 @@ 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 confirmDeleteConnection = () => {
if (selectedWorkspace.value === props.contextConnection.uid)
@@ -88,6 +122,21 @@ const hideConfirmModal = () => {
closeContext();
};
+const pin = () => {
+ pinConnection(props.contextConnection.uid);
+ closeContext();
+};
+
+const unpin = () => {
+ unpinConnection(props.contextConnection.uid);
+ closeContext();
+};
+
+const disconnect = () => {
+ disconnectWorkspace(props.contextConnection.uid);
+ closeContext();
+};
+
const closeContext = () => {
emit('close-context');
};
diff --git a/src/renderer/components/TheSettingBar.vue b/src/renderer/components/TheSettingBar.vue
index fd4533a3..6f66b928 100644
--- a/src/renderer/components/TheSettingBar.vue
+++ b/src/renderer/components/TheSettingBar.vue
@@ -70,7 +70,7 @@ const connectionsStore = useConnectionsStore();
const workspacesStore = useWorkspacesStore();
const { updateStatus } = storeToRefs(applicationStore);
-const { connections: getConnections } = storeToRefs(connectionsStore);
+const { connections: storedConnections, pinnedConnections, lastConnections } = storeToRefs(connectionsStore);
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const { showSettingModal, showScratchpad } = applicationStore;
@@ -85,13 +85,16 @@ const contextConnection: Ref = ref(null);
const connections = computed({
get () {
- return getConnections.value;
+ return storedConnections.value;
},
set (value: ConnectionParams[]) {
updateConnections(value);
}
});
+const pinnedConnectionsArr = computed(() => storedConnections.value.filter(c => pinnedConnections.value.has(c.uid)));
+const unpinnedConnectionsArr = computed(() => storedConnections.value.filter(c => !pinnedConnections.value.has(c.uid)));
+
const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value));
const contextMenu = (event: MouseEvent, connection: ConnectionParams) => {
diff --git a/src/renderer/i18n/en-US.ts b/src/renderer/i18n/en-US.ts
index 2fbc93f4..77b93013 100644
--- a/src/renderer/i18n/en-US.ts
+++ b/src/renderer/i18n/en-US.ts
@@ -139,7 +139,9 @@ module.exports = {
commit: 'Commit',
rollback: 'Rollback',
connectionString: 'Connection string',
- contributors: 'Contributors'
+ contributors: 'Contributors',
+ pin: 'Pin',
+ unpin: 'Unpin'
},
message: {
appWelcome: 'Welcome to Antares SQL Client!',
diff --git a/src/renderer/stores/connections.ts b/src/renderer/stores/connections.ts
index d948b02c..1dec580c 100644
--- a/src/renderer/stores/connections.ts
+++ b/src/renderer/stores/connections.ts
@@ -17,7 +17,9 @@ const persistentStore = new Store({
export const useConnectionsStore = defineStore('connections', {
state: () => ({
- connections: persistentStore.get('connections', []) as ConnectionParams[]
+ connections: persistentStore.get('connections', []) as ConnectionParams[],
+ pinnedConnections: new Set([...persistentStore.get('pinnedConnections', []) as string[]]) as Set,
+ lastConnections: persistentStore.get('lastConnections', {}) as {[k: string]: number}
}),
getters: {
getConnectionName: state => (uid: string) => {
@@ -63,6 +65,18 @@ export const useConnectionsStore = defineStore('connections', {
updateConnections (connections: ConnectionParams[]) {
this.connections = connections;
persistentStore.set('connections', this.connections);
+ },
+ pinConnection (uid: string) {
+ (this.pinnedConnections as Set).add(uid);
+ persistentStore.set('pinnedConnections', [...this.pinnedConnections]);
+ },
+ unpinConnection (uid: string) {
+ (this.pinnedConnections as Set).delete(uid);
+ persistentStore.set('pinnedConnections', [...this.pinnedConnections]);
+ },
+ updateLastConnection (uid: string) {
+ this.lastConnections[uid] = new Date().getTime();
+ persistentStore.set('lastConnections', this.lastConnections);
}
}
});
diff --git a/src/renderer/stores/workspaces.ts b/src/renderer/stores/workspaces.ts
index 6094fd47..ee6e50d0 100644
--- a/src/renderer/stores/workspaces.ts
+++ b/src/renderer/stores/workspaces.ts
@@ -170,6 +170,9 @@ export const useWorkspacesStore = defineStore('workspaces', {
let dataTypes: TypesGroup[] = [];
let indexTypes: string[] = [];
let clientCustomizations: Customizations;
+ const { updateLastConnection } = connectionsStore;
+
+ updateLastConnection(connection.uid);
switch (connection.client) {
case 'mysql':