mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +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:
parent
a635da68d4
commit
45c740ac98
6 changed files with 123 additions and 10 deletions
|
@ -33,16 +33,30 @@ final class DifferentialRevisionPHIDType extends PhabricatorPHIDType {
|
|||
$revision = $objects[$phid];
|
||||
|
||||
$title = $revision->getTitle();
|
||||
$id = $revision->getID();
|
||||
$status = $revision->getStatus();
|
||||
$monogram = $revision->getMonogram();
|
||||
$uri = $revision->getURI();
|
||||
|
||||
$handle->setName("D{$id}");
|
||||
$handle->setURI("/D{$id}");
|
||||
$handle->setFullName("D{$id}: {$title}");
|
||||
$handle
|
||||
->setName($monogram)
|
||||
->setURI($uri)
|
||||
->setFullName("{$monogram}: {$title}");
|
||||
|
||||
if ($revision->isClosed()) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,7 +397,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
|
||||
foreach ($commit_phids as $phid) {
|
||||
$revisions_commits[$phid] = $handles->renderHandle($phid)
|
||||
->setShowHovercard(true);
|
||||
->setShowHovercard(true)
|
||||
->setShowStateIcon(true);
|
||||
$revision_phid = key($drev_edges[$phid][$commit_drev]);
|
||||
$revision_handle = $handles->getHandleIfExists($revision_phid);
|
||||
if ($revision_handle) {
|
||||
|
@ -412,12 +413,16 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
}
|
||||
|
||||
foreach ($edge_types as $edge_type => $edge_name) {
|
||||
if ($edges[$edge_type]) {
|
||||
$edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type]));
|
||||
$view->addProperty(
|
||||
$edge_name,
|
||||
$edge_handles->renderList());
|
||||
if (!$edges[$edge_type]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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) {
|
||||
|
|
|
@ -31,6 +31,10 @@ final class PhabricatorObjectHandle
|
|||
private $tokenIcon;
|
||||
private $commandLineObjectName;
|
||||
|
||||
private $stateIcon;
|
||||
private $stateColor;
|
||||
private $stateName;
|
||||
|
||||
public function setIcon($icon) {
|
||||
$this->icon = $icon;
|
||||
return $this;
|
||||
|
@ -284,6 +288,54 @@ final class PhabricatorObjectHandle
|
|||
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) {
|
||||
return $this->renderLinkWithAttributes($name, array());
|
||||
|
|
|
@ -13,6 +13,7 @@ final class PHUIHandleListView
|
|||
private $handleList;
|
||||
private $asInline;
|
||||
private $asText;
|
||||
private $showStateIcons;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
|
@ -37,6 +38,15 @@ final class PHUIHandleListView
|
|||
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() {
|
||||
if ($this->getAsText()) {
|
||||
return null;
|
||||
|
@ -49,12 +59,19 @@ final class PHUIHandleListView
|
|||
|
||||
protected function getTagContent() {
|
||||
$list = $this->handleList;
|
||||
|
||||
$show_state_icons = $this->getShowStateIcons();
|
||||
|
||||
$items = array();
|
||||
foreach ($list as $handle) {
|
||||
$view = $list->renderHandle($handle->getPHID())
|
||||
->setShowHovercard(true)
|
||||
->setAsText($this->getAsText());
|
||||
|
||||
if ($show_state_icons) {
|
||||
$view->setShowStateIcon(true);
|
||||
}
|
||||
|
||||
$items[] = $view;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ final class PHUIHandleView
|
|||
private $asText;
|
||||
private $useShortName;
|
||||
private $showHovercard;
|
||||
private $showStateIcon;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
|
@ -48,6 +49,15 @@ final class PHUIHandleView
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setShowStateIcon($show_state_icon) {
|
||||
$this->showStateIcon = $show_state_icon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowStateIcon() {
|
||||
return $this->showStateIcon;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$handle = $this->handleList[$this->handlePHID];
|
||||
|
||||
|
@ -77,6 +87,11 @@ final class PHUIHandleView
|
|||
$link = $handle->renderLink($name);
|
||||
}
|
||||
|
||||
if ($this->showStateIcon) {
|
||||
$icon = $handle->renderStateIcon();
|
||||
$link = array($icon, ' ', $link);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,16 @@ final class PhabricatorRepositoryCommitPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setFullName($full_name);
|
||||
$handle->setURI($commit->getURI());
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue