Differential D18340 Diff 44159 src/applications/differential/constants/DifferentialRevisionStatus.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/constants/DifferentialRevisionStatus.php
| <?php | <?php | ||||
| /** | |||||
| * NOTE: you probably want {@class:ArcanistDifferentialRevisionStatus}. | |||||
| * This class just contains a mapping for color within the Differential | |||||
| * application. | |||||
| */ | |||||
| final class DifferentialRevisionStatus extends Phobject { | final class DifferentialRevisionStatus extends Phobject { | ||||
| const COLOR_STATUS_DEFAULT = 'bluegrey'; | const NEEDS_REVIEW = 'needs-review'; | ||||
| const COLOR_STATUS_DARK = 'indigo'; | const NEEDS_REVISION = 'needs-revision'; | ||||
| const COLOR_STATUS_BLUE = 'blue'; | const CHANGES_PLANNED = 'changes-planned'; | ||||
| const COLOR_STATUS_GREEN = 'green'; | const ACCEPTED = 'accepted'; | ||||
| const COLOR_STATUS_RED = 'red'; | const PUBLISHED = 'published'; | ||||
| const ABANDONED = 'abandoned'; | |||||
| public static function getRevisionStatusColor($status) { | |||||
| $default = self::COLOR_STATUS_DEFAULT; | private $key; | ||||
| private $spec = array(); | |||||
| $map = array( | |||||
| ArcanistDifferentialRevisionStatus::NEEDS_REVIEW => | public function getIcon() { | ||||
| self::COLOR_STATUS_DEFAULT, | return idx($this->spec, 'icon'); | ||||
| 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); | |||||
| } | } | ||||
| public static function getRevisionStatusIcon($status) { | public function getIconColor() { | ||||
| $default = 'fa-square-o bluegrey'; | return idx($this->spec, 'color.icon', 'bluegrey'); | ||||
| } | |||||
| $map = array( | public function getTagColor() { | ||||
| ArcanistDifferentialRevisionStatus::NEEDS_REVIEW => | return idx($this->spec, 'color.tag', 'bluegrey'); | ||||
| 'fa-square-o bluegrey', | } | ||||
| ArcanistDifferentialRevisionStatus::NEEDS_REVISION => | |||||
| 'fa-refresh', | public function getDisplayName() { | ||||
| ArcanistDifferentialRevisionStatus::CHANGES_PLANNED => | return idx($this->spec, 'name'); | ||||
| 'fa-headphones', | } | ||||
| ArcanistDifferentialRevisionStatus::ACCEPTED => | |||||
| 'fa-check', | public function isClosedStatus() { | ||||
| ArcanistDifferentialRevisionStatus::CLOSED => | return idx($this->spec, 'closed'); | ||||
| 'fa-check-square-o', | } | ||||
| ArcanistDifferentialRevisionStatus::ABANDONED => | |||||
| 'fa-plane', | public function isAbandoned() { | ||||
| ArcanistDifferentialRevisionStatus::IN_PREPARATION => | return ($this->key === self::ABANDONED); | ||||
| 'fa-question-circle', | } | ||||
| ); | |||||
| return idx($map, $status, $default); | public function isAccepted() { | ||||
| return ($this->key === self::ACCEPTED); | |||||
| } | } | ||||
| public static function renderFullDescription($status) { | public function isNeedsReview() { | ||||
| $status_name = | return ($this->key === self::NEEDS_REVIEW); | ||||
| ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status); | } | ||||
| 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; | |||||
| } | |||||
| $tag = id(new PHUITagView()) | private static function getMap() { | ||||
| ->setName($status_name) | $close_on_accept = PhabricatorEnv::getEnvConfig( | ||||
| ->setIcon(self::getRevisionStatusIcon($status)) | 'differential.close-on-accept'); | ||||
| ->setColor(self::getRevisionStatusColor($status)) | |||||
| ->setType(PHUITagView::TYPE_SHADE); | |||||
| return $tag; | 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() { | public static function getClosedStatuses() { | ||||
| $statuses = array( | $statuses = array( | ||||
| ArcanistDifferentialRevisionStatus::CLOSED, | ArcanistDifferentialRevisionStatus::CLOSED, | ||||
| ArcanistDifferentialRevisionStatus::ABANDONED, | ArcanistDifferentialRevisionStatus::ABANDONED, | ||||
| ); | ); | ||||
| Show All 15 Lines | return array( | ||||
| ArcanistDifferentialRevisionStatus::CHANGES_PLANNED, | ArcanistDifferentialRevisionStatus::CHANGES_PLANNED, | ||||
| ArcanistDifferentialRevisionStatus::ACCEPTED, | ArcanistDifferentialRevisionStatus::ACCEPTED, | ||||
| ArcanistDifferentialRevisionStatus::CLOSED, | ArcanistDifferentialRevisionStatus::CLOSED, | ||||
| ArcanistDifferentialRevisionStatus::ABANDONED, | ArcanistDifferentialRevisionStatus::ABANDONED, | ||||
| ArcanistDifferentialRevisionStatus::IN_PREPARATION, | ArcanistDifferentialRevisionStatus::IN_PREPARATION, | ||||
| ); | ); | ||||
| } | } | ||||
| public static function isClosedStatus($status) { | |||||
| return in_array($status, self::getClosedStatuses()); | |||||
| } | |||||
| } | } | ||||