launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06570
[Merge] lp:~rvb/maas/maas-bug-944528 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/maas-bug-944528 into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #944528 in MaaS: "No confirmation on MaaS key removal"
https://bugs.launchpad.net/maas/+bug/944528
For more details, see:
https://code.launchpad.net/~rvb/maas/maas-bug-944528/+merge/95548
This branch adds a confirmation JS popup when deleting an API key.
--
https://code.launchpad.net/~rvb/maas/maas-bug-944528/+merge/95548
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-bug-944528 into lp:maas.
=== modified file 'src/maasserver/static/js/prefs.js'
--- src/maasserver/static/js/prefs.js 2012-02-24 17:37:01 +0000
+++ src/maasserver/static/js/prefs.js 2012-03-02 12:22:22 +0000
@@ -50,12 +50,18 @@
.append(this.status_node);
},
+ confirm: function(message) {
+ return confirm(message);
+ },
+
bindDeleteRow: function(row) {
var self = this;
var delete_link = row.one('a.delete-link');
delete_link.on('click', function(e) {
e.preventDefault();
- self.deleteToken(row);
+ if (self.confirm("Are you sure you want to delete this key?")) {
+ self.deleteToken(row);
+ }
});
},
=== modified file 'src/maasserver/static/js/tests/test_prefs.js'
--- src/maasserver/static/js/tests/test_prefs.js 2012-02-24 17:37:01 +0000
+++ src/maasserver/static/js/tests/test_prefs.js 2012-03-02 12:22:22 +0000
@@ -17,10 +17,19 @@
setUp: function() {
Y.one("body").append(Y.Node.create(api_template));
- },
+ },
+
+ createWidget: function() {
+ var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ // Monkey patch widget.confirm.
+ widget.confirm = function(message) {
+ return true;
+ };
+ return widget;
+ },
testInitializer: function() {
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
// The "create a new API token" has been created.
@@ -37,7 +46,7 @@
},
test_nb_tokens: function() {
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
Y.Assert.areEqual(2, widget.get('nb_tokens'));
@@ -55,7 +64,7 @@
cfg.data);
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var link = widget.get('srcNode').one('.delete-link');
@@ -72,7 +81,7 @@
cfg.on.failure(3);
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var link = widget.get('srcNode').one('.delete-link');
@@ -93,7 +102,7 @@
cfg.on.success(3);
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var link = widget.get('srcNode').one('.delete-link');
@@ -106,7 +115,7 @@
},
test_createTokenFromKeys: function() {
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
var token = widget.createTokenFromKeys(
'consumer_key', 'token_key', 'token_secret');
@@ -126,7 +135,7 @@
cfg.data);
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var create_link = widget.get('srcNode').one('#create_token');
@@ -143,7 +152,7 @@
cfg.on.failure(3);
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var create_link = widget.get('srcNode').one('#create_token');
@@ -169,7 +178,7 @@
cfg.on.success(3, {response: Y.JSON.stringify(response)});
};
this.mockIO(mockXhr, module);
- var widget = new module.TokenWidget({srcNode: '#placeholder'});
+ var widget = this.createWidget();
this.addCleanup(function() { widget.destroy(); });
widget.render();
var create_link = widget.get('srcNode').one('#create_token');