diff --git a/tabby-core/src/api/index.ts b/tabby-core/src/api/index.ts index 879dc10a..fd797cde 100644 --- a/tabby-core/src/api/index.ts +++ b/tabby-core/src/api/index.ts @@ -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, Profile, ProfileSettingsComponent } from './profileProvider' +export { ProfileProvider, Profile, PartialProfile, ProfileSettingsComponent } from './profileProvider' export { PromptModalComponent } from '../components/promptModal.component' export { AppService } from '../services/app.service' diff --git a/tabby-core/src/api/profileProvider.ts b/tabby-core/src/api/profileProvider.ts index 2867669e..33433054 100644 --- a/tabby-core/src/api/profileProvider.ts +++ b/tabby-core/src/api/profileProvider.ts @@ -1,45 +1,56 @@ +/* eslint-disable @typescript-eslint/no-type-alias */ /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-empty-function */ import { BaseTabComponent } from '../components/baseTab.component' import { NewTabParameters } from '../services/tabs.service' export interface Profile { - id?: string + id: string type: string name: string group?: string - options: Record + options: any icon?: string color?: string - disableDynamicTitle?: boolean + disableDynamicTitle: boolean - weight?: number - isBuiltin?: boolean - isTemplate?: boolean + weight: number + isBuiltin: boolean + isTemplate: boolean } -export interface ProfileSettingsComponent { - profile: Profile +export type PartialProfile = Omit, 'type'>, 'name'> & { + type: string + name: string + options?: { + [K in keyof T['options']]?: T['options'][K] + } +} + +export interface ProfileSettingsComponent

{ + profile: P save?: () => void } -export abstract class ProfileProvider { +export abstract class ProfileProvider

{ id: string name: string supportsQuickConnect = false - settingsComponent?: new (...args: any[]) => ProfileSettingsComponent + settingsComponent?: new (...args: any[]) => ProfileSettingsComponent

configDefaults = {} - abstract getBuiltinProfiles (): Promise + abstract getBuiltinProfiles (): Promise[]> - abstract getNewTabParameters (profile: Profile): Promise> + abstract getNewTabParameters (profile: PartialProfile

): Promise> - abstract getDescription (profile: Profile): string + abstract getDescription (profile: PartialProfile

): string - quickConnect (query: string): Profile|null { + quickConnect (query: string): PartialProfile

|null { return null } - deleteProfile (profile: Profile): void { } + deleteProfile (profile: P): void { } } diff --git a/tabby-core/src/buttonProvider.ts b/tabby-core/src/buttonProvider.ts index 3517198c..26184073 100644 --- a/tabby-core/src/buttonProvider.ts +++ b/tabby-core/src/buttonProvider.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core' import { ToolbarButton, ToolbarButtonProvider } from './api/toolbarButtonProvider' import { HostAppService, Platform } from './api/hostApp' -import { Profile } from './api/profileProvider' +import { PartialProfile, Profile } from './api/profileProvider' import { ConfigService } from './services/config.service' import { HotkeysService } from './services/hotkeys.service' import { ProfilesService } from './services/profiles.service' @@ -32,7 +32,7 @@ export class ButtonProvider extends ToolbarButtonProvider { } } - async launchProfile (profile: Profile) { + async launchProfile (profile: PartialProfile) { await this.profilesService.openNewTabForProfile(profile) let recentProfiles = this.config.store.recentProfiles diff --git a/tabby-core/src/profiles.ts b/tabby-core/src/profiles.ts index b819c9d6..461539c4 100644 --- a/tabby-core/src/profiles.ts +++ b/tabby-core/src/profiles.ts @@ -1,7 +1,7 @@ import slugify from 'slugify' import { v4 as uuidv4 } from 'uuid' import { Injectable } from '@angular/core' -import { ConfigService, NewTabParameters, Profile, ProfileProvider } from './api' +import { ConfigService, NewTabParameters, PartialProfile, Profile, ProfileProvider } from './api' import { SplitTabComponent, SplitTabRecoveryProvider } from './components/splitTab.component' export interface SplitLayoutProfileOptions { @@ -13,7 +13,7 @@ export interface SplitLayoutProfile extends Profile { } @Injectable({ providedIn: 'root' }) -export class SplitLayoutProfilesService extends ProfileProvider { +export class SplitLayoutProfilesService extends ProfileProvider { id = 'split-layout' name = 'Saved layout' configDefaults = { @@ -29,7 +29,7 @@ export class SplitLayoutProfilesService extends ProfileProvider { super() } - async getBuiltinProfiles (): Promise { + async getBuiltinProfiles (): Promise[]> { return [] } @@ -43,7 +43,7 @@ export class SplitLayoutProfilesService extends ProfileProvider { async createProfile (tab: SplitTabComponent, name: string): Promise { const token = await tab.getRecoveryToken() - const profile: SplitLayoutProfile = { + const profile: PartialProfile = { id: `${this.id}:custom:${slugify(name)}:${uuidv4()}`, type: this.id, name, diff --git a/tabby-core/src/services/profiles.service.ts b/tabby-core/src/services/profiles.service.ts index 8cfe2f43..ef0c9c55 100644 --- a/tabby-core/src/services/profiles.service.ts +++ b/tabby-core/src/services/profiles.service.ts @@ -1,8 +1,8 @@ import { Injectable, Inject } from '@angular/core' import { NewTabParameters } from './tabs.service' import { BaseTabComponent } from '../components/baseTab.component' -import { Profile, ProfileProvider } from '../api/profileProvider' -import { SelectorOption } from '../api/selector' +import { PartialProfile, Profile, ProfileProvider } from '../api/profileProvider' +;import { SelectorOption } from '../api/selector' import { AppService } from './app.service' import { configMerge, ConfigProxy, ConfigService } from './config.service' import { NotificationsService } from './notifications.service' @@ -29,15 +29,18 @@ export class ProfilesService { private config: ConfigService, private notifications: NotificationsService, private selector: SelectorService, - @Inject(ProfileProvider) private profileProviders: ProfileProvider[], + @Inject(ProfileProvider) private profileProviders: ProfileProvider[], ) { } - async openNewTabForProfile (profile: Profile): Promise { + async openNewTabForProfile

(profile: PartialProfile

): Promise { const params = await this.newTabParametersForProfile(profile) if (params) { const tab = this.app.openNewTab(params) ;(this.app.getParentTab(tab) ?? tab).color = profile.color ?? null - tab.setTitle(profile.name) + + if (profile.name) { + tab.setTitle(profile.name) + } if (profile.disableDynamicTitle) { tab['enableDynamicTitle'] = false } @@ -46,16 +49,16 @@ export class ProfilesService { return null } - async newTabParametersForProfile (profile: Profile): Promise|null> { - profile = this.getConfigProxyForProfile(profile) - return this.providerForProfile(profile)?.getNewTabParameters(profile) ?? null + async newTabParametersForProfile

(profile: PartialProfile

): Promise|null> { + const fullProfile = this.getConfigProxyForProfile(profile) + return this.providerForProfile(fullProfile)?.getNewTabParameters(fullProfile) ?? null } - getProviders (): ProfileProvider[] { + getProviders (): ProfileProvider[] { return [...this.profileProviders] } - async getProfiles (): Promise { + async getProfiles (): Promise[]> { const lists = await Promise.all(this.config.enabledServices(this.profileProviders).map(x => x.getBuiltinProfiles())) let list = lists.reduce((a, b) => a.concat(b), []) list = [ @@ -68,28 +71,29 @@ export class ProfilesService { return list } - providerForProfile (profile: Profile): ProfileProvider|null { - return this.profileProviders.find(x => x.id === profile.type) ?? null + providerForProfile (profile: PartialProfile): ProfileProvider|null { + const provider = this.profileProviders.find(x => x.id === profile.type) ?? null + return provider as unknown as ProfileProvider|null } - getDescription (profile: Profile): string|null { + getDescription

(profile: PartialProfile

): string|null { profile = this.getConfigProxyForProfile(profile) return this.providerForProfile(profile)?.getDescription(profile) ?? null } - selectorOptionForProfile (profile: Profile): SelectorOption { - profile = this.getConfigProxyForProfile(profile) + selectorOptionForProfile

(profile: PartialProfile

): SelectorOption { + const fullProfile = this.getConfigProxyForProfile(profile) return { icon: profile.icon, - name: profile.group ? `${profile.group} / ${profile.name}` : profile.name, - description: this.providerForProfile(profile)?.getDescription(profile), + name: profile.group ? `${fullProfile.group} / ${fullProfile.name}` : fullProfile.name, + description: this.providerForProfile(fullProfile)?.getDescription(fullProfile), } } - showProfileSelector (): Promise { - return new Promise(async (resolve, reject) => { + showProfileSelector (): Promise|null> { + return new Promise|null>(async (resolve, reject) => { try { - const recentProfiles: Profile[] = this.config.store.recentProfiles + const recentProfiles: PartialProfile[] = this.config.store.recentProfiles let options: SelectorOption[] = recentProfiles.map(p => ({ ...this.selectorOptionForProfile(p), @@ -159,7 +163,7 @@ export class ProfilesService { }) } - async quickConnect (query: string): Promise { + async quickConnect (query: string): Promise|null> { for (const provider of this.getProviders()) { if (provider.supportsQuickConnect) { const profile = provider.quickConnect(query) @@ -172,9 +176,9 @@ export class ProfilesService { return null } - getConfigProxyForProfile (profile: Profile): Profile { + getConfigProxyForProfile (profile: PartialProfile): T { const provider = this.providerForProfile(profile) const defaults = configMerge(this.profileDefaults, provider?.configDefaults ?? {}) - return new ConfigProxy(profile, defaults) as unknown as Profile + return new ConfigProxy(profile, defaults) as unknown as T } } diff --git a/tabby-local/src/components/localProfileSettings.component.ts b/tabby-local/src/components/localProfileSettings.component.ts index f02e686f..a8043f77 100644 --- a/tabby-local/src/components/localProfileSettings.component.ts +++ b/tabby-local/src/components/localProfileSettings.component.ts @@ -10,7 +10,7 @@ import { ProfileSettingsComponent } from 'tabby-core' @Component({ template: require('./localProfileSettings.component.pug'), }) -export class LocalProfileSettingsComponent implements ProfileSettingsComponent { +export class LocalProfileSettingsComponent implements ProfileSettingsComponent { profile: LocalProfile constructor ( diff --git a/tabby-local/src/profiles.ts b/tabby-local/src/profiles.ts index a4738e77..e1ea5d3c 100644 --- a/tabby-local/src/profiles.ts +++ b/tabby-local/src/profiles.ts @@ -1,12 +1,12 @@ import deepClone from 'clone-deep' import { Injectable, Inject } from '@angular/core' -import { ProfileProvider, Profile, NewTabParameters, ConfigService, SplitTabComponent, AppService } from 'tabby-core' +import { ProfileProvider, NewTabParameters, ConfigService, SplitTabComponent, AppService, PartialProfile } from 'tabby-core' import { TerminalTabComponent } from './components/terminalTab.component' import { LocalProfileSettingsComponent } from './components/localProfileSettings.component' -import { ShellProvider, Shell, SessionOptions } from './api' +import { ShellProvider, Shell, SessionOptions, LocalProfile } from './api' @Injectable({ providedIn: 'root' }) -export class LocalProfilesService extends ProfileProvider { +export class LocalProfilesService extends ProfileProvider { id = 'local' name = 'Local' settingsComponent = LocalProfileSettingsComponent @@ -34,7 +34,7 @@ export class LocalProfilesService extends ProfileProvider { super() } - async getBuiltinProfiles (): Promise { + async getBuiltinProfiles (): Promise[]> { return (await this.getShells()).map(shell => ({ id: `local:${shell.id}`, type: 'local', @@ -45,20 +45,20 @@ export class LocalProfilesService extends ProfileProvider { })) } - async getNewTabParameters (profile: Profile): Promise> { + async getNewTabParameters (profile: PartialProfile): Promise> { profile = deepClone(profile) if (!profile.options?.cwd) { if (this.app.activeTab instanceof TerminalTabComponent && this.app.activeTab.session) { profile.options ??= {} - profile.options.cwd = await this.app.activeTab.session.getWorkingDirectory() + profile.options.cwd = await this.app.activeTab.session.getWorkingDirectory() ?? undefined } if (this.app.activeTab instanceof SplitTabComponent) { const focusedTab = this.app.activeTab.getFocusedTab() if (focusedTab instanceof TerminalTabComponent && focusedTab.session) { profile.options ??= {} - profile.options.cwd = await focusedTab.session.getWorkingDirectory() + profile.options!.cwd = await focusedTab.session.getWorkingDirectory() ?? undefined } } } @@ -84,7 +84,7 @@ export class LocalProfilesService extends ProfileProvider { } } - getDescription (profile: Profile): string { - return profile.options?.command + getDescription (profile: PartialProfile): string { + return profile.options?.command ?? '' } } diff --git a/tabby-local/src/services/terminal.service.ts b/tabby-local/src/services/terminal.service.ts index 02794251..ecd86ac7 100644 --- a/tabby-local/src/services/terminal.service.ts +++ b/tabby-local/src/services/terminal.service.ts @@ -1,6 +1,6 @@ import * as fs from 'mz/fs' import { Injectable } from '@angular/core' -import { Logger, LogService, ConfigService, ProfilesService } from 'tabby-core' +import { Logger, LogService, ConfigService, ProfilesService, PartialProfile } from 'tabby-core' import { TerminalTabComponent } from '../components/terminalTab.component' import { LocalProfile } from '../api' @@ -17,40 +17,42 @@ export class TerminalService { this.logger = log.create('terminal') } - async getDefaultProfile (): Promise { + async getDefaultProfile (): Promise> { const profiles = await this.profilesService.getProfiles() let profile = profiles.find(x => x.id === this.config.store.terminal.profile) if (!profile) { profile = profiles.filter(x => x.type === 'local' && x.isBuiltin)[0] } - return profile as LocalProfile + return profile as PartialProfile } /** * Launches a new terminal with a specific shell and CWD * @param pause Wait for a keypress when the shell exits */ - async openTab (profile?: LocalProfile|null, cwd?: string|null, pause?: boolean): Promise { + async openTab (profile?: PartialProfile|null, cwd?: string|null, pause?: boolean): Promise { if (!profile) { profile = await this.getDefaultProfile() } - cwd = cwd ?? profile.options.cwd + const fullProfile = this.profilesService.getConfigProxyForProfile(profile) + + cwd = cwd ?? fullProfile.options.cwd if (cwd && !fs.existsSync(cwd)) { console.warn('Ignoring non-existent CWD:', cwd) cwd = null } - this.logger.info(`Starting profile ${profile.name}`, profile) + this.logger.info(`Starting profile ${fullProfile.name}`, fullProfile) const options = { - ...profile.options, + ...fullProfile.options, pauseAfterExit: pause, cwd: cwd ?? undefined, } return (await this.profilesService.openNewTabForProfile({ - ...profile, + ...fullProfile, options, })) as TerminalTabComponent } diff --git a/tabby-serial/src/components/serialProfileSettings.component.ts b/tabby-serial/src/components/serialProfileSettings.component.ts index f1f3f73d..a2e788e3 100644 --- a/tabby-serial/src/components/serialProfileSettings.component.ts +++ b/tabby-serial/src/components/serialProfileSettings.component.ts @@ -9,7 +9,7 @@ import { SerialService } from '../services/serial.service' @Component({ template: require('./serialProfileSettings.component.pug'), }) -export class SerialProfileSettingsComponent implements ProfileSettingsComponent { +export class SerialProfileSettingsComponent implements ProfileSettingsComponent { profile: SerialProfile foundPorts: SerialPortInfo[] Platform = Platform diff --git a/tabby-serial/src/profiles.ts b/tabby-serial/src/profiles.ts index 3d5f8ea4..6da943cd 100644 --- a/tabby-serial/src/profiles.ts +++ b/tabby-serial/src/profiles.ts @@ -10,7 +10,7 @@ import { SerialService } from './services/serial.service' import { BAUD_RATES, SerialProfile } from './api' @Injectable({ providedIn: 'root' }) -export class SerialProfilesService extends ProfileProvider { +export class SerialProfilesService extends ProfileProvider { id = 'serial' name = 'Serial' settingsComponent = SerialProfileSettingsComponent diff --git a/tabby-serial/src/services/serial.service.ts b/tabby-serial/src/services/serial.service.ts index d71922c4..1f5b94bd 100644 --- a/tabby-serial/src/services/serial.service.ts +++ b/tabby-serial/src/services/serial.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import SerialPort from 'serialport' -import { ProfilesService } from 'tabby-core' +import { PartialProfile, ProfilesService } from 'tabby-core' import { SerialPortInfo, SerialProfile } from '../api' import { SerialTabComponent } from '../components/serialTab.component' @@ -24,19 +24,12 @@ export class SerialService { baudrate = parseInt(path.split('@')[1]) path = path.split('@')[0] } - const profile: SerialProfile = { + const profile: PartialProfile = { name: query, type: 'serial', options: { port: path, baudrate: baudrate, - databits: 8, - parity: 'none', - rtscts: false, - stopbits: 1, - xany: false, - xoff: false, - xon: false, }, } window.localStorage.lastSerialConnection = JSON.stringify(profile) diff --git a/tabby-settings/src/components/editProfileModal.component.ts b/tabby-settings/src/components/editProfileModal.component.ts index a1375275..3bc2dd18 100644 --- a/tabby-settings/src/components/editProfileModal.component.ts +++ b/tabby-settings/src/components/editProfileModal.component.ts @@ -15,15 +15,15 @@ const iconsClassList = Object.keys(iconsData).map( @Component({ template: require('./editProfileModal.component.pug'), }) -export class EditProfileModalComponent { - @Input() profile: Profile & ConfigProxy - @Input() profileProvider: ProfileProvider - @Input() settingsComponent: new () => ProfileSettingsComponent +export class EditProfileModalComponent

{ + @Input() profile: P & ConfigProxy + @Input() profileProvider: ProfileProvider

+ @Input() settingsComponent: new () => ProfileSettingsComponent

groupNames: string[] @ViewChild('placeholder', { read: ViewContainerRef }) placeholder: ViewContainerRef private _profile: Profile - private settingsComponentInstance: ProfileSettingsComponent + private settingsComponentInstance: ProfileSettingsComponent

constructor ( private injector: Injector, diff --git a/tabby-settings/src/components/profilesSettingsTab.component.ts b/tabby-settings/src/components/profilesSettingsTab.component.ts index e6ef6979..8fb8421f 100644 --- a/tabby-settings/src/components/profilesSettingsTab.component.ts +++ b/tabby-settings/src/components/profilesSettingsTab.component.ts @@ -3,12 +3,12 @@ import slugify from 'slugify' import deepClone from 'clone-deep' import { Component } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent } from 'tabby-core' +import { ConfigService, HostAppService, Profile, SelectorService, ProfilesService, PromptModalComponent, PlatformService, BaseComponent, PartialProfile } from 'tabby-core' import { EditProfileModalComponent } from './editProfileModal.component' interface ProfileGroup { name?: string - profiles: Profile[] + profiles: PartialProfile[] editable: boolean collapsed: boolean } @@ -19,9 +19,9 @@ interface ProfileGroup { styles: [require('./profilesSettingsTab.component.scss')], }) export class ProfilesSettingsTabComponent extends BaseComponent { - profiles: Profile[] = [] - builtinProfiles: Profile[] = [] - templateProfiles: Profile[] = [] + profiles: PartialProfile[] = [] + builtinProfiles: PartialProfile[] = [] + templateProfiles: PartialProfile[] = [] profileGroups: ProfileGroup[] filter = '' @@ -45,11 +45,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent { this.subscribeUntilDestroyed(this.config.changed$, () => this.refresh()) } - launchProfile (profile: Profile): void { + launchProfile (profile: PartialProfile): void { this.profilesService.openNewTabForProfile(profile) } - async newProfile (base?: Profile): Promise { + async newProfile (base?: PartialProfile): Promise { if (!base) { const profiles = [...this.templateProfiles, ...this.builtinProfiles, ...this.profiles] profiles.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0)) @@ -57,7 +57,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { 'Select a base profile to use as a template', profiles.map(p => ({ icon: p.icon, - description: this.profilesService.providerForProfile(p)?.getDescription(p), + description: this.profilesService.getDescription(p) ?? undefined, name: p.group ? `${p.group} / ${p.name}` : p.name, result: p, })), @@ -74,7 +74,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { await this.config.save() } - async editProfile (profile: Profile): Promise { + async editProfile (profile: PartialProfile): Promise { const modal = this.ngbModal.open( EditProfileModalComponent, { size: 'lg' }, @@ -93,7 +93,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { await this.config.save() } - async deleteProfile (profile: Profile): Promise { + async deleteProfile (profile: PartialProfile): Promise { if ((await this.platform.showMessageBox( { type: 'warning', @@ -102,7 +102,8 @@ export class ProfilesSettingsTabComponent extends BaseComponent { defaultId: 0, } )).response === 1) { - this.profilesService.providerForProfile(profile)?.deleteProfile(profile) + this.profilesService.providerForProfile(profile)?.deleteProfile( + this.profilesService.getConfigProxyForProfile(profile)) this.config.store.profiles = this.config.store.profiles.filter(x => x !== profile) await this.config.save() } @@ -181,7 +182,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { return !this.filter || group.profiles.some(x => this.isProfileVisible(x)) } - isProfileVisible (profile: Profile): boolean { + isProfileVisible (profile: PartialProfile): boolean { return !this.filter || profile.name.toLowerCase().includes(this.filter.toLowerCase()) } @@ -189,11 +190,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent { return icon?.startsWith('<') ?? false } - getDescription (profile: Profile): string|null { + getDescription (profile: PartialProfile): string|null { return this.profilesService.getDescription(profile) } - getTypeLabel (profile: Profile): string { + getTypeLabel (profile: PartialProfile): string { const name = this.profilesService.providerForProfile(profile)?.name if (name === 'Local') { return '' @@ -201,7 +202,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { return name ?? 'Unknown' } - getTypeColorClass (profile: Profile): string { + getTypeColorClass (profile: PartialProfile): string { return { ssh: 'secondary', serial: 'success', diff --git a/tabby-ssh/src/profiles.ts b/tabby-ssh/src/profiles.ts index 3d4dfb93..81247bbb 100644 --- a/tabby-ssh/src/profiles.ts +++ b/tabby-ssh/src/profiles.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { ProfileProvider, Profile, NewTabParameters } from 'tabby-core' +import { ProfileProvider, NewTabParameters, PartialProfile } from 'tabby-core' import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component' import { SSHTabComponent } from './components/sshTab.component' import { PasswordStorageService } from './services/passwordStorage.service' @@ -8,7 +8,7 @@ import { ALGORITHM_BLACKLIST, SSHAlgorithmType, SSHProfile } from './api' import * as ALGORITHMS from 'ssh2/lib/protocol/constants' @Injectable({ providedIn: 'root' }) -export class SSHProfilesService extends ProfileProvider { +export class SSHProfilesService extends ProfileProvider { id = 'ssh' name = 'SSH' supportsQuickConnect = true @@ -66,7 +66,7 @@ export class SSHProfilesService extends ProfileProvider { } } - async getBuiltinProfiles (): Promise { + async getBuiltinProfiles (): Promise[]> { return [{ id: `ssh:template`, type: 'ssh', @@ -83,22 +83,22 @@ export class SSHProfilesService extends ProfileProvider { }] } - async getNewTabParameters (profile: Profile): Promise> { + async getNewTabParameters (profile: PartialProfile): Promise> { return { type: SSHTabComponent, inputs: { profile }, } } - getDescription (profile: SSHProfile): string { - return profile.options.host + getDescription (profile: PartialProfile): string { + return profile.options?.host ?? '' } deleteProfile (profile: SSHProfile): void { this.passwordStorage.deletePassword(profile) } - quickConnect (query: string): SSHProfile { + quickConnect (query: string): PartialProfile { let user = 'root' let host = query let port = 22 diff --git a/tabby-telnet/src/components/telnetProfileSettings.component.ts b/tabby-telnet/src/components/telnetProfileSettings.component.ts index 0b6c21c4..eef0fa12 100644 --- a/tabby-telnet/src/components/telnetProfileSettings.component.ts +++ b/tabby-telnet/src/components/telnetProfileSettings.component.ts @@ -8,6 +8,6 @@ import { TelnetProfile } from '../session' @Component({ template: require('./telnetProfileSettings.component.pug'), }) -export class TelnetProfileSettingsComponent implements ProfileSettingsComponent { +export class TelnetProfileSettingsComponent implements ProfileSettingsComponent { profile: TelnetProfile } diff --git a/tabby-telnet/src/profiles.ts b/tabby-telnet/src/profiles.ts index 0163d64c..5089fd63 100644 --- a/tabby-telnet/src/profiles.ts +++ b/tabby-telnet/src/profiles.ts @@ -1,11 +1,11 @@ import { Injectable } from '@angular/core' -import { ProfileProvider, Profile, NewTabParameters } from 'tabby-core' +import { ProfileProvider, NewTabParameters, PartialProfile } 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 ProfileProvider { +export class TelnetProfilesService extends ProfileProvider { id = 'telnet' name = 'Telnet' supportsQuickConnect = false @@ -22,7 +22,7 @@ export class TelnetProfilesService extends ProfileProvider { }, } - async getBuiltinProfiles (): Promise { + async getBuiltinProfiles (): Promise[]> { return [ { id: `telnet:template`, @@ -55,7 +55,7 @@ export class TelnetProfilesService extends ProfileProvider { ] } - async getNewTabParameters (profile: Profile): Promise> { + async getNewTabParameters (profile: PartialProfile): Promise> { return { type: TelnetTabComponent, inputs: { profile }, @@ -66,7 +66,7 @@ export class TelnetProfilesService extends ProfileProvider { return profile.options.host ? `${profile.options.host}:${profile.options.port}` : '' } - quickConnect (query: string): TelnetProfile { + quickConnect (query: string): PartialProfile { let host = query let port = 23 if (host.includes('[')) {