mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
1da691113a
Summary: Currently, "Closed" and "Abandoned" are treated as "closed". I want to add a flag which treats "Accepted" as "Closed", too, for Asana and other companies who use an Asana-like workflow. The background here is that their workflow is a bit weird. They basically do audits, but have a lot of things which Diffusion doesn't do well right now. This one change makes Differential fit their workflow fairly well, even though it's an audit workflow. To prepare for this, normalize the definition of "closed" better. We have a few callsites which explicitly check for "ABANDONED || CLOSED", and normalizing this is cleaner anyway. Also delete the very old COMMITTED status, which has been obsolete for over a year. Test Plan: Browsed around most/all of the affected interfaces. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7653
99 lines
2.8 KiB
PHP
99 lines
2.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* NOTE: you probably want {@class:ArcanistDifferentialRevisionStatus}.
|
|
* This class just contains a mapping for color within the Differential
|
|
* application.
|
|
*/
|
|
|
|
final class DifferentialRevisionStatus {
|
|
|
|
const COLOR_STATUS_DEFAULT = 'status';
|
|
const COLOR_STATUS_DARK = 'status-dark';
|
|
const COLOR_STATUS_GREEN = 'status-green';
|
|
const COLOR_STATUS_RED = 'status-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::ACCEPTED =>
|
|
self::COLOR_STATUS_GREEN,
|
|
ArcanistDifferentialRevisionStatus::CLOSED =>
|
|
self::COLOR_STATUS_DARK,
|
|
ArcanistDifferentialRevisionStatus::ABANDONED =>
|
|
self::COLOR_STATUS_DARK,
|
|
);
|
|
return idx($map, $status, $default);
|
|
}
|
|
|
|
public static function getRevisionStatusIcon($status) {
|
|
$default = 'oh-open';
|
|
|
|
$map = array(
|
|
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW =>
|
|
'oh-open',
|
|
ArcanistDifferentialRevisionStatus::NEEDS_REVISION =>
|
|
'oh-open-red',
|
|
ArcanistDifferentialRevisionStatus::ACCEPTED =>
|
|
'oh-open-green',
|
|
ArcanistDifferentialRevisionStatus::CLOSED =>
|
|
'oh-closed-dark',
|
|
ArcanistDifferentialRevisionStatus::ABANDONED =>
|
|
'oh-closed-dark',
|
|
);
|
|
return idx($map, $status, $default);
|
|
}
|
|
|
|
public static function renderFullDescription($status) {
|
|
$color = self::getRevisionStatusColor($status);
|
|
$status_name =
|
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
|
|
|
|
$img = id(new PHUIIconView())
|
|
->setSpriteSheet(PHUIIconView::SPRITE_STATUS)
|
|
->setSpriteIcon(self::getRevisionStatusIcon($status));
|
|
|
|
$tag = phutil_tag(
|
|
'span',
|
|
array(
|
|
'class' => 'phui-header-'.$color.' plr',
|
|
),
|
|
array(
|
|
$img,
|
|
$status_name,
|
|
));
|
|
|
|
return $tag;
|
|
}
|
|
|
|
public static function getClosedStatuses() {
|
|
return array(
|
|
ArcanistDifferentialRevisionStatus::CLOSED,
|
|
ArcanistDifferentialRevisionStatus::ABANDONED,
|
|
);
|
|
}
|
|
|
|
public static function getOpenStatuses() {
|
|
return array_diff(self::getAllStatuses(), self::getClosedStatuses());
|
|
}
|
|
|
|
public static function getAllStatuses() {
|
|
return array(
|
|
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW,
|
|
ArcanistDifferentialRevisionStatus::NEEDS_REVISION,
|
|
ArcanistDifferentialRevisionStatus::ACCEPTED,
|
|
ArcanistDifferentialRevisionStatus::CLOSED,
|
|
ArcanistDifferentialRevisionStatus::ABANDONED,
|
|
);
|
|
}
|
|
|
|
public static function isClosedStatus($status) {
|
|
return in_array($status, self::getClosedStatuses());
|
|
}
|
|
|
|
}
|