Skip to content

Commit

Permalink
corrected menu service object, there was still part of code not more …
Browse files Browse the repository at this point in the history
…necessary after merge
  • Loading branch information
urz9999 committed Jan 12, 2021
1 parent b92088c commit 527532a
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions src/app/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import {Subscription} from 'rxjs';
})
export class MenuService extends NativeService {

// Used to define the only tray we want as active expecially in linux context
currentTray;
private redrawSubscription: Subscription;


constructor(
private workspaceService: WorkspaceService,
private configurationService: ConfigurationService,
Expand All @@ -31,73 +26,6 @@ export class MenuService extends NativeService {
private appService: AppService) {

super();

if (this.redrawSubscription) { this.redrawSubscription.unsubscribe(); }
this.redrawSubscription = this.appService.redrawList.subscribe(res => {
this.generateMenu();
});
}

generateMenu() {
const version = this.appService.getApp().getVersion();

let voices = [];
const activeSessions = this.sessionService.listSessions().filter(s => s.active);
const allSessions = activeSessions.concat(this.sessionService.alterOrderByTime(this.sessionService.listSessions().filter(s => !s.active)).slice(0, 5 - activeSessions.length));
allSessions.forEach((session: Session) => {
let icon = '';
let label = '';
switch (session.account.type) {
case AccountType.AWS_PLAIN_USER:
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName + ' - ' + (session.account as AwsPlainAccount).user;
break;
case AccountType.AWS:
case AccountType.AWS_TRUSTER:
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-aws.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName + ' - ' + (session.account as AwsAccount).role.name;
break;

case AccountType.AZURE:
icon = (session.active && !session.loading) ? __dirname + `/assets/images/icon-online-azure.png` : __dirname + `/assets/images/icon-offline.png`;
label = ' ' + session.account.accountName;
}
voices.push(
{ label,
type: 'normal',
icon,
click: (menuItem, browserWindow, event) => {
if (!session.active) {
this.sessionService.startSession(session);
this.credentialService.refreshCredentialsEmit.emit(session.account.type);

} else {
this.credentialService.refreshCredentialsEmit.emit(session.account.type);
this.sessionService.stopSession(session);
}
this.appService.redrawList.emit(true);
this.generateMenu();
} },
);
});

const extraInfo = [
{ type: 'separator' },
{ label: 'Show', type: 'normal', click: (menuItem, browserWindow, event) => { this.currentWindow.show(); } },
{ label: 'About', type: 'normal', click: (menuItem, browserWindow, event) => { this.currentWindow.show(); this.dialog.showMessageBox({ icon: __dirname + `/assets/images/Leapp.png`, message: `Leapp.\n` + `Version ${version} (${version})\n` + 'Copyright 2019 beSharp srl.', buttons: ['Ok'] }); } },
{ type: 'separator' },
{ label: 'Quit', type: 'normal', click: (menuItem, browserWindow, event) => { this.cleanBeforeExit(); } },
];

voices = voices.concat(extraInfo);
const contextMenu = this.Menu.buildFromTemplate(voices);

if (this.currentTray !== null && this.currentTray !== undefined) {
this.currentTray = new this.Tray(__dirname + `/assets/images/LeappMini.png`);
}

this.currentTray.setToolTip('Leapp');
this.currentTray.setContextMenu(contextMenu);
}

/**
Expand Down

0 comments on commit 527532a

Please sign in to comment.