mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-19 18:07:58 +00:00
added generic hotkeys for profile selectors by type
This commit is contained in:
@@ -4,7 +4,6 @@ import { ConfigProvider } from 'tabby-core'
|
||||
export class TelnetConfigProvider extends ConfigProvider {
|
||||
defaults = {
|
||||
hotkeys: {
|
||||
'telnet-profile-selector': [],
|
||||
'restart-telnet-session': [],
|
||||
},
|
||||
}
|
||||
|
@@ -5,10 +5,6 @@ import { HotkeyDescription, HotkeyProvider } from 'tabby-core'
|
||||
@Injectable()
|
||||
export class TelnetHotkeyProvider extends HotkeyProvider {
|
||||
hotkeys: HotkeyDescription[] = [
|
||||
{
|
||||
id: 'telnet-profile-selector',
|
||||
name: 'Show Telnet profile selector',
|
||||
},
|
||||
{
|
||||
id: 'restart-telnet-session',
|
||||
name: 'Restart current Telnet session',
|
||||
|
@@ -42,49 +42,5 @@ import { TelnetProfilesService } from './profiles'
|
||||
TelnetTabComponent,
|
||||
],
|
||||
})
|
||||
export default class TelnetModule {
|
||||
constructor (
|
||||
hotkeys: HotkeysService,
|
||||
private app: AppService,
|
||||
private selector: SelectorService,
|
||||
private profilesService: ProfilesService,
|
||||
private telnetProfiles: TelnetProfilesService,
|
||||
) {
|
||||
hotkeys.hotkey$.subscribe(hotkey => {
|
||||
if (hotkey === 'telnet-profile-selector') {
|
||||
this.showSelector()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async showSelector (): Promise<void> {
|
||||
let profiles = await this.profilesService.getProfiles()
|
||||
|
||||
profiles = profiles.filter(x => !x.isTemplate && x.type === 'telnet')
|
||||
|
||||
const options: SelectorOption<void>[] = profiles.map(p => ({
|
||||
...this.profilesService.selectorOptionForProfile(p),
|
||||
callback: () => this.profilesService.openNewTabForProfile(p),
|
||||
}))
|
||||
|
||||
options.push({
|
||||
name: 'Manage profiles',
|
||||
icon: 'fas fa-window-restore',
|
||||
callback: () => this.app.openNewTabRaw({
|
||||
type: SettingsTabComponent,
|
||||
inputs: { activeTab: 'profiles' },
|
||||
}),
|
||||
})
|
||||
|
||||
options.push({
|
||||
name: 'Quick connect',
|
||||
freeInputPattern: 'Connect to "%s"...',
|
||||
icon: 'fas fa-arrow-right',
|
||||
callback: query => this.profilesService.openNewTabForProfile(
|
||||
this.telnetProfiles.quickConnect(query)
|
||||
),
|
||||
})
|
||||
|
||||
await this.selector.show('Select an Telnet profile', options)
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||
export default class TelnetModule { }
|
||||
|
Reference in New Issue
Block a user