Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit a6c4c8d

Browse files
committed
Preserve modals in case of app install errors (bug 708362)
1 parent 7aaf0ae commit a6c4c8d

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

media/css/impala/apps.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,14 @@
9898
#myappsTrustedIFrame {
9999
z-index: 2002 !important;
100100
}
101+
102+
.inner-modal-error {
103+
h2, p {
104+
color: @error-red;
105+
}
106+
p {
107+
padding-bottom: 0.5em;
108+
border-bottom: 1px solid @light-gray;
109+
margin-bottom: 1em;
110+
}
111+
}

media/js/zamboni/apps.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,35 @@ exports.install = function(manifestUrl, opt) {
8484
};
8585

8686
exports._showError = function(errSummary, errMessage, opt) {
87-
var $errTarget = $('<a>');
87+
var $errTarget = $('<a>'),
88+
$visibleModals,
89+
$innerErr,
90+
win = opt.window || window;
8891
if (opt.mobile) {
89-
var $errBox = $('.apps-error-msg h2', opt.domContext);
9092
$('.apps-error-msg h2', opt.domContext).text(errSummary);
9193
$('.apps-error-msg p', opt.domContext).text(errMessage);
9294
$('.apps-error-msg', opt.domContext).show();
9395
$(opt.domContext).trigger('mobile_error_shown.apps');
9496
} else {
95-
var $modal = $('.apps-error-msg:first', opt.domContext).modal(
96-
$errTarget,
97-
{width: '400px', close: true,
98-
callback: opt.errModalCallback
99-
});
100-
$errTarget.trigger('click'); // show the modal
101-
$('.apps-error-msg h2', opt.domContext).text(errSummary);
102-
$('.apps-error-msg p', opt.domContext).text(errMessage);
97+
$visibleModals = $('.modal:visible', opt.domContext);
98+
if ($visibleModals.length) {
99+
$innerErr = $('.inner-modal-error', $visibleModals);
100+
if (!$innerErr.length) {
101+
$innerErr = $('<div class="inner-modal-error"><h2></h2><p></p></div>');
102+
$('.modal-inside', $visibleModals).prepend($innerErr);
103+
}
104+
$('h2', $innerErr).text(errSummary);
105+
$('p', $innerErr).text(errMessage);
106+
$(win).trigger('resize');
107+
} else {
108+
// Create a new modal:
109+
$('.apps-error-msg:first', opt.domContext).modal($errTarget,
110+
{width: '400px', close: true,
111+
callback: opt.errModalCallback});
112+
$errTarget.trigger('click'); // show the modal
113+
$('.apps-error-msg h2', opt.domContext).text(errSummary);
114+
$('.apps-error-msg p', opt.domContext).text(errMessage);
115+
}
103116
$(opt.domContext).trigger('error_shown.apps');
104117
}
105118

media/js/zamboni/tests/apps_tests.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $(document).ready(function(){
44
module('apps errors', {
55
setup: function() {
66
this.sandbox = tests.createSandbox('#apps-error-msg');
7+
$('.modal', this.sandbox).hide();
78
},
89
teardown: function() {
910
this.sandbox.remove();
@@ -88,9 +89,27 @@ test('test successful app install', function() {
8889
});
8990

9091

92+
asyncTest('test append to visible modal', function() {
93+
var $sb = $(this.sandbox);
94+
// Simulate a popup:
95+
$sb.append('<div class="existing modal"><div class="modal-inside"></div></div>');
96+
$sb.one('error_shown.apps', function() {
97+
equals($('.existing .inner-modal-error h2', $sb).text(),
98+
'App installation not allowed');
99+
equals($('.existing .inner-modal-error p', $sb).text(),
100+
'detailed message');
101+
start();
102+
});
103+
this.installAppWithError('http://nice.com/nice.webapp',
104+
{code: 'permissionDenied',
105+
message: "detailed message"});
106+
});
107+
108+
91109
module('apps as wrapper', {
92110
setup: function() {
93111
this.sandbox = tests.createSandbox('#apps-error-msg');
112+
$('.modal', this.sandbox).hide();
94113
},
95114
teardown: function() {
96115
this.sandbox.remove();

0 commit comments

Comments
 (0)