mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Projects for DifferentialRevision
Summary: T2628, Adding project tags to revisions Test Plan: Edit revision, verify projects can be tagged. Add project hashtag to comments or commit templates, verify revision is tagged with project Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9686
This commit is contained in:
parent
c1fab59fed
commit
248b4dfa9d
4 changed files with 117 additions and 1 deletions
|
@ -415,6 +415,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialPathField' => 'applications/differential/customfield/DifferentialPathField.php',
|
||||
'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php',
|
||||
'DifferentialProjectReviewersField' => 'applications/differential/customfield/DifferentialProjectReviewersField.php',
|
||||
'DifferentialProjectsField' => 'applications/differential/customfield/DifferentialProjectsField.php',
|
||||
'DifferentialRawDiffRenderer' => 'applications/differential/render/DifferentialRawDiffRenderer.php',
|
||||
'DifferentialReleephRequestFieldSpecification' => 'applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php',
|
||||
'DifferentialRemarkupRule' => 'applications/differential/remarkup/DifferentialRemarkupRule.php',
|
||||
|
@ -3108,6 +3109,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialPathField' => 'DifferentialCustomField',
|
||||
'DifferentialPrimaryPaneView' => 'AphrontView',
|
||||
'DifferentialProjectReviewersField' => 'DifferentialCustomField',
|
||||
'DifferentialProjectsField' => 'DifferentialCoreCustomField',
|
||||
'DifferentialRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
||||
'DifferentialReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'DifferentialRepositoryField' => 'DifferentialCoreCustomField',
|
||||
|
@ -3129,6 +3131,7 @@ phutil_register_library_map(array(
|
|||
7 => 'PhabricatorCustomFieldInterface',
|
||||
8 => 'PhabricatorApplicationTransactionInterface',
|
||||
9 => 'PhabricatorDestructableInterface',
|
||||
10 => 'PhabricatorProjectInterface',
|
||||
),
|
||||
'DifferentialRevisionDetailView' => 'AphrontView',
|
||||
'DifferentialRevisionEditController' => 'DifferentialController',
|
||||
|
|
|
@ -25,6 +25,7 @@ final class PhabricatorDifferentialConfigOptions
|
|||
new DifferentialSubscribersField(),
|
||||
new DifferentialRepositoryField(),
|
||||
new DifferentialLintField(),
|
||||
new DifferentialProjectsField(),
|
||||
new DifferentialUnitField(),
|
||||
new DifferentialViewPolicyField(),
|
||||
new DifferentialEditPolicyField(),
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
final class DifferentialProjectsField
|
||||
extends DifferentialCoreCustomField {
|
||||
|
||||
public function getFieldKey() {
|
||||
return 'phabricator:projects';
|
||||
}
|
||||
|
||||
public function getFieldName() {
|
||||
return pht('Projects');
|
||||
}
|
||||
|
||||
public function getFieldDescription() {
|
||||
return pht('Tag projects.');
|
||||
}
|
||||
|
||||
public function shouldAppearInPropertyView() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function shouldAppearInEditView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAppearInApplicationTransactions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function readValueFromRevision(
|
||||
DifferentialRevision $revision) {
|
||||
if (!$revision->getPHID()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$revision->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
$projects = array_reverse($projects);
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public function getNewValueForApplicationTransactions() {
|
||||
return array('=' => array_fuse($this->getValue()));
|
||||
}
|
||||
|
||||
public function readValueFromRequest(AphrontRequest $request) {
|
||||
$this->setValue($request->getArr($this->getFieldKey()));
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForEdit() {
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTokenizerControl())
|
||||
->setName($this->getFieldKey())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setValue($handles)
|
||||
->setLabel($this->getFieldName());
|
||||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorTransactions::TYPE_EDGE;
|
||||
}
|
||||
|
||||
public function shouldAppearInCommitMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowEditInCommitMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldOverwriteWhenCommitMessageIsEdited() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCommitMessageLabels() {
|
||||
return array(
|
||||
'Project',
|
||||
'Projects',
|
||||
);
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForCommitMessage() {
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
public function renderCommitMessageValue(array $handles) {
|
||||
return $this->renderObjectList($handles);
|
||||
}
|
||||
|
||||
public function shouldAppearInConduitDictionary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionMetadata() {
|
||||
return array('edge:type' => PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
}
|
||||
|
||||
public function parseValueFromCommitMessage($value) {
|
||||
return $this->parseObjectList(
|
||||
$value,
|
||||
array(
|
||||
PhabricatorProjectPHIDTypeProject::TYPECONST,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,8 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
PhabricatorSubscribableInterface,
|
||||
PhabricatorCustomFieldInterface,
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorDestructableInterface {
|
||||
PhabricatorDestructableInterface,
|
||||
PhabricatorProjectInterface {
|
||||
|
||||
protected $title = '';
|
||||
protected $originalTitle;
|
||||
|
|
Loading…
Reference in a new issue