Service navigation context menu: add Home button and disable action buttons when something is in progress
This commit is contained in:
parent
0d2f3a60cd
commit
f1c66b1db1
@ -18,24 +18,38 @@ let addButton;
|
||||
|
||||
|
||||
// Service context menu
|
||||
const serviceContextMenu = new Menu();
|
||||
serviceContextMenu.append(new MenuItem({
|
||||
label: 'Reload', click: () => {
|
||||
reloadService(serviceContextMenu.serviceId);
|
||||
}
|
||||
}));
|
||||
serviceContextMenu.append(new MenuItem({
|
||||
function openServiceContextMenu(event, serviceId) {
|
||||
event.preventDefault();
|
||||
const service = services[serviceId];
|
||||
|
||||
const menu = new Menu();
|
||||
const ready = service.view && service.viewReady, notReady = !service.view && !service.viewReady;
|
||||
menu.append(new MenuItem({
|
||||
label: 'Home', click: () => {
|
||||
service.view.loadURL(service.url)
|
||||
.catch(console.error);
|
||||
},
|
||||
enabled: ready,
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
label: ready ? 'Reload' : 'Load', click: () => {
|
||||
reloadService(serviceId);
|
||||
},
|
||||
enabled: ready || notReady,
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
label: 'Close', click: () => {
|
||||
unloadService(serviceContextMenu.serviceId);
|
||||
}
|
||||
}));
|
||||
serviceContextMenu.append(new MenuItem({type: "separator"}));
|
||||
serviceContextMenu.append(new MenuItem({
|
||||
unloadService(serviceId);
|
||||
},
|
||||
enabled: ready,
|
||||
}));
|
||||
menu.append(new MenuItem({type: "separator"}));
|
||||
menu.append(new MenuItem({
|
||||
label: 'Edit', click: () => {
|
||||
ipcRenderer.send('openServiceSettings', serviceContextMenu.serviceId);
|
||||
ipcRenderer.send('openServiceSettings', serviceId);
|
||||
}
|
||||
}));
|
||||
serviceContextMenu.append(new MenuItem({
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
label: 'Delete', click: () => {
|
||||
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||
type: 'question',
|
||||
@ -45,16 +59,12 @@ serviceContextMenu.append(new MenuItem({
|
||||
cancelId: 0,
|
||||
}).then(result => {
|
||||
if (result.response === 1) {
|
||||
ipcRenderer.send('deleteService', serviceContextMenu.serviceId);
|
||||
ipcRenderer.send('deleteService', serviceId);
|
||||
}
|
||||
}).catch(console.error);
|
||||
}
|
||||
}));
|
||||
|
||||
function openServiceContextMenu(event, index) {
|
||||
event.preventDefault();
|
||||
serviceContextMenu.serviceId = index;
|
||||
serviceContextMenu.popup({window: remote.getCurrentWindow()});
|
||||
}));
|
||||
menu.popup({window: remote.getCurrentWindow()});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user