Differential D18626 Diff 44738 src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
| <?php | <?php | ||||
| final class DifferentialRevisionCommandeerTransaction | final class DifferentialRevisionCommandeerTransaction | ||||
| extends DifferentialRevisionActionTransaction { | extends DifferentialRevisionActionTransaction { | ||||
| const TRANSACTIONTYPE = 'differential.revision.commandeer'; | const TRANSACTIONTYPE = 'differential.revision.commandeer'; | ||||
| const ACTIONKEY = 'commandeer'; | const ACTIONKEY = 'commandeer'; | ||||
| protected function getRevisionActionLabel() { | protected function getRevisionActionLabel() { | ||||
| return pht('Commandeer Revision'); | return pht('Commandeer Revision'); | ||||
| } | } | ||||
| protected function getRevisionActionDescription() { | protected function getRevisionActionDescription( | ||||
| DifferentialRevision $revision) { | |||||
| return pht('You will take control of this revision and become its author.'); | return pht('You will take control of this revision and become its author.'); | ||||
| } | } | ||||
| public function getIcon() { | public function getIcon() { | ||||
| return 'fa-flag'; | return 'fa-flag'; | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| Show All 38 Lines | final class DifferentialRevisionCommandeerTransaction | ||||
| protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
| if ($object->isClosed()) { | if ($object->isClosed()) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not commandeer this revision because it has already '. | 'You can not commandeer this revision because it has already '. | ||||
| 'been closed. You can only commandeer open revisions.')); | 'been closed. You can only commandeer open revisions.')); | ||||
| } | } | ||||
| if ($object->isDraft()) { | |||||
| throw new Exception( | |||||
| pht('You can not commandeer a draft revision.')); | |||||
| } | |||||
amckinley: What's the reasoning for this constraint? A "draft" revision will definitely have more activity… | |||||
Not Done Inline ActionsMostly just to make the logic easier to write for now. I think we'll probably allow this eventually, but I'm not sure anyone will really need it. epriestley: Mostly just to make the logic easier to write for now. I think we'll //probably// allow this… | |||||
| if ($this->isViewerRevisionAuthor($object, $viewer)) { | if ($this->isViewerRevisionAuthor($object, $viewer)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not commandeer this revision because you are already '. | 'You can not commandeer this revision because you are already '. | ||||
| 'the author.')); | 'the author.')); | ||||
| } | } | ||||
| } | } | ||||
| Show All 14 Lines | |||||
What's the reasoning for this constraint? A "draft" revision will definitely have more activity in the future, so commandeering is always premature?