mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +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:
parent
c724902ca9
commit
74d1983c68
3 changed files with 18 additions and 11 deletions
|
@ -377,6 +377,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$actions = array(
|
$actions = array(
|
||||||
DifferentialAction::ACTION_COMMENT => true,
|
DifferentialAction::ACTION_COMMENT => true,
|
||||||
);
|
);
|
||||||
|
$admin_actions = array();
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
$viewer = $this->getRequest()->getUser();
|
||||||
$viewer_phid = $viewer->getPHID();
|
$viewer_phid = $viewer->getPHID();
|
||||||
|
@ -409,18 +410,18 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
} else {
|
} else {
|
||||||
switch ($revision->getStatus()) {
|
switch ($revision->getStatus()) {
|
||||||
case DifferentialRevisionStatus::NEEDS_REVIEW:
|
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_ACCEPT] = true;
|
||||||
$actions[DifferentialAction::ACTION_REJECT] = true;
|
$actions[DifferentialAction::ACTION_REJECT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
break;
|
break;
|
||||||
case DifferentialRevisionStatus::NEEDS_REVISION:
|
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_ACCEPT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
break;
|
break;
|
||||||
case DifferentialRevisionStatus::ACCEPTED:
|
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_REJECT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] =
|
$actions[DifferentialAction::ACTION_RESIGN] =
|
||||||
$viewer_is_reviewer && !$viewer_did_accept;
|
$viewer_is_reviewer && !$viewer_did_accept;
|
||||||
|
@ -434,7 +435,19 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$actions[DifferentialAction::ACTION_ADDREVIEWERS] = true;
|
$actions[DifferentialAction::ACTION_ADDREVIEWERS] = true;
|
||||||
$actions[DifferentialAction::ACTION_ADDCCS] = 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) {
|
private function loadInlineComments(array $comments, array &$changesets) {
|
||||||
|
|
|
@ -69,11 +69,6 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
|
|
||||||
$revision = $this->revision;
|
$revision = $this->revision;
|
||||||
|
|
||||||
$actions = array();
|
|
||||||
foreach ($this->actions as $action) {
|
|
||||||
$actions[$action] = DifferentialAction::getActionVerb($action);
|
|
||||||
}
|
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$form = new AphrontFormView();
|
||||||
$form
|
$form
|
||||||
->setUser($this->user)
|
->setUser($this->user)
|
||||||
|
@ -84,7 +79,7 @@ final class DifferentialAddCommentView extends AphrontView {
|
||||||
->setLabel('Action')
|
->setLabel('Action')
|
||||||
->setName('action')
|
->setName('action')
|
||||||
->setID('comment-action')
|
->setID('comment-action')
|
||||||
->setOptions($actions))
|
->setOptions($this->actions))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setLabel('Add Reviewers')
|
->setLabel('Add Reviewers')
|
||||||
|
|
|
@ -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/lintstatus');
|
||||||
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
|
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
|
||||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
|
|
Loading…
Reference in a new issue