Differential D16806 Diff 40475 src/applications/maniphest/controller/ManiphestTaskDetailController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/controller/ManiphestTaskDetailController.php
Show All 24 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$field_list | $field_list | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->readFieldsFromStorage($task); | ->readFieldsFromStorage($task); | ||||
$edit_engine = id(new ManiphestEditEngine()) | $edit_engine = id(new ManiphestEditEngine()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setTargetObject($task); | ->setTargetObject($task); | ||||
$e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; | $edge_types = array( | ||||
$e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; | ManiphestTaskHasCommitEdgeType::EDGECONST, | ||||
$e_mock = ManiphestTaskHasMockEdgeType::EDGECONST; | ManiphestTaskHasRevisionEdgeType::EDGECONST, | ||||
ManiphestTaskHasMockEdgeType::EDGECONST, | |||||
PhabricatorObjectMentionedByObjectEdgeType::EDGECONST, | |||||
PhabricatorObjectMentionsObjectEdgeType::EDGECONST, | |||||
); | |||||
$phid = $task->getPHID(); | $phid = $task->getPHID(); | ||||
$query = id(new PhabricatorEdgeQuery()) | $query = id(new PhabricatorEdgeQuery()) | ||||
->withSourcePHIDs(array($phid)) | ->withSourcePHIDs(array($phid)) | ||||
->withEdgeTypes( | ->withEdgeTypes($edge_types); | ||||
array( | |||||
$e_commit, | |||||
$e_rev, | |||||
$e_mock, | |||||
)); | |||||
$edges = idx($query->execute(), $phid); | $edges = idx($query->execute(), $phid); | ||||
$phids = array_fill_keys($query->getDestinationPHIDs(), true); | $phids = array_fill_keys($query->getDestinationPHIDs(), true); | ||||
if ($task->getOwnerPHID()) { | if ($task->getOwnerPHID()) { | ||||
$phids[$task->getOwnerPHID()] = true; | $phids[$task->getOwnerPHID()] = true; | ||||
} | } | ||||
$phids[$task->getAuthorPHID()] = true; | $phids[$task->getAuthorPHID()] = true; | ||||
Show All 17 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$title = pht('%s %s', $monogram, $task->getTitle()); | $title = pht('%s %s', $monogram, $task->getTitle()); | ||||
$comment_view = $edit_engine | $comment_view = $edit_engine | ||||
->buildEditEngineCommentView($task); | ->buildEditEngineCommentView($task); | ||||
$timeline->setQuoteRef($monogram); | $timeline->setQuoteRef($monogram); | ||||
$comment_view->setTransactionTimeline($timeline); | $comment_view->setTransactionTimeline($timeline); | ||||
$view = id(new PHUITwoColumnView()) | $related_tabs = array(); | ||||
->setHeader($header) | $graph_menu = null; | ||||
->setCurtain($curtain) | |||||
->setMainColumn(array( | |||||
$timeline, | |||||
$comment_view, | |||||
)) | |||||
->addPropertySection(pht('Description'), $description) | |||||
->addPropertySection(pht('Details'), $details); | |||||
$graph_limit = 100; | $graph_limit = 100; | ||||
$task_graph = id(new ManiphestTaskGraph()) | $task_graph = id(new ManiphestTaskGraph()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setSeedPHID($task->getPHID()) | ->setSeedPHID($task->getPHID()) | ||||
->setLimit($graph_limit) | ->setLimit($graph_limit) | ||||
->loadGraph(); | ->loadGraph(); | ||||
if (!$task_graph->isEmpty()) { | if (!$task_graph->isEmpty()) { | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | if (!$task_graph->isEmpty()) { | ||||
->setIcon('fa-chevron-circle-down')); | ->setIcon('fa-chevron-circle-down')); | ||||
$graph_menu = id(new PHUIButtonView()) | $graph_menu = id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setIcon('fa-search') | ->setIcon('fa-search') | ||||
->setText($search_text) | ->setText($search_text) | ||||
->setDropdownMenu($dropdown_menu); | ->setDropdownMenu($dropdown_menu); | ||||
$graph_header = id(new PHUIHeaderView()) | $related_tabs[] = id(new PHUITabView()) | ||||
->setHeader(pht('Task Graph')) | ->setName(pht('Task Graph')) | ||||
->addActionLink($graph_menu); | ->setKey('graph') | ||||
->appendChild($graph_table); | |||||
} | |||||
$related_tabs[] = $this->newMocksTab($task, $query); | |||||
$related_tabs[] = $this->newMentionsTab($task, $query); | |||||
$tab_view = null; | |||||
$view->addPropertySection($graph_header, $graph_table); | $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')); | |||||
if ($graph_menu) { | |||||
$related_header->addActionLink($graph_menu); | |||||
} | |||||
$tab_view = id(new PHUIObjectBoxView()) | |||||
->setHeader($related_header) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->addTabGroup($tab_group); | |||||
} | |||||
$view = id(new PHUITwoColumnView()) | |||||
->setHeader($header) | |||||
->setCurtain($curtain) | |||||
->setMainColumn( | |||||
array( | |||||
$tab_view, | |||||
$timeline, | |||||
$comment_view, | |||||
)) | |||||
->addPropertySection(pht('Description'), $description) | |||||
->addPropertySection(pht('Details'), $details); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setPageObjectPHIDs( | ->setPageObjectPHIDs( | ||||
array( | array( | ||||
$task->getPHID(), | $task->getPHID(), | ||||
)) | )) | ||||
->appendChild( | ->appendChild($view); | ||||
array( | |||||
$view, | |||||
)); | |||||
} | } | ||||
private function buildHeaderView(ManiphestTask $task) { | private function buildHeaderView(ManiphestTask $task) { | ||||
$view = id(new PHUIHeaderView()) | $view = id(new PHUIHeaderView()) | ||||
->setHeader($task->getTitle()) | ->setHeader($task->getTitle()) | ||||
->setUser($this->getRequest()->getUser()) | ->setUser($this->getRequest()->getUser()) | ||||
->setPolicyObject($task); | ->setPolicyObject($task); | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | if ($source) { | ||||
'href' => 'mailto:'.$source.'?subject='.$subject, | 'href' => 'mailto:'.$source.'?subject='.$subject, | ||||
), | ), | ||||
$source)); | $source)); | ||||
} | } | ||||
$edge_types = array( | $edge_types = array( | ||||
ManiphestTaskHasRevisionEdgeType::EDGECONST | ManiphestTaskHasRevisionEdgeType::EDGECONST | ||||
=> pht('Differential Revisions'), | => pht('Differential Revisions'), | ||||
ManiphestTaskHasMockEdgeType::EDGECONST | |||||
=> pht('Pholio Mocks'), | |||||
); | ); | ||||
$revisions_commits = array(); | $revisions_commits = array(); | ||||
$commit_phids = array_keys( | $commit_phids = array_keys( | ||||
$edges[ManiphestTaskHasCommitEdgeType::EDGECONST]); | $edges[ManiphestTaskHasCommitEdgeType::EDGECONST]); | ||||
if ($commit_phids) { | if ($commit_phids) { | ||||
$commit_drev = DiffusionCommitHasRevisionEdgeType::EDGECONST; | $commit_drev = DiffusionCommitHasRevisionEdgeType::EDGECONST; | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if (strlen($description)) { | ||||
), | ), | ||||
id(new PHUIRemarkupView($viewer, $description)) | id(new PHUIRemarkupView($viewer, $description)) | ||||
->setContextObject($task))); | ->setContextObject($task))); | ||||
} | } | ||||
return $section; | return $section; | ||||
} | } | ||||
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, | |||||
chad: I'll file something to keep track. | |||||
// 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(); | |||||
$view = new PHUIPropertyListView(); | |||||
if ($in_phids) { | |||||
$in_handles = $viewer->loadHandles($in_phids); | |||||
$view->addProperty(pht('Mentioned In'), $in_handles->renderList()); | |||||
} | |||||
if ($out_phids) { | |||||
$out_handles = $viewer->loadHandles($out_phids); | |||||
$view->addProperty(pht('Mentioned Here'), $out_handles->renderList()); | |||||
} | |||||
return id(new PHUITabView()) | |||||
->setName(pht('Mentions')) | |||||
->setKey('mentions') | |||||
->appendChild($view); | |||||
} | |||||
} | } |
I'll file something to keep track.