Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php b/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
index 1f6164733a..aef3c7e224 100644
--- a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
+++ b/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
@@ -1,34 +1,53 @@
<?php
final class PhabricatorAuditCommitStatusConstants {
const NONE = 0;
const NEEDS_AUDIT = 1;
const CONCERN_RAISED = 2;
const PARTIALLY_AUDITED = 3;
const FULLY_AUDITED = 4;
public static function getStatusNameMap() {
$map = array(
self::NONE => pht('None'),
self::NEEDS_AUDIT => pht('Audit Required'),
self::CONCERN_RAISED => pht('Concern Raised'),
self::PARTIALLY_AUDITED => pht('Partially Audited'),
self::FULLY_AUDITED => pht('Audited'),
);
return $map;
}
public static function getStatusName($code) {
return idx(self::getStatusNameMap(), $code, 'Unknown');
}
public static function getOpenStatusConstants() {
return array(
self::CONCERN_RAISED,
self::NEEDS_AUDIT,
);
}
+ public static function getStatusColor($code) {
+ switch ($code) {
+ case self::CONCERN_RAISED:
+ $color = 'red';
+ break;
+ case self::NEEDS_AUDIT:
+ case self::PARTIALLY_AUDITED:
+ $color = 'orange';
+ break;
+ case self::FULLY_AUDITED:
+ $color = 'green';
+ break;
+ default:
+ $color = null;
+ break;
+ }
+ return $color;
+ }
+
}
diff --git a/src/applications/audit/constants/PhabricatorAuditStatusConstants.php b/src/applications/audit/constants/PhabricatorAuditStatusConstants.php
index 8d8ce45e68..f80760d614 100644
--- a/src/applications/audit/constants/PhabricatorAuditStatusConstants.php
+++ b/src/applications/audit/constants/PhabricatorAuditStatusConstants.php
@@ -1,62 +1,65 @@
<?php
final class PhabricatorAuditStatusConstants {
const NONE = '';
const AUDIT_NOT_REQUIRED = 'audit-not-required';
const AUDIT_REQUIRED = 'audit-required';
const CONCERNED = 'concerned';
const ACCEPTED = 'accepted';
const AUDIT_REQUESTED = 'requested';
const RESIGNED = 'resigned';
const CLOSED = 'closed';
const CC = 'cc';
public static function getStatusNameMap() {
$map = array(
self::NONE => pht('Not Applicable'),
self::AUDIT_NOT_REQUIRED => pht('Audit Not Required'),
self::AUDIT_REQUIRED => pht('Audit Required'),
self::CONCERNED => pht('Concern Raised'),
self::ACCEPTED => pht('Accepted'),
self::AUDIT_REQUESTED => pht('Audit Requested'),
self::RESIGNED => pht('Resigned'),
self::CLOSED => pht('Closed'),
self::CC => pht("Was CC'd"),
);
return $map;
}
public static function getStatusName($code) {
return idx(self::getStatusNameMap(), $code, pht('Unknown'));
}
public static function getStatusColor($code) {
switch ($code) {
case self::CONCERNED:
$color = 'red';
break;
case self::AUDIT_REQUIRED:
$color = 'orange';
break;
+ case self::ACCEPTED:
+ $color = 'green';
+ break;
default:
$color = null;
break;
}
return $color;
}
public static function getOpenStatusConstants() {
return array(
self::AUDIT_REQUIRED,
self::AUDIT_REQUESTED,
self::CONCERNED,
);
}
public static function isOpenStatus($status) {
return in_array($status, self::getOpenStatusConstants());
}
}
diff --git a/src/applications/audit/view/PhabricatorAuditCommitListView.php b/src/applications/audit/view/PhabricatorAuditCommitListView.php
index cc3cc0e1ea..f654efcbe2 100644
--- a/src/applications/audit/view/PhabricatorAuditCommitListView.php
+++ b/src/applications/audit/view/PhabricatorAuditCommitListView.php
@@ -1,119 +1,123 @@
<?php
final class PhabricatorAuditCommitListView extends AphrontView {
private $commits;
private $handles;
private $noDataString;
public function setNoDataString($no_data_string) {
$this->noDataString = $no_data_string;
return $this;
}
public function setCommits(array $commits) {
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
$this->commits = mpull($commits, null, 'getPHID');
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function setAuthorityPHIDs(array $phids) {
$this->authorityPHIDs = $phids;
return $this;
}
public function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->commits as $commit) {
if ($commit->getAuthorPHID()) {
$phids[$commit->getAuthorPHID()] = true;
}
$phids[$commit->getPHID()] = true;
if ($commit->getAudits()) {
foreach ($commit->getAudits() as $audit) {
$phids[$audit->getActorPHID()] = true;
}
}
}
return array_keys($phids);
}
private function getHandle($phid) {
$handle = idx($this->handles, $phid);
if (!$handle) {
throw new Exception("No handle for '{$phid}'!");
}
return $handle;
}
private function getCommitDescription($phid) {
if ($this->commits === null) {
return null;
}
$commit = idx($this->commits, $phid);
if (!$commit) {
return null;
}
return $commit->getCommitData()->getSummary();
}
public function render() {
$list = new PHUIObjectItemListView();
$list->setCards(true);
$list->setFlush(true);
foreach ($this->commits as $commit) {
$commit_phid = $commit->getPHID();
$commit_name = $this->getHandle($commit_phid)->getName();
$commit_link = $this->getHandle($commit_phid)->getURI();
$commit_desc = $this->getCommitDescription($commit_phid);
$author_name = null;
if ($commit->getAuthorPHID()) {
$author_name = $this->getHandle($commit->getAuthorPHID())->renderLink();
}
$auditors = array();
if ($commit->getAudits()) {
foreach ($commit->getAudits() as $audit) {
$actor_phid = $audit->getActorPHID();
$auditors[$actor_phid] = $this->getHandle($actor_phid)->renderLink();
}
$auditors = phutil_implode_html(', ', $auditors);
}
$committed = phabricator_datetime($commit->getEpoch(), $this->user);
+ $audit_status = $commit->getAuditStatus();
$commit_status = PhabricatorAuditCommitStatusConstants::getStatusName(
- $commit->getAuditStatus());
+ $audit_status);
+ $status_color = PhabricatorAuditCommitStatusConstants::getStatusColor(
+ $audit_status);
$item = id(new PHUIObjectItemView())
+ ->setBarColor($status_color)
->setObjectName($commit_name)
->setHeader($commit_desc)
->setHref($commit_link)
->addAttribute($commit_status)
->addIcon('none', $committed);
if (!empty($auditors)) {
$item->addAttribute(pht('Auditors: %s', $auditors));
}
if ($author_name) {
$item->addByline(pht('Author: %s', $author_name));
}
$list->addItem($item);
}
if ($this->noDataString) {
$list->setNoDataString($this->noDataString);
}
return $list->render();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jul 27, 3:51 PM (1 w, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
185964
Default Alt Text
(7 KB)

Event Timeline