From fb738ea6de6bbcc7480705d53995cd8ec88e6f40 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Mon, 23 Dec 2013 22:28:47 +0100 Subject: [PATCH] [JENKINS-20772] Only show error message in dialog This change removes the superfluous UI elements around the error message if possible. Otherwise, fall back to existing behavior of adding entire page to iframe. (cherry picked from commit b856cc2434b33ed7fec3492223e141747369bba3) --- core/src/main/resources/jenkins/model/Jenkins/oops.jelly | 2 ++ core/src/main/resources/lib/form/apply/apply.js | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/jenkins/model/Jenkins/oops.jelly b/core/src/main/resources/jenkins/model/Jenkins/oops.jelly index 2a7e0910d2b8..5380997667dc 100644 --- a/core/src/main/resources/jenkins/model/Jenkins/oops.jelly +++ b/core/src/main/resources/jenkins/model/Jenkins/oops.jelly @@ -41,6 +41,7 @@ THE SOFTWARE.

${%Oops!}

+

${%problemHappened} ${%checkJIRA} @@ -51,6 +52,7 @@ THE SOFTWARE.

${%Stack trace}

${h.printThrowable(request.getAttribute('javax.servlet.error.exception'))}
+
\ No newline at end of file diff --git a/core/src/main/resources/lib/form/apply/apply.js b/core/src/main/resources/lib/form/apply/apply.js index 35c7433ad04a..be6ddf57ac46 100644 --- a/core/src/main/resources/lib/form/apply/apply.js +++ b/core/src/main/resources/lib/form/apply/apply.js @@ -12,7 +12,7 @@ Behaviour.specify("INPUT.apply-button", 'apply', 0, function (e) { }); responseDialog.setHeader("Error"); - responseDialog.setBody("
"); + responseDialog.setBody("
"); responseDialog.render(document.body); var target; // iframe @@ -42,7 +42,12 @@ Behaviour.specify("INPUT.apply-button", 'apply', 0, function (e) { } else { // otherwise this is possibly an error from the server, so we need to render the whole content. var doc = target.contentDocument || target.contentWindow.document; - $(containerId).appendChild(doc.getElementsByTagName('body')[0]); + var error = doc.getElementById('error-description'); + if (!error) { + // fallback if it's not a regular error dialog from oops.jelly: use the entire body + error = doc.getElementsByTagName('body')[0]; + } + $(containerId).appendChild(error); var r = YAHOO.util.Dom.getClientRegion(); responseDialog.cfg.setProperty("width",r.width*3/4+"px"); responseDialog.cfg.setProperty("height",r.height*3/4+"px");