mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-28 04:00:17 +01:00
Summary: Ref T11114. This replaces the old edit controller with a new one based entirely on EditEngine. This removes the CustomFieldEditEngineExtension hack for Differential, since remaining field types are fairly straightforward and work with existing EditEngine support, as far as I can tell. Test Plan: - Created a revision via web diffs. - Updated a revision via web diffs. - Edited a revision via web. - Edited nonstandard custom fields ("Blame Revision", "JIRA Issues"). - Created a revision via CLI. - Updated a revision via CLI. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17054
110 lines
2.6 KiB
PHP
110 lines
2.6 KiB
PHP
<?php
|
|
|
|
final class DifferentialProjectsField
|
|
extends DifferentialCoreCustomField {
|
|
|
|
public function getFieldKey() {
|
|
return 'phabricator:projects';
|
|
}
|
|
|
|
public function getFieldName() {
|
|
return pht('Tags');
|
|
}
|
|
|
|
public function getFieldDescription() {
|
|
return pht('Tag projects.');
|
|
}
|
|
|
|
public function shouldAppearInPropertyView() {
|
|
return false;
|
|
}
|
|
|
|
public function shouldAppearInApplicationTransactions() {
|
|
return true;
|
|
}
|
|
|
|
protected function readValueFromRevision(
|
|
DifferentialRevision $revision) {
|
|
if (!$revision->getPHID()) {
|
|
return array();
|
|
}
|
|
|
|
$projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
$revision->getPHID(),
|
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
|
$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 renderEditControl(array $handles) {
|
|
return id(new AphrontFormTokenizerControl())
|
|
->setUser($this->getViewer())
|
|
->setName($this->getFieldKey())
|
|
->setDatasource(new PhabricatorProjectDatasource())
|
|
->setValue($this->getValue())
|
|
->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(
|
|
'Tags',
|
|
'Project',
|
|
'Projects',
|
|
);
|
|
}
|
|
|
|
public function getRequiredHandlePHIDsForCommitMessage() {
|
|
return $this->getValue();
|
|
}
|
|
|
|
public function renderCommitMessageValue(array $handles) {
|
|
return $this->renderObjectList($handles);
|
|
}
|
|
|
|
public function shouldAppearInConduitDictionary() {
|
|
// To improve performance, we exclude this field from Conduit results.
|
|
// See T11404 for discussion. In modern "differential.revision.search",
|
|
// this information is available efficiently as an attachment.
|
|
return false;
|
|
}
|
|
|
|
public function getApplicationTransactionMetadata() {
|
|
return array(
|
|
'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
|
);
|
|
}
|
|
|
|
public function parseValueFromCommitMessage($value) {
|
|
return $this->parseObjectList(
|
|
$value,
|
|
array(
|
|
PhabricatorProjectProjectPHIDType::TYPECONST,
|
|
));
|
|
}
|
|
|
|
}
|