Merge pull request #8709 from Clem-Fern/feat#8680

This commit is contained in:
Eugene 2023-07-18 17:12:14 +02:00 committed by GitHub
commit 8b89db41d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 8 deletions

View file

@ -76,10 +76,11 @@ export class SelectorModalComponent<T> {
{ sort: true }, { sort: true },
).search(f) ).search(f)
const freeOption = this.options.find(x => x.freeInputPattern) this.options.filter(x => x.freeInputPattern).forEach(freeOption => {
if (freeOption && !this.filteredOptions.includes(freeOption)) { if (!this.filteredOptions.includes(freeOption)) {
this.filteredOptions.push(freeOption) this.filteredOptions.push(freeOption)
} }
})
} }
this.selectedIndex = Math.max(0, this.selectedIndex) this.selectedIndex = Math.max(0, this.selectedIndex)
this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex) this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex)

View file

@ -54,3 +54,4 @@ hacks:
disableVibrancyWhileDragging: false disableVibrancyWhileDragging: false
enableFluentBackground: false enableFluentBackground: false
language: null language: null
defaultQuickConnectProvider: "ssh"

View file

@ -219,6 +219,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
name: this.translate.instant('Quick connect'), name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'), freeInputPattern: this.translate.instant('Connect to "%s"...'),
icon: 'fas fa-arrow-right', icon: 'fas fa-arrow-right',
description: `(${provider.name.toUpperCase()})`,
callback: query => { callback: query => {
const p = provider.quickConnect(query) const p = provider.quickConnect(query)
if (p) { if (p) {

View file

@ -177,17 +177,20 @@ export class ProfilesService {
}) })
} catch { } } catch { }
if (this.getProviders().some(x => x.supportsQuickConnect)) { this.getProviders().filter(x => x.supportsQuickConnect).forEach(provider => {
options.push({ options.push({
name: this.translate.instant('Quick connect'), name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'), freeInputPattern: this.translate.instant('Connect to "%s"...'),
description: `(${provider.name.toUpperCase()})`,
icon: 'fas fa-arrow-right', icon: 'fas fa-arrow-right',
weight: provider.id !== this.config.store.defaultQuickConnectProvider ? 1 : 0,
callback: query => { callback: query => {
const profile = this.quickConnect(query) const profile = provider.quickConnect(query)
resolve(profile) resolve(profile)
}, },
}) })
} })
await this.selector.show(this.translate.instant('Select profile or enter an address'), options) await this.selector.show(this.translate.instant('Select profile or enter an address'), options)
} catch (err) { } catch (err) {
reject(err) reject(err)

View file

@ -149,6 +149,20 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
option(ngValue='wt', translation) Windows Terminal option(ngValue='wt', translation) Windows Terminal
option(ngValue='cygwin', translation) Cygwin option(ngValue='cygwin', translation) Cygwin
.form-line
.header
.title(translate) Default "Connect to" type
.description(translate) Default connection type used by quick connect feature (ex. SSH, Telnet)
select.form-control(
[(ngModel)]='config.store.defaultQuickConnectProvider',
(ngModelChange)='config.save()',
)
option(
*ngFor='let provider of getQuickConnectProviders()',
[ngValue]='provider.id'
) {{provider.name}}
.form-line.content-box .form-line.content-box
.header .header
.title(translate) Default profile settings .title(translate) Default profile settings

View file

@ -312,4 +312,8 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
isProfileBlacklisted (profile: PartialProfile<Profile>): boolean { isProfileBlacklisted (profile: PartialProfile<Profile>): boolean {
return profile.id && this.config.store.profileBlacklist.includes(profile.id) return profile.id && this.config.store.profileBlacklist.includes(profile.id)
} }
getQuickConnectProviders (): ProfileProvider<Profile>[] {
return this.profileProviders.filter(x => x.supportsQuickConnect)
}
} }

View file

@ -8,7 +8,7 @@ import { TelnetProfile } from './session'
export class TelnetProfilesService extends ProfileProvider<TelnetProfile> { export class TelnetProfilesService extends ProfileProvider<TelnetProfile> {
id = 'telnet' id = 'telnet'
name = 'Telnet' name = 'Telnet'
supportsQuickConnect = false supportsQuickConnect = true
settingsComponent = TelnetProfileSettingsComponent settingsComponent = TelnetProfileSettingsComponent
configDefaults = { configDefaults = {
options: { options: {