2016-06-22 14:35:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorObjectRelationship extends Phobject {
|
|
|
|
|
|
|
|
private $viewer;
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
private $contentSource;
|
2016-06-22 14:35:40 +02:00
|
|
|
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
public function setContentSource(PhabricatorContentSource $content_source) {
|
|
|
|
$this->contentSource = $content_source;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentSource() {
|
|
|
|
return $this->contentSource;
|
|
|
|
}
|
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
final public function getRelationshipConstant() {
|
|
|
|
return $this->getPhobjectClassConstant('RELATIONSHIPKEY');
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function isEnabledForObject($object);
|
|
|
|
|
|
|
|
abstract public function getEdgeConstant();
|
|
|
|
|
|
|
|
abstract protected function getActionName();
|
|
|
|
abstract protected function getActionIcon();
|
|
|
|
|
2016-06-22 17:04:14 +02:00
|
|
|
abstract public function canRelateObjects($src, $dst);
|
|
|
|
|
|
|
|
abstract public function getDialogTitleText();
|
|
|
|
abstract public function getDialogHeaderText();
|
|
|
|
abstract public function getDialogButtonText();
|
|
|
|
|
|
|
|
public function getDialogInstructionsText() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
public function shouldAppearInActionMenu() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function isActionEnabled($object) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
return PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$object,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
}
|
|
|
|
|
2016-06-29 01:05:05 +02:00
|
|
|
public function getRequiredRelationshipCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final public function newSource() {
|
2016-06-29 03:38:45 +02:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
return $this->newRelationshipSource()
|
|
|
|
->setViewer($viewer);
|
2016-06-29 01:05:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
abstract protected function newRelationshipSource();
|
|
|
|
|
|
|
|
final public function getSourceURI($object) {
|
|
|
|
$relationship_key = $this->getRelationshipConstant();
|
|
|
|
$object_phid = $object->getPHID();
|
|
|
|
|
|
|
|
return "/search/source/{$relationship_key}/{$object_phid}/";
|
|
|
|
}
|
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
final public function newAction($object) {
|
|
|
|
$is_enabled = $this->isActionEnabled($object);
|
|
|
|
$action_uri = $this->getActionURI($object);
|
|
|
|
|
|
|
|
return id(new PhabricatorActionView())
|
|
|
|
->setName($this->getActionName())
|
|
|
|
->setHref($action_uri)
|
|
|
|
->setIcon($this->getActionIcon())
|
|
|
|
->setDisabled(!$is_enabled)
|
|
|
|
->setWorkflow(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
final public static function getAllRelationships() {
|
|
|
|
return id(new PhutilClassMapQuery())
|
|
|
|
->setAncestorClass(__CLASS__)
|
|
|
|
->setUniqueMethod('getRelationshipConstant')
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getActionURI($object) {
|
|
|
|
$phid = $object->getPHID();
|
2016-06-22 17:04:14 +02:00
|
|
|
$type = $this->getRelationshipConstant();
|
|
|
|
return "/search/rel/{$type}/{$phid}/";
|
2016-06-22 14:35:40 +02:00
|
|
|
}
|
|
|
|
|
2016-06-30 20:37:38 +02:00
|
|
|
public function getMaximumSelectionSize() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
public function canUndoRelationship() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willUpdateRelationships($object, array $add, array $rem) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function didUpdateRelationships($object, array $add, array $rem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
}
|