Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat#8680: add "connect to" option in profile selector for each provider supporting quick connect #8709

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tabby-core/src/components/selectorModal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ export class SelectorModalComponent<T> {
{ sort: true },
).search(f)

const freeOption = this.options.find(x => x.freeInputPattern)
if (freeOption && !this.filteredOptions.includes(freeOption)) {
this.filteredOptions.push(freeOption)
}
this.options.filter(x => x.freeInputPattern).forEach(freeOption => {
if (!this.filteredOptions.includes(freeOption)) {
this.filteredOptions.push(freeOption)
}
})
}
this.selectedIndex = Math.max(0, this.selectedIndex)
this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex)
Expand Down
1 change: 1 addition & 0 deletions tabby-core/src/configDefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ hacks:
disableVibrancyWhileDragging: false
enableFluentBackground: false
language: null
defaultQuickConnectProvider: "ssh"
1 change: 1 addition & 0 deletions tabby-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'),
icon: 'fas fa-arrow-right',
description: `(${provider.name.toUpperCase()})`,
callback: query => {
const p = provider.quickConnect(query)
if (p) {
Expand Down
9 changes: 6 additions & 3 deletions tabby-core/src/services/profiles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,20 @@ export class ProfilesService {
})
} catch { }

if (this.getProviders().some(x => x.supportsQuickConnect)) {
this.getProviders().filter(x => x.supportsQuickConnect).forEach(provider => {
options.push({
name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'),
description: `(${provider.name.toUpperCase()})`,
icon: 'fas fa-arrow-right',
weight: provider.id !== this.config.store.defaultQuickConnectProvider ? 1 : 0,
callback: query => {
const profile = this.quickConnect(query)
const profile = provider.quickConnect(query)
resolve(profile)
},
})
}
})

await this.selector.show(this.translate.instant('Select profile or enter an address'), options)
} catch (err) {
reject(err)
Expand Down
14 changes: 14 additions & 0 deletions tabby-settings/src/components/profilesSettingsTab.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
option(ngValue='wt', translation) Windows Terminal
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
.header
.title(translate) Default profile settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,8 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
isProfileBlacklisted (profile: PartialProfile<Profile>): boolean {
return profile.id && this.config.store.profileBlacklist.includes(profile.id)
}

getQuickConnectProviders (): ProfileProvider<Profile>[] {
return this.profileProviders.filter(x => x.supportsQuickConnect)
}
}
2 changes: 1 addition & 1 deletion tabby-telnet/src/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TelnetProfile } from './session'
export class TelnetProfilesService extends ProfileProvider<TelnetProfile> {
id = 'telnet'
name = 'Telnet'
supportsQuickConnect = false
supportsQuickConnect = true
settingsComponent = TelnetProfileSettingsComponent
configDefaults = {
options: {
Expand Down