Always use images- for the start of an event name, not image-

- Also keep all the images handlers in the image events region in the
  typescript event definition file.

Signed-off-by: Eric Promislow <epromislow@suse.com>
This commit is contained in:
Eric Promislow
2021-10-03 17:29:27 -07:00
parent 4a33668895
commit df2d9b4fde
4 changed files with 19 additions and 19 deletions

View File

@@ -266,13 +266,13 @@ export default {
mounted() {
this.main = document.getElementsByTagName('main')[0];
ipcRenderer.on('image-process-cancelled', (event) => {
ipcRenderer.on('images-process-cancelled', (event) => {
this.handleProcessCancelled();
});
ipcRenderer.on('image-process-ended', (event, status) => {
ipcRenderer.on('images-process-ended', (event, status) => {
this.handleProcessEnd(status);
});
ipcRenderer.on('image-process-output', (event, data, isStderr) => {
ipcRenderer.on('images-process-output', (event, data, isStderr) => {
this.appendImageManagerOutput(data, isStderr);
});
},

View File

@@ -183,7 +183,7 @@ export abstract class ImageProcessor extends EventEmitter {
const dataString = data.toString();
if (sendNotifications) {
this.emit('image-process-output', dataString, false);
this.emit('images-process-output', dataString, false);
}
result.stdout += dataString;
});
@@ -203,7 +203,7 @@ export abstract class ImageProcessor extends EventEmitter {
}
result.stderr += dataString;
if (sendNotifications) {
this.emit('image-process-output', dataString, true);
this.emit('images-process-output', dataString, true);
}
});
child.on('exit', (code, signal) => {

View File

@@ -30,8 +30,8 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
imageManager.on('readiness-changed', (state: boolean) => {
window.send('images-check-state', state);
});
imageManager.on('image-process-output', (data: string, isStderr: boolean) => {
window.send('image-process-output', data, isStderr);
imageManager.on('images-process-output', (data: string, isStderr: boolean) => {
window.send('images-process-output', data, isStderr);
});
function onImagesChanged(images: ImageContents[]) {
@@ -52,13 +52,13 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
try {
await imageManager.deleteImage(imageID);
await imageManager.refreshImages();
event.reply('image-process-ended', 0);
event.reply('images-process-ended', 0);
} catch (err) {
await Electron.dialog.showMessageBox({
message: `Error trying to delete image ${ imageName } (${ imageID }):\n\n ${ err.stderr } `,
type: 'error'
});
event.reply('image-process-ended', 1);
event.reply('images-process-ended', 1);
}
});
@@ -75,13 +75,13 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
const results = Electron.dialog.showOpenDialogSync(options);
if (results === undefined) {
event.reply('image-process-cancelled');
event.reply('images-process-cancelled');
return;
}
if (results.length !== 1) {
console.log(`Expecting exactly one result, got ${ results.join(', ') }`);
event.reply('image-process-cancelled');
event.reply('images-process-cancelled');
return;
}
@@ -99,7 +99,7 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
type: 'error'
});
}
event.reply('image-process-ended', code);
event.reply('images-process-ended', code);
});
Electron.ipcMain.on('do-image-pull', async(event, imageName) => {
@@ -119,7 +119,7 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
type: 'error'
});
}
event.reply('image-process-ended', code);
event.reply('images-process-ended', code);
});
Electron.ipcMain.on('do-image-scan', async(event, imageName) => {
@@ -139,7 +139,7 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
type: 'error'
});
}
event.reply('image-process-ended', code);
event.reply('images-process-ended', code);
});
Electron.ipcMain.on('do-image-push', async(event, imageName, imageID, tag) => {
@@ -155,7 +155,7 @@ export function setupImageProcessor(imageProcessorName: string, k8sManager: K8s.
type: 'error'
});
}
event.reply('image-process-ended', code);
event.reply('images-process-ended', code);
});
Electron.ipcMain.handle('images-check-state', () => {

View File

@@ -23,7 +23,6 @@ type RecursivePartial<T> = {
interface IpcMainEvents {
'k8s-restart': () => void;
'settings-read': () => void;
'images-namespaces-read': () => Array<string>;
'k8s-versions': () => void;
'k8s-reset': (mode: 'fast' | 'wipe') => void;
'k8s-state': () => void;
@@ -46,6 +45,7 @@ interface IpcMainEvents {
'do-image-scan': (imageName: string) => void;
'do-image-push': (imageName: string, imageID: string, tag: string) => void;
'do-image-deletion': (imageName: string, imageID: string) => void;
'images-namespaces-read': () => Array<string>;
// #endregion
// #region firstrun
@@ -91,9 +91,9 @@ interface IpcRendererEvents {
'service-changed': (services: import('@/k8s-engine/k8s').ServiceEntry[]) => void;
// #region Images
'image-process-cancelled': () => void;
'image-process-ended': (exitCode: number) => void;
'image-process-output': (data: string, isStdErr: boolean) => void;
'images-process-cancelled': () => void;
'images-process-ended': (exitCode: number) => void;
'images-process-output': (data: string, isStdErr: boolean) => void;
'images-changed': (images: {imageName: string, tag: string, imageID: string, size: string}[]) => void;
'images-check-state': (state: boolean) => void;
'images-namespaces': (namespaces: string[]) => void;