Skip to content

Commit

Permalink
ref ef6b8a4
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Aug 18, 2023
1 parent a9c63b5 commit 7687972
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tabby-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { BootstrapData, PluginInfo, BOOTSTRAP_DATA } from './mainProcess'
export { HostWindowService } from './hostWindow'
export { HostAppService, Platform } from './hostApp'
export { FileProvider } from './fileProvider'
export { ProfileProvider, ConnectableProfileProvider, Profile, ConnectableProfile, PartialProfile, ProfileSettingsComponent, ProfileGroup, PartialProfileGroup } from './profileProvider'
export { ProfileProvider, ConnectableProfileProvider, QuickConnectProfileProvider, Profile, ConnectableProfile, PartialProfile, ProfileSettingsComponent, ProfileGroup, PartialProfileGroup } from './profileProvider'
export { PromptModalComponent } from '../components/promptModal.component'
export * from './commands'

Expand Down
12 changes: 5 additions & 7 deletions tabby-core/src/api/profileProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ export abstract class ProfileProvider<P extends Profile> {
deleteProfile (profile: P): void { }
}

export abstract class ConnectableProfileProvider<P extends ConnectableProfile> extends ProfileProvider<P> {
export abstract class ConnectableProfileProvider<P extends ConnectableProfile> extends ProfileProvider<P> {}

quickConnect (query: string): PartialProfile<P>|null {
return null
}
export abstract class QuickConnectProfileProvider<P extends ConnectableProfile> extends ConnectableProfileProvider<P> {

intoQuickConnectString (profile: P): string|null {
return null
}
abstract quickConnect (query: string): PartialProfile<P>|null

abstract intoQuickConnectString (profile: P): string|null

}
4 changes: 2 additions & 2 deletions tabby-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { FastHtmlBindDirective } from './directives/fastHtmlBind.directive'
import { DropZoneDirective } from './directives/dropZone.directive'
import { CdkAutoDropGroup } from './directives/cdkAutoDropGroup.directive'

import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, ConnectableProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'
import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, QuickConnectProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'

import { AppService } from './services/app.service'
import { ConfigService } from './services/config.service'
Expand Down Expand Up @@ -214,7 +214,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
callback: () => this.profilesService.openNewTabForProfile(p),
}))

if (provider instanceof ConnectableProfileProvider) {
if (provider instanceof QuickConnectProfileProvider) {
options.push({
name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'),
Expand Down
8 changes: 4 additions & 4 deletions tabby-core/src/services/profiles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { NewTabParameters } from './tabs.service'
import { BaseTabComponent } from '../components/baseTab.component'
import { ConnectableProfileProvider, PartialProfile, PartialProfileGroup, Profile, ProfileGroup, ProfileProvider } from '../api/profileProvider'
import { QuickConnectProfileProvider, PartialProfile, PartialProfileGroup, Profile, ProfileGroup, ProfileProvider } from '../api/profileProvider'
import { SelectorOption } from '../api/selector'
import { AppService } from './app.service'
import { configMerge, ConfigProxy, ConfigService } from './config.service'
Expand Down Expand Up @@ -230,7 +230,7 @@ export class ProfilesService {
selectorOptionForProfile <P extends Profile, T> (profile: PartialProfile<P>): SelectorOption<T> {
const fullProfile = this.getConfigProxyForProfile(profile)
const provider = this.providerForProfile(fullProfile)
const freeInputEquivalent = provider instanceof ConnectableProfileProvider ? provider.intoQuickConnectString(fullProfile) ?? undefined : undefined
const freeInputEquivalent = provider instanceof QuickConnectProfileProvider ? provider.intoQuickConnectString(fullProfile) ?? undefined : undefined
return {
...profile,
group: this.resolveProfileGroupName(profile.group ?? ''),
Expand Down Expand Up @@ -308,7 +308,7 @@ export class ProfilesService {
} catch { }

this.getProviders().forEach(provider => {
if (provider instanceof ConnectableProfileProvider) {
if (provider instanceof QuickConnectProfileProvider) {
options.push({
name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'),
Expand Down Expand Up @@ -338,7 +338,7 @@ export class ProfilesService {

async quickConnect (query: string): Promise<PartialProfile<Profile>|null> {
for (const provider of this.getProviders()) {
if (provider instanceof ConnectableProfileProvider) {
if (provider instanceof QuickConnectProfileProvider) {
const profile = provider.quickConnect(query)
if (profile) {
return profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
import deepClone from 'clone-deep'
import { Component, Inject } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService, Platform, ProfileGroup, PartialProfileGroup, ConnectableProfileProvider } from 'tabby-core'
import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile, ProfileProvider, TranslateService, Platform, ProfileGroup, PartialProfileGroup, QuickConnectProfileProvider } from 'tabby-core'
import { EditProfileModalComponent } from './editProfileModal.component'
import { EditProfileGroupModalComponent, EditProfileGroupModalComponentResult } from './editProfileGroupModal.component'

Expand Down Expand Up @@ -345,7 +345,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
}

getQuickConnectProviders (): ProfileProvider<Profile>[] {
return this.profileProviders.filter(x => x instanceof ConnectableProfileProvider)
return this.profileProviders.filter(x => x instanceof QuickConnectProfileProvider)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tabby-ssh/src/profiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, InjectFlags, Injector } from '@angular/core'
import { NewTabParameters, PartialProfile, TranslateService, ConnectableProfileProvider } from 'tabby-core'
import { NewTabParameters, PartialProfile, TranslateService, QuickConnectProfileProvider } from 'tabby-core'
import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component'
import { SSHTabComponent } from './components/sshTab.component'
Expand All @@ -8,7 +8,7 @@ import { ALGORITHM_BLACKLIST, SSHAlgorithmType, SSHProfile } from './api'
import { SSHProfileImporter } from './api/importer'

@Injectable({ providedIn: 'root' })
export class SSHProfilesService extends ConnectableProfileProvider<SSHProfile> {
export class SSHProfilesService extends QuickConnectProfileProvider<SSHProfile> {
id = 'ssh'
name = 'SSH'
settingsComponent = SSHProfileSettingsComponent
Expand Down
12 changes: 10 additions & 2 deletions tabby-telnet/src/profiles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@angular/core'
import { NewTabParameters, PartialProfile, TranslateService, ConnectableProfileProvider } from 'tabby-core'
import { NewTabParameters, PartialProfile, TranslateService, QuickConnectProfileProvider } from 'tabby-core'
import { TelnetProfileSettingsComponent } from './components/telnetProfileSettings.component'
import { TelnetTabComponent } from './components/telnetTab.component'
import { TelnetProfile } from './session'

@Injectable({ providedIn: 'root' })
export class TelnetProfilesService extends ConnectableProfileProvider<TelnetProfile> {
export class TelnetProfilesService extends QuickConnectProfileProvider<TelnetProfile> {
id = 'telnet'
name = 'Telnet'
supportsQuickConnect = true
Expand Down Expand Up @@ -96,4 +96,12 @@ export class TelnetProfilesService extends ConnectableProfileProvider<TelnetProf
},
}
}

intoQuickConnectString (profile: TelnetProfile): string | null {
let s = profile.options.host
if (profile.options.port !== 23) {
s = `${s}:${profile.options.port}`
}
return s
}
}

0 comments on commit 7687972

Please sign in to comment.