Skip to content

Commit fc9db6e

Browse files
author
epriestley
committed
Put subprojects and milestones back into the Project UI
Summary: Ref T10010. Restores subprojects and milestones to the UI with a more modern style and more warnings. Test Plan: {F1085207} {F1085208} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10010 Differential Revision: https://secure.phabricator.com/D15152
1 parent 354858e commit fc9db6e

11 files changed

+541
-140
lines changed

src/__phutil_library_map__.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,7 +2913,6 @@
29132913
'PhabricatorProjectMembersProfilePanel' => 'applications/project/profilepanel/PhabricatorProjectMembersProfilePanel.php',
29142914
'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php',
29152915
'PhabricatorProjectMembersViewController' => 'applications/project/controller/PhabricatorProjectMembersViewController.php',
2916-
'PhabricatorProjectMilestonesController' => 'applications/project/controller/PhabricatorProjectMilestonesController.php',
29172916
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
29182917
'PhabricatorProjectNameContextFreeGrammar' => 'applications/project/lipsum/PhabricatorProjectNameContextFreeGrammar.php',
29192918
'PhabricatorProjectNoProjectsDatasource' => 'applications/project/typeahead/PhabricatorProjectNoProjectsDatasource.php',
@@ -2937,7 +2936,9 @@
29372936
'PhabricatorProjectSlug' => 'applications/project/storage/PhabricatorProjectSlug.php',
29382937
'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
29392938
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
2939+
'PhabricatorProjectSubprojectWarningController' => 'applications/project/controller/PhabricatorProjectSubprojectWarningController.php',
29402940
'PhabricatorProjectSubprojectsController' => 'applications/project/controller/PhabricatorProjectSubprojectsController.php',
2941+
'PhabricatorProjectSubprojectsProfilePanel' => 'applications/project/profilepanel/PhabricatorProjectSubprojectsProfilePanel.php',
29412942
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
29422943
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
29432944
'PhabricatorProjectTransactionEditor' => 'applications/project/editor/PhabricatorProjectTransactionEditor.php',
@@ -7330,7 +7331,6 @@
73307331
'PhabricatorProjectMembersProfilePanel' => 'PhabricatorProfilePanel',
73317332
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
73327333
'PhabricatorProjectMembersViewController' => 'PhabricatorProjectController',
7333-
'PhabricatorProjectMilestonesController' => 'PhabricatorProjectController',
73347334
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
73357335
'PhabricatorProjectNameContextFreeGrammar' => 'PhutilContextFreeGrammar',
73367336
'PhabricatorProjectNoProjectsDatasource' => 'PhabricatorTypeaheadDatasource',
@@ -7357,7 +7357,9 @@
73577357
'PhabricatorStandardCustomFieldInterface',
73587358
),
73597359
'PhabricatorProjectStatus' => 'Phobject',
7360+
'PhabricatorProjectSubprojectWarningController' => 'PhabricatorProjectController',
73607361
'PhabricatorProjectSubprojectsController' => 'PhabricatorProjectController',
7362+
'PhabricatorProjectSubprojectsProfilePanel' => 'PhabricatorProfilePanel',
73617363
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
73627364
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
73637365
'PhabricatorProjectTransactionEditor' => 'PhabricatorApplicationTransactionEditor',

src/applications/project/application/PhabricatorProjectApplication.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function getRoutes() {
9191
=> 'PhabricatorProjectWatchController',
9292
'silence/(?P<id>[1-9]\d*)/'
9393
=> 'PhabricatorProjectSilenceController',
94+
'warning/(?P<id>[1-9]\d*)/'
95+
=> 'PhabricatorProjectSubprojectWarningController',
9496
),
9597
'/tag/' => array(
9698
'(?P<slug>[^/]+)/' => 'PhabricatorProjectViewController',

src/applications/project/controller/PhabricatorProjectEditController.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function handleRequest(AphrontRequest $request) {
4242
if ($parent_id) {
4343
$query = id(new PhabricatorProjectQuery())
4444
->setViewer($viewer)
45+
->needImages(true)
4546
->requireCapabilities(
4647
array(
4748
PhabricatorPolicyCapability::CAN_VIEW,
@@ -58,7 +59,7 @@ public function handleRequest(AphrontRequest $request) {
5859

5960
if ($is_milestone) {
6061
if (!$parent->supportsMilestones()) {
61-
$cancel_uri = "/project/milestones/{$parent_id}/";
62+
$cancel_uri = "/project/subprojects/{$parent_id}/";
6263
return $this->newDialog()
6364
->setTitle(pht('No Milestones'))
6465
->appendParagraph(
@@ -91,20 +92,13 @@ protected function buildApplicationCrumbs() {
9192
$engine = $this->getEngine();
9293
if ($engine) {
9394
$parent = $engine->getParentProject();
94-
if ($parent) {
95-
$id = $parent->getID();
95+
$milestone = $engine->getMilestoneProject();
96+
if ($parent || $milestone) {
97+
$id = nonempty($parent, $milestone)->getID();
9698
$crumbs->addTextCrumb(
9799
pht('Subprojects'),
98100
$this->getApplicationURI("subprojects/{$id}/"));
99101
}
100-
101-
$milestone = $engine->getMilestoneProject();
102-
if ($milestone) {
103-
$id = $milestone->getID();
104-
$crumbs->addTextCrumb(
105-
pht('Milestones'),
106-
$this->getApplicationURI("milestones/{$id}/"));
107-
}
108102
}
109103

110104
return $crumbs;

src/applications/project/controller/PhabricatorProjectMilestonesController.php

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/applications/project/controller/PhabricatorProjectProfileController.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function handleRequest(AphrontRequest $request) {
4545
$watch_action = $this->renderWatchAction($project);
4646
$header->addActionLink($watch_action);
4747

48+
$milestone_list = $this->buildMilestoneList($project);
49+
$subproject_list = $this->buildSubprojectList($project);
50+
4851
$member_list = id(new PhabricatorProjectMemberListView())
4952
->setUser($viewer)
5053
->setProject($project)
@@ -82,6 +85,8 @@ public function handleRequest(AphrontRequest $request) {
8285
))
8386
->setSideColumn(
8487
array(
88+
$milestone_list,
89+
$subproject_list,
8590
$member_list,
8691
$watcher_list,
8792
));
@@ -176,5 +181,90 @@ private function renderWatchAction(PhabricatorProject $project) {
176181
->setHref($watch_href);
177182
}
178183

184+
private function buildMilestoneList(PhabricatorProject $project) {
185+
if (!$project->getHasMilestones()) {
186+
return null;
187+
}
188+
189+
$viewer = $this->getViewer();
190+
$id = $project->getID();
191+
192+
$milestones = id(new PhabricatorProjectQuery())
193+
->setViewer($viewer)
194+
->withParentProjectPHIDs(array($project->getPHID()))
195+
->needImages(true)
196+
->withIsMilestone(true)
197+
->setOrder('newest')
198+
->execute();
199+
if (!$milestones) {
200+
return null;
201+
}
202+
203+
$milestone_list = id(new PhabricatorProjectListView())
204+
->setUser($viewer)
205+
->setProjects($milestones)
206+
->renderList();
207+
208+
$view_all = id(new PHUIButtonView())
209+
->setTag('a')
210+
->setIcon(
211+
id(new PHUIIconView())
212+
->setIcon('fa-list-ul'))
213+
->setText(pht('View All'))
214+
->setHref("/project/subprojects/{$id}/");
215+
216+
$header = id(new PHUIHeaderView())
217+
->setHeader(pht('Milestones'))
218+
->addActionLink($view_all);
219+
220+
return id(new PHUIObjectBoxView())
221+
->setHeader($header)
222+
->setBackground(PHUIBoxView::GREY)
223+
->setObjectList($milestone_list);
224+
}
225+
226+
private function buildSubprojectList(PhabricatorProject $project) {
227+
if (!$project->getHasSubprojects()) {
228+
return null;
229+
}
230+
231+
$viewer = $this->getViewer();
232+
$id = $project->getID();
233+
234+
$limit = 25;
235+
236+
$subprojects = id(new PhabricatorProjectQuery())
237+
->setViewer($viewer)
238+
->withParentProjectPHIDs(array($project->getPHID()))
239+
->needImages(true)
240+
->withIsMilestone(false)
241+
->setLimit($limit)
242+
->execute();
243+
if (!$subprojects) {
244+
return null;
245+
}
246+
247+
$subproject_list = id(new PhabricatorProjectListView())
248+
->setUser($viewer)
249+
->setProjects($subprojects)
250+
->renderList();
251+
252+
$view_all = id(new PHUIButtonView())
253+
->setTag('a')
254+
->setIcon(
255+
id(new PHUIIconView())
256+
->setIcon('fa-list-ul'))
257+
->setText(pht('View All'))
258+
->setHref("/project/subprojects/{$id}/");
259+
260+
$header = id(new PHUIHeaderView())
261+
->setHeader(pht('Subprojects'))
262+
->addActionLink($view_all);
263+
264+
return id(new PHUIObjectBoxView())
265+
->setHeader($header)
266+
->setBackground(PHUIBoxView::GREY)
267+
->setObjectList($subproject_list);
268+
}
179269

180270
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
final class PhabricatorProjectSubprojectWarningController
4+
extends PhabricatorProjectController {
5+
6+
public function handleRequest(AphrontRequest $request) {
7+
$viewer = $request->getViewer();
8+
9+
$response = $this->loadProject();
10+
if ($response) {
11+
return $response;
12+
}
13+
14+
$project = $this->getProject();
15+
16+
$can_edit = PhabricatorPolicyFilter::hasCapability(
17+
$viewer,
18+
$project,
19+
PhabricatorPolicyCapability::CAN_EDIT);
20+
21+
if (!$can_edit) {
22+
return new Aphront404Response();
23+
}
24+
25+
$id = $project->getID();
26+
$cancel_uri = "/project/subprojects/{$id}/";
27+
$done_uri = "/project/edit/?parent={$id}";
28+
29+
if ($request->isFormPost()) {
30+
return id(new AphrontRedirectResponse())
31+
->setURI($done_uri);
32+
}
33+
34+
$doc_href = PhabricatorEnv::getDoclink('Projects User Guide');
35+
36+
$conversion_help = pht(
37+
"Creating a project's first subproject **moves all ".
38+
"members** and **destroys all workboard columns**.".
39+
"\n\n".
40+
"See [[ %s | Projects User Guide ]] in the documentation for details. ".
41+
"This process can not be undone.",
42+
$doc_href);
43+
44+
return $this->newDialog()
45+
->setTitle(pht('Convert to Parent Project'))
46+
->appendChild(new PHUIRemarkupView($viewer, $conversion_help))
47+
->addCancelButton($cancel_uri)
48+
->addSubmitButton(pht('Convert Project'));
49+
}
50+
51+
}

0 commit comments

Comments
 (0)