Skip to content

Commit e7c4bc4

Browse files
committed
bug 12266
- Show 'delete' instead of 'create' in dialog - Select domain's parent upon deletion, for UI consistency
1 parent fdb21b5 commit e7c4bc4

2 files changed

Lines changed: 99 additions & 91 deletions

File tree

ui/scripts/domains.js

Lines changed: 97 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
notification: function(args) {
2525
return 'Domain is deleted';
2626
}
27-
},
27+
},
2828

2929
createForm: {
30-
title: 'Delete domain',
31-
preFilter: function(args) {
30+
title: 'Delete domain',
31+
createLabel: 'Delete',
32+
preFilter: function(args) {
3233
if(isAdmin()) {
3334
args.$form.find('.form-item[rel=isForced]').css('display', 'inline-block');
3435
}
35-
},
36+
},
3637
fields: {
3738
isForced: {
3839
label: 'Force delete',
@@ -43,7 +44,7 @@
4344
},
4445

4546
action: function(args) {
46-
var array1 = [];
47+
var array1 = [];
4748
if(args.$form.find('.form-item[rel=isForced]').css("display") != "none") //uncomment after Brian fix it to include $form in args
4849
array1.push("&cleanup=" + (args.data.isForced == "on"));
4950

@@ -58,6 +59,12 @@
5859
{jobId: jid}
5960
}
6061
);
62+
63+
// Quick fix for proper UI reaction to delete domain
64+
var $item = $('.name.selected').closest('li');
65+
var $itemParent = $item.closest('li');
66+
$itemParent.parent().parent().find('.name:first').click();
67+
$item.remove();
6168
}
6269
});
6370
},
@@ -70,63 +77,63 @@
7077
edit: {
7178
label: 'Edit domain details',
7279
messages: {
73-
notification: function(args) {
80+
notification: function(args) {
7481
return 'Edited domain: ' + args.name;
7582
}
7683
},
77-
action: function(args) {
78-
var domainObj;
79-
84+
action: function(args) {
85+
var domainObj;
86+
8087
$.ajax({
8188
url: createURL("updateDomain&id=" + args.context.domains[0].id + "&name=" + todb(args.data.name)),
8289
async: false,
8390
dataType: "json",
84-
success: function(json) {
91+
success: function(json) {
8592
domainObj = json.updatedomainresponse.domain;
8693
}
87-
});
94+
});
8895

8996
$.ajax({
9097
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=0&max=" + args.data.vmLimit),
9198
dataType: "json",
9299
async: false,
93-
success: function(json) {
94-
domainObj["vmLimit"] = args.data.vmLimit;
100+
success: function(json) {
101+
domainObj["vmLimit"] = args.data.vmLimit;
95102
}
96-
});
103+
});
97104
$.ajax({
98105
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=1&max=" + args.data.ipLimit),
99106
dataType: "json",
100107
async: false,
101-
success: function(json) {
102-
domainObj["ipLimit"] = args.data.ipLimit;
108+
success: function(json) {
109+
domainObj["ipLimit"] = args.data.ipLimit;
103110
}
104-
});
111+
});
105112
$.ajax({
106113
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=2&max=" + args.data.volumeLimit),
107114
dataType: "json",
108115
async: false,
109-
success: function(json) {
110-
domainObj["volumeLimit"] = args.data.volumeLimit;
116+
success: function(json) {
117+
domainObj["volumeLimit"] = args.data.volumeLimit;
111118
}
112-
});
119+
});
113120
$.ajax({
114121
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=3&max=" + args.data.snapshotLimit),
115122
dataType: "json",
116123
async: false,
117-
success: function(json) {
118-
domainObj["snapshotLimit"] = args.data.snapshotLimit;
124+
success: function(json) {
125+
domainObj["snapshotLimit"] = args.data.snapshotLimit;
119126
}
120127
});
121128
$.ajax({
122129
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=4&max=" + args.data.templateLimit),
123130
dataType: "json",
124131
async: false,
125-
success: function(json) {
126-
domainObj["templateLimit"] = args.data.templateLimit;
132+
success: function(json) {
133+
domainObj["templateLimit"] = args.data.templateLimit;
127134
}
128135
});
129-
136+
130137
args.response.success({data: domainObj});
131138
}
132139
},
@@ -181,23 +188,23 @@
181188
},
182189
{
183190
id: { label: 'ID' },
184-
vmLimit: {
191+
vmLimit: {
185192
label: 'Instance limits',
186193
isEditable: true
187194
},
188-
ipLimit: {
195+
ipLimit: {
189196
label: 'Public IP limits',
190197
isEditable: true
191198
},
192-
volumeLimit: {
199+
volumeLimit: {
193200
label: 'Volume limits',
194201
isEditable: true
195202
},
196-
snapshotLimit: {
203+
snapshotLimit: {
197204
label: 'Snapshot limits',
198205
isEditable: true
199206
},
200-
templateLimit: {
207+
templateLimit: {
201208
label: 'Template limits',
202209
isEditable: true
203210
},
@@ -206,90 +213,90 @@
206213
volumeTotal: { label: 'Volumes' }
207214
}
208215
],
209-
dataProvider: function(args) {
210-
var domainObj = args.context.domains[0];
211-
$.ajax({
216+
dataProvider: function(args) {
217+
var domainObj = args.context.domains[0];
218+
$.ajax({
212219
url: createURL("listAccounts&domainid=" + domainObj.id),
213220
async: false,
214221
dataType: "json",
215-
success: function(json) {
216-
var items = json.listaccountsresponse.account;
222+
success: function(json) {
223+
var items = json.listaccountsresponse.account;
217224
var total;
218-
if (items != null)
219-
total = items.length;
225+
if (items != null)
226+
total = items.length;
220227
else
221-
total = 0;
222-
domainObj["accountTotal"] = total;
223-
}
224-
});
225-
226-
$.ajax({
228+
total = 0;
229+
domainObj["accountTotal"] = total;
230+
}
231+
});
232+
233+
$.ajax({
227234
url: createURL("listVirtualMachines&domainid=" + domainObj.id),
228235
async: false,
229236
dataType: "json",
230-
success: function(json) {
231-
var items = json.listvirtualmachinesresponse.virtualmachine;
237+
success: function(json) {
238+
var items = json.listvirtualmachinesresponse.virtualmachine;
232239
var total;
233-
if (items != null)
234-
total = items.length;
240+
if (items != null)
241+
total = items.length;
235242
else
236-
total = 0;
237-
domainObj["vmTotal"] = total;
238-
}
239-
});
240-
241-
$.ajax({
243+
total = 0;
244+
domainObj["vmTotal"] = total;
245+
}
246+
});
247+
248+
$.ajax({
242249
url: createURL("listVolumes&domainid=" + domainObj.id),
243250
async: false,
244251
dataType: "json",
245-
success: function(json) {
246-
var items = json.listvolumesresponse.volume;
252+
success: function(json) {
253+
var items = json.listvolumesresponse.volume;
247254
var total;
248-
if (items != null)
249-
total = items.length;
255+
if (items != null)
256+
total = items.length;
250257
else
251-
total = 0;
252-
domainObj["volumeTotal"] = total;
253-
}
254-
});
255-
258+
total = 0;
259+
domainObj["volumeTotal"] = total;
260+
}
261+
});
262+
256263
$.ajax({
257264
url: createURL("listResourceLimits&domainid=" + domainObj.id),
258265
async: false,
259266
dataType: "json",
260267
success: function(json) {
261-
var limits = json.listresourcelimitsresponse.resourcelimit;
262-
if (limits != null) {
268+
var limits = json.listresourcelimitsresponse.resourcelimit;
269+
if (limits != null) {
263270
for (var i = 0; i < limits.length; i++) {
264271
var limit = limits[i];
265272
switch (limit.resourcetype) {
266-
case "0":
267-
domainObj["vmLimit"] = limit.max;
273+
case "0":
274+
domainObj["vmLimit"] = limit.max;
268275
break;
269-
case "1":
270-
domainObj["ipLimit"] = limit.max;
276+
case "1":
277+
domainObj["ipLimit"] = limit.max;
271278
break;
272-
case "2":
273-
domainObj["volumeLimit"] = limit.max;
279+
case "2":
280+
domainObj["volumeLimit"] = limit.max;
274281
break;
275-
case "3":
276-
domainObj["snapshotLimit"] = limit.max;
282+
case "3":
283+
domainObj["snapshotLimit"] = limit.max;
277284
break;
278-
case "4":
279-
domainObj["templateLimit"] = limit.max;
285+
case "4":
286+
domainObj["templateLimit"] = limit.max;
280287
break;
281288
}
282289
}
283-
}
284-
}
285-
});
286-
290+
}
291+
}
292+
});
293+
287294
args.response.success({
288295
data: domainObj,
289296
actionFilter: domainActionfilter
290297
});
291298
}
292-
}
299+
}
293300
}
294301
},
295302
labelField: 'name',
@@ -326,19 +333,19 @@
326333
}
327334
}
328335
};
329-
336+
330337
var domainActionfilter = function(args) {
331338
var jsonObj = args.context.item;
332-
var allowedActions = [];
333-
if(isAdmin()) {
334-
allowedActions.push("create");
335-
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
339+
var allowedActions = [];
340+
if(isAdmin()) {
341+
allowedActions.push("create");
342+
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
336343
allowedActions.push("edit"); //merge updateResourceCount into edit
337-
allowedActions.push("delete");
338-
}
339-
}
340-
//allowedActions.push("updateResourceCount");
344+
allowedActions.push("delete");
345+
}
346+
}
347+
//allowedActions.push("updateResourceCount");
341348
return allowedActions;
342-
}
343-
349+
}
350+
344351
})(cloudStack, testData);

ui/scripts/ui/dialog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
var $formContainer = $('<div>').addClass('form-container');
2222
var $message = $('<span>').addClass('message').appendTo($formContainer).html(args.form.desc);
2323
var $form = $('<form>').appendTo($formContainer);
24+
var createLabel = args.form.createLabel;
2425

2526
// Render fields and events
2627
$.each(args.form.fields, function(key, field) {
@@ -297,7 +298,7 @@
297298
},
298299
buttons: [
299300
{
300-
text: 'Create',
301+
text: createLabel ? createLabel : 'Create',
301302
'class': 'ok',
302303
click: function() {
303304
if (!complete($formContainer)) { return false; }

0 commit comments

Comments
 (0)