Pholio - allow Pholio Mocks to be attached to Maniphest Tasks (and vice versa)
Summary: Fixes T2654. Test Plan: attached lots of mocks and tasks to one another from both maniphest and pholio. verified transactions rendered okay in both applications Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2654 Differential Revision: https://secure.phabricator.com/D6501
This commit is contained in:
@@ -56,25 +56,42 @@ final class PhabricatorSearchAttachController
|
||||
$phids = array_values($phids);
|
||||
|
||||
if ($edge_type) {
|
||||
$do_txn = $object instanceof PhabricatorApplicationTransactionInterface;
|
||||
$old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$this->phid,
|
||||
$edge_type);
|
||||
$add_phids = $phids;
|
||||
$rem_phids = array_diff($old_phids, $add_phids);
|
||||
|
||||
$editor = id(new PhabricatorEdgeEditor());
|
||||
$editor->setActor($user);
|
||||
foreach ($add_phids as $phid) {
|
||||
$editor->addEdge($this->phid, $edge_type, $phid);
|
||||
}
|
||||
foreach ($rem_phids as $phid) {
|
||||
$editor->removeEdge($this->phid, $edge_type, $phid);
|
||||
}
|
||||
if ($do_txn) {
|
||||
|
||||
try {
|
||||
$editor->save();
|
||||
} catch (PhabricatorEdgeCycleException $ex) {
|
||||
$this->raiseGraphCycleException($ex);
|
||||
$txn_editor = $object->getApplicationTransactionEditor()
|
||||
->setActor($user)
|
||||
->setContentSourceFromRequest($request);
|
||||
$txn_template = $object->getApplicationTransactionObject()
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $edge_type)
|
||||
->setNewValue(array(
|
||||
'+' => array_fuse($add_phids),
|
||||
'-' => array_fuse($rem_phids)));
|
||||
$txn_editor->applyTransactions($object, array($txn_template));
|
||||
|
||||
} else {
|
||||
|
||||
$editor = id(new PhabricatorEdgeEditor());
|
||||
$editor->setActor($user);
|
||||
foreach ($add_phids as $phid) {
|
||||
$editor->addEdge($this->phid, $edge_type, $phid);
|
||||
}
|
||||
foreach ($rem_phids as $phid) {
|
||||
$editor->removeEdge($this->phid, $edge_type, $phid);
|
||||
}
|
||||
|
||||
try {
|
||||
$editor->save();
|
||||
} catch (PhabricatorEdgeCycleException $ex) {
|
||||
$this->raiseGraphCycleException($ex);
|
||||
}
|
||||
}
|
||||
|
||||
return id(new AphrontReloadResponse())->setURI($handle->getURI());
|
||||
@@ -100,12 +117,7 @@ final class PhabricatorSearchAttachController
|
||||
$obj_dialog
|
||||
->setUser($user)
|
||||
->setHandles($handles)
|
||||
->setFilters(array(
|
||||
'assigned' => 'Assigned to Me',
|
||||
'created' => 'Created By Me',
|
||||
'open' => 'All Open '.$strings['target_plural_noun'],
|
||||
'all' => 'All '.$strings['target_plural_noun'],
|
||||
))
|
||||
->setFilters($this->getFilters($strings))
|
||||
->setSelectedFilter($strings['selected'])
|
||||
->setExcluded($this->phid)
|
||||
->setCancelURI($handle->getURI())
|
||||
@@ -198,6 +210,10 @@ final class PhabricatorSearchAttachController
|
||||
$noun = 'Commits';
|
||||
$selected = 'created';
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$noun = 'Mocks';
|
||||
$selected = 'created';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($this->action) {
|
||||
@@ -234,10 +250,29 @@ final class PhabricatorSearchAttachController
|
||||
);
|
||||
}
|
||||
|
||||
private function getFilters(array $strings) {
|
||||
if ($this->type == PhabricatorPHIDConstants::PHID_TYPE_MOCK) {
|
||||
$filters = array(
|
||||
'created' => 'Created By Me',
|
||||
'all' => 'All '.$strings['target_plural_noun'],
|
||||
);
|
||||
} else {
|
||||
$filters = array(
|
||||
'assigned' => 'Assigned to Me',
|
||||
'created' => 'Created By Me',
|
||||
'open' => 'All Open '.$strings['target_plural_noun'],
|
||||
'all' => 'All '.$strings['target_plural_noun'],
|
||||
);
|
||||
}
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
private function getEdgeType($src_type, $dst_type) {
|
||||
$t_cmit = PhabricatorPHIDConstants::PHID_TYPE_CMIT;
|
||||
$t_task = PhabricatorPHIDConstants::PHID_TYPE_TASK;
|
||||
$t_drev = PhabricatorPHIDConstants::PHID_TYPE_DREV;
|
||||
$t_mock = PhabricatorPHIDConstants::PHID_TYPE_MOCK;
|
||||
|
||||
$map = array(
|
||||
$t_cmit => array(
|
||||
@@ -247,11 +282,15 @@ final class PhabricatorSearchAttachController
|
||||
$t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT,
|
||||
$t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
|
||||
$t_drev => PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV,
|
||||
$t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK,
|
||||
),
|
||||
$t_drev => array(
|
||||
$t_drev => PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV,
|
||||
$t_task => PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK,
|
||||
),
|
||||
$t_mock => array(
|
||||
$t_task => PhabricatorEdgeConfig::TYPE_MOCK_HAS_TASK,
|
||||
),
|
||||
);
|
||||
|
||||
if (empty($map[$src_type][$dst_type])) {
|
||||
|
||||
@@ -31,7 +31,11 @@ final class PhabricatorSearchSelectController
|
||||
break;
|
||||
case 'created';
|
||||
$query->setParameter('author', array($user->getPHID()));
|
||||
$query->setParameter('open', 1);
|
||||
// TODO - if / when we allow pholio mocks to be archived, etc
|
||||
// update this
|
||||
if ($this->type != PhabricatorPHIDConstants::PHID_TYPE_MOCK) {
|
||||
$query->setParameter('open', 1);
|
||||
}
|
||||
break;
|
||||
case 'open':
|
||||
$query->setParameter('open', 1);
|
||||
@@ -69,6 +73,9 @@ final class PhabricatorSearchSelectController
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_DREV:
|
||||
$pattern = '/\bD(\d+)\b/i';
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$pattern = '/\bM(\d+)\b/i';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$pattern) {
|
||||
@@ -97,6 +104,11 @@ final class PhabricatorSearchSelectController
|
||||
'id IN (%Ld)',
|
||||
$object_ids);
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$objects = id(new PholioMock())->loadAllWhere(
|
||||
'id IN (%Ld)',
|
||||
$object_ids);
|
||||
break;
|
||||
}
|
||||
|
||||
return array_fill_keys(mpull($objects, 'getPHID'), true);
|
||||
|
||||
Reference in New Issue
Block a user