mirror of
https://github.com/Eugeny/tabby
synced 2024-12-12 14:22:43 +00:00
ref ef6b8a4eaa
This commit is contained in:
parent
a9c63b5305
commit
7687972e65
7 changed files with 26 additions and 20 deletions
|
@ -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'
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
@ -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"...'),
|
||||
|
|
|
@ -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'
|
||||
|
@ -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 ?? ''),
|
||||
|
@ -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"...'),
|
||||
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue