diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 3f4d388029..640c179500 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -987,6 +987,18 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/differential/behavior-show-all-comments.js', ), + 'javelin-behavior-differential-show-field-details' => + array( + 'uri' => '/res/1dfd4d10/rsrc/js/application/differential/behavior-show-field-details.js', + 'type' => 'js', + 'requires' => + array( + 0 => 'javelin-behavior', + 1 => 'javelin-stratcom', + 2 => 'javelin-dom', + ), + 'disk' => '/rsrc/js/application/differential/behavior-show-field-details.js', + ), 'javelin-behavior-differential-show-more' => array( 'uri' => '/res/e92c5272/rsrc/js/application/differential/behavior-show-more.js', diff --git a/src/applications/differential/field/specification/lint/DifferentialLintFieldSpecification.php b/src/applications/differential/field/specification/lint/DifferentialLintFieldSpecification.php index 872fa645ee..f6adf8fa9f 100644 --- a/src/applications/differential/field/specification/lint/DifferentialLintFieldSpecification.php +++ b/src/applications/differential/field/specification/lint/DifferentialLintFieldSpecification.php @@ -52,6 +52,8 @@ final class DifferentialLintFieldSpecification $lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff); $ldata = $this->getDiffProperty('arc:lint'); $ltail = null; + $have_details = false; + if ($ldata) { $ldata = igroup($ldata, 'path'); $lint_messages = array(); @@ -78,11 +80,20 @@ final class DifferentialLintFieldSpecification ), $line_link); } + if ($description != '') { + $have_details = true; + } $message_markup[] = hsprintf( '
  • '. '%s (%s) %s '. 'at line '.$line_link. - '

    %s

    '. + javelin_render_tag( + 'div', + array( + 'sigil' => 'differential-field-detail', + 'style' => 'display: none;', + ), + '%s'). '
  • ', $severity, ucwords($severity), @@ -106,6 +117,17 @@ final class DifferentialLintFieldSpecification ''; } + Javelin::initBehavior('differential-show-field-details'); + if ($have_details) { + $lmsg .= ' - '.javelin_render_tag( + 'a', + array( + 'href' => '#details', + 'sigil' => 'differential-show-field-details', + ), + 'Details'); + } + return $lstar.' '.$lmsg.$ltail; } } diff --git a/src/applications/differential/field/specification/lint/__init__.php b/src/applications/differential/field/specification/lint/__init__.php index 0041dfe5f7..e6a63dd8d7 100644 --- a/src/applications/differential/field/specification/lint/__init__.php +++ b/src/applications/differential/field/specification/lint/__init__.php @@ -8,6 +8,8 @@ phutil_require_module('phabricator', 'applications/differential/field/specification/base'); phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory'); +phutil_require_module('phabricator', 'infrastructure/javelin/api'); +phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/field/specification/unit/DifferentialUnitFieldSpecification.php b/src/applications/differential/field/specification/unit/DifferentialUnitFieldSpecification.php index 6a8e365e68..133e58f96a 100644 --- a/src/applications/differential/field/specification/unit/DifferentialUnitFieldSpecification.php +++ b/src/applications/differential/field/specification/unit/DifferentialUnitFieldSpecification.php @@ -53,6 +53,7 @@ final class DifferentialUnitFieldSpecification $postponed_count = 0; $udata = $this->getDiffProperty('arc:unit'); $utail = null; + $have_details = false; if ($udata) { $unit_messages = array(); @@ -66,6 +67,10 @@ final class DifferentialUnitFieldSpecification $userdata = phutil_utf8_shorten(idx($test, 'userdata'), 512); $userdata = $engine->markupText($userdata); + if ($userdata != '') { + $have_details = true; + } + $unit_messages[] = '
  • '. ''. @@ -73,7 +78,13 @@ final class DifferentialUnitFieldSpecification ''. ' '. phutil_escape_html($name). - '

    '.$userdata.'

    '. + javelin_render_tag( + 'div', + array( + 'sigil' => 'differential-field-detail', + 'style' => 'display: none;', + ), + $userdata). '
  • '; } else if ($result == DifferentialUnitTestResult::RESULT_POSTPONED) { @@ -98,6 +109,17 @@ final class DifferentialUnitFieldSpecification $umsg = $postponed_count.' '.$umsg; } + Javelin::initBehavior('differential-show-field-details'); + if ($have_details) { + $umsg .= ' - '.javelin_render_tag( + 'a', + array( + 'href' => '#details', + 'sigil' => 'differential-show-field-details', + ), + 'Details'); + } + return $ustar.' '.$umsg.$utail; } diff --git a/src/applications/differential/field/specification/unit/__init__.php b/src/applications/differential/field/specification/unit/__init__.php index 9c7b32e314..ad46eae787 100644 --- a/src/applications/differential/field/specification/unit/__init__.php +++ b/src/applications/differential/field/specification/unit/__init__.php @@ -11,6 +11,8 @@ phutil_require_module('phabricator', 'applications/differential/constants/unitte phutil_require_module('phabricator', 'applications/differential/field/specification/base'); phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory'); phutil_require_module('phabricator', 'applications/markup/engine'); +phutil_require_module('phabricator', 'infrastructure/javelin/api'); +phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/webroot/rsrc/js/application/differential/behavior-show-field-details.js b/webroot/rsrc/js/application/differential/behavior-show-field-details.js new file mode 100644 index 0000000000..af1abb26f8 --- /dev/null +++ b/webroot/rsrc/js/application/differential/behavior-show-field-details.js @@ -0,0 +1,31 @@ +/** + * @provides javelin-behavior-differential-show-field-details + * @requires javelin-behavior + * javelin-stratcom + * javelin-dom + */ + +JX.behavior('differential-show-field-details', function() { + + JX.Stratcom.listen( + 'click', + 'differential-show-field-details', + function(e) { + var node = e.getNode('tag:td'); + var data = JX.Stratcom.getData(node); + var details = JX.DOM.scry( + node, + 'div', + 'differential-field-detail'); + for (var i=0; i < details.length; i++) { + if (!data.detailsShown) { + JX.DOM.show(details[i]); + } else { + JX.DOM.hide(details[i]); + } + } + data.detailsShown = !data.detailsShown; + e.kill(); + }); + +});