2015-11-29 10:05:41 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectsEditEngineExtension
|
|
|
|
extends PhabricatorEditEngineExtension {
|
|
|
|
|
|
|
|
const EXTENSIONKEY = 'projects.projects';
|
|
|
|
|
2016-12-16 04:45:55 -08:00
|
|
|
const EDITKEY_ADD = 'projects.add';
|
|
|
|
const EDITKEY_SET = 'projects.set';
|
|
|
|
const EDITKEY_REMOVE = 'projects.remove';
|
|
|
|
|
2015-11-29 10:05:41 -08:00
|
|
|
public function getExtensionPriority() {
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isExtensionEnabled() {
|
|
|
|
return PhabricatorApplication::isClassInstalled(
|
|
|
|
'PhabricatorProjectApplication');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getExtensionName() {
|
|
|
|
return pht('Projects');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function supportsObject(
|
|
|
|
PhabricatorEditEngine $engine,
|
|
|
|
PhabricatorApplicationTransactionInterface $object) {
|
|
|
|
|
|
|
|
return ($object instanceof PhabricatorProjectInterface);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildCustomEditFields(
|
|
|
|
PhabricatorEditEngine $engine,
|
|
|
|
PhabricatorApplicationTransactionInterface $object) {
|
|
|
|
|
|
|
|
$edge_type = PhabricatorTransactions::TYPE_EDGE;
|
|
|
|
$project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
|
|
|
|
|
|
|
$object_phid = $object->getPHID();
|
|
|
|
if ($object_phid) {
|
|
|
|
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
|
|
$object_phid,
|
|
|
|
$project_edge_type);
|
|
|
|
$project_phids = array_reverse($project_phids);
|
|
|
|
} else {
|
|
|
|
$project_phids = array();
|
|
|
|
}
|
|
|
|
|
2018-01-11 10:58:10 -08:00
|
|
|
$viewer = $engine->getViewer();
|
|
|
|
|
2015-11-29 10:05:41 -08:00
|
|
|
$projects_field = id(new PhabricatorProjectsEditField())
|
|
|
|
->setKey('projectPHIDs')
|
2016-01-24 09:39:53 -08:00
|
|
|
->setLabel(pht('Tags'))
|
2015-11-29 10:05:41 -08:00
|
|
|
->setEditTypeKey('projects')
|
2016-01-24 09:39:53 -08:00
|
|
|
->setAliases(array('project', 'projects', 'tag', 'tags'))
|
2015-12-07 11:37:51 -08:00
|
|
|
->setIsCopyable(true)
|
2015-11-29 13:24:47 -08:00
|
|
|
->setUseEdgeTransactions(true)
|
2016-01-24 09:39:53 -08:00
|
|
|
->setCommentActionLabel(pht('Change Project Tags'))
|
2016-04-06 06:22:44 -07:00
|
|
|
->setCommentActionOrder(8000)
|
2016-01-24 09:39:53 -08:00
|
|
|
->setDescription(pht('Select project tags for the object.'))
|
2015-11-29 10:05:41 -08:00
|
|
|
->setTransactionType($edge_type)
|
|
|
|
->setMetadataValue('edge:type', $project_edge_type)
|
2018-01-11 10:58:10 -08:00
|
|
|
->setValue($project_phids)
|
|
|
|
->setViewer($viewer);
|
2015-11-29 10:05:41 -08:00
|
|
|
|
2018-01-11 10:58:10 -08:00
|
|
|
$projects_datasource = id(new PhabricatorProjectDatasource())
|
|
|
|
->setViewer($viewer);
|
2015-12-16 05:09:21 -08:00
|
|
|
|
2016-12-16 04:45:55 -08:00
|
|
|
$edit_add = $projects_field->getConduitEditType(self::EDITKEY_ADD)
|
2016-01-24 09:39:53 -08:00
|
|
|
->setConduitDescription(pht('Add project tags.'));
|
2015-12-16 05:09:21 -08:00
|
|
|
|
2016-12-16 04:45:55 -08:00
|
|
|
$edit_set = $projects_field->getConduitEditType(self::EDITKEY_SET)
|
2015-12-16 05:09:21 -08:00
|
|
|
->setConduitDescription(
|
2016-01-24 09:39:53 -08:00
|
|
|
pht('Set project tags, overwriting current value.'));
|
2015-12-16 05:09:21 -08:00
|
|
|
|
2016-12-16 04:45:55 -08:00
|
|
|
$edit_rem = $projects_field->getConduitEditType(self::EDITKEY_REMOVE)
|
2016-01-24 09:39:53 -08:00
|
|
|
->setConduitDescription(pht('Remove project tags.'));
|
2015-12-16 05:09:21 -08:00
|
|
|
|
2018-01-11 10:58:10 -08:00
|
|
|
$projects_field->getBulkEditType(self::EDITKEY_ADD)
|
|
|
|
->setBulkEditLabel(pht('Add project tags'))
|
|
|
|
->setDatasource($projects_datasource);
|
|
|
|
|
|
|
|
$projects_field->getBulkEditType(self::EDITKEY_SET)
|
|
|
|
->setBulkEditLabel(pht('Set project tags to'))
|
|
|
|
->setDatasource($projects_datasource);
|
|
|
|
|
|
|
|
$projects_field->getBulkEditType(self::EDITKEY_REMOVE)
|
|
|
|
->setBulkEditLabel(pht('Remove project tags'))
|
|
|
|
->setDatasource($projects_datasource);
|
|
|
|
|
2015-11-29 10:05:41 -08:00
|
|
|
return array(
|
|
|
|
$projects_field,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|