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
|
// Service context menu
|
||||||
const serviceContextMenu = new Menu();
|
function openServiceContextMenu(event, serviceId) {
|
||||||
serviceContextMenu.append(new MenuItem({
|
event.preventDefault();
|
||||||
label: 'Reload', click: () => {
|
const service = services[serviceId];
|
||||||
reloadService(serviceContextMenu.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,
|
||||||
}));
|
}));
|
||||||
serviceContextMenu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
|
label: ready ? 'Reload' : 'Load', click: () => {
|
||||||
|
reloadService(serviceId);
|
||||||
|
},
|
||||||
|
enabled: ready || notReady,
|
||||||
|
}));
|
||||||
|
menu.append(new MenuItem({
|
||||||
label: 'Close', click: () => {
|
label: 'Close', click: () => {
|
||||||
unloadService(serviceContextMenu.serviceId);
|
unloadService(serviceId);
|
||||||
}
|
},
|
||||||
|
enabled: ready,
|
||||||
}));
|
}));
|
||||||
serviceContextMenu.append(new MenuItem({type: "separator"}));
|
menu.append(new MenuItem({type: "separator"}));
|
||||||
serviceContextMenu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
label: 'Edit', click: () => {
|
label: 'Edit', click: () => {
|
||||||
ipcRenderer.send('openServiceSettings', serviceContextMenu.serviceId);
|
ipcRenderer.send('openServiceSettings', serviceId);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
serviceContextMenu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
label: 'Delete', click: () => {
|
label: 'Delete', click: () => {
|
||||||
dialog.showMessageBox(remote.getCurrentWindow(), {
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
type: 'question',
|
type: 'question',
|
||||||
@ -45,16 +59,12 @@ serviceContextMenu.append(new MenuItem({
|
|||||||
cancelId: 0,
|
cancelId: 0,
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
if (result.response === 1) {
|
if (result.response === 1) {
|
||||||
ipcRenderer.send('deleteService', serviceContextMenu.serviceId);
|
ipcRenderer.send('deleteService', serviceId);
|
||||||
}
|
}
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
menu.popup({window: remote.getCurrentWindow()});
|
||||||
function openServiceContextMenu(event, index) {
|
|
||||||
event.preventDefault();
|
|
||||||
serviceContextMenu.serviceId = index;
|
|
||||||
serviceContextMenu.popup({window: remote.getCurrentWindow()});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user