Skip to content

Commit c0f74d0

Browse files
committed
Merge branch 'develop' into readmeUpdates
2 parents 82586ee + a782e8b commit c0f74d0

File tree

4 files changed

+432
-174
lines changed

4 files changed

+432
-174
lines changed
39.3 KB
Loading

lib/MessageHandler.js

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"use strict";
44
"use babel";
55

6+
import path from "path";
7+
8+
const packageRoot = atom.packages.resolvePackagePath("build-ibmstreams");
9+
const STREAMING_ANALYTICS_ICON_PATH = `${packageRoot}${path.sep}assets${path.sep}streaming_analytics_200x200.png`;
10+
611
export class MessageHandler {
712
consoleService: null;
813

@@ -25,28 +30,15 @@ export class MessageHandler {
2530
atom.notifications.addInfo(messageOutput, {});
2631
}
2732
}
28-
// if (input && input.output) {
29-
// const messageText = input.output
30-
// .map(outputMsg => outputMsg.message_text)
31-
// .join("\n");
32-
// if (input.status === "building" || input.status === "waiting") {
33-
// atom.notifications.addInfo(input.status+"...", {detail: messageText});
34-
// }
35-
// } else if (typeof(input) === "string") {
36-
// this.consoleService.log(input);
37-
// if (showNotification) {
38-
// atom.notifications.addInfo(input, {});
39-
// }
40-
// }
4133
}
4234

4335
handleBuildSuccess(messageOutput: Array<any>) {
4436
const message = this.getLoggableMessage(messageOutput);
4537
if (message) {
46-
this.consoleService.log(message);
38+
this.consoleService.success(message);
4739
atom.notifications.addSuccess("Build succeeded", {detail: message, dismissable: true});
4840
} else {
49-
this.consoleService.log("Build succeeded");
41+
this.consoleService.success("Build succeeded");
5042
atom.notifications.addSuccess("Build succeeded", {dismissable: true});
5143
}
5244
}
@@ -63,14 +55,21 @@ export class MessageHandler {
6355
}
6456

6557
handleSubmitProgressMessage(input) {
66-
58+
if (typeof(input) === "string") {
59+
atom.notifications.addInfo(input, {});
60+
}
61+
this.consoleService.log(input);
6762
}
6863

69-
handleSubmitSuccess(input) {
70-
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {dismissable: true});
64+
handleSubmitSuccess(input, notificationButtons = []) {
65+
let addedButtons = {};
66+
if (Array.isArray(notificationButtons)) {
67+
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
68+
}
69+
atom.notifications.addSuccess(`Job ${input.name} is ${input.health}`, {...addedButtons, dismissable: true});
7170

7271
if (this.consoleService) {
73-
this.consoleService.log(`Job ${input.name} is ${input.health}`);
72+
this.consoleService.success(`Job ${input.name} is ${input.health}`);
7473
}
7574
}
7675

@@ -99,9 +98,13 @@ export class MessageHandler {
9998
}
10099
console.error(input);
101100
}
102-
handleSuccess(input, detail, showNotification, showConsoleMsg) {
101+
handleSuccess(input, detail, showNotification, showConsoleMsg, notificationButtons = []) {
102+
let addedButtons = {};
103+
if (Array.isArray(notificationButtons)) {
104+
addedButtons.buttons = notificationButtons.map(obj => ({onDidClick: obj.callbackFn, text: obj.label}));
105+
}
103106
if (showNotification) {
104-
atom.notifications.addSuccess(input, {detail: detail, dismissable: true});
107+
atom.notifications.addSuccess(input, {...addedButtons, detail: detail, dismissable: true});
105108
}
106109
if (showConsoleMsg) {
107110
if (this.consoleService) {
@@ -118,13 +121,29 @@ export class MessageHandler {
118121
}
119122

120123
showDialog(message, detail, buttonObjs) {
124+
125+
const nativeImage = require("electron").nativeImage;
126+
121127
const labels = buttonObjs.map(obj => obj.label);
122128
const callbacks = buttonObjs.map(obj => obj.callbackFn);
123129
let buttons = {};
124130
labels.forEach((label, index) => {
125131
buttons[label] = callbacks[index];
126132
});
127-
atom.confirm({message: message, detailedMessage: detail, buttons: buttons});
133+
atom.confirm(
134+
{
135+
message: message,
136+
detail: detail,
137+
buttons: labels,
138+
icon: STREAMING_ANALYTICS_ICON_PATH
139+
},
140+
(chosen, checkboxChecked) => {
141+
const callback = callbacks[chosen];
142+
if (typeof(callback) === "function") {
143+
return callback();
144+
}
145+
}
146+
);
128147
}
129148

130149
handleCredentialsMissing() {

0 commit comments

Comments
 (0)