[MediaWiki-commits] [Gerrit] refactor SprintListController - change (phabricator...Sprint)
Christopher Johnson (WMDE) has submitted this change and it was merged. Change subject: refactor SprintListController .. refactor SprintListController adds ProjectsTableView adds tests for SprintBuildStats refactor SprintController split getAuxFields method to allow testing pass $can_edit as a parameter to crumb builders Change-Id: I3b3440fc1788f5335a30b4aca6c7b02192821694 --- M src/__phutil_library_map__.php M src/controller/SprintController.php M src/controller/SprintDataViewController.php M src/controller/SprintListController.php M src/controller/SprintReportController.php D src/controller/SprintUIInterface.php D src/controller/ViewController.php M src/query/SprintQuery.php M src/tests/SprintBuildStatsTest.php M src/tests/SprintControllerTest.php M src/tests/SprintQueryTest.php A src/view/ProjectsTableView.php M src/view/burndown/SprintDataView.php M src/view/reports/ProjectOpenTasksView.php 14 files changed, 361 insertions(+), 174 deletions(-) Approvals: Christopher Johnson (WMDE): Verified; Looks good to me, approved diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ba22c60..7a8185b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -22,6 +22,7 @@ 'OpenTasksView' => 'view/reports/OpenTasksView.php', 'PhabricatorFactSprintEngine' => 'fact/PhabricatorFactSprintEngine.php', 'ProjectOpenTasksView' => 'view/reports/ProjectOpenTasksView.php', +'ProjectsTableView' => 'view/ProjectsTableView.php', 'SprintApplication' => 'application/SprintApplication.php', 'SprintApplicationTest' => 'tests/SprintApplicationTest.php', 'SprintBeginDateField' => 'customfield/SprintBeginDateField.php', diff --git a/src/controller/SprintController.php b/src/controller/SprintController.php index a7041b4..61b7ff1 100644 --- a/src/controller/SprintController.php +++ b/src/controller/SprintController.php @@ -82,11 +82,8 @@ return $crumbs; } - protected function buildSprintApplicationCrumbs() { + protected function buildSprintApplicationCrumbs($can_create) { $crumbs = $this->buildCrumbs('slowvote', '/sprint/'); - - $can_create = $this->hasApplicationCapability( -ProjectCreateProjectsCapability::CAPABILITY); $crumbs->addAction( id(new PHUIListItemView()) diff --git a/src/controller/SprintDataViewController.php b/src/controller/SprintDataViewController.php index 4c44c57..0526ed4 100644 --- a/src/controller/SprintDataViewController.php +++ b/src/controller/SprintDataViewController.php @@ -2,7 +2,6 @@ final class SprintDataViewController extends SprintController { - // Project data private $projectID; public function willProcessRequest(array $data) { @@ -13,41 +12,24 @@ $request = $this->getRequest(); $viewer = $request->getUser(); - -// Load the project we're looking at, based on the project ID in the URL. -$project = id(new PhabricatorProjectQuery()) -->setViewer($viewer) -->withIDs(array($this->projectID)) -->executeOne(); +$pid = $this->projectID; +$project = $this->loadProject($viewer, $pid); if (!$project) { return new Aphront404Response(); } -$error_box = false; -$burndown_view = false; +$error_box = null; +$burndown_view = null; try { - $burndown_view = id(new SprintDataView()) - ->setProject($project) - ->setViewer($viewer) - ->setRequest($request); + $burndown_view = $this->getBurndownView($request, $project, $viewer); } catch (BurndownException $e) { - $error_box = id(new AphrontErrorView()) - ->setTitle(pht('Burndown could not be rendered for this project')) - ->setErrors(array($e->getMessage())); + $error_box = $this->getErrorBox($e); } -$pid = $project->getID(); -$crumbs = $this->buildSprintApplicationCrumbs(); -$crumbs->addTextCrumb( -$project->getName(), -'/project/view/'.$pid); -$crumbs->addTextCrumb(pht('Burndown')); -$crumbs->addAction( -id(new PHUIListItemView()) -->setName(pht('Sprint Board')) -->setHref('/sprint/board/'.$pid) -->setIcon('fa-columns')); +$can_create = $this->hasApplicationCapability( +ProjectCreateProjectsCapability::CAPABILITY); +$crumbs = $this->getCrumbs($project, $can_create); return $this->buildApplicationPage( array( @@ -60,4 +42,44 @@ 'device' => true, )); } + + public function loadProject($viewer, $pid) { +// Load the project we're looking at, based on the project ID in the URL. +$project = id(new PhabricatorProjectQuery()) +->setViewer($viewer) +->withIDs(array($pid)) +->executeOne(); + return $project; + } + + public function getCrumbs($project, $can_create) { +$pid = $project->getID(); + +$crumbs = $this->build
[MediaWiki-commits] [Gerrit] refactor SprintListController - change (phabricator...Sprint)
Christopher Johnson (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/182697 Change subject: refactor SprintListController .. refactor SprintListController adds ProjectsTableView adds tests for SprintBuildStats refactor SprintController split getAuxFields method to allow testing pass $can_edit as a parameter to crumb builders Change-Id: I3b3440fc1788f5335a30b4aca6c7b02192821694 --- M src/__phutil_library_map__.php M src/controller/SprintController.php M src/controller/SprintDataViewController.php M src/controller/SprintListController.php M src/controller/SprintReportController.php D src/controller/SprintUIInterface.php D src/controller/ViewController.php M src/query/SprintQuery.php M src/tests/SprintBuildStatsTest.php M src/tests/SprintControllerTest.php M src/tests/SprintQueryTest.php A src/view/ProjectsTableView.php M src/view/burndown/SprintDataView.php M src/view/reports/ProjectOpenTasksView.php 14 files changed, 361 insertions(+), 174 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint refs/changes/97/182697/1 diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ba22c60..7a8185b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -22,6 +22,7 @@ 'OpenTasksView' => 'view/reports/OpenTasksView.php', 'PhabricatorFactSprintEngine' => 'fact/PhabricatorFactSprintEngine.php', 'ProjectOpenTasksView' => 'view/reports/ProjectOpenTasksView.php', +'ProjectsTableView' => 'view/ProjectsTableView.php', 'SprintApplication' => 'application/SprintApplication.php', 'SprintApplicationTest' => 'tests/SprintApplicationTest.php', 'SprintBeginDateField' => 'customfield/SprintBeginDateField.php', diff --git a/src/controller/SprintController.php b/src/controller/SprintController.php index a7041b4..61b7ff1 100644 --- a/src/controller/SprintController.php +++ b/src/controller/SprintController.php @@ -82,11 +82,8 @@ return $crumbs; } - protected function buildSprintApplicationCrumbs() { + protected function buildSprintApplicationCrumbs($can_create) { $crumbs = $this->buildCrumbs('slowvote', '/sprint/'); - - $can_create = $this->hasApplicationCapability( -ProjectCreateProjectsCapability::CAPABILITY); $crumbs->addAction( id(new PHUIListItemView()) diff --git a/src/controller/SprintDataViewController.php b/src/controller/SprintDataViewController.php index 4c44c57..0526ed4 100644 --- a/src/controller/SprintDataViewController.php +++ b/src/controller/SprintDataViewController.php @@ -2,7 +2,6 @@ final class SprintDataViewController extends SprintController { - // Project data private $projectID; public function willProcessRequest(array $data) { @@ -13,41 +12,24 @@ $request = $this->getRequest(); $viewer = $request->getUser(); - -// Load the project we're looking at, based on the project ID in the URL. -$project = id(new PhabricatorProjectQuery()) -->setViewer($viewer) -->withIDs(array($this->projectID)) -->executeOne(); +$pid = $this->projectID; +$project = $this->loadProject($viewer, $pid); if (!$project) { return new Aphront404Response(); } -$error_box = false; -$burndown_view = false; +$error_box = null; +$burndown_view = null; try { - $burndown_view = id(new SprintDataView()) - ->setProject($project) - ->setViewer($viewer) - ->setRequest($request); + $burndown_view = $this->getBurndownView($request, $project, $viewer); } catch (BurndownException $e) { - $error_box = id(new AphrontErrorView()) - ->setTitle(pht('Burndown could not be rendered for this project')) - ->setErrors(array($e->getMessage())); + $error_box = $this->getErrorBox($e); } -$pid = $project->getID(); -$crumbs = $this->buildSprintApplicationCrumbs(); -$crumbs->addTextCrumb( -$project->getName(), -'/project/view/'.$pid); -$crumbs->addTextCrumb(pht('Burndown')); -$crumbs->addAction( -id(new PHUIListItemView()) -->setName(pht('Sprint Board')) -->setHref('/sprint/board/'.$pid) -->setIcon('fa-columns')); +$can_create = $this->hasApplicationCapability( +ProjectCreateProjectsCapability::CAPABILITY); +$crumbs = $this->getCrumbs($project, $can_create); return $this->buildApplicationPage( array( @@ -60,4 +42,44 @@ 'device' => true, )); } + + public function loadProject($viewer, $pid) { +// Load the project we're looking at, based on the project ID in the URL. +$project = id(new PhabricatorProjectQuery()) +->setViewer($viewer) +->withIDs(array($pid)) +->executeOne(); + return $project; + } + + public function getCrumbs($project, $can_create) { +$