mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Begin transitioning audits to modern (string) status constants, from legacy (integer) status constants
Summary: Ref T13195. See PHI851. Audits currently have older integer status constants. We've moved almost all object types away from this to string constants (which are better in basically every way, and particularly way better for exposing over the API). Commits/audits are currently accessible over the API and expose these constants via a "statuses" constraint. Prepare to move toward modern string constants by defining a new, more modern map of status details and defining the existing methods in terms of it. Test Plan: Browsed audits checking for icons/names/open-ness, saw no changes. This change should have no user-visible effects, as it just reorganizes code. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13195 Differential Revision: https://secure.phabricator.com/D19642
This commit is contained in:
parent
5a38b75f16
commit
ef26b06ca8
1 changed files with 68 additions and 64 deletions
|
@ -9,17 +9,16 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
|||
const FULLY_AUDITED = 4;
|
||||
const NEEDS_VERIFICATION = 5;
|
||||
|
||||
public static function getStatusNameMap() {
|
||||
$map = array(
|
||||
self::NONE => pht('No Audits'),
|
||||
self::NEEDS_AUDIT => pht('Audit Required'),
|
||||
self::CONCERN_RAISED => pht('Concern Raised'),
|
||||
self::NEEDS_VERIFICATION => pht('Needs Verification'),
|
||||
self::PARTIALLY_AUDITED => pht('Partially Audited'),
|
||||
self::FULLY_AUDITED => pht('Audited'),
|
||||
);
|
||||
const MODERN_NONE = 'none';
|
||||
const MODERN_NEEDS_AUDIT = 'needs-audit';
|
||||
const MODERN_CONCERN_RAISED = 'concern-raised';
|
||||
const MODERN_PARTIALLY_AUDITED = 'partially-audited';
|
||||
const MODERN_AUDITED = 'audited';
|
||||
const MODERN_NEEDS_VERIFICATION = 'needs-verification';
|
||||
|
||||
return $map;
|
||||
public static function getStatusNameMap() {
|
||||
$map = self::getMap();
|
||||
return ipull($map, 'name', 'legacy');
|
||||
}
|
||||
|
||||
public static function getStatusName($code) {
|
||||
|
@ -27,66 +26,71 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
|||
}
|
||||
|
||||
public static function getOpenStatusConstants() {
|
||||
return array(
|
||||
self::CONCERN_RAISED,
|
||||
self::NEEDS_AUDIT,
|
||||
self::NEEDS_VERIFICATION,
|
||||
self::PARTIALLY_AUDITED,
|
||||
);
|
||||
$constants = array();
|
||||
foreach (self::getMap() as $map) {
|
||||
if (!$map['closed']) {
|
||||
$constants[] = $map['legacy'];
|
||||
}
|
||||
}
|
||||
return $constants;
|
||||
}
|
||||
|
||||
public static function getStatusColor($code) {
|
||||
switch ($code) {
|
||||
case self::CONCERN_RAISED:
|
||||
$color = 'red';
|
||||
break;
|
||||
case self::NEEDS_AUDIT:
|
||||
$color = 'orange';
|
||||
break;
|
||||
case self::PARTIALLY_AUDITED:
|
||||
$color = 'yellow';
|
||||
break;
|
||||
case self::FULLY_AUDITED:
|
||||
$color = 'green';
|
||||
break;
|
||||
case self::NONE:
|
||||
$color = 'bluegrey';
|
||||
break;
|
||||
case self::NEEDS_VERIFICATION:
|
||||
$color = 'indigo';
|
||||
break;
|
||||
default:
|
||||
$color = null;
|
||||
break;
|
||||
}
|
||||
return $color;
|
||||
$map = self::getMap();
|
||||
$map = ipull($map, 'color', 'legacy');
|
||||
return idx($map, $code);
|
||||
}
|
||||
|
||||
public static function getStatusIcon($code) {
|
||||
switch ($code) {
|
||||
case self::CONCERN_RAISED:
|
||||
$icon = 'fa-times-circle';
|
||||
break;
|
||||
case self::NEEDS_AUDIT:
|
||||
$icon = 'fa-exclamation-circle';
|
||||
break;
|
||||
case self::PARTIALLY_AUDITED:
|
||||
$icon = 'fa-check-circle-o';
|
||||
break;
|
||||
case self::FULLY_AUDITED:
|
||||
$icon = 'fa-check-circle';
|
||||
break;
|
||||
case self::NONE:
|
||||
$icon = 'fa-check';
|
||||
break;
|
||||
case self::NEEDS_VERIFICATION:
|
||||
$icon = 'fa-refresh';
|
||||
break;
|
||||
default:
|
||||
$icon = null;
|
||||
break;
|
||||
}
|
||||
return $icon;
|
||||
$map = self::getMap();
|
||||
$map = ipull($map, 'icon', 'legacy');
|
||||
return idx($map, $code);
|
||||
}
|
||||
|
||||
private static function getMap() {
|
||||
return array(
|
||||
self::MODERN_NONE => array(
|
||||
'name' => pht('No Audits'),
|
||||
'legacy' => self::NONE,
|
||||
'icon' => 'fa-check',
|
||||
'color' => 'bluegrey',
|
||||
'closed' => true,
|
||||
),
|
||||
self::MODERN_NEEDS_AUDIT => array(
|
||||
'name' => pht('Audit Required'),
|
||||
'legacy' => self::NEEDS_AUDIT,
|
||||
'icon' => 'fa-exclamation-circle',
|
||||
'color' => 'orange',
|
||||
'closed' => false,
|
||||
),
|
||||
self::MODERN_CONCERN_RAISED => array(
|
||||
'name' => pht('Concern Raised'),
|
||||
'legacy' => self::CONCERN_RAISED,
|
||||
'icon' => 'fa-times-circle',
|
||||
'color' => 'red',
|
||||
'closed' => false,
|
||||
),
|
||||
self::MODERN_PARTIALLY_AUDITED => array(
|
||||
'name' => pht('Partially Audited'),
|
||||
'legacy' => self::PARTIALLY_AUDITED,
|
||||
'icon' => 'fa-check-circle-o',
|
||||
'color' => 'yellow',
|
||||
'closed' => false,
|
||||
),
|
||||
self::MODERN_AUDITED => array(
|
||||
'name' => pht('Audited'),
|
||||
'legacy' => self::FULLY_AUDITED,
|
||||
'icon' => 'fa-check-circle',
|
||||
'color' => 'green',
|
||||
'closed' => true,
|
||||
),
|
||||
self::MODERN_NEEDS_VERIFICATION => array(
|
||||
'name' => pht('Needs Verification'),
|
||||
'legacy' => self::NEEDS_VERIFICATION,
|
||||
'icon' => 'fa-refresh',
|
||||
'color' => 'indigo',
|
||||
'closed' => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue