diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 226adfdc69..065c588ddb 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2305,7 +2305,7 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index 0000000000..e3fb188a14 --- /dev/null +++ b/src/applications/audit/constants/PhabricatorAuditRequestStatus.php @@ -0,0 +1,80 @@ +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 index 54eb332124..0000000000 --- a/src/applications/audit/constants/PhabricatorAuditStatusConstants.php +++ /dev/null @@ -1,90 +0,0 @@ - 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 index 81317fd47e..7b97ea515a 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -178,11 +178,6 @@ final class PhabricatorAuditEditor } $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 index cd621ce821..50041330dc 100644 --- a/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php +++ b/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php @@ -153,13 +153,13 @@ final class PhabricatorAuditManagementDeleteWorkflow 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 index 6037781edc..7b893b1e52 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -898,12 +898,13 @@ final class DiffusionCommitController extends DiffusionController { $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 index 088e5dc71a..8f1362860d 100644 --- a/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php +++ b/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php @@ -98,9 +98,9 @@ final class DiffusionDoorkeeperCommitFeedStoryPublisher } 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 index a244241449..1dfcbcc05b 100644 --- a/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php +++ b/src/applications/diffusion/engineextension/DiffusionAuditorsSearchEngineAttachment.php @@ -20,8 +20,11 @@ final class DiffusionAuditorsSearchEngineAttachment $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 index 59508d77fb..b8ebf9c022 100644 --- a/src/applications/diffusion/herald/HeraldCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php @@ -166,8 +166,8 @@ final class HeraldCommitAdapter 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 index 25984c93e1..0c5bdbced7 100644 --- a/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php +++ b/src/applications/diffusion/query/DiffusionCommitRequiredActionResultBucket.php @@ -90,7 +90,7 @@ final class DiffusionCommitRequiredActionResultBucket $objects = $this->objects; $has_concern = array( - PhabricatorAuditStatusConstants::CONCERNED, + PhabricatorAuditRequestStatus::CONCERNED, ); $has_concern = array_fuse($has_concern); @@ -119,8 +119,8 @@ final class DiffusionCommitRequiredActionResultBucket $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 index 5ade7f3513..9cd42eab36 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php @@ -31,7 +31,7 @@ final class DiffusionCommitAcceptTransaction } 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 index c80301e6ee..b6657b73f2 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php @@ -21,12 +21,12 @@ abstract class DiffusionCommitAuditTransaction 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 @@ abstract class DiffusionCommitAuditTransaction $commit, $viewer, array( - PhabricatorAuditStatusConstants::ACCEPTED, + PhabricatorAuditRequestStatus::ACCEPTED, )); } @@ -53,7 +53,7 @@ abstract class DiffusionCommitAuditTransaction $commit, $viewer, array( - PhabricatorAuditStatusConstants::CONCERNED, + PhabricatorAuditRequestStatus::CONCERNED, )); } @@ -117,7 +117,7 @@ abstract class DiffusionCommitAuditTransaction $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 index 9ef51b9e90..15b44543e9 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php @@ -16,7 +16,7 @@ final class DiffusionCommitAuditorsTransaction $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 index ffd084412e..8f2744f21d 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php @@ -37,7 +37,7 @@ final class DiffusionCommitConcernTransaction } 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 index 8adc8346dc..1f5a4b94b0 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitResignTransaction.php @@ -36,7 +36,7 @@ final class DiffusionCommitResignTransaction } 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 index 1165b03a3f..606a0656e0 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php +++ b/src/applications/repository/storage/PhabricatorRepositoryAuditRequest.php @@ -50,14 +50,13 @@ final class PhabricatorRepositoryAuditRequest } 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 index f0c7d6abf8..31413ea0c2 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php +++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php @@ -312,14 +312,14 @@ final class PhabricatorRepositoryCommit 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; }