Skip to content

Commit

Permalink
Add alerts and perform code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
senthuran16 committed Feb 24, 2020
1 parent cd670b4 commit b288dbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
define(['require', 'jquery', 'constants'],
function (require, $, Constants) {
define(['require', 'jquery', 'constants', 'alerts'],
function (require, $, Constants, alerts) {
var self = this;
var Utils = function () {
};
Expand All @@ -16,109 +16,6 @@ define(['require', 'jquery', 'constants'],
editorUrl: window.location.protocol + "//" + window.location.host + '/editor'
};

// /**
// * getting extension data from back end.
// * @returns {Map|Map}
// */
// function getExtensionDetails() { // TODO remove
// return new Map(Object.entries({}));
//
//
//
//
// // return new Map(Object.entries({
// // "kafka": {
// // "extensionStatus": "NOT_INSTALLED",
// // "extensionInfo": {
// // "name": "kafka",
// // "version": "5.0.8-SNAPSHOT"
// // }
// // },
// // "redis": {
// // "extensionStatus": "NOT_INSTALLED",
// // "extensionInfo": {
// // "name": "redis",
// // "version": "3.1.2-SNAPSHOT"
// // },
// // "manuallyInstall": [
// // {
// // "name": "redis-clients",
// // "version": "2.3.0",
// // "download": {
// // "info": {
// // "description": "redis clients is like a one extension",
// // "install": "by using this way we can install redis-clients"
// // },
// // "autoDownloadable": false,
// // "url": "https://repo1.maven.org/maven2/org/apache/redis/redis_2.11/2.1.1/redis_2.11-2.1.1.jar"
// // },
// // "type": "BUNDLE",
// // "lookupRegex": "kafka-clients-(.+).jar"
// // },
// // {
// // "name": "redis-server",
// // "version": "2.3.0",
// // "download": {
// // "info": {
// // "description": "redis clients is like a one extension",
// // "install": "by using this way we can install redis-clients"
// // },
// // "autoDownloadable": false,
// // "url": "https://repo1.maven.org/maven2/org/apache/redis/redis_2.11/2.1.1/kafka_2.11-2.1.1.jar"
// // },
// // "type": "BUNDLE",
// // "lookupRegex": "kafka-server-(.+).jar"
// // }
// // ]
// // },
// // "grpc": {
// // "extensionStatus": "NOT_INSTALLED",
// // "extensionInfo": {
// // "name": "grpc",
// // "version": "3.1.2-SNAPSHOT"
// // },
// // "manuallyInstall": [
// // {
// // "name": "grpc-clients",
// // "version": "2.3.0",
// // "download": {
// // "info": {
// // "description": "grpc clients is like a one extension",
// // "install": "by using this way we can install grpc-clients"
// // },
// // "autoDownloadable": false,
// // "url": "https://repo1.maven.org/maven2/org/apache/grpc/grpc_2.11/2.1.1/grpc_2.11-2.1.1.jar"
// // },
// // "type": "BUNDLE",
// // "lookupRegex": "grpc-clients-(.+).jar"
// // },
// // {
// // "name": "grpc-server",
// // "version": "2.3.0",
// // "download": {
// // "info": {
// // "description": "grpc server is like a one extension",
// // "install": "by using this way we can install grpc-server"
// // },
// // "autoDownloadable": false,
// // "url": "https://repo1.maven.org/maven2/org/apache/grpc/grpc_2.11/2.1.1/grpc_2.11-2.1.1.jar"
// // },
// // "type": "BUNDLE",
// // "lookupRegex": "grpc-server-(.+).jar"
// // }
// // ]
// // },
// // "nats": {
// // "extensionStatus": "NOT_INSTALLED",
// // "extensionInfo": {
// // "name": "nats",
// // "version": "3.1.2-SNAPSHOT"
// // },
// // }
// // }));
// },


/**
* Installs or un-installs an extension.
*
Expand Down Expand Up @@ -154,7 +51,7 @@ define(['require', 'jquery', 'constants'],
"<div class='container-fluid'>" +
"<form class='form-horizontal' onsubmit='return false'>" +
"<div class='form-group'>" +
"<label for='configName' class='col-sm-9 file-dialog-label'>" + "Are you sure you want to install " +
"<label for='configName' class='col-sm-9 file-dialog-label'>" + "Are you sure you want to " +
requestedActionText.toLowerCase() + " <b>" + extension.extensionInfo.name + "</b>?" +
"</label>" +
"</div>" +
Expand Down Expand Up @@ -194,9 +91,14 @@ define(['require', 'jquery', 'constants'],
success: function (response) {
handleCallback(extension, response.status, callerObject, response, callerScope);
app.utils.extensionStatusListener.reArrangeExtensions(extension, response.status);
alerts.info(`Extension was successfully ${action.toLowerCase()}ed. ` +
`Please restart the editor.`);
},
error: function (e) {
throw "Unable to read extension statuses"; // TODO show error message
var message = `Unable to ${action.toLowerCase()} the extension. ` +
`Please check editor console for further information.`;
alerts.error(message);
throw message;
}
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
*/
define(['jquery', 'lodash', 'log', 'remarkable', 'handlebar', 'designViewUtils', 'constants', 'app/source-editor/completion-engine'],
function ($, _, log, Remarkable, Handlebars, DesignViewUtils, Constants, CompletionEngine) {
define(['jquery', 'lodash', 'log', 'remarkable', 'handlebar', 'designViewUtils', 'constants', 'app/source-editor/completion-engine', 'alerts'],
function ($, _, log, Remarkable, Handlebars, DesignViewUtils, Constants, CompletionEngine, alerts) {
/**
* Load operators from the Completion engine.
*
Expand Down Expand Up @@ -328,6 +328,8 @@ define(['jquery', 'lodash', 'log', 'remarkable', 'handlebar', 'designViewUtils',
self._application.utils.extensionData = new Map(Object.entries(data));
},
error: function (e) {
alerts.error("Unable to read extension statuses." +
"Please see the editor console for further information.")
throw "Unable to read extension statuses";
}
});
Expand Down Expand Up @@ -408,10 +410,8 @@ define(['jquery', 'lodash', 'log', 'remarkable', 'handlebar', 'designViewUtils',
OperatorFinder.prototype.moveInstallationUpdatedExtension = function (extension, currentArray, targetArray) {
var index = currentArray.indexOf(extension);
if (index > -1) {
console.log("Before Lengths", currentArray.length, targetArray.length);
currentArray.splice(index, 1);
targetArray.push(extension);
console.log("After Lengths", currentArray.length, targetArray.length);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ <h4 data-placement="right" data-container="body" title="{{fqn}}">
<a href="#" data-extension-name="{{extension.extensionInfo.name}}"
title="Click here to Un-install"
class="extension-un-install-btn">
<i class="fw fw-delete"></i>
<i class="fw fw-cancel"></i>
</a>
</span>
{{/if}}
Expand Down

0 comments on commit b288dbb

Please sign in to comment.