deprecated matchedHotkey

This commit is contained in:
Eugene Pankov
2021-07-05 22:52:32 +02:00
parent da599567f8
commit 461cd2bec7
21 changed files with 141 additions and 32 deletions

View File

@@ -41,7 +41,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
this.logger = this.log.create('terminalTab')
this.subscribeUntilDestroyed(this.hotkeys.matchedHotkey, hotkey => {
this.subscribeUntilDestroyed(this.hotkeys.hotkey$, hotkey => {
if (!this.hasFocus) {
return
}

View File

@@ -10,6 +10,7 @@ export class SSHConfigProvider extends ConfigProvider {
agentPath: null,
},
hotkeys: {
'ssh-profile-selector': [],
'restart-ssh-session': [],
'launch-winscp': [],
},

View File

@@ -5,6 +5,10 @@ import { HotkeyDescription, HotkeyProvider } from 'tabby-core'
@Injectable()
export class SSHHotkeyProvider extends HotkeyProvider {
hotkeys: HotkeyDescription[] = [
{
id: 'ssh-profile-selector',
name: 'Show SSH profile selector',
},
{
id: 'restart-ssh-session',
name: 'Restart current SSH session',

View File

@@ -4,8 +4,8 @@ import { FormsModule } from '@angular/forms'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { ToastrModule } from 'ngx-toastr'
import { NgxFilesizeModule } from 'ngx-filesize'
import TabbyCoreModule, { ConfigProvider, TabRecoveryProvider, HotkeyProvider, TabContextMenuItemProvider, ProfileProvider } from 'tabby-core'
import { SettingsTabProvider } from 'tabby-settings'
import TabbyCoreModule, { ConfigProvider, TabRecoveryProvider, HotkeyProvider, TabContextMenuItemProvider, ProfileProvider, HotkeysService, ProfilesService, AppService, SelectorService, SelectorOption } from 'tabby-core'
import { SettingsTabComponent, SettingsTabProvider } from 'tabby-settings'
import TabbyTerminalModule from 'tabby-terminal'
import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component'
@@ -40,7 +40,7 @@ import { SSHProfilesService } from './profiles'
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
{ provide: HotkeyProvider, useClass: SSHHotkeyProvider, multi: true },
{ provide: TabContextMenuItemProvider, useClass: SFTPContextMenu, multi: true },
{ provide: ProfileProvider, useClass: SSHProfilesService, multi: true },
{ provide: ProfileProvider, useExisting: SSHProfilesService, multi: true },
],
entryComponents: [
SSHProfileSettingsComponent,
@@ -59,4 +59,49 @@ import { SSHProfilesService } from './profiles'
SFTPPanelComponent,
],
})
export default class SSHModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
export default class SSHModule {
constructor (
hotkeys: HotkeysService,
private app: AppService,
private selector: SelectorService,
private profilesService: ProfilesService,
private sshProfiles: SSHProfilesService,
) {
hotkeys.hotkey$.subscribe(hotkey => {
if (hotkey === 'ssh-profile-selector') {
this.showSelector()
}
})
}
async showSelector (): Promise<void> {
let profiles = await this.profilesService.getProfiles()
profiles = profiles.filter(x => !x.isTemplate && x.type === 'ssh')
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.sshProfiles.quickConnect(query)
),
})
await this.selector.show('Select an SSH profile', options)
}
}