Skip to content

Commit

Permalink
B #5405: Redirect delete flow (#1232)
Browse files Browse the repository at this point in the history
Co-authored-by: Jorge Lobo <[email protected]>
(cherry picked from commit c944294)
  • Loading branch information
jloboescalona2 authored and tinova committed May 19, 2021
1 parent 909775d commit a54ede3
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
98 changes: 54 additions & 44 deletions src/sunstone/public/app/sunstone.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ define(function(require) {

var actionCfg = actions[action];
var notify = actionCfg.notify;

var condition = actionCfg["condition"];

//Is the condition to run the action met?
Expand All @@ -965,67 +964,78 @@ define(function(require) {
var err = actionCfg["error"];

switch (actionCfg.type){
case "create":
case "register":
call({data:dataArg, success: callback, error:err});
case "create":
case "register":
call({data:dataArg, success: callback, error:err});
break;
case "single":
if (extraParam !== undefined) {
call({
data:{
id:dataArg,
extra_param: extraParam
},
success: callback, error:err
});
} else {
call({data:{id:dataArg}, success: callback, error:err});
};
case "single":
if (extraParam !== undefined) {
call({
data:{
id:dataArg,
extra_param: extraParam
},
success: callback,
error: err
});
} else {
call({
data:{
id:dataArg
},
success: callback,
error:err
});
};
break;
case "list":
call({success: callback, error:err, options:dataArg});
case "list":
call({success: callback, error:err, options:dataArg});
break;
case "monitor_global":
call({
case "monitor_global":
call({
timeout: true,
success: callback,
error:err,
data: {monitor: dataArg}});
break;
case "monitor":
case "monitor_single":
call({
case "monitor":
case "monitor_single":
call({
timeout: true,
success: callback,
error:err,
data: {id:dataArg, monitor: extraParam}});
break;
case "multiple":
$.each(dataArg, function() {
if (extraParam) {
call({
data:{
id:this,
extra_param:extraParam
},
success: callback,
error: err});
case "multiple":
$.each(dataArg, function() {
if (extraParam) {
call({
data:{
id:this,
extra_param:extraParam
},
success: callback,
error: err
});
} else {
call({
data:{id:this},
success: callback,
error:err});
data:{
id:this
},
success: callback,
error: err
});
}
});
break;
default:
if (dataArg && extraParam) {
call(dataArg, extraParam);
} else if (dataArg) {
call(dataArg);
} else {
call();
}
default:
if (dataArg && extraParam) {
call(dataArg, extraParam);
} else if (dataArg) {
call(dataArg);
} else {
call();
}
}

if (notify) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ define(function(require) {
"ServiceTemplate.create" : _commonActions.create(CREATE_DIALOG_ID),
"ServiceTemplate.show" : _commonActions.show(),
"ServiceTemplate.refresh" : _commonActions.refresh(),
"ServiceTemplate.delete" : _commonActions.del(),
"ServiceTemplate.delete" : _commonActions.delWithoutRedirect(),
"ServiceTemplate.chown": _commonActions.multipleAction("chown"),
"ServiceTemplate.chgrp": _commonActions.multipleAction("chgrp"),
"ServiceTemplate.chmod": _commonActions.singleAction("chmod"),
Expand Down
26 changes: 24 additions & 2 deletions src/sunstone/public/app/utils/common-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define(function(require) {
CommonActions.prototype.list = _list;
CommonActions.prototype.show = _show;
CommonActions.prototype.refresh = _refresh;
CommonActions.prototype.delWithoutRedirect = _delWithoutRedirect;
CommonActions.prototype.del = _del;
CommonActions.prototype.multipleAction = _multipleAction;
CommonActions.prototype.singleAction = _singleAction;
Expand Down Expand Up @@ -115,6 +116,27 @@ define(function(require) {
};
}

function _delWithoutRedirect() {
var that = this;
return {
type: "multiple",
call : that.openNebulaResource.del,
callback : function(request, response) {
var tab = $("#" + that.tabId);
if (Sunstone.getTab() == that.tabId) {
Sunstone.showTab(that.tabId);
}
},
elements: function(opts) {
return Sunstone.getDataTable(that.tabId).elements(opts);
},
error: function(req, res){
Notifier.notifyError(res && res.error && res.error.message);
},
notify: true
};
}

function _multipleAction(actionStr, notify) {
notify_bool = true;
if(notify != undefined){
Expand Down Expand Up @@ -214,7 +236,7 @@ define(function(require) {
call: function() {
var selectedNodes = Sunstone.getDataTable(that.tabId).elements();
if (selectedNodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
Notifier.notifyMessage(Locale.tr("Please select one (and just one) resource to update."));
return false;
}

Expand All @@ -232,7 +254,7 @@ define(function(require) {
call: function() {
var selectedNodes = Sunstone.getDataTable(that.tabId).elements();
if (selectedNodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
Notifier.notifyMessage(Locale.tr("Please select one (and just one) resource to update."));
return false;
}

Expand Down

0 comments on commit a54ede3

Please sign in to comment.