@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modularize Differential Reviewer actions in Herald

Ref T8726. Modularizes the "Add Reviewers" and "Add Blocking Reviewers" Herald actions.

+426 -136
+4 -4
resources/sql/autopatches/20150724.herald.1.sql resources/sql/autopatches/20150730.herald.1.sql
··· 1 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 1 + UPDATE {$NAMESPACE}_herald.herald_action a 2 2 JOIN {$NAMESPACE}_herald.herald_rule r 3 3 ON a.ruleID = r.id 4 4 SET a.action = 'subscribers.add' 5 5 WHERE r.ruleType != 'personal' 6 6 AND a.action = 'addcc'; 7 7 8 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 8 + UPDATE {$NAMESPACE}_herald.herald_action a 9 9 JOIN {$NAMESPACE}_herald.herald_rule r 10 10 ON a.ruleID = r.id 11 11 SET a.action = 'subscribers.self.add' 12 12 WHERE r.ruleType = 'personal' 13 13 AND a.action = 'addcc'; 14 14 15 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 15 + UPDATE {$NAMESPACE}_herald.herald_action a 16 16 JOIN {$NAMESPACE}_herald.herald_rule r 17 17 ON a.ruleID = r.id 18 18 SET a.action = 'subscribers.remove' 19 19 WHERE r.ruleType != 'personal' 20 20 AND a.action = 'remcc'; 21 21 22 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 22 + UPDATE {$NAMESPACE}_herald.herald_action a 23 23 JOIN {$NAMESPACE}_herald.herald_rule r 24 24 ON a.ruleID = r.id 25 25 SET a.action = 'subscribers.self.remove'
+2 -2
resources/sql/autopatches/20150724.herald.2.sql resources/sql/autopatches/20150730.herald.2.sql
··· 1 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 1 + UPDATE {$NAMESPACE}_herald.herald_action a 2 2 JOIN {$NAMESPACE}_herald.herald_rule r 3 3 ON a.ruleID = r.id 4 4 SET a.action = 'email.other' 5 5 WHERE r.ruleType != 'personal' 6 6 AND a.action = 'email'; 7 7 8 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 8 + UPDATE {$NAMESPACE}_herald.herald_action a 9 9 JOIN {$NAMESPACE}_herald.herald_rule r 10 10 ON a.ruleID = r.id 11 11 SET a.action = 'email.self'
+2 -2
resources/sql/autopatches/20150724.herald.3.sql resources/sql/autopatches/20150730.herald.3.sql
··· 1 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 1 + UPDATE {$NAMESPACE}_herald.herald_action a 2 2 JOIN {$NAMESPACE}_herald.herald_rule r 3 3 ON a.ruleID = r.id 4 4 SET a.action = 'projects.add' 5 5 WHERE a.action = 'addprojects'; 6 6 7 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 7 + UPDATE {$NAMESPACE}_herald.herald_action a 8 8 JOIN {$NAMESPACE}_herald.herald_rule r 9 9 ON a.ruleID = r.id 10 10 SET a.action = 'projects.remove'
+2 -2
resources/sql/autopatches/20150724.herald.4.sql resources/sql/autopatches/20150730.herald.4.sql
··· 1 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 1 + UPDATE {$NAMESPACE}_herald.herald_action a 2 2 JOIN {$NAMESPACE}_herald.herald_rule r 3 3 ON a.ruleID = r.id 4 4 SET a.action = 'maniphest.assign.other' 5 5 WHERE r.ruleType != 'personal' 6 6 AND a.action = 'assigntask'; 7 7 8 - UPDATE {$NAMESPACE}_herald.herald_actionrecord a 8 + UPDATE {$NAMESPACE}_herald.herald_action a 9 9 JOIN {$NAMESPACE}_herald.herald_rule r 10 10 ON a.ruleID = r.id 11 11 SET a.action = 'maniphest.assign.self'
+27
resources/sql/autopatches/20150730.herald.5.sql
··· 1 + UPDATE {$NAMESPACE}_herald.herald_action a 2 + JOIN {$NAMESPACE}_herald.herald_rule r 3 + ON a.ruleID = r.id 4 + SET a.action = 'differential.reviewers.blocking' 5 + WHERE r.ruleType != 'personal' 6 + AND a.action = 'addreviewers'; 7 + 8 + UPDATE {$NAMESPACE}_herald.herald_action a 9 + JOIN {$NAMESPACE}_herald.herald_rule r 10 + ON a.ruleID = r.id 11 + SET a.action = 'differential.reviewers.self.blocking' 12 + WHERE r.ruleType = 'personal' 13 + AND a.action = 'addreviewers'; 14 + 15 + UPDATE {$NAMESPACE}_herald.herald_action a 16 + JOIN {$NAMESPACE}_herald.herald_rule r 17 + ON a.ruleID = r.id 18 + SET a.action = 'differential.reviewers.add' 19 + WHERE r.ruleType != 'personal' 20 + AND a.action = 'addblockingreviewers'; 21 + 22 + UPDATE {$NAMESPACE}_herald.herald_action a 23 + JOIN {$NAMESPACE}_herald.herald_rule r 24 + ON a.ruleID = r.id 25 + SET a.action = 'differential.reviewers.self.add' 26 + WHERE r.ruleType = 'personal' 27 + AND a.action = 'addblockingreviewers';
+10
src/__phutil_library_map__.php
··· 435 435 'DifferentialReviewer' => 'applications/differential/storage/DifferentialReviewer.php', 436 436 'DifferentialReviewerForRevisionEdgeType' => 'applications/differential/edge/DifferentialReviewerForRevisionEdgeType.php', 437 437 'DifferentialReviewerStatus' => 'applications/differential/constants/DifferentialReviewerStatus.php', 438 + 'DifferentialReviewersAddBlockingReviewersHeraldAction' => 'applications/differential/herald/DifferentialReviewersAddBlockingReviewersHeraldAction.php', 439 + 'DifferentialReviewersAddBlockingSelfHeraldAction' => 'applications/differential/herald/DifferentialReviewersAddBlockingSelfHeraldAction.php', 440 + 'DifferentialReviewersAddReviewersHeraldAction' => 'applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php', 441 + 'DifferentialReviewersAddSelfHeraldAction' => 'applications/differential/herald/DifferentialReviewersAddSelfHeraldAction.php', 438 442 'DifferentialReviewersField' => 'applications/differential/customfield/DifferentialReviewersField.php', 443 + 'DifferentialReviewersHeraldAction' => 'applications/differential/herald/DifferentialReviewersHeraldAction.php', 439 444 'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php', 440 445 'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php', 441 446 'DifferentialRevisionAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php', ··· 4044 4049 'DifferentialReviewer' => 'Phobject', 4045 4050 'DifferentialReviewerForRevisionEdgeType' => 'PhabricatorEdgeType', 4046 4051 'DifferentialReviewerStatus' => 'Phobject', 4052 + 'DifferentialReviewersAddBlockingReviewersHeraldAction' => 'DifferentialReviewersHeraldAction', 4053 + 'DifferentialReviewersAddBlockingSelfHeraldAction' => 'DifferentialReviewersHeraldAction', 4054 + 'DifferentialReviewersAddReviewersHeraldAction' => 'DifferentialReviewersHeraldAction', 4055 + 'DifferentialReviewersAddSelfHeraldAction' => 'DifferentialReviewersHeraldAction', 4047 4056 'DifferentialReviewersField' => 'DifferentialCoreCustomField', 4057 + 'DifferentialReviewersHeraldAction' => 'HeraldAction', 4048 4058 'DifferentialReviewersView' => 'AphrontView', 4049 4059 'DifferentialRevision' => array( 4050 4060 'DifferentialDAO',
-59
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1588 1588 $revision, 1589 1589 $revision->getActiveDiff()); 1590 1590 1591 - $reviewers = $revision->getReviewerStatus(); 1592 - $reviewer_phids = mpull($reviewers, 'getReviewerPHID'); 1593 - 1594 - $adapter->setExplicitReviewers($reviewer_phids); 1595 - 1596 1591 return $adapter; 1597 1592 } 1598 1593 ··· 1602 1597 HeraldTranscript $transcript) { 1603 1598 1604 1599 $xactions = array(); 1605 - 1606 - // Build a transaction to adjust reviewers. 1607 - $reviewers = array( 1608 - DifferentialReviewerStatus::STATUS_ADDED => 1609 - array_keys($adapter->getReviewersAddedByHerald()), 1610 - DifferentialReviewerStatus::STATUS_BLOCKING => 1611 - array_keys($adapter->getBlockingReviewersAddedByHerald()), 1612 - ); 1613 - 1614 - $old_reviewers = $object->getReviewerStatus(); 1615 - $old_reviewers = mpull($old_reviewers, null, 'getReviewerPHID'); 1616 - 1617 - $value = array(); 1618 - foreach ($reviewers as $status => $phids) { 1619 - foreach ($phids as $phid) { 1620 - if ($phid == $object->getAuthorPHID()) { 1621 - // Don't try to add the revision's author as a reviewer, since this 1622 - // isn't valid and doesn't make sense. 1623 - continue; 1624 - } 1625 - 1626 - // If the target is already a reviewer, don't try to change anything 1627 - // if their current status is at least as strong as the new status. 1628 - // For example, don't downgrade an "Accepted" to a "Blocking Reviewer". 1629 - $old_reviewer = idx($old_reviewers, $phid); 1630 - if ($old_reviewer) { 1631 - $old_status = $old_reviewer->getStatus(); 1632 - 1633 - $old_strength = DifferentialReviewerStatus::getStatusStrength( 1634 - $old_status); 1635 - $new_strength = DifferentialReviewerStatus::getStatusStrength( 1636 - $status); 1637 - 1638 - if ($new_strength <= $old_strength) { 1639 - continue; 1640 - } 1641 - } 1642 - 1643 - $value['+'][$phid] = array( 1644 - 'data' => array( 1645 - 'status' => $status, 1646 - ), 1647 - ); 1648 - } 1649 - } 1650 - 1651 - if ($value) { 1652 - $edge_reviewer = DifferentialRevisionHasReviewerEdgeType::EDGECONST; 1653 - 1654 - $xactions[] = id(new DifferentialTransaction()) 1655 - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 1656 - ->setMetadataValue('edge:type', $edge_reviewer) 1657 - ->setNewValue($value); 1658 - } 1659 1600 1660 1601 // Require legalpad document signatures. 1661 1602 $legal_phids = $adapter->getRequiredSignatureDocumentPHIDs();
+33
src/applications/differential/herald/DifferentialReviewersAddBlockingReviewersHeraldAction.php
··· 1 + <?php 2 + 3 + final class DifferentialReviewersAddBlockingReviewersHeraldAction 4 + extends DifferentialReviewersHeraldAction { 5 + 6 + const ACTIONCONST = 'differential.reviewers.blocking'; 7 + 8 + public function getHeraldActionName() { 9 + return pht('Add blocking reviewers'); 10 + } 11 + 12 + public function supportsRuleType($rule_type) { 13 + return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); 14 + } 15 + 16 + public function applyEffect($object, HeraldEffect $effect) { 17 + return $this->applyReviewers($effect->getTarget(), $is_blocking = true); 18 + } 19 + 20 + public function getHeraldActionStandardType() { 21 + return self::STANDARD_PHID_LIST; 22 + } 23 + 24 + protected function getDatasource() { 25 + return new PhabricatorMetaMTAMailableDatasource(); 26 + } 27 + 28 + public function renderActionDescription($value) { 29 + return pht('Add blocking reviewers: %s.', $this->renderHandleList($value)); 30 + } 31 + 32 + } 33 +
+30
src/applications/differential/herald/DifferentialReviewersAddBlockingSelfHeraldAction.php
··· 1 + <?php 2 + 3 + final class DifferentialReviewersAddBlockingSelfHeraldAction 4 + extends DifferentialReviewersHeraldAction { 5 + 6 + const ACTIONCONST = 'differential.reviewers.self.blocking'; 7 + 8 + public function getHeraldActionName() { 9 + return pht('Add me as a blocking reviewer'); 10 + } 11 + 12 + public function supportsRuleType($rule_type) { 13 + return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); 14 + } 15 + 16 + public function applyEffect($object, HeraldEffect $effect) { 17 + $phid = $effect->getRule()->getAuthorPHID(); 18 + return $this->applyReviewers(array($phid), $is_blocking = true); 19 + } 20 + 21 + public function getHeraldActionStandardType() { 22 + return self::STANDARD_NONE; 23 + } 24 + 25 + public function renderActionDescription($value) { 26 + return pht('Add rule author as blocking reviewer.'); 27 + } 28 + 29 + } 30 +
+33
src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php
··· 1 + <?php 2 + 3 + final class DifferentialReviewersAddReviewersHeraldAction 4 + extends DifferentialReviewersHeraldAction { 5 + 6 + const ACTIONCONST = 'differential.reviewers.add'; 7 + 8 + public function getHeraldActionName() { 9 + return pht('Add reviewers'); 10 + } 11 + 12 + public function supportsRuleType($rule_type) { 13 + return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); 14 + } 15 + 16 + public function applyEffect($object, HeraldEffect $effect) { 17 + return $this->applyReviewers($effect->getTarget(), $is_blocking = false); 18 + } 19 + 20 + public function getHeraldActionStandardType() { 21 + return self::STANDARD_PHID_LIST; 22 + } 23 + 24 + protected function getDatasource() { 25 + return new PhabricatorMetaMTAMailableDatasource(); 26 + } 27 + 28 + public function renderActionDescription($value) { 29 + return pht('Add reviewers: %s.', $this->renderHandleList($value)); 30 + } 31 + 32 + } 33 +
+30
src/applications/differential/herald/DifferentialReviewersAddSelfHeraldAction.php
··· 1 + <?php 2 + 3 + final class DifferentialReviewersAddSelfHeraldAction 4 + extends DifferentialReviewersHeraldAction { 5 + 6 + const ACTIONCONST = 'differential.reviewers.self.add'; 7 + 8 + public function getHeraldActionName() { 9 + return pht('Add me as a reviewer'); 10 + } 11 + 12 + public function supportsRuleType($rule_type) { 13 + return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); 14 + } 15 + 16 + public function applyEffect($object, HeraldEffect $effect) { 17 + $phid = $effect->getRule()->getAuthorPHID(); 18 + return $this->applyReviewers(array($phid), $is_blocking = false); 19 + } 20 + 21 + public function getHeraldActionStandardType() { 22 + return self::STANDARD_NONE; 23 + } 24 + 25 + public function renderActionDescription($value) { 26 + return pht('Add rule author as reviewer.'); 27 + } 28 + 29 + } 30 +
+240
src/applications/differential/herald/DifferentialReviewersHeraldAction.php
··· 1 + <?php 2 + 3 + abstract class DifferentialReviewersHeraldAction 4 + extends HeraldAction { 5 + 6 + const DO_NO_TARGETS = 'do.no-targets'; 7 + const DO_AUTHORS = 'do.authors'; 8 + const DO_INVALID = 'do.invalid'; 9 + const DO_ALREADY_REVIEWERS = 'do.already-reviewers'; 10 + const DO_PERMISSION = 'do.permission'; 11 + const DO_ADD_REVIEWERS = 'do.add-reviewers'; 12 + const DO_ADD_BLOCKING_REVIEWERS = 'do.add-blocking-reviewers'; 13 + 14 + public function getActionGroupKey() { 15 + return HeraldApplicationActionGroup::ACTIONGROUPKEY; 16 + } 17 + 18 + public function supportsObject($object) { 19 + return ($object instanceof DifferentialRevision); 20 + } 21 + 22 + protected function applyReviewers(array $phids, $is_blocking) { 23 + $adapter = $this->getAdapter(); 24 + $object = $adapter->getObject(); 25 + 26 + $phids = array_fuse($phids); 27 + if (!$phids) { 28 + $this->logEffect(self::DO_NO_TARGETS); 29 + return; 30 + } 31 + 32 + // Don't try to add revision authors as reviewers. 33 + $authors = array(); 34 + foreach ($phids as $phid) { 35 + if ($phid == $object->getAuthorPHID()) { 36 + $authors[] = $phid; 37 + unset($phids[$phid]); 38 + } 39 + } 40 + 41 + if ($authors) { 42 + $this->logEffect(self::DO_AUTHORS, $authors); 43 + } 44 + 45 + if (!$phids) { 46 + return; 47 + } 48 + 49 + $reviewers = $object->getReviewerStatus(); 50 + $reviewers = mpull($reviewers, null, 'getReviewerPHID'); 51 + 52 + if ($is_blocking) { 53 + $new_status = DifferentialReviewerStatus::STATUS_BLOCKING; 54 + } else { 55 + $new_status = DifferentialReviewerStatus::STATUS_ADDED; 56 + } 57 + 58 + $new_strength = DifferentialReviewerStatus::getStatusStrength( 59 + $new_status); 60 + 61 + $already = array(); 62 + foreach ($phids as $phid) { 63 + if (!isset($reviewers[$phid])) { 64 + continue; 65 + } 66 + 67 + // If we're applying a stronger status (usually, upgrading a reviewer 68 + // into a blocking reviewer), skip this check so we apply the change. 69 + $old_strength = DifferentialReviewerStatus::getStatusStrength( 70 + $reviewers[$phid]->getStatus()); 71 + if ($old_strength <= $new_strength) { 72 + continue; 73 + } 74 + 75 + $already[] = $phid; 76 + unset($phids[$phid]); 77 + } 78 + 79 + if ($already) { 80 + $this->logEffect(self::DO_ALREADY_REVIEWERS, $already); 81 + } 82 + 83 + if (!$phids) { 84 + return; 85 + } 86 + 87 + $targets = id(new PhabricatorObjectQuery()) 88 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 89 + ->withPHIDs($phids) 90 + ->execute(); 91 + $targets = mpull($targets, null, 'getPHID'); 92 + 93 + $invalid = array(); 94 + foreach ($phids as $phid) { 95 + if (empty($targets[$phid])) { 96 + $invalid[] = $phid; 97 + unset($phids[$phid]); 98 + } 99 + } 100 + 101 + if ($invalid) { 102 + $this->logEffect(self::DO_INVALID, $invalid); 103 + } 104 + 105 + if (!$phids) { 106 + return; 107 + } 108 + 109 + $no_access = array(); 110 + foreach ($targets as $phid => $target) { 111 + if (!($target instanceof PhabricatorUser)) { 112 + continue; 113 + } 114 + 115 + $can_view = PhabricatorPolicyFilter::hasCapability( 116 + $target, 117 + $object, 118 + PhabricatorPolicyCapability::CAN_VIEW); 119 + if ($can_view) { 120 + continue; 121 + } 122 + 123 + $no_access[] = $phid; 124 + unset($phids[$phid]); 125 + } 126 + 127 + if ($no_access) { 128 + $this->logEffect(self::DO_PERMISSION, $no_access); 129 + } 130 + 131 + if (!$phids) { 132 + return; 133 + } 134 + 135 + $value = array(); 136 + foreach ($phids as $phid) { 137 + $value[$phid] = array( 138 + 'data' => array( 139 + 'status' => $new_status, 140 + ), 141 + ); 142 + } 143 + 144 + $edgetype_reviewer = DifferentialRevisionHasReviewerEdgeType::EDGECONST; 145 + 146 + $xaction = $adapter->newTransaction() 147 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 148 + ->setMetadataValue('edge:type', $edgetype_reviewer) 149 + ->setNewValue( 150 + array( 151 + '+' => $value, 152 + )); 153 + 154 + $adapter->queueTransaction($xaction); 155 + 156 + if ($is_blocking) { 157 + $this->logEffect(self::DO_ADD_BLOCKING_REVIEWERS, $phids); 158 + } else { 159 + $this->logEffect(self::DO_ADD_REVIEWERS, $phids); 160 + } 161 + } 162 + 163 + protected function getActionEffectMap() { 164 + return array( 165 + self::DO_NO_TARGETS => array( 166 + 'icon' => 'fa-ban', 167 + 'color' => 'grey', 168 + 'name' => pht('No Targets'), 169 + ), 170 + self::DO_AUTHORS => array( 171 + 'icon' => 'fa-user', 172 + 'color' => 'grey', 173 + 'name' => pht('Revision Author'), 174 + ), 175 + self::DO_INVALID => array( 176 + 'icon' => 'fa-ban', 177 + 'color' => 'red', 178 + 'name' => pht('Invalid Targets'), 179 + ), 180 + self::DO_ALREADY_REVIEWERS => array( 181 + 'icon' => 'fa-user', 182 + 'color' => 'grey', 183 + 'name' => pht('Already Reviewers'), 184 + ), 185 + self::DO_PERMISSION => array( 186 + 'icon' => 'fa-ban', 187 + 'color' => 'red', 188 + 'name' => pht('No Permission'), 189 + ), 190 + self::DO_ADD_REVIEWERS => array( 191 + 'icon' => 'fa-user', 192 + 'color' => 'green', 193 + 'name' => pht('Added Reviewers'), 194 + ), 195 + self::DO_ADD_BLOCKING_REVIEWERS => array( 196 + 'icon' => 'fa-user', 197 + 'color' => 'green', 198 + 'name' => pht('Added Blocking Reviewers'), 199 + ), 200 + ); 201 + } 202 + 203 + public function renderActionEffectDescription($type, $data) { 204 + switch ($type) { 205 + case self::DO_NO_TARGETS: 206 + return pht('Rule lists no targets.'); 207 + case self::DO_AUTHORS: 208 + return pht( 209 + 'Declined to add revision author as reviewer: %s.', 210 + $this->renderHandleList($data)); 211 + case self::DO_INVALID: 212 + return pht( 213 + 'Declined to act on %s invalid target(s): %s.', 214 + new PhutilNumber(count($data)), 215 + $this->renderHandleList($data)); 216 + case self::DO_ALREADY_REVIEWERS: 217 + return pht( 218 + '%s target(s) were already reviewers: %s.', 219 + new PhutilNumber(count($data)), 220 + $this->renderHandleList($data)); 221 + case self::DO_PERMISSION: 222 + return pht( 223 + '%s target(s) do not have permission to see the revision: %s.', 224 + new PhutilNumber(count($data)), 225 + $this->renderHandleList($data)); 226 + case self::DO_ADD_REVIEWERS: 227 + return pht( 228 + 'Added %s reviewer(s): %s.', 229 + new PhutilNumber(count($data)), 230 + $this->renderHandleList($data)); 231 + case self::DO_ADD_BLOCKING_REVIEWERS: 232 + return pht( 233 + 'Added %s blocking reviewer(s): %s.', 234 + new PhutilNumber(count($data)), 235 + $this->renderHandleList($data)); 236 + } 237 + } 238 + 239 + 240 + }
+3 -50
src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
··· 5 5 6 6 protected $revision; 7 7 8 - protected $explicitReviewers; 9 - protected $addReviewerPHIDs = array(); 10 - protected $blockingReviewerPHIDs = array(); 11 8 protected $buildPlans = array(); 12 9 protected $requiredSignatureDocumentPHIDs = array(); 13 10 ··· 83 80 return $object; 84 81 } 85 82 86 - public function setExplicitReviewers($explicit_reviewers) { 87 - $this->explicitReviewers = $explicit_reviewers; 88 - return $this; 89 - } 90 - 91 - public function getReviewersAddedByHerald() { 92 - return $this->addReviewerPHIDs; 93 - } 94 - 95 - public function getBlockingReviewersAddedByHerald() { 96 - return $this->blockingReviewerPHIDs; 97 - } 98 - 99 83 public function getRequiredSignatureDocumentPHIDs() { 100 84 return $this->requiredSignatureDocumentPHIDs; 101 85 } ··· 147 131 } 148 132 149 133 public function loadReviewers() { 150 - // TODO: This can probably go away as I believe it's just a performance 151 - // optimization, just retaining it while modularizing fields to limit the 152 - // scope of that change. 153 - if (isset($this->explicitReviewers)) { 154 - return array_keys($this->explicitReviewers); 155 - } else { 156 - return $this->revision->getReviewers(); 157 - } 134 + $reviewers = $this->getObject()->getReviewerStatus(); 135 + return mpull($reviewers, 'getReviewerPHID'); 158 136 } 159 137 160 138 public function getActions($rule_type) { ··· 162 140 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: 163 141 return array_merge( 164 142 array( 165 - self::ACTION_ADD_REVIEWERS, 166 - self::ACTION_ADD_BLOCKING_REVIEWERS, 167 143 self::ACTION_APPLY_BUILD_PLANS, 168 144 self::ACTION_REQUIRE_SIGNATURE, 169 145 ), 170 146 parent::getActions($rule_type)); 171 147 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 172 148 return array_merge( 173 - array( 174 - self::ACTION_ADD_REVIEWERS, 175 - self::ACTION_ADD_BLOCKING_REVIEWERS, 176 - ), 149 + array(), 177 150 parent::getActions($rule_type)); 178 151 } 179 152 } ··· 186 159 foreach ($effects as $effect) { 187 160 $action = $effect->getAction(); 188 161 switch ($action) { 189 - case self::ACTION_ADD_REVIEWERS: 190 - foreach ($effect->getTarget() as $phid) { 191 - $this->addReviewerPHIDs[$phid] = true; 192 - } 193 - $result[] = new HeraldApplyTranscript( 194 - $effect, 195 - true, 196 - pht('Added reviewers.')); 197 - break; 198 - case self::ACTION_ADD_BLOCKING_REVIEWERS: 199 - // This adds reviewers normally, it just also marks them blocking. 200 - foreach ($effect->getTarget() as $phid) { 201 - $this->addReviewerPHIDs[$phid] = true; 202 - $this->blockingReviewerPHIDs[$phid] = true; 203 - } 204 - $result[] = new HeraldApplyTranscript( 205 - $effect, 206 - true, 207 - pht('Added blocking reviewers.')); 208 - break; 209 162 case self::ACTION_APPLY_BUILD_PLANS: 210 163 foreach ($effect->getTarget() as $phid) { 211 164 $this->buildPlans[] = $phid;
-17
src/applications/herald/adapter/HeraldAdapter.php
··· 27 27 const CONDITION_IS_FALSE = 'false'; 28 28 29 29 const ACTION_AUDIT = 'audit'; 30 - const ACTION_ADD_REVIEWERS = 'addreviewers'; 31 - const ACTION_ADD_BLOCKING_REVIEWERS = 'addblockingreviewers'; 32 30 const ACTION_APPLY_BUILD_PLANS = 'applybuildplans'; 33 31 const ACTION_BLOCK = 'block'; 34 32 const ACTION_REQUIRE_SIGNATURE = 'signature'; ··· 717 715 case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: 718 716 $standard = array( 719 717 self::ACTION_AUDIT => pht('Trigger an Audit by'), 720 - self::ACTION_ADD_REVIEWERS => pht('Add reviewers'), 721 - self::ACTION_ADD_BLOCKING_REVIEWERS => pht('Add blocking reviewers'), 722 718 self::ACTION_APPLY_BUILD_PLANS => pht('Run build plans'), 723 719 self::ACTION_REQUIRE_SIGNATURE => pht('Require legal signatures'), 724 720 self::ACTION_BLOCK => pht('Block change with message'), ··· 727 723 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 728 724 $standard = array( 729 725 self::ACTION_AUDIT => pht('Trigger an Audit by me'), 730 - self::ACTION_ADD_REVIEWERS => pht('Add me as a reviewer'), 731 - self::ACTION_ADD_BLOCKING_REVIEWERS => 732 - pht('Add me as a blocking reviewer'), 733 726 ); 734 727 break; 735 728 default: ··· 769 762 if ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) { 770 763 switch ($action->getAction()) { 771 764 case self::ACTION_AUDIT: 772 - case self::ACTION_ADD_REVIEWERS: 773 - case self::ACTION_ADD_BLOCKING_REVIEWERS: 774 - // For personal rules, force these actions to target the rule owner. 775 - $target = array($author_phid); 776 765 break; 777 766 case self::ACTION_BLOCK: 778 767 break; ··· 808 797 if ($is_personal) { 809 798 switch ($action) { 810 799 case self::ACTION_AUDIT: 811 - case self::ACTION_ADD_REVIEWERS: 812 - case self::ACTION_ADD_BLOCKING_REVIEWERS: 813 800 return new HeraldEmptyFieldValue(); 814 801 } 815 802 } else { 816 803 switch ($action) { 817 804 case self::ACTION_AUDIT: 818 - case self::ACTION_ADD_REVIEWERS: 819 - case self::ACTION_ADD_BLOCKING_REVIEWERS: 820 - return $this->buildTokenizerFieldValue( 821 - new PhabricatorProjectOrUserDatasource()); 822 805 case self::ACTION_APPLY_BUILD_PLANS: 823 806 return $this->buildTokenizerFieldValue( 824 807 new HarbormasterBuildPlanDatasource());
+10
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 1323 1323 'Removed projects: %2$s.', 1324 1324 ), 1325 1325 1326 + 'Added %s reviewer(s): %s.' => array( 1327 + 'Added a reviewer: %2$s.', 1328 + 'Added reviewers: %2$s.', 1329 + ), 1330 + 1331 + 'Added %s blocking reviewer(s): %s.' => array( 1332 + 'Added a blocking reviewer: %2$s.', 1333 + 'Added blocking reviewers: %2$s.', 1334 + ), 1335 + 1326 1336 ); 1327 1337 } 1328 1338