mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Expose "Abandon Revision" to non-authors with a config flag.
Summary: Fixes T4720. Allows non-authors to permanently reject a differential by exposing the "Abandon Revision" action via a configuration flag. Test Plan: {F161434} Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4720 Differential Revision: https://secure.phabricator.com/D9306
This commit is contained in:
parent
8ea9935ea5
commit
1e2a592ceb
4 changed files with 24 additions and 1 deletions
|
@ -811,6 +811,10 @@ return array(
|
||||||
// only the submitter can close a revision.
|
// only the submitter can close a revision.
|
||||||
'differential.always-allow-close' => false,
|
'differential.always-allow-close' => false,
|
||||||
|
|
||||||
|
// If you set this to true, any user can abandon any revision. If false, only
|
||||||
|
// the submitter can abandon a revision.
|
||||||
|
'differential.always-allow-abandon' => false,
|
||||||
|
|
||||||
// If you set this to true, any user can reopen a revision so long as it has
|
// If you set this to true, any user can reopen a revision so long as it has
|
||||||
// been closed. This can be useful if a revision is accidentally closed or
|
// been closed. This can be useful if a revision is accidentally closed or
|
||||||
// if a developer changes his or her mind after closing a revision. If it is
|
// if a developer changes his or her mind after closing a revision. If it is
|
||||||
|
|
|
@ -165,6 +165,17 @@ final class PhabricatorDifferentialConfigOptions
|
||||||
"where the reviewer is often the actual committer can benefit ".
|
"where the reviewer is often the actual committer can benefit ".
|
||||||
"from turning this option to true. If false, only the submitter ".
|
"from turning this option to true. If false, only the submitter ".
|
||||||
"can close a revision.")),
|
"can close a revision.")),
|
||||||
|
$this->newOption('differential.always-allow-abandon', 'bool', false)
|
||||||
|
->setBoolOptions(
|
||||||
|
array(
|
||||||
|
pht('Allow any user'),
|
||||||
|
pht('Restrict to submitter'),
|
||||||
|
))
|
||||||
|
->setSummary(pht('Allows any user to abandon revisions.'))
|
||||||
|
->setDescription(
|
||||||
|
pht(
|
||||||
|
'If you set this to true, any user can abandon any revision. If '.
|
||||||
|
'false, only the submitter can abandon a revision.')),
|
||||||
$this->newOption('differential.allow-reopen', 'bool', false)
|
$this->newOption('differential.allow-reopen', 'bool', false)
|
||||||
->setBoolOptions(
|
->setBoolOptions(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -553,6 +553,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
|
|
||||||
$allow_self_accept = PhabricatorEnv::getEnvConfig(
|
$allow_self_accept = PhabricatorEnv::getEnvConfig(
|
||||||
'differential.allow-self-accept');
|
'differential.allow-self-accept');
|
||||||
|
$always_allow_abandon = PhabricatorEnv::getEnvConfig(
|
||||||
|
'differential.always-allow-abandon');
|
||||||
$always_allow_close = PhabricatorEnv::getEnvConfig(
|
$always_allow_close = PhabricatorEnv::getEnvConfig(
|
||||||
'differential.always-allow-close');
|
'differential.always-allow-close');
|
||||||
$allow_reopen = PhabricatorEnv::getEnvConfig(
|
$allow_reopen = PhabricatorEnv::getEnvConfig(
|
||||||
|
@ -586,17 +588,20 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
} else {
|
} else {
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
|
||||||
$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 ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||||
case ArcanistDifferentialRevisionStatus::CHANGES_PLANNED:
|
case ArcanistDifferentialRevisionStatus::CHANGES_PLANNED:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
|
||||||
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
||||||
$actions[DifferentialAction::ACTION_REJECT] = !$viewer_has_rejected;
|
$actions[DifferentialAction::ACTION_REJECT] = !$viewer_has_rejected;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
break;
|
break;
|
||||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
|
||||||
$actions[DifferentialAction::ACTION_ACCEPT] = !$viewer_has_accepted;
|
$actions[DifferentialAction::ACTION_ACCEPT] = !$viewer_has_accepted;
|
||||||
$actions[DifferentialAction::ACTION_REJECT] = true;
|
$actions[DifferentialAction::ACTION_REJECT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
|
|
|
@ -789,6 +789,9 @@ final class DifferentialTransactionEditor
|
||||||
$actor_phid = $this->getActor()->getPHID();
|
$actor_phid = $this->getActor()->getPHID();
|
||||||
$actor_is_author = ($author_phid == $actor_phid);
|
$actor_is_author = ($author_phid == $actor_phid);
|
||||||
|
|
||||||
|
$config_abandon_key = 'differential.always-allow-abandon';
|
||||||
|
$always_allow_abandon = PhabricatorEnv::getEnvConfig($config_abandon_key);
|
||||||
|
|
||||||
$config_close_key = 'differential.always-allow-close';
|
$config_close_key = 'differential.always-allow-close';
|
||||||
$always_allow_close = PhabricatorEnv::getEnvConfig($config_close_key);
|
$always_allow_close = PhabricatorEnv::getEnvConfig($config_close_key);
|
||||||
|
|
||||||
|
@ -860,7 +863,7 @@ final class DifferentialTransactionEditor
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DifferentialAction::ACTION_ABANDON:
|
case DifferentialAction::ACTION_ABANDON:
|
||||||
if (!$actor_is_author) {
|
if (!$actor_is_author && !$always_allow_abandon) {
|
||||||
return pht(
|
return pht(
|
||||||
"You can not abandon this revision because you do not own it. ".
|
"You can not abandon this revision because you do not own it. ".
|
||||||
"You can only abandon revisions you own.");
|
"You can only abandon revisions you own.");
|
||||||
|
|
Loading…
Reference in a new issue