diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index eae5e70b65..842b76a8ea 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -545,6 +545,7 @@ phutil_register_library_map(array( 'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php', 'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php', 'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php', + 'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php', 'DifferentialRevisionRequiredActionResultBucket' => 'applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php', 'DifferentialRevisionResultBucket' => 'applications/differential/query/DifferentialRevisionResultBucket.php', 'DifferentialRevisionReviewersHeraldField' => 'applications/differential/herald/DifferentialRevisionReviewersHeraldField.php', @@ -552,6 +553,7 @@ phutil_register_library_map(array( 'DifferentialRevisionSearchEngine' => 'applications/differential/query/DifferentialRevisionSearchEngine.php', 'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php', 'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php', + 'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php', 'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php', 'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php', 'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php', @@ -5195,6 +5197,7 @@ phutil_register_library_map(array( 'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource', 'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField', + 'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionRequiredActionResultBucket' => 'DifferentialRevisionResultBucket', 'DifferentialRevisionResultBucket' => 'PhabricatorSearchResultBucket', 'DifferentialRevisionReviewersHeraldField' => 'DifferentialRevisionHeraldField', @@ -5202,6 +5205,7 @@ phutil_register_library_map(array( 'DifferentialRevisionSearchEngine' => 'PhabricatorApplicationSearchEngine', 'DifferentialRevisionStatus' => 'Phobject', 'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField', + 'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType', diff --git a/src/applications/differential/editor/DifferentialRevisionEditEngine.php b/src/applications/differential/editor/DifferentialRevisionEditEngine.php index 9bd986c33d..c9627a50b0 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditEngine.php +++ b/src/applications/differential/editor/DifferentialRevisionEditEngine.php @@ -64,12 +64,32 @@ final class DifferentialRevisionEditEngine id(new PhabricatorTextEditField()) ->setKey('title') ->setLabel(pht('Title')) + ->setIsRequired(true) ->setTransactionType( DifferentialRevisionTitleTransaction::TRANSACTIONTYPE) ->setDescription(pht('The title of the revision.')) ->setConduitDescription(pht('Retitle the revision.')) ->setConduitTypeDescription(pht('New revision title.')) ->setValue($object->getTitle()), + id(new PhabricatorRemarkupEditField()) + ->setKey('summary') + ->setLabel(pht('Summary')) + ->setTransactionType( + DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE) + ->setDescription(pht('The summary of the revision.')) + ->setConduitDescription(pht('Change the revision summary.')) + ->setConduitTypeDescription(pht('New revision summary.')) + ->setValue($object->getSummary()), + id(new PhabricatorDatasourceEditField()) + ->setKey('repositoryPHID') + ->setLabel(pht('Repository')) + ->setDatasource(new DiffusionRepositoryDatasource()) + ->setTransactionType( + DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE) + ->setDescription(pht('The repository the revision belongs to.')) + ->setConduitDescription(pht('Change the repository for this revision.')) + ->setConduitTypeDescription(pht('New repository.')) + ->setSingleValue($object->getRepositoryPHID()), ); } diff --git a/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php b/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php new file mode 100644 index 0000000000..63c7f2c32d --- /dev/null +++ b/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php @@ -0,0 +1,95 @@ +getRepositoryPHID(); + } + + public function applyInternalEffects($object, $value) { + $object->setRepositoryPHID($value); + } + + public function getTitle() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + if ($old && $new) { + return pht( + '%s changed the repository for this revision from %s to %s.', + $this->renderAuthor(), + $this->renderHandle($old), + $this->renderHandle($new)); + } else if ($new) { + return pht( + '%s set the repository for this revision to %s.', + $this->renderAuthor(), + $this->renderHandle($new)); + } else { + return pht( + '%s removed %s as the repository for this revision.', + $this->renderAuthor(), + $this->renderHandle($old)); + } + } + + public function getTitleForFeed() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + if ($old && $new) { + return pht( + '%s changed the repository for %s from %s to %s.', + $this->renderAuthor(), + $this->renderObject(), + $this->renderHandle($old), + $this->renderHandle($new)); + } else if ($new) { + return pht( + '%s set the repository for %s to %s.', + $this->renderAuthor(), + $this->renderObject(), + $this->renderHandle($new)); + } else { + return pht( + '%s removed %s as the repository for %s.', + $this->renderAuthor(), + $this->renderHandle($old), + $this->renderObject()); + } + } + + public function validateTransactions($object, array $xactions) { + $actor = $this->getActor(); + + $errors = array(); + + $old_value = $object->getRepositoryPHID(); + foreach ($xactions as $xaction) { + $new_value = $xaction->getNewValue(); + if (!$new_value) { + continue; + } + + if ($new_value == $old_value) { + continue; + } + + $repository = id(new PhabricatorRepositoryQuery()) + ->setViewer($actor) + ->withPHIDs(array($new_value)) + ->executeOne(); + if (!$repository) { + $errors[] = $this->newInvalidError( + pht( + 'Repository "%s" is not a valid repository, or you do not have '. + 'permission to view it.'), + $xaction); + } + } + + return $errors; + } + +} diff --git a/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php new file mode 100644 index 0000000000..0ad6ba0971 --- /dev/null +++ b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php @@ -0,0 +1,56 @@ +getSummary(); + } + + public function applyInternalEffects($object, $value) { + $object->setSummary($value); + } + + public function getTitle() { + return pht( + '%s edited the summary of this revision.', + $this->renderAuthor()); + } + + public function getTitleForFeed() { + return pht( + '%s updated the summary of %s.', + $this->renderAuthor(), + $this->renderObject()); + } + + public function hasChangeDetailView() { + return true; + } + + public function getMailDiffSectionHeader() { + return pht('CHANGES TO REVISION SUMMARY'); + } + + public function newChangeDetailView() { + $viewer = $this->getViewer(); + + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) + ->setViewer($viewer) + ->setOldText($this->getOldValue()) + ->setNewText($this->getNewValue()); + } + + public function newRemarkupChanges() { + $changes = array(); + + $changes[] = $this->newRemarkupChange() + ->setOldValue($this->getOldValue()) + ->setNewValue($this->getNewValue()); + + return $changes; + } + +}