Browse Source

sort hosts in the jump hosts list

Eugene Pankov 3 years ago
parent
commit
9bc6831f40

+ 1 - 0
package.json

@@ -46,6 +46,7 @@
     "graceful-fs": "^4.2.9",
     "html-loader": "3.1.0",
     "json-loader": "^0.5.7",
+    "thenby": "^1.3.4",
     "lru-cache": "^6.0.0",
     "macos-release": "^3.0.1",
     "ngx-sortablejs": "^11.1.0",

+ 0 - 1
tabby-core/package.json

@@ -27,7 +27,6 @@
     "ngx-perfect-scrollbar": "^10.1.0",
     "ngx-translate-messageformat-compiler": "^4.11.0",
     "readable-stream": "3.6.0",
-    "thenby": "^1.3.4",
     "uuid": "^8.0.0"
   },
   "peerDependencies": {

+ 0 - 5
tabby-core/yarn.lock

@@ -161,11 +161,6 @@ string_decoder@^1.1.1:
   dependencies:
     safe-buffer "~5.2.0"
 
-thenby@^1.3.4:
-  version "1.3.4"
-  resolved "https://registry.yarnpkg.com/thenby/-/thenby-1.3.4.tgz#81581f6e1bb324c6dedeae9bfc28e59b1a2201cc"
-  integrity sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ==
-
 tslib@^1.10.0:
   version "1.14.1"
   resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"

+ 1 - 1
tabby-ssh/src/components/sshProfileSettings.component.pug

@@ -61,7 +61,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
                 label(translate) Jump host
                 select.form-control([(ngModel)]='profile.options.jumpHost')
                     option([ngValue]='null', translate) Select
-                    option([ngValue]='x.id', *ngFor='let x of jumpHosts') {{x.name}}
+                    option([ngValue]='x.id', *ngFor='let x of jumpHosts') {{getJumpHostLabel(x)}}
 
 
             .d-flex.w-100(*ngIf='connectionMode === "socksProxy"')

+ 7 - 0
tabby-ssh/src/components/sshProfileSettings.component.ts

@@ -1,6 +1,7 @@
 /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
 import { Component, ViewChild } from '@angular/core'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { firstBy } from 'thenby'
 
 import { ConfigService, FileProvidersService, Platform, HostAppService, PromptModalComponent, PartialProfile } from 'tabby-core'
 import { LoginScriptsSettingsComponent } from 'tabby-terminal'
@@ -34,6 +35,8 @@ export class SSHProfileSettingsComponent {
 
     async ngOnInit () {
         this.jumpHosts = this.config.store.profiles.filter(x => x.type === 'ssh' && x !== this.profile)
+        this.jumpHosts.sort(firstBy(x => this.getJumpHostLabel(x)))
+
         for (const k of Object.values(SSHAlgorithmType)) {
             this.algorithms[k] = {}
             for (const alg of this.profile.options.algorithms?.[k] ?? []) {
@@ -63,6 +66,10 @@ export class SSHProfileSettingsComponent {
         }
     }
 
+    getJumpHostLabel (p: PartialProfile<SSHProfile>) {
+        return p.group ? `${p.group} / ${p.name}` : p.name
+    }
+
     async setPassword () {
         const modal = this.ngbModal.open(PromptModalComponent)
         modal.componentInstance.prompt = `Password for ${this.profile.options.user}@${this.profile.options.host}`

+ 5 - 0
yarn.lock

@@ -8143,6 +8143,11 @@ text-table@^0.2.0, text-table@~0.2.0:
   resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz"
   integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
 
+thenby@^1.3.4:
+  version "1.3.4"
+  resolved "https://registry.yarnpkg.com/thenby/-/thenby-1.3.4.tgz#81581f6e1bb324c6dedeae9bfc28e59b1a2201cc"
+  integrity sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ==
+
 [email protected]:
   version "0.0.2"
   resolved "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz"