tabContextMenu.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Injectable } from '@angular/core'
  2. import { BaseTabComponent, TabContextMenuItemProvider, HostAppService, Platform, MenuItemOptions, TranslateService } from 'tabby-core'
  3. import { SSHTabComponent } from './components/sshTab.component'
  4. import { SSHService } from './services/ssh.service'
  5. /** @hidden */
  6. @Injectable()
  7. export class SFTPContextMenu extends TabContextMenuItemProvider {
  8. weight = 10
  9. constructor (
  10. private hostApp: HostAppService,
  11. private ssh: SSHService,
  12. private translate: TranslateService,
  13. ) {
  14. super()
  15. }
  16. async getItems (tab: BaseTabComponent): Promise<MenuItemOptions[]> {
  17. if (!(tab instanceof SSHTabComponent)) {
  18. return []
  19. }
  20. const items = [{
  21. label: this.translate.instant('Open SFTP panel'),
  22. click: () => {
  23. tab.openSFTP()
  24. },
  25. }]
  26. if (this.hostApp.platform === Platform.Windows && this.ssh.getWinSCPPath()) {
  27. items.push({
  28. label: this.translate.instant('Launch WinSCP'),
  29. click: (): void => {
  30. this.ssh.launchWinSCP(tab.sshSession!)
  31. },
  32. })
  33. }
  34. return items
  35. }
  36. }