diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4a7a30b8ec..0c6ea3d867 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1742,6 +1742,7 @@ phutil_register_library_map(array( 'ReleephRequestHeaderView' => 'applications/releeph/view/request/header/ReleephRequestHeaderView.php', 'ReleephRequestIntentsView' => 'applications/releeph/view/request/ReleephRequestIntentsView.php', 'ReleephRequestReplyHandler' => 'applications/releeph/mail/ReleephRequestReplyHandler.php', + 'ReleephRequestStatus' => 'applications/releeph/constants/ReleephRequestStatus.php', 'ReleephRequestStatusView' => 'applications/releeph/view/request/ReleephRequestStatusView.php', 'ReleephRequestTransaction' => 'applications/releeph/storage/ReleephRequestTransaction.php', 'ReleephRequestTransactionComment' => 'applications/releeph/storage/ReleephRequestTransactionComment.php', diff --git a/src/applications/releeph/constants/ReleephRequestStatus.php b/src/applications/releeph/constants/ReleephRequestStatus.php new file mode 100644 index 0000000000..9009c821fd --- /dev/null +++ b/src/applications/releeph/constants/ReleephRequestStatus.php @@ -0,0 +1,32 @@ + pht('Requested'), + self::STATUS_REJECTED => pht('Rejected'), + self::STATUS_ABANDONED => pht('Abandoned'), + self::STATUS_PICKED => pht('Picked'), + self::STATUS_REVERTED => pht('Reverted'), + self::STATUS_NEEDS_PICK => pht('Needs Pick'), + self::STATUS_NEEDS_REVERT => pht('Needs Revert'), + ); + return idx($descriptions, $status, '??'); + } + + public static function getStatusClassSuffixFor($status) { + $description = self::getStatusDescriptionFor($status); + $class = str_replace(' ', '-', strtolower($description)); + return $class; + } + +} diff --git a/src/applications/releeph/field/specification/ReleephStatusFieldSpecification.php b/src/applications/releeph/field/specification/ReleephStatusFieldSpecification.php index 202e5aba86..49e307df43 100644 --- a/src/applications/releeph/field/specification/ReleephStatusFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephStatusFieldSpecification.php @@ -14,13 +14,13 @@ final class ReleephStatusFieldSpecification } private static $filters = array( - 'req' => ReleephRequest::STATUS_REQUESTED, - 'app' => ReleephRequest::STATUS_NEEDS_PICK, - 'rej' => ReleephRequest::STATUS_REJECTED, - 'abn' => ReleephRequest::STATUS_ABANDONED, - 'mer' => ReleephRequest::STATUS_PICKED, - 'rrq' => ReleephRequest::STATUS_NEEDS_REVERT, - 'rev' => ReleephRequest::STATUS_REVERTED, + 'req' => ReleephRequestStatus::STATUS_REQUESTED, + 'app' => ReleephRequestStatus::STATUS_NEEDS_PICK, + 'rej' => ReleephRequestStatus::STATUS_REJECTED, + 'abn' => ReleephRequestStatus::STATUS_ABANDONED, + 'mer' => ReleephRequestStatus::STATUS_PICKED, + 'rrq' => ReleephRequestStatus::STATUS_NEEDS_REVERT, + 'rev' => ReleephRequestStatus::STATUS_REVERTED, ); protected function appendSelectControls( @@ -34,7 +34,7 @@ final class ReleephStatusFieldSpecification ); foreach (self::$filters as $code => $status) { - $name = ReleephRequest::getStatusDescriptionFor($status); + $name = ReleephRequestStatus::getStatusDescriptionFor($status); $filter_names[$code] = $name; } diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index 50148c072d..f1d499b49f 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -34,14 +34,6 @@ final class ReleephRequest extends ReleephDAO { const REVERT_OK = 5; const REVERT_FAILED = 6; - const STATUS_REQUESTED = 1; - const STATUS_NEEDS_PICK = 2; // aka approved - const STATUS_REJECTED = 3; - const STATUS_ABANDONED = 4; - const STATUS_PICKED = 5; - const STATUS_REVERTED = 6; - const STATUS_NEEDS_REVERT = 7; // aka revert requested - public function shouldBeInBranch() { return $this->getPusherIntent() == self::INTENT_WANT && @@ -92,50 +84,31 @@ final class ReleephRequest extends ReleephDAO { private function calculateStatus() { if ($this->shouldBeInBranch()) { if ($this->getInBranch()) { - return self::STATUS_PICKED; + return ReleephRequestStatus::STATUS_PICKED; } else { - return self::STATUS_NEEDS_PICK; + return ReleephRequestStatus::STATUS_NEEDS_PICK; } } else { if ($this->getInBranch()) { - return self::STATUS_NEEDS_REVERT; + return ReleephRequestStatus::STATUS_NEEDS_REVERT; } else { $has_been_in_branch = $this->getCommitIdentifier(); // Regardless of why we reverted something, always say reverted if it // was once in the branch. if ($has_been_in_branch) { - return self::STATUS_REVERTED; + return ReleephRequestStatus::STATUS_REVERTED; } elseif ($this->getPusherIntent() === ReleephRequest::INTENT_PASS) { // Otherwise, if it has never been in the branch, explicitly say why: - return self::STATUS_REJECTED; + return ReleephRequestStatus::STATUS_REJECTED; } elseif ($this->getRequestorIntent() === ReleephRequest::INTENT_WANT) { - return self::STATUS_REQUESTED; + return ReleephRequestStatus::STATUS_REQUESTED; } else { - return self::STATUS_ABANDONED; + return ReleephRequestStatus::STATUS_ABANDONED; } } } } - public static function getStatusDescriptionFor($status) { - static $descriptions = array( - self::STATUS_REQUESTED => 'Requested', - self::STATUS_REJECTED => 'Rejected', - self::STATUS_ABANDONED => 'Abandoned', - self::STATUS_PICKED => 'Picked', - self::STATUS_REVERTED => 'Reverted', - self::STATUS_NEEDS_PICK => 'Needs Pick', - self::STATUS_NEEDS_REVERT => 'Needs Revert', - ); - return idx($descriptions, $status, '??'); - } - - public static function getStatusClassSuffixFor($status) { - $description = self::getStatusDescriptionFor($status); - $class = str_replace(' ', '-', strtolower($description)); - return $class; - } - /* -( Lisk mechanics )----------------------------------------------------- */ diff --git a/src/applications/releeph/view/branch/ReleephBranchBoxView.php b/src/applications/releeph/view/branch/ReleephBranchBoxView.php index 2d91b4430b..7a5acde4c3 100644 --- a/src/applications/releeph/view/branch/ReleephBranchBoxView.php +++ b/src/applications/releeph/view/branch/ReleephBranchBoxView.php @@ -115,7 +115,7 @@ final class ReleephBranchBoxView extends AphrontView { $cells = array(); foreach ($statistics as $status => $count) { - $description = ReleephRequest::getStatusDescriptionFor($status); + $description = ReleephRequestStatus::getStatusDescriptionFor($status); $cells[] = phutil_tag('th', array(), $count); $cells[] = phutil_tag('td', array(), $description); } diff --git a/src/applications/releeph/view/request/ReleephRequestStatusView.php b/src/applications/releeph/view/request/ReleephRequestStatusView.php index 4076f037f6..2b61ad9a2f 100644 --- a/src/applications/releeph/view/request/ReleephRequestStatusView.php +++ b/src/applications/releeph/view/request/ReleephRequestStatusView.php @@ -16,15 +16,15 @@ final class ReleephRequestStatusView extends AphrontView { $status = $request->getStatus(); $pick_status = $request->getPickStatus(); - $description = ReleephRequest::getStatusDescriptionFor($status); + $description = ReleephRequestStatus::getStatusDescriptionFor($status); $warning = null; - if ($status == ReleephRequest::STATUS_NEEDS_PICK) { + if ($status == ReleephRequestStatus::STATUS_NEEDS_PICK) { if ($pick_status == ReleephRequest::PICK_FAILED) { $warning = 'Last pick failed!'; } - } elseif ($status == ReleephRequest::STATUS_NEEDS_REVERT) { + } elseif ($status == ReleephRequestStatus::STATUS_NEEDS_REVERT) { if ($pick_status == ReleephRequest::REVERT_FAILED) { $warning = 'Last revert failed!'; } diff --git a/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php b/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php index fd09821b92..f616d9663d 100644 --- a/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php +++ b/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php @@ -55,7 +55,8 @@ final class ReleephRequestHeaderView extends AphrontView { $rr_div_class = 'releeph-request-header '. 'releeph-request-header-border '. - 'releeph-border-color-'.ReleephRequest::getStatusClassSuffixFor($status); + 'releeph-border-color-'. + ReleephRequestStatus::getStatusClassSuffixFor($status); $hidden_link = phutil_tag( 'a',