From 36f466399d2a49cb98918587e3bba4e0c8f8da3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hornych?= Date: Sat, 28 Sep 2024 14:38:43 +0200 Subject: [PATCH] feat(#113): sort connections alphabetically with preconfigured connections showing first --- .../explorer/component/ConnectionEditor.vue | 12 +++++++++--- .../explorer/component/ConnectionExplorerPanel.vue | 12 +++++++++++- src/modules/connection/service/ConnectionService.ts | 4 ++-- src/modules/connection/store/connectionStore.ts | 10 ++++++---- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/modules/connection/explorer/component/ConnectionEditor.vue b/src/modules/connection/explorer/component/ConnectionEditor.vue index a4997ae2..dc8d2199 100644 --- a/src/modules/connection/explorer/component/ConnectionEditor.vue +++ b/src/modules/connection/explorer/component/ConnectionEditor.vue @@ -130,10 +130,10 @@ const observabilityUrlRules = [ async (value: any) => { const result = await testObservabilityApiConnection() if (result) { - modifiedConnection.value.gqlUrlTested = ApiTestResult.Success + modifiedConnection.value.observabilityUrlTested = ApiTestResult.Success return true } - modifiedConnection.value.gqlUrlTested = ApiTestResult.Failure + modifiedConnection.value.observabilityUrlTested = ApiTestResult.Failure return t('explorer.connection.editor.form.observability.validations.unreachable') } ] @@ -220,7 +220,13 @@ async function testGqlApiConnection(): Promise { } } async function testObservabilityApiConnection():Promise{ - return (await ky.get(modifiedConnection.value.observabilityUrl + '/metrics')).ok + // will be deleted anyway + return true + // try { + // return (await ky.get(modifiedConnection.value.observabilityUrl + '/metrics')).ok + // } catch (e) { + // return false + // } } function reset(): void { diff --git a/src/modules/connection/explorer/component/ConnectionExplorerPanel.vue b/src/modules/connection/explorer/component/ConnectionExplorerPanel.vue index f07fab9c..d128e931 100644 --- a/src/modules/connection/explorer/component/ConnectionExplorerPanel.vue +++ b/src/modules/connection/explorer/component/ConnectionExplorerPanel.vue @@ -6,6 +6,7 @@ import { Connection } from '@/modules/connection/model/Connection' import ConnectionItem from '@/modules/connection/explorer/component/ConnectionItem.vue' import { EvitaLabConfig, useEvitaLabConfig } from '@/modules/config/EvitaLabConfig' import ConnectionEditor from '@/modules/connection/explorer/component/ConnectionEditor.vue' +import Immutable from 'immutable' const evitaLabConfig: EvitaLabConfig = useEvitaLabConfig() const connectionService: ConnectionService = useConnectionService() @@ -20,7 +21,16 @@ const emit = defineEmits<{ }>() const addConnectionDialogOpen = ref(false) -const connections = computed(() => connectionService.getConnections()) +const connections = computed>(() => connectionService.getConnections() + .sort((a: Connection, b: Connection) => { + if (a.preconfigured && !b.preconfigured) { + return -1 + } + if (b.preconfigured && !a.preconfigured) { + return 1 + } + return a.name.localeCompare(b.name) + }))