mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
Differential - add unit and lint information to diff view
Summary: see title. Note that fields that use customs storage don't work because I didn't think it made sense to load a revision object to get that data. Further, we don't have a revision id at some points, so its not clear what does / does not work...? Also added a link to upsell this diff view as I had trouble finding it. Test Plan: viewed some diffs Reviewers: epriestley, vrana Reviewed By: epriestley CC: chad, aran, Korvin Maniphest Tasks: T2026 Differential Revision: https://secure.phabricator.com/D3962
This commit is contained in:
parent
d4a022be6f
commit
5a58d168ed
5 changed files with 118 additions and 5 deletions
|
@ -83,10 +83,38 @@ final class DifferentialDiffViewController extends DifferentialController {
|
|||
$top_panel = $action_panel;
|
||||
}
|
||||
|
||||
$arc_unit = id(new DifferentialDiffProperty())->loadOneWhere(
|
||||
'diffID = %d and name = %s',
|
||||
$this->id,
|
||||
'arc:unit');
|
||||
$props = id(new DifferentialDiffProperty())->loadAllWhere(
|
||||
'diffID = %d',
|
||||
$diff->getID());
|
||||
$props = mpull($props, 'getData', 'getName');
|
||||
|
||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||
->getFieldSpecifications();
|
||||
foreach ($aux_fields as $key => $aux_field) {
|
||||
if (!$aux_field->shouldAppearOnDiffView()) {
|
||||
unset($aux_fields[$key]);
|
||||
} else {
|
||||
$aux_field->setUser($this->getRequest()->getUser());
|
||||
}
|
||||
}
|
||||
|
||||
$dict = array();
|
||||
foreach ($aux_fields as $key => $aux_field) {
|
||||
$aux_field->setDiff($diff);
|
||||
$aux_field->setManualDiff($diff);
|
||||
$aux_field->setDiffProperties($props);
|
||||
$value = $aux_field->renderValueForDiffView();
|
||||
if (strlen($value)) {
|
||||
$label = rtrim($aux_field->renderLabelForDiffView(), ':');
|
||||
$dict[$label] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$action_panel = new AphrontHeadsupView();
|
||||
$action_panel->setProperties($dict);
|
||||
$action_panel->setHeader(pht('Diff Properties'));
|
||||
|
||||
$arc_unit = idx($props, 'arc:unit');
|
||||
if ($arc_unit) {
|
||||
$test_data = array($arc_unit->getName() => $arc_unit->getData());
|
||||
} else {
|
||||
|
@ -120,6 +148,7 @@ final class DifferentialDiffViewController extends DifferentialController {
|
|||
->appendChild(
|
||||
array(
|
||||
$top_panel->render(),
|
||||
$action_panel->render(),
|
||||
$table_of_contents->render(),
|
||||
$details->render(),
|
||||
)),
|
||||
|
|
|
@ -338,6 +338,63 @@ abstract class DifferentialFieldSpecification {
|
|||
}
|
||||
|
||||
|
||||
/* -( Extending the Diff View Interface )------------------------------ */
|
||||
|
||||
|
||||
/**
|
||||
* Determine if this field should appear on the diff detail view
|
||||
* interface. One use of this interface is to add purely informational
|
||||
* fields to the diff view, without any sort of backing storage.
|
||||
*
|
||||
* NOTE: These diffs are not necessarily attached yet to a revision.
|
||||
* As such, a field on the diff view can not rely on the existence of a
|
||||
* revision or use storage attached to the revision.
|
||||
*
|
||||
* If you return true from this method, you must implement the methods
|
||||
* @{method:renderLabelForDiffView} and
|
||||
* @{method:renderValueForDiffView}.
|
||||
*
|
||||
* @return bool True if this field should appear when viewing a diff.
|
||||
* @task view
|
||||
*/
|
||||
public function shouldAppearOnDiffView() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a string field label which will appear in the diff detail
|
||||
* table.
|
||||
*
|
||||
* You must implement this method if you return true from
|
||||
* @{method:shouldAppearOnDiffView}.
|
||||
*
|
||||
* @return string Label for field in revision detail view.
|
||||
* @task view
|
||||
*/
|
||||
public function renderLabelForDiffView() {
|
||||
throw new DifferentialFieldSpecificationIncompleteException($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a markup block representing the field for the diff detail
|
||||
* view. Note that you can return null to suppress display (for instance,
|
||||
* if the field shows related objects of some type and the revision doesn't
|
||||
* have any related objects).
|
||||
*
|
||||
* You must implement this method if you return true from
|
||||
* @{method:shouldAppearOnDiffView}.
|
||||
*
|
||||
* @return string|null Display markup for field value, or null to suppress
|
||||
* field rendering.
|
||||
* @task view
|
||||
*/
|
||||
public function renderValueForDiffView() {
|
||||
throw new DifferentialFieldSpecificationIncompleteException($this);
|
||||
}
|
||||
|
||||
|
||||
/* -( Extending the E-mail Interface )------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,17 @@
|
|||
final class DifferentialLintFieldSpecification
|
||||
extends DifferentialFieldSpecification {
|
||||
|
||||
public function shouldAppearOnDiffView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function renderLabelForDiffView() {
|
||||
return $this->renderLabelForRevisionView();
|
||||
}
|
||||
|
||||
public function renderValueForDiffView() {
|
||||
return $this->renderValueForRevisionView();
|
||||
}
|
||||
public function shouldAppearOnRevisionView() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
final class DifferentialUnitFieldSpecification
|
||||
extends DifferentialFieldSpecification {
|
||||
|
||||
public function shouldAppearOnDiffView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function renderLabelForDiffView() {
|
||||
return $this->renderLabelForRevisionView();
|
||||
}
|
||||
|
||||
public function renderValueForDiffView() {
|
||||
return $this->renderValueForRevisionView();
|
||||
}
|
||||
|
||||
public function shouldAppearOnRevisionView() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -155,10 +155,14 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
|||
}
|
||||
$last_base = $base;
|
||||
|
||||
$id_link = phutil_render_tag(
|
||||
'a',
|
||||
array('href' => '/differential/diff/'.$id.'/'),
|
||||
phutil_escape_html($id));
|
||||
$rows[] =
|
||||
'<tr'.$class.'>'.
|
||||
'<td class="revhistory-name">'.phutil_escape_html($name).'</td>'.
|
||||
'<td class="revhistory-id">'.phutil_escape_html($id).'</td>'.
|
||||
'<td class="revhistory-id">'.$id_link.'</td>'.
|
||||
'<td class="revhistory-base">'.phutil_escape_html($base).'</td>'.
|
||||
'<td class="revhistory-desc">'.phutil_escape_html($desc).'</td>'.
|
||||
'<td class="revhistory-age">'.$age.'</td>'.
|
||||
|
|
Loading…
Reference in a new issue