Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14732434
D21599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Referenced Files
None
Subscribers
None
D21599.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2305,7 +2305,7 @@
'PhabricatorAuditManagementDeleteWorkflow' => 'applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php',
'PhabricatorAuditManagementWorkflow' => 'applications/audit/management/PhabricatorAuditManagementWorkflow.php',
'PhabricatorAuditReplyHandler' => 'applications/audit/mail/PhabricatorAuditReplyHandler.php',
- 'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php',
+ 'PhabricatorAuditRequestStatus' => 'applications/audit/constants/PhabricatorAuditRequestStatus.php',
'PhabricatorAuditSynchronizeManagementWorkflow' => 'applications/audit/management/PhabricatorAuditSynchronizeManagementWorkflow.php',
'PhabricatorAuditTransaction' => 'applications/audit/storage/PhabricatorAuditTransaction.php',
'PhabricatorAuditTransactionComment' => 'applications/audit/storage/PhabricatorAuditTransactionComment.php',
@@ -8651,7 +8651,7 @@
'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow',
'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorAuditReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
- 'PhabricatorAuditStatusConstants' => 'Phobject',
+ 'PhabricatorAuditRequestStatus' => 'Phobject',
'PhabricatorAuditSynchronizeManagementWorkflow' => 'PhabricatorAuditManagementWorkflow',
'PhabricatorAuditTransaction' => 'PhabricatorModularTransaction',
'PhabricatorAuditTransactionComment' => array(
diff --git a/src/applications/audit/constants/PhabricatorAuditRequestStatus.php b/src/applications/audit/constants/PhabricatorAuditRequestStatus.php
new file mode 100644
--- /dev/null
+++ b/src/applications/audit/constants/PhabricatorAuditRequestStatus.php
@@ -0,0 +1,80 @@
+<?php
+
+final class PhabricatorAuditRequestStatus extends Phobject {
+
+ const AUDIT_REQUIRED = 'audit-required';
+ const CONCERNED = 'concerned';
+ const ACCEPTED = 'accepted';
+ const AUDIT_REQUESTED = 'requested';
+ const RESIGNED = 'resigned';
+
+ private $key;
+
+ public static function newForStatus($status) {
+ $result = new self();
+ $result->key = $status;
+ return $result;
+ }
+
+ public function getIconIcon() {
+ return $this->getMapProperty('icon');
+ }
+
+ public function getIconColor() {
+ return $this->getMapProperty('icon.color');
+ }
+
+ public function getStatusName() {
+ $name = $this->getMapProperty('name');
+ if ($name !== null) {
+ return $name;
+ }
+
+ return pht('Unknown Audit Request Status ("%s")', $this->key);
+ }
+
+ public function getStatusValue() {
+ return $this->key;
+ }
+
+ public function isResigned() {
+ return ($this->key === self::RESIGNED);
+ }
+
+ private function getMapProperty($key, $default = null) {
+ $map = self::newStatusMap();
+ $spec = idx($map, $this->key, array());
+ return idx($spec, $key, $default);
+ }
+
+ private static function newStatusMap() {
+ return array(
+ self::AUDIT_REQUIRED => array(
+ 'name' => pht('Audit Required'),
+ 'icon' => 'fa-exclamation-circle',
+ 'icon.color' => 'orange',
+ ),
+ self::AUDIT_REQUESTED => array(
+ 'name' => pht('Audit Requested'),
+ 'icon' => 'fa-exclamation-circle',
+ 'icon.color' => 'orange',
+ ),
+ self::CONCERNED => array(
+ 'name' => pht('concern Raised'),
+ 'icon' => 'fa-times-circle',
+ 'icon.color' => 'red',
+ ),
+ self::ACCEPTED => array(
+ 'name' => pht('Accepted'),
+ 'icon' => 'fa-check-circle',
+ 'icon.color' => 'green',
+ ),
+ self::RESIGNED => array(
+ 'name' => pht('Resigned'),
+ 'icon' => 'fa-times',
+ 'icon.color' => 'grey',
+ ),
+ );
+ }
+
+}
diff --git a/src/applications/audit/constants/PhabricatorAuditStatusConstants.php b/src/applications/audit/constants/PhabricatorAuditStatusConstants.php
deleted file mode 100644
--- a/src/applications/audit/constants/PhabricatorAuditStatusConstants.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-final class PhabricatorAuditStatusConstants extends Phobject {
-
- const AUDIT_REQUIRED = 'audit-required';
- const CONCERNED = 'concerned';
- const ACCEPTED = 'accepted';
- const AUDIT_REQUESTED = 'requested';
- const RESIGNED = 'resigned';
-
- public static function getStatusNameMap() {
- $map = array(
- 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'),
- );
-
- return $map;
- }
-
- public static function getActionRequiredStatusConstants() {
- return array(
- self::AUDIT_REQUIRED,
- self::AUDIT_REQUESTED,
- );
- }
-
- 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:
- case self::AUDIT_REQUESTED:
- $color = 'orange';
- break;
- case self::ACCEPTED:
- $color = 'green';
- break;
- case self::RESIGNED:
- $color = 'grey';
- break;
- default:
- $color = 'bluegrey';
- break;
- }
- return $color;
- }
-
- public static function getStatusIcon($code) {
- switch ($code) {
- case self::AUDIT_REQUIRED:
- case self::AUDIT_REQUESTED:
- $icon = PHUIStatusItemView::ICON_WARNING;
- break;
- case self::CONCERNED:
- $icon = PHUIStatusItemView::ICON_REJECT;
- break;
- case self::ACCEPTED:
- $icon = PHUIStatusItemView::ICON_ACCEPT;
- break;
- case self::RESIGNED:
- $icon = 'fa-times';
- break;
- default:
- $icon = PHUIStatusItemView::ICON_QUESTION;
- break;
- }
- return $icon;
- }
-
- 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/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php
--- a/src/applications/audit/editor/PhabricatorAuditEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditEditor.php
@@ -178,11 +178,6 @@
}
$object->attachAudits($commit->getAudits());
- $status_concerned = PhabricatorAuditStatusConstants::CONCERNED;
- $status_resigned = PhabricatorAuditStatusConstants::RESIGNED;
- $status_accepted = PhabricatorAuditStatusConstants::ACCEPTED;
- $status_concerned = PhabricatorAuditStatusConstants::CONCERNED;
-
$actor_phid = $this->getActingAsPHID();
$actor_is_author = ($object->getAuthorPHID()) &&
($actor_phid == $object->getAuthorPHID());
diff --git a/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php b/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php
--- a/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php
+++ b/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php
@@ -153,13 +153,13 @@
foreach ($commit_audits as $audit) {
$audit_id = $audit->getID();
+ $status = $audit->getAuditRequestStatusObject();
$description = sprintf(
'%10d %-16s %-16s %s: %s',
$audit_id,
$handles[$audit->getAuditorPHID()]->getName(),
- PhabricatorAuditStatusConstants::getStatusName(
- $audit->getAuditStatus()),
+ $status->getStatusName(),
$commit->getRepository()->formatCommitName(
$commit->getCommitIdentifier()),
trim($commit->getSummary()));
diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php
--- a/src/applications/diffusion/controller/DiffusionCommitController.php
+++ b/src/applications/diffusion/controller/DiffusionCommitController.php
@@ -898,12 +898,13 @@
$view = new PHUIStatusListView();
foreach ($audit_requests as $request) {
- $code = $request->getAuditStatus();
+ $status = $request->getAuditRequestStatusObject();
+
$item = new PHUIStatusItemView();
$item->setIcon(
- PhabricatorAuditStatusConstants::getStatusIcon($code),
- PhabricatorAuditStatusConstants::getStatusColor($code),
- PhabricatorAuditStatusConstants::getStatusName($code));
+ $status->getIconIcon(),
+ $status->getIconColor(),
+ $status->getStatusName());
$auditor_phid = $request->getAuditorPHID();
$target = $viewer->renderHandle($auditor_phid);
diff --git a/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php b/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php
--- a/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php
+++ b/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php
@@ -98,9 +98,9 @@
}
switch ($status) {
- case PhabricatorAuditStatusConstants::AUDIT_REQUIRED:
- case PhabricatorAuditStatusConstants::AUDIT_REQUESTED:
- case PhabricatorAuditStatusConstants::CONCERNED:
+ case PhabricatorAuditRequestStatus::AUDIT_REQUIRED:
+ case PhabricatorAuditRequestStatus::AUDIT_REQUESTED:
+ case PhabricatorAuditRequestStatus::CONCERNED:
$active += array_fuse($request_phids);
break;
default:
diff --git a/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php b/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php
--- a/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php
+++ b/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php
@@ -20,8 +20,11 @@
$list = array();
foreach ($auditors as $auditor) {
+ $status = $auditor->getAuditRequestStatusObject();
+
$list[] = array(
'auditorPHID' => $auditor->getAuditorPHID(),
+ 'status' => $status->getStatusValue(),
);
}
diff --git a/src/applications/diffusion/herald/HeraldCommitAdapter.php b/src/applications/diffusion/herald/HeraldCommitAdapter.php
--- a/src/applications/diffusion/herald/HeraldCommitAdapter.php
+++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php
@@ -166,8 +166,8 @@
public function loadAuditNeededPackages() {
if ($this->auditNeededPackages === null) {
$status_arr = array(
- PhabricatorAuditStatusConstants::AUDIT_REQUIRED,
- PhabricatorAuditStatusConstants::CONCERNED,
+ PhabricatorAuditRequestStatus::AUDIT_REQUIRED,
+ PhabricatorAuditRequestStatus::CONCERNED,
);
$requests = id(new PhabricatorRepositoryAuditRequest())
->loadAllWhere(
diff --git a/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php b/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php
--- a/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php
+++ b/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php
@@ -90,7 +90,7 @@
$objects = $this->objects;
$has_concern = array(
- PhabricatorAuditStatusConstants::CONCERNED,
+ PhabricatorAuditRequestStatus::CONCERNED,
);
$has_concern = array_fuse($has_concern);
@@ -119,8 +119,8 @@
$objects = $this->objects;
$should_audit = array(
- PhabricatorAuditStatusConstants::AUDIT_REQUIRED,
- PhabricatorAuditStatusConstants::AUDIT_REQUESTED,
+ PhabricatorAuditRequestStatus::AUDIT_REQUIRED,
+ PhabricatorAuditRequestStatus::AUDIT_REQUESTED,
);
$should_audit = array_fuse($should_audit);
diff --git a/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
--- a/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
+++ b/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
@@ -31,7 +31,7 @@
}
public function applyExternalEffects($object, $value) {
- $status = PhabricatorAuditStatusConstants::ACCEPTED;
+ $status = PhabricatorAuditRequestStatus::ACCEPTED;
$actor = $this->getActor();
$this->applyAuditorEffect($object, $actor, $value, $status);
}
diff --git a/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php
--- a/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php
+++ b/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php
@@ -21,12 +21,12 @@
PhabricatorRepositoryCommit $commit,
PhabricatorUser $viewer) {
- // This omits various inactive states like "Resigned" and "Not Required".
+ // This omits inactive states; currently just "Resigned".
$active = array(
- PhabricatorAuditStatusConstants::AUDIT_REQUIRED,
- PhabricatorAuditStatusConstants::CONCERNED,
- PhabricatorAuditStatusConstants::ACCEPTED,
- PhabricatorAuditStatusConstants::AUDIT_REQUESTED,
+ PhabricatorAuditRequestStatus::AUDIT_REQUIRED,
+ PhabricatorAuditRequestStatus::CONCERNED,
+ PhabricatorAuditRequestStatus::ACCEPTED,
+ PhabricatorAuditRequestStatus::AUDIT_REQUESTED,
);
$active = array_fuse($active);
@@ -42,7 +42,7 @@
$commit,
$viewer,
array(
- PhabricatorAuditStatusConstants::ACCEPTED,
+ PhabricatorAuditRequestStatus::ACCEPTED,
));
}
@@ -53,7 +53,7 @@
$commit,
$viewer,
array(
- PhabricatorAuditStatusConstants::CONCERNED,
+ PhabricatorAuditRequestStatus::CONCERNED,
));
}
@@ -117,7 +117,7 @@
$map = array();
- $with_authority = ($status != PhabricatorAuditStatusConstants::RESIGNED);
+ $with_authority = ($status != PhabricatorAuditRequestStatus::RESIGNED);
if ($with_authority) {
foreach ($audits as $audit) {
if ($commit->hasAuditAuthority($actor, $audit, $acting_phid)) {
diff --git a/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php
--- a/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php
+++ b/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php
@@ -16,7 +16,7 @@
$auditors = $this->generateOldValue($object);
$old_auditors = $auditors;
- $request_status = PhabricatorAuditStatusConstants::AUDIT_REQUESTED;
+ $request_status = PhabricatorAuditRequestStatus::AUDIT_REQUESTED;
$rem = idx($value, '-', array());
foreach ($rem as $phid) {
diff --git a/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php
--- a/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php
+++ b/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php
@@ -37,7 +37,7 @@
}
public function applyExternalEffects($object, $value) {
- $status = PhabricatorAuditStatusConstants::CONCERNED;
+ $status = PhabricatorAuditRequestStatus::CONCERNED;
$actor = $this->getActor();
$this->applyAuditorEffect($object, $actor, $value, $status);
}
diff --git a/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php
--- a/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php
+++ b/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php
@@ -36,7 +36,7 @@
}
public function applyExternalEffects($object, $value) {
- $status = PhabricatorAuditStatusConstants::RESIGNED;
+ $status = PhabricatorAuditRequestStatus::RESIGNED;
$actor = $this->getActor();
$this->applyAuditorEffect($object, $actor, $value, $status);
}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php b/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
--- a/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php
@@ -50,14 +50,13 @@
}
public function isResigned() {
- switch ($this->getAuditStatus()) {
- case PhabricatorAuditStatusConstants::RESIGNED:
- return true;
- }
-
- return false;
+ return $this->getAuditRequestStatusObject()->isResigned();
}
+ public function getAuditRequestStatusObject() {
+ $status = $this->getAuditStatus();
+ return PhabricatorAuditRequestStatus::newForStatus($status);
+ }
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -312,14 +312,14 @@
foreach ($requests as $request) {
switch ($request->getAuditStatus()) {
- case PhabricatorAuditStatusConstants::AUDIT_REQUIRED:
- case PhabricatorAuditStatusConstants::AUDIT_REQUESTED:
+ case PhabricatorAuditRequestStatus::AUDIT_REQUIRED:
+ case PhabricatorAuditRequestStatus::AUDIT_REQUESTED:
$any_need = true;
break;
- case PhabricatorAuditStatusConstants::ACCEPTED:
+ case PhabricatorAuditRequestStatus::ACCEPTED:
$any_accept = true;
break;
- case PhabricatorAuditStatusConstants::CONCERNED:
+ case PhabricatorAuditRequestStatus::CONCERNED:
$any_concern = true;
break;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 19, 4:43 PM (18 h, 54 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7019585
Default Alt Text
D21599.diff (18 KB)
Attached To
Mode
D21599: Modernize and clean up "PhabricatorAuditStatusConstants"
Attached
Detach File
Event Timeline
Log In to Comment