1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Render revision and audit state icons in Maniphest

Summary:
Fixes T7076. This could probably use some tweaking but should get the basics in place.

This shows overall object state (e.g., "Needs Review"), not individual viewer state (e.g., "you need to review this"). After the bucketing changes it seems like we're mostly in a reasonable place on showing global state instead of viewer state. This makes the overall change much easier than it might otherwise have been.

Test Plan: {F2351867}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7076

Differential Revision: https://secure.phabricator.com/D17193
This commit is contained in:
epriestley 2017-01-12 12:25:36 -08:00
parent a635da68d4
commit 45c740ac98
6 changed files with 123 additions and 10 deletions

View file

@ -33,16 +33,30 @@ final class DifferentialRevisionPHIDType extends PhabricatorPHIDType {
$revision = $objects[$phid]; $revision = $objects[$phid];
$title = $revision->getTitle(); $title = $revision->getTitle();
$id = $revision->getID();
$status = $revision->getStatus(); $status = $revision->getStatus();
$monogram = $revision->getMonogram();
$uri = $revision->getURI();
$handle->setName("D{$id}"); $handle
$handle->setURI("/D{$id}"); ->setName($monogram)
$handle->setFullName("D{$id}: {$title}"); ->setURI($uri)
->setFullName("{$monogram}: {$title}");
if ($revision->isClosed()) { if ($revision->isClosed()) {
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
} }
$status = $revision->getStatus();
$icon = DifferentialRevisionStatus::getRevisionStatusIcon($status);
$color = DifferentialRevisionStatus::getRevisionStatusColor($status);
$name = ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
$status);
$handle
->setStateIcon($icon)
->setStateColor($color)
->setStateName($name);
} }
} }

View file

@ -397,7 +397,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
foreach ($commit_phids as $phid) { foreach ($commit_phids as $phid) {
$revisions_commits[$phid] = $handles->renderHandle($phid) $revisions_commits[$phid] = $handles->renderHandle($phid)
->setShowHovercard(true); ->setShowHovercard(true)
->setShowStateIcon(true);
$revision_phid = key($drev_edges[$phid][$commit_drev]); $revision_phid = key($drev_edges[$phid][$commit_drev]);
$revision_handle = $handles->getHandleIfExists($revision_phid); $revision_handle = $handles->getHandleIfExists($revision_phid);
if ($revision_handle) { if ($revision_handle) {
@ -412,12 +413,16 @@ final class ManiphestTaskDetailController extends ManiphestController {
} }
foreach ($edge_types as $edge_type => $edge_name) { foreach ($edge_types as $edge_type => $edge_name) {
if ($edges[$edge_type]) { if (!$edges[$edge_type]) {
$edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type])); continue;
$view->addProperty(
$edge_name,
$edge_handles->renderList());
} }
$edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type]));
$edge_list = $edge_handles->renderList()
->setShowStateIcons(true);
$view->addProperty($edge_name, $edge_list);
} }
if ($revisions_commits) { if ($revisions_commits) {

View file

@ -31,6 +31,10 @@ final class PhabricatorObjectHandle
private $tokenIcon; private $tokenIcon;
private $commandLineObjectName; private $commandLineObjectName;
private $stateIcon;
private $stateColor;
private $stateName;
public function setIcon($icon) { public function setIcon($icon) {
$this->icon = $icon; $this->icon = $icon;
return $this; return $this;
@ -284,6 +288,54 @@ final class PhabricatorObjectHandle
return $this->complete; return $this->complete;
} }
public function setStateIcon($state_icon) {
$this->stateIcon = $state_icon;
return $this;
}
public function getStateIcon() {
return $this->stateIcon;
}
public function setStateColor($state_color) {
$this->stateColor = $state_color;
return $this;
}
public function getStateColor() {
return $this->stateColor;
}
public function setStateName($state_name) {
$this->stateName = $state_name;
return $this;
}
public function getStateName() {
return $this->stateName;
}
public function renderStateIcon() {
$icon = $this->getStateIcon();
if ($icon === null) {
$icon = 'fa-question-circle-o';
}
$color = $this->getStateColor();
$name = $this->getStateName();
if ($name === null) {
$name = pht('Unknown');
}
return id(new PHUIIconView())
->setIcon($icon, $color)
->addSigil('has-tooltip')
->setMetadata(
array(
'tip' => $name,
));
}
public function renderLink($name = null) { public function renderLink($name = null) {
return $this->renderLinkWithAttributes($name, array()); return $this->renderLinkWithAttributes($name, array());

View file

@ -13,6 +13,7 @@ final class PHUIHandleListView
private $handleList; private $handleList;
private $asInline; private $asInline;
private $asText; private $asText;
private $showStateIcons;
public function setHandleList(PhabricatorHandleList $list) { public function setHandleList(PhabricatorHandleList $list) {
$this->handleList = $list; $this->handleList = $list;
@ -37,6 +38,15 @@ final class PHUIHandleListView
return $this->asText; return $this->asText;
} }
public function setShowStateIcons($show_state_icons) {
$this->showStateIcons = $show_state_icons;
return $this;
}
public function getShowStateIcons() {
return $this->showStateIcons;
}
protected function getTagName() { protected function getTagName() {
if ($this->getAsText()) { if ($this->getAsText()) {
return null; return null;
@ -49,12 +59,19 @@ final class PHUIHandleListView
protected function getTagContent() { protected function getTagContent() {
$list = $this->handleList; $list = $this->handleList;
$show_state_icons = $this->getShowStateIcons();
$items = array(); $items = array();
foreach ($list as $handle) { foreach ($list as $handle) {
$view = $list->renderHandle($handle->getPHID()) $view = $list->renderHandle($handle->getPHID())
->setShowHovercard(true) ->setShowHovercard(true)
->setAsText($this->getAsText()); ->setAsText($this->getAsText());
if ($show_state_icons) {
$view->setShowStateIcon(true);
}
$items[] = $view; $items[] = $view;
} }

View file

@ -17,6 +17,7 @@ final class PHUIHandleView
private $asText; private $asText;
private $useShortName; private $useShortName;
private $showHovercard; private $showHovercard;
private $showStateIcon;
public function setHandleList(PhabricatorHandleList $list) { public function setHandleList(PhabricatorHandleList $list) {
$this->handleList = $list; $this->handleList = $list;
@ -48,6 +49,15 @@ final class PHUIHandleView
return $this; return $this;
} }
public function setShowStateIcon($show_state_icon) {
$this->showStateIcon = $show_state_icon;
return $this;
}
public function getShowStateIcon() {
return $this->showStateIcon;
}
public function render() { public function render() {
$handle = $this->handleList[$this->handlePHID]; $handle = $this->handleList[$this->handlePHID];
@ -77,6 +87,11 @@ final class PHUIHandleView
$link = $handle->renderLink($name); $link = $handle->renderLink($name);
} }
if ($this->showStateIcon) {
$icon = $handle->renderStateIcon();
$link = array($icon, ' ', $link);
}
return $link; return $link;
} }

View file

@ -81,6 +81,16 @@ final class PhabricatorRepositoryCommitPHIDType extends PhabricatorPHIDType {
$handle->setFullName($full_name); $handle->setFullName($full_name);
$handle->setURI($commit->getURI()); $handle->setURI($commit->getURI());
$handle->setTimestamp($commit->getEpoch()); $handle->setTimestamp($commit->getEpoch());
$status = $commit->getAuditStatus();
$icon = PhabricatorAuditCommitStatusConstants::getStatusIcon($status);
$color = PhabricatorAuditCommitStatusConstants::getStatusColor($status);
$name = PhabricatorAuditCommitStatusConstants::getStatusName($status);
$handle
->setStateIcon($icon)
->setStateColor($color)
->setStateName($name);
} }
} }