2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class ManiphestTaskDetailController extends ManiphestController {
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 22:44:52 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-02 02:06:57 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 22:44:14 +02:00
|
|
|
$task = id(new ManiphestTaskQuery())
|
2015-08-02 02:06:57 +02:00
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($id))
|
2014-12-11 01:27:30 +01:00
|
|
|
->needSubscriberPHIDs(true)
|
2013-09-25 22:44:14 +02:00
|
|
|
->executeOne();
|
2011-03-31 06:38:24 +02:00
|
|
|
if (!$task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-17 00:58:35 +02:00
|
|
|
$field_list = PhabricatorCustomField::getObjectFields(
|
|
|
|
$task,
|
|
|
|
PhabricatorCustomField::ROLE_VIEW);
|
2014-02-21 23:44:01 +01:00
|
|
|
$field_list
|
2015-08-02 02:06:57 +02:00
|
|
|
->setViewer($viewer)
|
2014-02-21 23:44:01 +01:00
|
|
|
->readFieldsFromStorage($task);
|
2013-03-08 02:24:58 +01:00
|
|
|
|
2016-03-08 13:42:58 +01:00
|
|
|
$edit_engine = id(new ManiphestEditEngine())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setTargetObject($task);
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
$edge_types = array(
|
|
|
|
ManiphestTaskHasCommitEdgeType::EDGECONST,
|
|
|
|
ManiphestTaskHasRevisionEdgeType::EDGECONST,
|
|
|
|
ManiphestTaskHasMockEdgeType::EDGECONST,
|
|
|
|
PhabricatorObjectMentionedByObjectEdgeType::EDGECONST,
|
|
|
|
PhabricatorObjectMentionsObjectEdgeType::EDGECONST,
|
|
|
|
);
|
2012-07-19 05:41:42 +02:00
|
|
|
|
|
|
|
$phid = $task->getPHID();
|
|
|
|
|
|
|
|
$query = id(new PhabricatorEdgeQuery())
|
|
|
|
->withSourcePHIDs(array($phid))
|
2016-11-06 17:10:02 +01:00
|
|
|
->withEdgeTypes($edge_types);
|
2012-12-11 23:03:16 +01:00
|
|
|
$edges = idx($query->execute(), $phid);
|
2012-07-19 05:41:42 +02:00
|
|
|
$phids = array_fill_keys($query->getDestinationPHIDs(), true);
|
2012-04-05 02:34:25 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
if ($task->getOwnerPHID()) {
|
|
|
|
$phids[$task->getOwnerPHID()] = true;
|
|
|
|
}
|
|
|
|
$phids[$task->getAuthorPHID()] = true;
|
|
|
|
|
2011-08-03 23:20:05 +02:00
|
|
|
$phids = array_keys($phids);
|
2015-08-02 02:06:57 +02:00
|
|
|
$handles = $viewer->loadHandles($phids);
|
2013-03-08 02:24:58 +01:00
|
|
|
|
2014-11-13 23:44:55 +01:00
|
|
|
$timeline = $this->buildTransactionTimeline(
|
|
|
|
$task,
|
2016-03-21 19:19:48 +01:00
|
|
|
new ManiphestTransactionQuery());
|
2013-03-08 02:24:33 +01:00
|
|
|
|
2015-12-04 15:37:36 +01:00
|
|
|
$monogram = $task->getMonogram();
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs()
|
2016-03-05 00:44:24 +01:00
|
|
|
->addTextCrumb($monogram)
|
|
|
|
->setBorder(true);
|
2012-12-11 23:03:16 +01:00
|
|
|
|
|
|
|
$header = $this->buildHeaderView($task);
|
2016-03-05 00:44:24 +01:00
|
|
|
$details = $this->buildPropertyView($task, $field_list, $edges, $handles);
|
2016-03-21 19:19:48 +01:00
|
|
|
$description = $this->buildDescriptionView($task);
|
2016-03-08 13:42:58 +01:00
|
|
|
$curtain = $this->buildCurtain($task, $edit_engine);
|
2013-09-29 00:55:38 +02:00
|
|
|
|
2015-12-04 15:37:36 +01:00
|
|
|
$title = pht('%s %s', $monogram, $task->getTitle());
|
|
|
|
|
2016-03-08 13:42:58 +01:00
|
|
|
$comment_view = $edit_engine
|
2015-12-04 15:37:36 +01:00
|
|
|
->buildEditEngineCommentView($task);
|
2015-11-29 02:49:56 +01:00
|
|
|
|
2015-12-04 16:12:12 +01:00
|
|
|
$timeline->setQuoteRef($monogram);
|
|
|
|
$comment_view->setTransactionTimeline($timeline);
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
$related_tabs = array();
|
|
|
|
$graph_menu = null;
|
2016-03-05 00:44:24 +01:00
|
|
|
|
2016-07-14 06:07:34 +02:00
|
|
|
$graph_limit = 100;
|
2016-07-01 17:50:16 +02:00
|
|
|
$task_graph = id(new ManiphestTaskGraph())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setSeedPHID($task->getPHID())
|
2016-07-14 06:07:34 +02:00
|
|
|
->setLimit($graph_limit)
|
2016-07-01 17:50:16 +02:00
|
|
|
->loadGraph();
|
|
|
|
if (!$task_graph->isEmpty()) {
|
2016-07-28 22:54:10 +02:00
|
|
|
$parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
|
|
|
|
$subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
|
|
|
|
$parent_map = $task_graph->getEdges($parent_type);
|
|
|
|
$subtask_map = $task_graph->getEdges($subtask_type);
|
|
|
|
$parent_list = idx($parent_map, $task->getPHID(), array());
|
|
|
|
$subtask_list = idx($subtask_map, $task->getPHID(), array());
|
|
|
|
$has_parents = (bool)$parent_list;
|
|
|
|
$has_subtasks = (bool)$subtask_list;
|
|
|
|
|
|
|
|
$search_text = pht('Search...');
|
|
|
|
|
|
|
|
// First, get a count of direct parent tasks and subtasks. If there
|
|
|
|
// are too many of these, we just don't draw anything. You can use
|
|
|
|
// the search button to browse tasks with the search UI instead.
|
|
|
|
$direct_count = count($parent_list) + count($subtask_list);
|
|
|
|
|
|
|
|
if ($direct_count > $graph_limit) {
|
2016-07-14 06:07:34 +02:00
|
|
|
$message = pht(
|
2016-07-28 22:54:10 +02:00
|
|
|
'Task graph too large to display (this task is directly connected '.
|
|
|
|
'to more than %s other tasks). Use %s to explore connected tasks.',
|
|
|
|
$graph_limit,
|
|
|
|
phutil_tag('strong', array(), $search_text));
|
2016-07-14 06:07:34 +02:00
|
|
|
$message = phutil_tag('em', array(), $message);
|
|
|
|
$graph_table = id(new PHUIPropertyListView())
|
|
|
|
->addTextContent($message);
|
|
|
|
} else {
|
2016-07-28 22:54:10 +02:00
|
|
|
// If there aren't too many direct tasks, but there are too many total
|
|
|
|
// tasks, we'll only render directly connected tasks.
|
|
|
|
if ($task_graph->isOverLimit()) {
|
|
|
|
$task_graph->setRenderOnlyAdjacentNodes(true);
|
|
|
|
}
|
2016-07-14 06:07:34 +02:00
|
|
|
$graph_table = $task_graph->newGraphTable();
|
|
|
|
}
|
|
|
|
|
2016-07-28 22:26:36 +02:00
|
|
|
$parents_uri = urisprintf(
|
|
|
|
'/?subtaskIDs=%d#R',
|
|
|
|
$task->getID());
|
|
|
|
$parents_uri = $this->getApplicationURI($parents_uri);
|
|
|
|
|
|
|
|
$subtasks_uri = urisprintf(
|
|
|
|
'/?parentIDs=%d#R',
|
|
|
|
$task->getID());
|
|
|
|
$subtasks_uri = $this->getApplicationURI($subtasks_uri);
|
|
|
|
|
|
|
|
$dropdown_menu = id(new PhabricatorActionListView())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setHref($parents_uri)
|
|
|
|
->setName(pht('Search Parent Tasks'))
|
|
|
|
->setDisabled(!$has_parents)
|
|
|
|
->setIcon('fa-chevron-circle-up'))
|
|
|
|
->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setHref($subtasks_uri)
|
|
|
|
->setName(pht('Search Subtasks'))
|
|
|
|
->setDisabled(!$has_subtasks)
|
|
|
|
->setIcon('fa-chevron-circle-down'));
|
|
|
|
|
|
|
|
$graph_menu = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setIcon('fa-search')
|
2016-07-28 22:54:10 +02:00
|
|
|
->setText($search_text)
|
2016-07-28 22:26:36 +02:00
|
|
|
->setDropdownMenu($dropdown_menu);
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
$related_tabs[] = id(new PHUITabView())
|
|
|
|
->setName(pht('Task Graph'))
|
|
|
|
->setKey('graph')
|
|
|
|
->appendChild($graph_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
$related_tabs[] = $this->newMocksTab($task, $query);
|
|
|
|
$related_tabs[] = $this->newMentionsTab($task, $query);
|
|
|
|
|
|
|
|
$tab_view = null;
|
|
|
|
|
|
|
|
$related_tabs = array_filter($related_tabs);
|
|
|
|
if ($related_tabs) {
|
|
|
|
$tab_group = new PHUITabGroupView();
|
|
|
|
foreach ($related_tabs as $tab) {
|
|
|
|
$tab_group->addTab($tab);
|
|
|
|
}
|
|
|
|
|
|
|
|
$related_header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Related Objects'));
|
2016-07-28 22:26:36 +02:00
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
if ($graph_menu) {
|
|
|
|
$related_header->addActionLink($graph_menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
$tab_view = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($related_header)
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
->addTabGroup($tab_group);
|
2016-07-01 17:50:16 +02:00
|
|
|
}
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
|
|
|
->setCurtain($curtain)
|
|
|
|
->setMainColumn(
|
|
|
|
array(
|
|
|
|
$tab_view,
|
|
|
|
$timeline,
|
|
|
|
$comment_view,
|
|
|
|
))
|
|
|
|
->addPropertySection(pht('Description'), $description)
|
|
|
|
->addPropertySection(pht('Details'), $details);
|
|
|
|
|
|
|
|
|
2015-11-29 02:49:56 +01:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->setPageObjectPHIDs(
|
|
|
|
array(
|
|
|
|
$task->getPHID(),
|
|
|
|
))
|
2016-11-06 17:10:02 +01:00
|
|
|
->appendChild($view);
|
2016-03-05 00:44:24 +01:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
2011-02-19 07:15:28 +01:00
|
|
|
|
2012-12-11 23:03:16 +01:00
|
|
|
private function buildHeaderView(ManiphestTask $task) {
|
2013-09-17 18:12:37 +02:00
|
|
|
$view = id(new PHUIHeaderView())
|
2013-09-25 22:44:45 +02:00
|
|
|
->setHeader($task->getTitle())
|
|
|
|
->setUser($this->getRequest()->getUser())
|
|
|
|
->setPolicyObject($task);
|
2012-12-11 23:03:16 +01:00
|
|
|
|
2016-03-05 00:44:24 +01:00
|
|
|
$priority_name = ManiphestTaskPriority::getTaskPriorityName(
|
|
|
|
$task->getPriority());
|
|
|
|
$priority_color = ManiphestTaskPriority::getTaskPriorityColor(
|
|
|
|
$task->getPriority());
|
2013-09-24 17:42:04 +02:00
|
|
|
|
2016-03-05 00:44:24 +01:00
|
|
|
$status = $task->getStatus();
|
|
|
|
$status_name = ManiphestTaskStatus::renderFullDescription(
|
|
|
|
$status, $priority_name, $priority_color);
|
2013-09-24 17:42:04 +02:00
|
|
|
$view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_name);
|
2012-12-11 23:03:16 +01:00
|
|
|
|
2016-03-05 00:44:24 +01:00
|
|
|
$view->setHeaderIcon(ManiphestTaskStatus::getStatusIcon(
|
|
|
|
$task->getStatus()).' '.$priority_color);
|
|
|
|
|
|
|
|
if (ManiphestTaskPoints::getIsEnabled()) {
|
|
|
|
$points = $task->getPoints();
|
|
|
|
if ($points !== null) {
|
|
|
|
$points_name = pht('%s %s',
|
|
|
|
$task->getPoints(),
|
|
|
|
ManiphestTaskPoints::getPointsLabel());
|
|
|
|
$tag = id(new PHUITagView())
|
|
|
|
->setName($points_name)
|
|
|
|
->setShade('blue')
|
|
|
|
->setType(PHUITagView::TYPE_SHADE);
|
|
|
|
|
|
|
|
$view->addTag($tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:03:16 +01:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-08 13:42:58 +01:00
|
|
|
private function buildCurtain(
|
|
|
|
ManiphestTask $task,
|
|
|
|
PhabricatorEditEngine $edit_engine) {
|
2016-03-06 19:16:00 +01:00
|
|
|
$viewer = $this->getViewer();
|
2012-12-11 23:03:16 +01:00
|
|
|
|
|
|
|
$id = $task->getID();
|
|
|
|
$phid = $task->getPHID();
|
|
|
|
|
2013-09-25 22:44:52 +02:00
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$task,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
2016-03-06 19:16:00 +01:00
|
|
|
$curtain = $this->newCurtainView($task);
|
2013-09-25 22:44:52 +02:00
|
|
|
|
2016-03-06 19:16:00 +01:00
|
|
|
$curtain->addAction(
|
2012-12-11 23:03:16 +01:00
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Edit Task'))
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2015-12-09 01:54:46 +01:00
|
|
|
->setHref($this->getApplicationURI("/task/edit/{$id}/"))
|
2013-09-25 22:44:52 +02:00
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit));
|
2012-12-11 23:03:16 +01:00
|
|
|
|
2016-03-08 13:42:58 +01:00
|
|
|
$edit_config = $edit_engine->loadDefaultEditConfiguration();
|
2015-12-08 16:54:01 +01:00
|
|
|
$can_create = (bool)$edit_config;
|
2016-03-08 13:42:58 +01:00
|
|
|
|
|
|
|
$can_reassign = $edit_engine->hasEditAccessToTransaction(
|
|
|
|
ManiphestTransaction::TYPE_OWNER);
|
|
|
|
|
2015-12-08 16:54:01 +01:00
|
|
|
if ($can_create) {
|
|
|
|
$form_key = $edit_config->getIdentifier();
|
2015-12-14 23:51:22 +01:00
|
|
|
$edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))
|
|
|
|
->setQueryParam('parent', $id)
|
|
|
|
->setQueryParam('template', $id)
|
|
|
|
->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
|
2015-12-08 16:54:01 +01:00
|
|
|
$edit_uri = $this->getApplicationURI($edit_uri);
|
|
|
|
} else {
|
|
|
|
// TODO: This will usually give us a somewhat-reasonable error page, but
|
|
|
|
// could be a bit cleaner.
|
2015-12-09 01:54:46 +01:00
|
|
|
$edit_uri = "/task/edit/{$id}/";
|
2015-12-08 16:54:01 +01:00
|
|
|
$edit_uri = $this->getApplicationURI($edit_uri);
|
|
|
|
}
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
$subtask_item = id(new PhabricatorActionView())
|
2016-06-21 02:49:38 +02:00
|
|
|
->setName(pht('Create Subtask'))
|
|
|
|
->setHref($edit_uri)
|
|
|
|
->setIcon('fa-level-down')
|
|
|
|
->setDisabled(!$can_create)
|
|
|
|
->setWorkflow(!$can_create);
|
|
|
|
|
2016-06-22 19:24:54 +02:00
|
|
|
$relationship_list = PhabricatorObjectRelationshipList::newForObject(
|
|
|
|
$viewer,
|
|
|
|
$task);
|
|
|
|
|
2016-06-30 19:20:56 +02:00
|
|
|
$submenu_actions = array(
|
2016-07-01 17:50:16 +02:00
|
|
|
$subtask_item,
|
2016-06-30 19:20:56 +02:00
|
|
|
ManiphestTaskHasParentRelationship::RELATIONSHIPKEY,
|
|
|
|
ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY,
|
|
|
|
ManiphestTaskMergeInRelationship::RELATIONSHIPKEY,
|
|
|
|
ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY,
|
|
|
|
);
|
|
|
|
|
|
|
|
$task_submenu = $relationship_list->newActionSubmenu($submenu_actions)
|
|
|
|
->setName(pht('Edit Related Tasks...'))
|
|
|
|
->setIcon('fa-anchor');
|
|
|
|
|
|
|
|
$curtain->addAction($task_submenu);
|
2016-03-06 19:16:00 +01:00
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
$relationship_submenu = $relationship_list->newActionMenu();
|
|
|
|
if ($relationship_submenu) {
|
|
|
|
$curtain->addAction($relationship_submenu);
|
|
|
|
}
|
|
|
|
|
2016-03-06 19:16:00 +01:00
|
|
|
$owner_phid = $task->getOwnerPHID();
|
2016-03-06 22:28:02 +01:00
|
|
|
$author_phid = $task->getAuthorPHID();
|
|
|
|
$handles = $viewer->loadHandles(array($owner_phid, $author_phid));
|
|
|
|
|
2016-03-06 19:16:00 +01:00
|
|
|
if ($owner_phid) {
|
2016-03-06 22:28:02 +01:00
|
|
|
$image_uri = $handles[$owner_phid]->getImageURI();
|
|
|
|
$image_href = $handles[$owner_phid]->getURI();
|
|
|
|
$owner = $viewer->renderHandle($owner_phid)->render();
|
|
|
|
$content = phutil_tag('strong', array(), $owner);
|
|
|
|
$assigned_to = id(new PHUIHeadThingView())
|
|
|
|
->setImage($image_uri)
|
|
|
|
->setImageHref($image_href)
|
|
|
|
->setContent($content);
|
2016-03-06 19:16:00 +01:00
|
|
|
} else {
|
|
|
|
$assigned_to = phutil_tag('em', array(), pht('None'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$curtain->newPanel()
|
|
|
|
->setHeaderText(pht('Assigned To'))
|
|
|
|
->appendChild($assigned_to);
|
|
|
|
|
2016-03-06 22:28:02 +01:00
|
|
|
$author_uri = $handles[$author_phid]->getImageURI();
|
|
|
|
$author_href = $handles[$author_phid]->getURI();
|
|
|
|
$author = $viewer->renderHandle($author_phid)->render();
|
|
|
|
$content = phutil_tag('strong', array(), $author);
|
2016-03-10 17:58:23 +01:00
|
|
|
$date = phabricator_date($task->getDateCreated(), $viewer);
|
|
|
|
$content = pht('%s, %s', $content, $date);
|
2016-03-06 22:28:02 +01:00
|
|
|
$authored_by = id(new PHUIHeadThingView())
|
|
|
|
->setImage($author_uri)
|
|
|
|
->setImageHref($author_href)
|
|
|
|
->setContent($content);
|
2016-03-06 19:16:00 +01:00
|
|
|
|
|
|
|
$curtain->newPanel()
|
2016-03-06 22:28:02 +01:00
|
|
|
->setHeaderText(pht('Authored By'))
|
|
|
|
->appendChild($authored_by);
|
2016-03-06 19:16:00 +01:00
|
|
|
|
|
|
|
return $curtain;
|
2012-12-11 23:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(
|
|
|
|
ManiphestTask $task,
|
2013-09-17 01:02:27 +02:00
|
|
|
PhabricatorCustomFieldList $field_list,
|
2012-12-11 23:03:16 +01:00
|
|
|
array $edges,
|
2015-03-30 03:56:28 +02:00
|
|
|
$handles) {
|
2012-12-11 23:03:16 +01:00
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
2016-03-05 00:44:24 +01:00
|
|
|
->setUser($viewer);
|
2016-02-09 13:28:22 +01:00
|
|
|
|
2012-12-11 23:03:16 +01:00
|
|
|
$source = $task->getOriginalEmailSource();
|
|
|
|
if ($source) {
|
|
|
|
$subject = '[T'.$task->getID().'] '.$task->getTitle();
|
|
|
|
$view->addProperty(
|
|
|
|
pht('From Email'),
|
2013-01-18 03:43:35 +01:00
|
|
|
phutil_tag(
|
2012-12-11 23:03:16 +01:00
|
|
|
'a',
|
|
|
|
array(
|
2014-10-07 15:01:04 +02:00
|
|
|
'href' => 'mailto:'.$source.'?subject='.$subject,
|
2013-07-20 00:59:29 +02:00
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$source));
|
2012-12-11 23:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$edge_types = array(
|
2014-07-18 00:41:08 +02:00
|
|
|
ManiphestTaskHasRevisionEdgeType::EDGECONST
|
|
|
|
=> pht('Differential Revisions'),
|
2012-12-11 23:03:16 +01:00
|
|
|
);
|
|
|
|
|
2013-04-06 20:40:43 +02:00
|
|
|
$revisions_commits = array();
|
|
|
|
|
|
|
|
$commit_phids = array_keys(
|
2014-07-18 00:42:06 +02:00
|
|
|
$edges[ManiphestTaskHasCommitEdgeType::EDGECONST]);
|
2013-04-06 20:40:43 +02:00
|
|
|
if ($commit_phids) {
|
2015-01-01 04:43:26 +01:00
|
|
|
$commit_drev = DiffusionCommitHasRevisionEdgeType::EDGECONST;
|
2013-04-13 07:48:16 +02:00
|
|
|
$drev_edges = id(new PhabricatorEdgeQuery())
|
|
|
|
->withSourcePHIDs($commit_phids)
|
|
|
|
->withEdgeTypes(array($commit_drev))
|
|
|
|
->execute();
|
2013-04-06 20:40:43 +02:00
|
|
|
|
2013-04-13 07:48:16 +02:00
|
|
|
foreach ($commit_phids as $phid) {
|
2015-12-24 21:33:13 +01:00
|
|
|
$revisions_commits[$phid] = $handles->renderHandle($phid)
|
|
|
|
->setShowHovercard(true);
|
2013-04-13 07:48:16 +02:00
|
|
|
$revision_phid = key($drev_edges[$phid][$commit_drev]);
|
2015-03-30 03:56:28 +02:00
|
|
|
$revision_handle = $handles->getHandleIfExists($revision_phid);
|
2013-04-06 20:40:43 +02:00
|
|
|
if ($revision_handle) {
|
2014-07-18 00:41:08 +02:00
|
|
|
$task_drev = ManiphestTaskHasRevisionEdgeType::EDGECONST;
|
2013-04-13 07:48:16 +02:00
|
|
|
unset($edges[$task_drev][$revision_phid]);
|
2013-04-06 20:40:43 +02:00
|
|
|
$revisions_commits[$phid] = hsprintf(
|
|
|
|
'%s / %s',
|
2015-12-24 21:33:13 +01:00
|
|
|
$revision_handle->renderHovercardLink($revision_handle->getName()),
|
2013-04-06 20:40:43 +02:00
|
|
|
$revisions_commits[$phid]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:03:16 +01:00
|
|
|
foreach ($edge_types as $edge_type => $edge_name) {
|
|
|
|
if ($edges[$edge_type]) {
|
2015-03-30 15:18:54 +02:00
|
|
|
$edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type]));
|
2012-12-11 23:03:16 +01:00
|
|
|
$view->addProperty(
|
|
|
|
$edge_name,
|
2015-03-30 15:18:54 +02:00
|
|
|
$edge_handles->renderList());
|
2012-12-11 23:03:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-06 20:40:43 +02:00
|
|
|
if ($revisions_commits) {
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Commits'),
|
|
|
|
phutil_implode_html(phutil_tag('br'), $revisions_commits));
|
|
|
|
}
|
|
|
|
|
2013-09-24 20:10:46 +02:00
|
|
|
$field_list->appendFieldsToPropertyList(
|
|
|
|
$task,
|
|
|
|
$viewer,
|
|
|
|
$view);
|
|
|
|
|
2016-03-05 00:44:24 +01:00
|
|
|
if ($view->hasAnyProperties()) {
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-03-21 19:19:48 +01:00
|
|
|
private function buildDescriptionView(ManiphestTask $task) {
|
|
|
|
$viewer = $this->getViewer();
|
2013-10-11 16:53:56 +02:00
|
|
|
|
|
|
|
$section = null;
|
2016-03-21 19:19:48 +01:00
|
|
|
|
|
|
|
$description = $task->getDescription();
|
|
|
|
if (strlen($description)) {
|
2013-10-11 16:53:56 +02:00
|
|
|
$section = new PHUIPropertyListView();
|
|
|
|
$section->addTextContent(
|
2013-01-29 03:46:48 +01:00
|
|
|
phutil_tag(
|
2012-12-11 23:03:16 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
2016-03-21 19:19:48 +01:00
|
|
|
id(new PHUIRemarkupView($viewer, $description))
|
|
|
|
->setContextObject($task)));
|
2012-07-19 05:41:42 +02:00
|
|
|
}
|
2012-12-11 23:03:16 +01:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
return $section;
|
2012-07-19 05:41:42 +02:00
|
|
|
}
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
private function newMocksTab(
|
|
|
|
ManiphestTask $task,
|
|
|
|
PhabricatorEdgeQuery $edge_query) {
|
|
|
|
|
|
|
|
$mock_type = ManiphestTaskHasMockEdgeType::EDGECONST;
|
|
|
|
$mock_phids = $edge_query->getDestinationPHIDs(array(), array($mock_type));
|
|
|
|
if (!$mock_phids) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$handles = $viewer->loadHandles($mock_phids);
|
|
|
|
|
|
|
|
// TODO: It would be nice to render this as pinboard-style thumbnails,
|
|
|
|
// similar to "{M123}", instead of a list of links.
|
|
|
|
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->addProperty(pht('Mocks'), $handles->renderList());
|
|
|
|
|
|
|
|
return id(new PHUITabView())
|
|
|
|
->setName(pht('Mocks'))
|
|
|
|
->setKey('mocks')
|
|
|
|
->appendChild($view);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function newMentionsTab(
|
|
|
|
ManiphestTask $task,
|
|
|
|
PhabricatorEdgeQuery $edge_query) {
|
|
|
|
|
|
|
|
$in_type = PhabricatorObjectMentionedByObjectEdgeType::EDGECONST;
|
|
|
|
$out_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST;
|
|
|
|
|
|
|
|
$in_phids = $edge_query->getDestinationPHIDs(array(), array($in_type));
|
|
|
|
$out_phids = $edge_query->getDestinationPHIDs(array(), array($out_type));
|
|
|
|
|
|
|
|
// Filter out any mentioned users from the list. These are not generally
|
|
|
|
// very interesting to show in a relationship summary since they usually
|
|
|
|
// end up as subscribers anyway.
|
|
|
|
|
|
|
|
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
|
|
|
|
foreach ($out_phids as $key => $out_phid) {
|
|
|
|
if (phid_get_type($out_phid) == $user_type) {
|
|
|
|
unset($out_phids[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$in_phids && !$out_phids) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
2016-11-18 23:04:20 +01:00
|
|
|
$in_handles = $viewer->loadHandles($in_phids);
|
|
|
|
$out_handles = $viewer->loadHandles($out_phids);
|
|
|
|
|
|
|
|
$in_handles = $this->getCompleteHandles($in_handles);
|
|
|
|
$out_handles = $this->getCompleteHandles($out_handles);
|
|
|
|
|
|
|
|
if (!count($in_handles) && !count($out_handles)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-11-06 17:10:02 +01:00
|
|
|
$view = new PHUIPropertyListView();
|
|
|
|
|
2016-11-18 23:04:20 +01:00
|
|
|
if (count($in_handles)) {
|
2016-11-06 17:10:02 +01:00
|
|
|
$view->addProperty(pht('Mentioned In'), $in_handles->renderList());
|
|
|
|
}
|
|
|
|
|
2016-11-18 23:04:20 +01:00
|
|
|
if (count($out_handles)) {
|
2016-11-06 17:10:02 +01:00
|
|
|
$view->addProperty(pht('Mentioned Here'), $out_handles->renderList());
|
|
|
|
}
|
|
|
|
|
|
|
|
return id(new PHUITabView())
|
|
|
|
->setName(pht('Mentions'))
|
|
|
|
->setKey('mentions')
|
|
|
|
->appendChild($view);
|
|
|
|
}
|
|
|
|
|
2016-11-18 23:04:20 +01:00
|
|
|
private function getCompleteHandles(PhabricatorHandleList $handles) {
|
|
|
|
$phids = array();
|
|
|
|
|
|
|
|
foreach ($handles as $phid => $handle) {
|
|
|
|
if (!$handle->isComplete()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$phids[] = $phid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $handles->newSublist($phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|