Page MenuHomePhabricator

D18340.diff
No OneTemporary

D18340.diff

diff --git a/src/applications/differential/constants/DifferentialRevisionStatus.php b/src/applications/differential/constants/DifferentialRevisionStatus.php
--- a/src/applications/differential/constants/DifferentialRevisionStatus.php
+++ b/src/applications/differential/constants/DifferentialRevisionStatus.php
@@ -1,74 +1,130 @@
<?php
-/**
- * NOTE: you probably want {@class:ArcanistDifferentialRevisionStatus}.
- * This class just contains a mapping for color within the Differential
- * application.
- */
-
final class DifferentialRevisionStatus extends Phobject {
- const COLOR_STATUS_DEFAULT = 'bluegrey';
- const COLOR_STATUS_DARK = 'indigo';
- const COLOR_STATUS_BLUE = 'blue';
- const COLOR_STATUS_GREEN = 'green';
- const COLOR_STATUS_RED = 'red';
-
- public static function getRevisionStatusColor($status) {
- $default = self::COLOR_STATUS_DEFAULT;
-
- $map = array(
- ArcanistDifferentialRevisionStatus::NEEDS_REVIEW =>
- self::COLOR_STATUS_DEFAULT,
- ArcanistDifferentialRevisionStatus::NEEDS_REVISION =>
- self::COLOR_STATUS_RED,
- ArcanistDifferentialRevisionStatus::CHANGES_PLANNED =>
- self::COLOR_STATUS_RED,
- ArcanistDifferentialRevisionStatus::ACCEPTED =>
- self::COLOR_STATUS_GREEN,
- ArcanistDifferentialRevisionStatus::CLOSED =>
- self::COLOR_STATUS_DARK,
- ArcanistDifferentialRevisionStatus::ABANDONED =>
- self::COLOR_STATUS_DARK,
- ArcanistDifferentialRevisionStatus::IN_PREPARATION =>
- self::COLOR_STATUS_BLUE,
- );
- return idx($map, $status, $default);
+ const NEEDS_REVIEW = 'needs-review';
+ const NEEDS_REVISION = 'needs-revision';
+ const CHANGES_PLANNED = 'changes-planned';
+ const ACCEPTED = 'accepted';
+ const PUBLISHED = 'published';
+ const ABANDONED = 'abandoned';
+
+ private $key;
+ private $spec = array();
+
+ public function getIcon() {
+ return idx($this->spec, 'icon');
}
- public static function getRevisionStatusIcon($status) {
- $default = 'fa-square-o bluegrey';
-
- $map = array(
- ArcanistDifferentialRevisionStatus::NEEDS_REVIEW =>
- 'fa-square-o bluegrey',
- ArcanistDifferentialRevisionStatus::NEEDS_REVISION =>
- 'fa-refresh',
- ArcanistDifferentialRevisionStatus::CHANGES_PLANNED =>
- 'fa-headphones',
- ArcanistDifferentialRevisionStatus::ACCEPTED =>
- 'fa-check',
- ArcanistDifferentialRevisionStatus::CLOSED =>
- 'fa-check-square-o',
- ArcanistDifferentialRevisionStatus::ABANDONED =>
- 'fa-plane',
- ArcanistDifferentialRevisionStatus::IN_PREPARATION =>
- 'fa-question-circle',
- );
- return idx($map, $status, $default);
+ public function getIconColor() {
+ return idx($this->spec, 'color.icon', 'bluegrey');
+ }
+
+ public function getTagColor() {
+ return idx($this->spec, 'color.tag', 'bluegrey');
}
- public static function renderFullDescription($status) {
- $status_name =
- ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
+ public function getDisplayName() {
+ return idx($this->spec, 'name');
+ }
+
+ public function isClosedStatus() {
+ return idx($this->spec, 'closed');
+ }
- $tag = id(new PHUITagView())
- ->setName($status_name)
- ->setIcon(self::getRevisionStatusIcon($status))
- ->setColor(self::getRevisionStatusColor($status))
- ->setType(PHUITagView::TYPE_SHADE);
+ public function isAbandoned() {
+ return ($this->key === self::ABANDONED);
+ }
- return $tag;
+ public function isAccepted() {
+ return ($this->key === self::ACCEPTED);
+ }
+
+ public function isNeedsReview() {
+ return ($this->key === self::NEEDS_REVIEW);
+ }
+
+ public static function newForLegacyStatus($legacy_status) {
+ $result = new self();
+
+ $map = self::getMap();
+ foreach ($map as $key => $spec) {
+ if (!isset($spec['legacy'])) {
+ continue;
+ }
+
+ if ($spec['legacy'] != $legacy_status) {
+ continue;
+ }
+
+ $result->key = $key;
+ $result->spec = $spec;
+ break;
+ }
+
+ return $result;
+ }
+
+ private static function getMap() {
+ $close_on_accept = PhabricatorEnv::getEnvConfig(
+ 'differential.close-on-accept');
+
+ return array(
+ self::NEEDS_REVIEW => array(
+ 'name' => pht('Needs Review'),
+ 'legacy' => 0,
+ 'icon' => 'fa-code',
+ 'closed' => false,
+ 'color.icon' => 'grey',
+ 'color.tag' => 'bluegrey',
+ 'color.ansi' => 'magenta',
+ ),
+ self::NEEDS_REVISION => array(
+ 'name' => pht('Needs Revision'),
+ 'legacy' => 1,
+ 'icon' => 'fa-refresh',
+ 'closed' => false,
+ 'color.icon' => 'red',
+ 'color.tag' => 'red',
+ 'color.ansi' => 'red',
+ ),
+ self::CHANGES_PLANNED => array(
+ 'name' => pht('Changes Planned'),
+ 'legacy' => 5,
+ 'icon' => 'fa-headphones',
+ 'closed' => false,
+ 'color.icon' => 'red',
+ 'color.tag' => 'red',
+ 'color.ansi' => 'red',
+ ),
+ self::ACCEPTED => array(
+ 'name' => pht('Accepted'),
+ 'legacy' => 2,
+ 'icon' => 'fa-check',
+ 'closed' => $close_on_accept,
+ 'color.icon' => 'green',
+ 'color.tag' => 'green',
+ 'color.ansi' => 'green',
+ ),
+ self::PUBLISHED => array(
+ 'name' => pht('Closed'),
+ 'legacy' => 3,
+ 'icon' => 'fa-check-square-o',
+ 'closed' => true,
+ 'color.icon' => 'black',
+ 'color.tag' => 'indigo',
+ 'color.ansi' => 'cyan',
+ ),
+ self::ABANDONED => array(
+ 'name' => pht('Abandoned'),
+ 'legacy' => 4,
+ 'icon' => 'fa-plane',
+ 'closed' => true,
+ 'color.icon' => 'black',
+ 'color.tag' => 'indigo',
+ 'color.ansi' => null,
+ ),
+ );
}
public static function getClosedStatuses() {
@@ -100,8 +156,4 @@
);
}
- public static function isClosedStatus($status) {
- return in_array($status, self::getClosedStatuses());
- }
-
}
diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -508,11 +508,13 @@
->setPolicyObject($revision)
->setHeaderIcon('fa-cog');
- $status = $revision->getStatus();
- $status_name =
- DifferentialRevisionStatus::renderFullDescription($status);
+ $status_tag = id(new PHUITagView())
+ ->setName($revision->getStatusDisplayName())
+ ->setIcon($revision->getStatusIcon())
+ ->setColor($revision->getStatusIconColor())
+ ->setType(PHUITagView::TYPE_SHADE);
- $view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_name);
+ $view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_tag);
return $view;
}
diff --git a/src/applications/differential/phid/DifferentialRevisionPHIDType.php b/src/applications/differential/phid/DifferentialRevisionPHIDType.php
--- a/src/applications/differential/phid/DifferentialRevisionPHIDType.php
+++ b/src/applications/differential/phid/DifferentialRevisionPHIDType.php
@@ -48,8 +48,8 @@
$status = $revision->getStatus();
- $icon = DifferentialRevisionStatus::getRevisionStatusIcon($status);
- $color = DifferentialRevisionStatus::getRevisionStatusColor($status);
+ $icon = $revision->getStatusIcon($status);
+ $color = $revision->getStatusIconColor($status);
$name = $revision->getStatusDisplayName();
$handle
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -613,47 +613,36 @@
}
public function isClosed() {
- return DifferentialRevisionStatus::isClosedStatus($this->getStatus());
+ return $this->getStatusObject()->isClosedStatus();
}
public function isAbandoned() {
- $status_abandoned = ArcanistDifferentialRevisionStatus::ABANDONED;
- return ($this->getStatus() == $status_abandoned);
+ return $this->getStatusObject()->isAbandoned();
}
public function isAccepted() {
- $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
- return ($this->getStatus() == $status_accepted);
+ return $this->getStatusObject()->isAccepted();
}
public function isNeedsReview() {
- $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
- return ($this->getStatus() == $status_review);
+ return $this->getStatusObject()->isNeedsReview();
}
public function getStatusIcon() {
- $map = array(
- ArcanistDifferentialRevisionStatus::NEEDS_REVIEW
- => 'fa-code grey',
- ArcanistDifferentialRevisionStatus::NEEDS_REVISION
- => 'fa-refresh red',
- ArcanistDifferentialRevisionStatus::CHANGES_PLANNED
- => 'fa-headphones red',
- ArcanistDifferentialRevisionStatus::ACCEPTED
- => 'fa-check green',
- ArcanistDifferentialRevisionStatus::CLOSED
- => 'fa-check-square-o black',
- ArcanistDifferentialRevisionStatus::ABANDONED
- => 'fa-plane black',
- );
-
- return idx($map, $this->getStatus());
+ return $this->getStatusObject()->getIcon();
}
public function getStatusDisplayName() {
+ return $this->getStatusObject()->getDisplayName();
+ }
+
+ public function getStatusIconColor() {
+ return $this->getStatusObject()->getIconColor();
+ }
+
+ public function getStatusObject() {
$status = $this->getStatus();
- return ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
- $status);
+ return DifferentialRevisionStatus::newForLegacyStatus($status);
}
public function getFlag(PhabricatorUser $viewer) {
diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php
--- a/src/applications/differential/view/DifferentialRevisionListView.php
+++ b/src/applications/differential/view/DifferentialRevisionListView.php
@@ -145,8 +145,11 @@
$item->setDisabled(true);
}
+ $icon = $revision->getStatusIcon();
+ $color = $revision->getStatusIconColor();
+
$item->setStatusIcon(
- $revision->getStatusIcon(),
+ "{$icon} {$color}",
$revision->getStatusDisplayName());
$list->addItem($item);
diff --git a/src/infrastructure/graph/DifferentialRevisionGraph.php b/src/infrastructure/graph/DifferentialRevisionGraph.php
--- a/src/infrastructure/graph/DifferentialRevisionGraph.php
+++ b/src/infrastructure/graph/DifferentialRevisionGraph.php
@@ -27,10 +27,12 @@
if ($object) {
$status_icon = $object->getStatusIcon();
+ $status_color = $object->getStatusIconColor();
$status_name = $object->getStatusDisplayName();
$status = array(
- id(new PHUIIconView())->setIcon($status_icon),
+ id(new PHUIIconView())
+ ->setIcon($status_icon, $status_color),
' ',
$status_name,
);

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 22, 9:18 AM (4 h, 11 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7027700
Default Alt Text
D18340.diff (11 KB)

Event Timeline