Incorrect notification for scripts that executed with error or warnings
*/
(function (window, $) {
+ const ERROR_STATUS = "ERROR",
+ WARNING_STATUS = "WARNING",
+ SUCCESS_STATUS = "SUCCESS_STATUS";
+
let uiHelper = $(window).adaptTo("foundation-ui");
$(window).adaptTo("foundation-registry").register(
checkStatus(jobId)
}, 1000);
} else if (dataObject.type === 'finished') {
- console.log(scriptPath + " finished: " + JSON.stringify(dataObject.entries));
+ let status = getResponseStatus(dataObject),
+ title;
+
switch(mode){
case 'DRY_RUN':
- uiHelper.notify('info', 'Dry Run executed successfully', 'Info');
+ title = 'Dry Run';
break;
case 'RUN':
- uiHelper.notify('info', 'Run on author executed successfully', 'Info');
+ title = 'Run on author';
+ break;
+ }
+ switch (status) {
+ case ERROR_STATUS:
+ uiHelper.alert(title, 'Executed with errors', 'error');
+ break;
+ case WARNING_STATUS:
+ uiHelper.alert(title, 'Executed with warnings', 'notice');
+ break;
+ case SUCCESS_STATUS:
+ uiHelper.notify(title, 'Executed successfully', 'success');
break;
}
} else if (dataObject.type === 'unknown') {
});
}
+ function getResponseStatus(data) {
+ let statuses = new Set(data.entries.map(entry => entry.status)),
+ result;
+ if (statuses.has(ERROR_STATUS)) {
+ result = ERROR_STATUS;
+ } else if (statuses.has(WARNING_STATUS)) {
+ result = WARNING_STATUS;
+ } else {
+ result = SUCCESS_STATUS;
+ }
+ return result;
+ }
+
function isFolder(selections) {
return selections[0].items._container.innerHTML.includes("folder");
}
