Differential D21401 Diff 50944 src/applications/differential/xaction/DifferentialRevisionActionTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionActionTransaction.php
| Show All 11 Lines | try { | ||||
| $this->validateAction($object, $viewer); | $this->validateAction($object, $viewer); | ||||
| return true; | return true; | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| abstract protected function validateAction($object, PhabricatorUser $viewer); | abstract protected function validateAction($object, PhabricatorUser $viewer); | ||||
| abstract protected function getRevisionActionLabel(); | abstract protected function getRevisionActionLabel( | ||||
| DifferentialRevision $revision, | |||||
| PhabricatorUser $viewer); | |||||
| protected function validateOptionValue($object, $actor, array $value) { | protected function validateOptionValue($object, $actor, array $value) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function getCommandKeyword() { | public function getCommandKeyword() { | ||||
| return null; | return null; | ||||
| } | } | ||||
| Show All 19 Lines | return id(new PhutilSortVector()) | ||||
| ->addInt($this->getRevisionActionOrder()); | ->addInt($this->getRevisionActionOrder()); | ||||
| } | } | ||||
| protected function getRevisionActionGroupKey() { | protected function getRevisionActionGroupKey() { | ||||
| return DifferentialRevisionEditEngine::ACTIONGROUP_REVISION; | return DifferentialRevisionEditEngine::ACTIONGROUP_REVISION; | ||||
| } | } | ||||
| protected function getRevisionActionDescription( | protected function getRevisionActionDescription( | ||||
| DifferentialRevision $revision) { | DifferentialRevision $revision, | ||||
| PhabricatorUser $viewer) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| protected function getRevisionActionSubmitButtonText( | protected function getRevisionActionSubmitButtonText( | ||||
| DifferentialRevision $revision) { | DifferentialRevision $revision, | ||||
| PhabricatorUser $viewer) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| public static function loadAllActions() { | public static function loadAllActions() { | ||||
| return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
| ->setUniqueMethod('getRevisionActionKey') | ->setUniqueMethod('getRevisionActionKey') | ||||
| ->execute(); | ->execute(); | ||||
| Show All 30 Lines | public function newEditField( | ||||
| $field = id(new PhabricatorApplyEditField()) | $field = id(new PhabricatorApplyEditField()) | ||||
| ->setKey($this->getRevisionActionKey()) | ->setKey($this->getRevisionActionKey()) | ||||
| ->setTransactionType($this->getTransactionTypeConstant()) | ->setTransactionType($this->getTransactionTypeConstant()) | ||||
| ->setCanApplyWithoutEditCapability($is_review) | ->setCanApplyWithoutEditCapability($is_review) | ||||
| ->setValue(true); | ->setValue(true); | ||||
| if ($this->isActionAvailable($revision, $viewer)) { | if ($this->isActionAvailable($revision, $viewer)) { | ||||
| $label = $this->getRevisionActionLabel(); | $label = $this->getRevisionActionLabel($revision, $viewer); | ||||
| if ($label !== null) { | if ($label !== null) { | ||||
| $field->setCommentActionLabel($label); | $field->setCommentActionLabel($label); | ||||
| $description = $this->getRevisionActionDescription($revision); | $description = $this->getRevisionActionDescription($revision, $viewer); | ||||
| $field->setActionDescription($description); | $field->setActionDescription($description); | ||||
| $group_key = $this->getRevisionActionGroupKey(); | $group_key = $this->getRevisionActionGroupKey(); | ||||
| $field->setCommentActionGroupKey($group_key); | $field->setCommentActionGroupKey($group_key); | ||||
| $button_text = $this->getRevisionActionSubmitButtonText($revision); | $button_text = $this->getRevisionActionSubmitButtonText( | ||||
| $revision, | |||||
| $viewer); | |||||
| $field->setActionSubmitButtonText($button_text); | $field->setActionSubmitButtonText($button_text); | ||||
| // Currently, every revision action conflicts with every other | // Currently, every revision action conflicts with every other | ||||
| // revision action: for example, you can not simultaneously Accept and | // revision action: for example, you can not simultaneously Accept and | ||||
| // Reject a revision. | // Reject a revision. | ||||
| // Under some configurations, some combinations of actions are sort of | // Under some configurations, some combinations of actions are sort of | ||||
| // technically permissible. For example, you could reasonably Reject | // technically permissible. For example, you could reasonably Reject | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||