From 5a9625424cd7360435bc873a93567f3d8fd26990 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 9 Dec 2019 18:06:16 +0100 Subject: [PATCH] added 'duplicate as admin' tab menu item --- terminus-terminal/src/tabContextMenu.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/terminus-terminal/src/tabContextMenu.ts b/terminus-terminal/src/tabContextMenu.ts index 7cc1eb61..3c0e0652 100644 --- a/terminus-terminal/src/tabContextMenu.ts +++ b/terminus-terminal/src/tabContextMenu.ts @@ -2,6 +2,8 @@ import { Injectable, NgZone } from '@angular/core' import { ToastrService } from 'ngx-toastr' import { ConfigService, BaseTabComponent, TabContextMenuItemProvider } from 'terminus-core' import { TerminalTabComponent } from './components/terminalTab.component' +import { UACService } from './services/uac.service' +import { TerminalService } from './services/terminal.service' /** @hidden */ @Injectable() @@ -10,6 +12,8 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider { private config: ConfigService, private zone: NgZone, private toastr: ToastrService, + private uac: UACService, + private terminalService: TerminalService, ) { super() } @@ -18,7 +22,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider { if (!(tab instanceof TerminalTabComponent)) { return [] } - return [ + const items: Electron.MenuItemConstructorOptions[] = [ { label: 'Save as profile', click: () => this.zone.run(async () => { @@ -38,5 +42,19 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider { }), }, ] + + + if (this.uac.isAvailable) { + items.push({ + label: 'Duplicate as administrator', + click: () => this.zone.run(async () => { + this.terminalService.openTabWithOptions({ + ...tab.sessionOptions, + runAsAdministrator: true, + }) + }), + }) + } + return items } }