mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
ReleephRequestStatus
Summary: This is just a bit of gardening in order to make the responsive-UI diff easier; I'll be putting `getColorFor($status)` type things in this class, following the pattern in `ManiphestTaskStatus`. Test Plan: Poke around Releeph. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5893
This commit is contained in:
parent
fcb7286533
commit
da92d79d8d
7 changed files with 54 additions and 47 deletions
|
@ -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',
|
||||
|
|
32
src/applications/releeph/constants/ReleephRequestStatus.php
Normal file
32
src/applications/releeph/constants/ReleephRequestStatus.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
final class ReleephRequestStatus {
|
||||
|
||||
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 static function getStatusDescriptionFor($status) {
|
||||
$descriptions = array(
|
||||
self::STATUS_REQUESTED => 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )----------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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!';
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue