Skip to content

Commit 0a132e4

Browse files
author
epriestley
committedJul 1, 2016
Render parent and child tasks in Maniphest with a graph trace
Summary: Ref T4788. This seems reasonable locally, but not sure how it will feel on real data. Might need some tweaks, or might just be a terrible idea. Test Plan: {F1708059} Reviewers: chad Reviewed By: chad Maniphest Tasks: T4788 Differential Revision: https://secure.phabricator.com/D16214
1 parent cc7ae60 commit 0a132e4

File tree

7 files changed

+135
-15
lines changed

7 files changed

+135
-15
lines changed
 

‎src/__phutil_library_map__.php

+2
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,7 @@
14301430
'ManiphestTaskEditBulkJobType' => 'applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php',
14311431
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
14321432
'ManiphestTaskFulltextEngine' => 'applications/maniphest/search/ManiphestTaskFulltextEngine.php',
1433+
'ManiphestTaskGraph' => 'infrastructure/graph/ManiphestTaskGraph.php',
14331434
'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php',
14341435
'ManiphestTaskHasCommitRelationship' => 'applications/maniphest/relationship/ManiphestTaskHasCommitRelationship.php',
14351436
'ManiphestTaskHasDuplicateTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasDuplicateTaskEdgeType.php',
@@ -5947,6 +5948,7 @@
59475948
'ManiphestTaskEditBulkJobType' => 'PhabricatorWorkerBulkJobType',
59485949
'ManiphestTaskEditController' => 'ManiphestController',
59495950
'ManiphestTaskFulltextEngine' => 'PhabricatorFulltextEngine',
5951+
'ManiphestTaskGraph' => 'PhabricatorObjectGraph',
59505952
'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType',
59515953
'ManiphestTaskHasCommitRelationship' => 'ManiphestTaskRelationship',
59525954
'ManiphestTaskHasDuplicateTaskEdgeType' => 'PhabricatorEdgeType',

‎src/applications/maniphest/controller/ManiphestTaskDetailController.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public function handleRequest(AphrontRequest $request) {
3131
->setTargetObject($task);
3232

3333
$e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST;
34-
$e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
35-
$e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
3634
$e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST;
3735
$e_mock = ManiphestTaskHasMockEdgeType::EDGECONST;
3836

@@ -43,8 +41,6 @@ public function handleRequest(AphrontRequest $request) {
4341
->withEdgeTypes(
4442
array(
4543
$e_commit,
46-
$e_dep_on,
47-
$e_dep_by,
4844
$e_rev,
4945
$e_mock,
5046
));
@@ -91,6 +87,15 @@ public function handleRequest(AphrontRequest $request) {
9187
->addPropertySection(pht('Description'), $description)
9288
->addPropertySection(pht('Details'), $details);
9389

90+
$task_graph = id(new ManiphestTaskGraph())
91+
->setViewer($viewer)
92+
->setSeedPHID($task->getPHID())
93+
->loadGraph();
94+
if (!$task_graph->isEmpty()) {
95+
$graph_table = $task_graph->newGraphTable();
96+
$view->addPropertySection(pht('Task Graph'), $graph_table);
97+
}
98+
9499
return $this->newPage()
95100
->setTitle($title)
96101
->setCrumbs($crumbs)
@@ -186,9 +191,7 @@ private function buildCurtain(
186191
$edit_uri = $this->getApplicationURI($edit_uri);
187192
}
188193

189-
$task_submenu = array();
190-
191-
$task_submenu[] = id(new PhabricatorActionView())
194+
$subtask_item = id(new PhabricatorActionView())
192195
->setName(pht('Create Subtask'))
193196
->setHref($edit_uri)
194197
->setIcon('fa-level-down')
@@ -200,6 +203,7 @@ private function buildCurtain(
200203
$task);
201204

202205
$submenu_actions = array(
206+
$subtask_item,
203207
ManiphestTaskHasParentRelationship::RELATIONSHIPKEY,
204208
ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY,
205209
ManiphestTaskMergeInRelationship::RELATIONSHIPKEY,
@@ -280,10 +284,6 @@ private function buildPropertyView(
280284
}
281285

282286
$edge_types = array(
283-
ManiphestTaskDependedOnByTaskEdgeType::EDGECONST
284-
=> pht('Parent Tasks'),
285-
ManiphestTaskDependsOnTaskEdgeType::EDGECONST
286-
=> pht('Subtasks'),
287287
ManiphestTaskHasRevisionEdgeType::EDGECONST
288288
=> pht('Differential Revisions'),
289289
ManiphestTaskHasMockEdgeType::EDGECONST

‎src/applications/maniphest/storage/ManiphestTask.php

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ public function getMonogram() {
179179
return 'T'.$this->getID();
180180
}
181181

182+
public function getURI() {
183+
return '/'.$this->getMonogram();
184+
}
185+
182186
public function attachGroupByProjectPHID($phid) {
183187
$this->groupByProjectPHID = $phid;
184188
return $this;

‎src/applications/search/relationship/PhabricatorObjectRelationshipList.php

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public function newActionSubmenu(array $keys) {
5252
$actions = array();
5353

5454
foreach ($keys as $key) {
55+
// If we're passed a menu item, just include it verbatim.
56+
if ($key instanceof PhabricatorActionView) {
57+
$actions[] = $key;
58+
continue;
59+
}
60+
5561
$relationship = $this->getRelationship($key);
5662
if (!$relationship) {
5763
throw new Exception(

‎src/infrastructure/diff/view/PHUIDiffGraphView.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,31 @@ public function renderGraph(array $parents) {
137137
);
138138
}
139139

140-
// If this is the last page in history, replace the "o" with an "x" so we
141-
// do not draw a connecting line downward, and replace "^" with an "X" for
142-
// repositories with exactly one commit.
140+
// If this is the last page in history, replace any "o" characters at the
141+
// bottom of columns with "x" characters so we do not draw a connecting
142+
// line downward, and replace "^" with an "X" for repositories with
143+
// exactly one commit.
143144
if ($this->getIsTail() && $graph) {
145+
$terminated = array();
146+
foreach (array_reverse(array_keys($graph)) as $key) {
147+
$line = $graph[$key]['line'];
148+
$len = strlen($line);
149+
for ($ii = 0; $ii < $len; $ii++) {
150+
if (isset($terminated[$ii])) {
151+
continue;
152+
}
153+
154+
$c = $line[$ii];
155+
if ($c == 'o') {
156+
$terminated[$ii] = true;
157+
$graph[$key]['line'][$ii] = 'x';
158+
} else if ($c != ' ') {
159+
$terminated[$ii] = true;
160+
}
161+
}
162+
}
163+
144164
$last = array_pop($graph);
145-
$last['line'] = str_replace('o', 'x', $last['line']);
146165
$last['line'] = str_replace('^', 'X', $last['line']);
147166
$graph[] = $last;
148167
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
final class ManiphestTaskGraph
4+
extends PhabricatorObjectGraph {
5+
6+
protected function getEdgeTypes() {
7+
return array(
8+
ManiphestTaskDependedOnByTaskEdgeType::EDGECONST,
9+
ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
10+
);
11+
}
12+
13+
protected function getParentEdgeType() {
14+
return ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
15+
}
16+
17+
protected function newQuery() {
18+
return new ManiphestTaskQuery();
19+
}
20+
21+
protected function newTableRow($phid, $object, $trace) {
22+
$viewer = $this->getViewer();
23+
24+
if ($object) {
25+
$status = $object->getStatus();
26+
$priority = $object->getPriority();
27+
$status_icon = ManiphestTaskStatus::getStatusIcon($status);
28+
$status_name = ManiphestTaskStatus::getTaskStatusName($status);
29+
$priority_color = ManiphestTaskPriority::getTaskPriorityColor($priority);
30+
31+
32+
$status = array(
33+
id(new PHUIIconView())->setIcon($status_icon, $priority_color),
34+
' ',
35+
$status_name,
36+
);
37+
38+
$owner_phid = $object->getOwnerPHID();
39+
if ($owner_phid) {
40+
$assigned = $viewer->renderHandle($owner_phid);
41+
} else {
42+
$assigned = phutil_tag('em', array(), pht('None'));
43+
}
44+
45+
$link = phutil_tag(
46+
'a',
47+
array(
48+
'href' => $object->getURI(),
49+
),
50+
array(
51+
$object->getMonogram(),
52+
' ',
53+
$object->getTitle(),
54+
));
55+
} else {
56+
$status = null;
57+
$assigned = null;
58+
$link = $viewer->renderHandle($phid);
59+
}
60+
61+
return array(
62+
$trace,
63+
$status,
64+
$assigned,
65+
$link,
66+
);
67+
}
68+
69+
protected function newTable(AphrontTableView $table) {
70+
return $table
71+
->setHeaders(
72+
array(
73+
null,
74+
pht('Status'),
75+
pht('Assigned'),
76+
pht('Task'),
77+
))
78+
->setColumnClasses(
79+
array(
80+
'threads',
81+
null,
82+
null,
83+
'wide',
84+
));
85+
}
86+
87+
}

‎src/infrastructure/graph/PhabricatorObjectGraph.php

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ final protected function loadEdges(array $nodes) {
5555

5656
$map = array();
5757
foreach ($nodes as $node) {
58+
$map[$node] = array();
59+
5860
foreach ($edge_types as $edge_type) {
5961
$dst_phids = $query->getDestinationPHIDs(
6062
array($node),

0 commit comments

Comments
 (0)
Failed to load comments.