1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Remove field selector on Diff view and Revision List View

Summary:
Ref T2222. This has some minor functionality regressions:

  - The plain diff page no longer shows unit/test status. I want to give diffs separate custom fields for this.
  - It was technically possible to shove more data on the list view, although this doensn't affect the default config.

Test Plan: Looked at list view, diff detail view. Grepped for changes.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

Differential Revision: https://secure.phabricator.com/D8470
This commit is contained in:
epriestley 2014-03-09 11:46:13 -07:00
parent 48059265f3
commit 3910d0d5e1
6 changed files with 25 additions and 93 deletions

View file

@ -94,35 +94,10 @@ final class DifferentialDiffViewController extends DifferentialController {
$diff->getID()); $diff->getID());
$props = mpull($props, 'getData', 'getName'); $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;
}
}
$property_head = id(new PHUIHeaderView()) $property_head = id(new PHUIHeaderView())
->setHeader(pht('Properties')); ->setHeader(pht('Properties'));
$property_view = new PHUIPropertyListView(); $property_view = new PHUIPropertyListView();
foreach ($dict as $key => $value) {
$property_view->addProperty($key, $value);
}
$changesets = $diff->loadChangesets(); $changesets = $diff->loadChangesets();
$changesets = msort($changesets, 'getSortKey'); $changesets = msort($changesets, 'getSortKey');

View file

@ -30,8 +30,7 @@ final class DifferentialRevisionListController extends DifferentialController
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$template = id(new DifferentialRevisionListView()) $template = id(new DifferentialRevisionListView())
->setUser($user) ->setUser($user);
->setFields(DifferentialRevisionListView::getDefaultFields($user));
$views = array(); $views = array();
if ($query->getQueryKey() == 'active') { if ($query->getQueryKey() == 'active') {

View file

@ -766,7 +766,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
$view = id(new DifferentialRevisionListView()) $view = id(new DifferentialRevisionListView())
->setRevisions($revisions) ->setRevisions($revisions)
->setFields(DifferentialRevisionListView::getDefaultFields($user))
->setUser($user); ->setUser($user);
$phids = $view->getRequiredHandlePHIDs(); $phids = $view->getRequiredHandlePHIDs();

View file

@ -7,7 +7,6 @@ final class DifferentialRevisionListView extends AphrontView {
private $revisions; private $revisions;
private $handles; private $handles;
private $fields;
private $highlightAge; private $highlightAge;
private $header; private $header;
private $noDataString; private $noDataString;
@ -22,12 +21,6 @@ final class DifferentialRevisionListView extends AphrontView {
return $this; return $this;
} }
public function setFields(array $fields) {
assert_instances_of($fields, 'DifferentialFieldSpecification');
$this->fields = $fields;
return $this;
}
public function setRevisions(array $revisions) { public function setRevisions(array $revisions) {
assert_instances_of($revisions, 'DifferentialRevision'); assert_instances_of($revisions, 'DifferentialRevision');
$this->revisions = $revisions; $this->revisions = $revisions;
@ -41,10 +34,12 @@ final class DifferentialRevisionListView extends AphrontView {
public function getRequiredHandlePHIDs() { public function getRequiredHandlePHIDs() {
$phids = array(); $phids = array();
foreach ($this->fields as $field) {
foreach ($this->revisions as $revision) { foreach ($this->revisions as $revision) {
$phids[] = $field->getRequiredHandlePHIDsForRevisionList($revision); $phids[] = array($revision->getAuthorPHID());
}
// TODO: Switch to getReviewerStatus(), but not all callers pass us
// revisions with this data loaded.
$phids[] = $revision->getReviewers();
} }
return array_mergev($phids); return array_mergev($phids);
} }
@ -79,10 +74,6 @@ final class DifferentialRevisionListView extends AphrontView {
$this->initBehavior('phabricator-tooltips', array()); $this->initBehavior('phabricator-tooltips', array());
$this->requireResource('aphront-tooltip-css'); $this->requireResource('aphront-tooltip-css');
foreach ($this->fields as $field) {
$field->setHandles($this->handles);
}
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();
$list->setCards(true); $list->setCards(true);
@ -90,7 +81,6 @@ final class DifferentialRevisionListView extends AphrontView {
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setUser($user); ->setUser($user);
$rev_fields = array();
$icons = array(); $icons = array();
$phid = $revision->getPHID(); $phid = $revision->getPHID();
@ -116,21 +106,12 @@ final class DifferentialRevisionListView extends AphrontView {
$this->highlightAge && $this->highlightAge &&
!$revision->isClosed(); !$revision->isClosed();
$object_age = PHUIObjectItemView::AGE_FRESH;
foreach ($this->fields as $field) {
if ($show_age) {
if ($field instanceof DifferentialDateModifiedFieldSpecification) {
if ($stale && $modified < $stale) { if ($stale && $modified < $stale) {
$object_age = PHUIObjectItemView::AGE_OLD; $object_age = PHUIObjectItemView::AGE_OLD;
} else if ($fresh && $modified < $fresh) { } else if ($fresh && $modified < $fresh) {
$object_age = PHUIObjectItemView::AGE_STALE; $object_age = PHUIObjectItemView::AGE_STALE;
} } else {
} $object_age = PHUIObjectItemView::AGE_FRESH;
}
$rev_header = $field->renderHeaderForRevisionList();
$rev_fields[$rev_header] = $field
->renderValueForRevisionList($revision);
} }
$status_name = $status_name =
@ -163,20 +144,19 @@ final class DifferentialRevisionListView extends AphrontView {
$author_handle = $this->handles[$revision->getAuthorPHID()]; $author_handle = $this->handles[$revision->getAuthorPHID()];
$item->addByline(pht('Author: %s', $author_handle->renderLink())); $item->addByline(pht('Author: %s', $author_handle->renderLink()));
// Reviewers $reviewers = array();
$item->addAttribute(pht('Reviewers: %s', $rev_fields['Reviewers'])); // TODO: As above, this should be based on `getReviewerStatus()`.
foreach ($revision->getReviewers() as $reviewer) {
$item->setEpoch($revision->getDateModified(), $object_age); $reviewers[] = $this->handles[$reviewer]->renderLink();
// First remove the fields we already have
$count = 7;
$rev_fields = array_slice($rev_fields, $count);
// Then add each one of them
// TODO: Add render-to-foot-icon support
foreach ($rev_fields as $header => $field) {
$item->addAttribute(pht('%s: %s', $header, $field));
} }
if (!$reviewers) {
$reviewers = phutil_tag('em', array(), pht('None'));
} else {
$reviewers = phutil_implode_html(', ', $reviewers);
}
$item->addAttribute(pht('Reviewers: %s', $reviewers));
$item->setEpoch($revision->getDateModified(), $object_age);
switch ($status) { switch ($status) {
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
@ -205,23 +185,4 @@ final class DifferentialRevisionListView extends AphrontView {
return $list; return $list;
} }
public static function getDefaultFields(PhabricatorUser $user) {
$selector = DifferentialFieldSelector::newSelector();
$fields = $selector->getFieldSpecifications();
foreach ($fields as $key => $field) {
$field->setUser($user);
if (!$field->shouldAppearOnRevisionList()) {
unset($fields[$key]);
}
}
if (!$fields) {
throw new Exception(
"Phabricator configuration has no fields that appear on the list ".
"interface!");
}
return $selector->sortFieldsForRevisionList($fields);
}
} }

View file

@ -211,7 +211,6 @@ abstract class DiffusionBrowseController extends DiffusionController {
$view = id(new DifferentialRevisionListView()) $view = id(new DifferentialRevisionListView())
->setRevisions($revisions) ->setRevisions($revisions)
->setFields(DifferentialRevisionListView::getDefaultFields($user))
->setUser($user); ->setUser($user);
$phids = $view->getRequiredHandlePHIDs(); $phids = $view->getRequiredHandlePHIDs();

View file

@ -219,7 +219,6 @@ final class PhabricatorHomeMainController
$revision_view = id(new DifferentialRevisionListView()) $revision_view = id(new DifferentialRevisionListView())
->setHighlightAge(true) ->setHighlightAge(true)
->setRevisions(array_merge($blocking, $active)) ->setRevisions(array_merge($blocking, $active))
->setFields(DifferentialRevisionListView::getDefaultFields($user))
->setUser($user); ->setUser($user);
$phids = array_merge( $phids = array_merge(
array($user_phid), array($user_phid),