1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Move Abandon Revision action to the bottom if it's an admin action.

Test Plan:
Login as admin, look at an open revision you don't own, you should be able to
choose '(Admin) Abandon Revision', the option should be on the bottom and should
abandon the revision after sending the comment.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1060
This commit is contained in:
Marek Sapota 2011-10-27 12:32:02 -07:00
parent c724902ca9
commit 74d1983c68
3 changed files with 18 additions and 11 deletions
src/applications/differential

View file

@ -377,6 +377,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$actions = array(
DifferentialAction::ACTION_COMMENT => true,
);
$admin_actions = array();
$viewer = $this->getRequest()->getUser();
$viewer_phid = $viewer->getPHID();
@ -409,18 +410,18 @@ class DifferentialRevisionViewController extends DifferentialController {
} else {
switch ($revision->getStatus()) {
case DifferentialRevisionStatus::NEEDS_REVIEW:
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$admin_actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$actions[DifferentialAction::ACTION_ACCEPT] = true;
$actions[DifferentialAction::ACTION_REJECT] = true;
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
break;
case DifferentialRevisionStatus::NEEDS_REVISION:
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$admin_actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$actions[DifferentialAction::ACTION_ACCEPT] = true;
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
break;
case DifferentialRevisionStatus::ACCEPTED:
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$admin_actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
$actions[DifferentialAction::ACTION_REJECT] = true;
$actions[DifferentialAction::ACTION_RESIGN] =
$viewer_is_reviewer && !$viewer_did_accept;
@ -434,7 +435,19 @@ class DifferentialRevisionViewController extends DifferentialController {
$actions[DifferentialAction::ACTION_ADDREVIEWERS] = true;
$actions[DifferentialAction::ACTION_ADDCCS] = true;
return array_keys(array_filter($actions));
$actions = array_keys(array_filter($actions));
$admin_actions = array_keys(array_filter($admin_actions));
$actions_dict = array();
foreach ($actions as $action) {
$actions_dict[$action] = DifferentialAction::getActionVerb($action);
}
foreach ($admin_actions as $action) {
$actions_dict[$action] =
'(Admin) ' . DifferentialAction::getActionVerb($action);
}
return $actions_dict;
}
private function loadInlineComments(array $comments, array &$changesets) {

View file

@ -69,11 +69,6 @@ final class DifferentialAddCommentView extends AphrontView {
$revision = $this->revision;
$actions = array();
foreach ($this->actions as $action) {
$actions[$action] = DifferentialAction::getActionVerb($action);
}
$form = new AphrontFormView();
$form
->setUser($this->user)
@ -84,7 +79,7 @@ final class DifferentialAddCommentView extends AphrontView {
->setLabel('Action')
->setName('action')
->setID('comment-action')
->setOptions($actions))
->setOptions($this->actions))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel('Add Reviewers')

View file

@ -6,7 +6,6 @@
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/constants/lintstatus');
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
phutil_require_module('phabricator', 'infrastructure/celerity/api');