Christopher Johnson (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/186217
Change subject: Fixes board issues caused by SprintValidator ...................................................................... Fixes board issues caused by SprintValidator Updates SprintBoardTaskEditController Phabricator does not pass the current project context to the task edit controller. Since validation occurs at the card level, rendering the card after a form post requires a new project object. The project object does not need to be the current project, but it has to be a Sprint in order for the board to be re-rendered The assumption is that all cards in a Sprint Board will have at least one valid Sprint project attachment, so this should never fail. Also fixes missing default and update routes in SprintApplication Change-Id: Ibcc25d3b0dac5e9b8f4a5809c2d8d12b226cd6f6 --- M src/application/SprintApplication.php M src/controller/SprintController.php M src/controller/board/SprintBoardMoveController.php M src/controller/board/SprintBoardTaskEditController.php 4 files changed, 59 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint refs/changes/17/186217/1 diff --git a/src/application/SprintApplication.php b/src/application/SprintApplication.php index dfbb6b7..c46673e 100644 --- a/src/application/SprintApplication.php +++ b/src/application/SprintApplication.php @@ -39,6 +39,7 @@ return array( '/project/sprint/' => array( + '' => 'SprintListController', 'archive/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectArchiveController', 'board/(?P<projectID>[1-9]\d*)/' => array( @@ -80,6 +81,8 @@ 'report/' => 'SprintListController', 'report/list/' => 'SprintListController', 'report/(?:(?P<view>\w+)/)?' => 'SprintReportController', + 'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/' + => 'PhabricatorProjectUpdateController', 'view/(?P<id>\d+)/' => 'SprintDataViewController', ), '/tag/' => array( diff --git a/src/controller/SprintController.php b/src/controller/SprintController.php index 96531d9..f18a043 100644 --- a/src/controller/SprintController.php +++ b/src/controller/SprintController.php @@ -141,7 +141,7 @@ $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->addIcon("profile/{$id}/", $name, null, $picture); $nav->addIcon("burn/{$id}/", pht('Burndown'), 'fa-fire'); - $nav->addIcon("sboard/{$id}/", pht('Sprint Board'), $board_icon); + $nav->addIcon("board/{$id}/", pht('Sprint Board'), $board_icon); } else { $nav->setBaseURI(new PhutilURI($this->getProjectsURI())); $nav->addIcon("profile/{$id}/", $name, null, $picture); diff --git a/src/controller/board/SprintBoardMoveController.php b/src/controller/board/SprintBoardMoveController.php index 73c33d7..ef1203e 100644 --- a/src/controller/board/SprintBoardMoveController.php +++ b/src/controller/board/SprintBoardMoveController.php @@ -168,6 +168,7 @@ $card = id(new SprintBoardTaskCard()) ->setViewer($viewer) ->setTask($object) + ->setProject($project) ->setOwner($owner) ->setCanEdit(true) ->getItem(); diff --git a/src/controller/board/SprintBoardTaskEditController.php b/src/controller/board/SprintBoardTaskEditController.php index 5de827a..a7170f8 100644 --- a/src/controller/board/SprintBoardTaskEditController.php +++ b/src/controller/board/SprintBoardTaskEditController.php @@ -25,6 +25,10 @@ ManiphestEditProjectsCapability::CAPABILITY); $can_edit_status = $this->hasApplicationCapability( ManiphestEditStatusCapability::CAPABILITY); + $can_create_projects = PhabricatorPolicyFilter::hasCapability( + $user, + PhabricatorApplication::getByClass('PhabricatorProjectApplication'), + ProjectCreateProjectsCapability::CAPABILITY); $parent_task = null; $template_id = null; @@ -126,11 +130,14 @@ // You can only have a parent task if you're creating a new task. $parent_id = $request->getInt('parent'); - if ($parent_id) { + if (strlen($parent_id)) { $parent_task = id(new ManiphestTaskQuery()) ->setViewer($user) ->withIDs(array($parent_id)) ->executeOne(); + if (!$parent_task) { + return new Aphront404Response(); + } if (!$template_id) { $template_id = $parent_id; } @@ -365,8 +372,12 @@ ->withPHIDs(array($task->getOwnerPHID())) ->executeOne(); } + + $project = $this->getSprintProjectforTask($user, $projects); + $tasks = id(new SprintBoardTaskCard()) ->setViewer($user) + ->setProject($project) ->setTask($task) ->setOwner($owner) ->setCanEdit(true) @@ -378,6 +389,17 @@ ->executeOne(); if (!$column) { return new Aphront404Response(); + } + + // re-load projects for accuracy as they are not re-loaded via + // the editor + $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $task->getPHID(), + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); + $task->attachProjectPHIDs($project_phids); + $remove_from_board = false; + if (!in_array($column->getProjectPHID(), $project_phids)) { + $remove_from_board = true; } $positions = id(new PhabricatorProjectColumnPositionQuery()) @@ -394,7 +416,7 @@ if ($order == PhabricatorProjectColumn::ORDER_NATURAL) { // TODO: This is a little bit awkward, because PHP and JS use // slightly different sort order parameters to achieve the same - // effect. It would be unify this a bit at some point. + // effect. It would be good to unify this a bit at some point. $sort_map = array(); foreach ($positions as $position) { $sort_map[$position->getObjectPHID()] = array( @@ -411,6 +433,7 @@ $data = array( 'sortMap' => $sort_map, + 'removeFromBoard' => $remove_from_board, ); break; case 'task': @@ -649,6 +672,17 @@ } if ($can_edit_projects) { + $caption = null; + if ($can_create_projects) { + $caption = javelin_tag( + 'a', + array( + 'href' => '/project/create/', + 'mustcapture' => true, + 'sigil' => 'project-create', + ), + pht('Create New Project')); + } $form ->appendChild( id(new AphrontFormTokenizerControl()) @@ -656,15 +690,7 @@ ->setName('projects') ->setValue($projects_value) ->setID($project_tokenizer_id) - ->setCaption( - javelin_tag( - 'a', - array( - 'href' => '/project/create/', - 'mustcapture' => true, - 'sigil' => 'project-create', - ), - pht('Create New Project'))) + ->setCaption($caption) ->setDatasource(new PhabricatorProjectDatasource())); } @@ -756,4 +782,21 @@ )); } + private function getSprintProjectforTask($user, $projects) { + $project = null; + $query = id(new PhabricatorProjectQuery()) + ->setViewer($user) + ->withPHIDs($projects); + $projects = $query->execute(); + + foreach ($projects as $project) { + $sprintquery = id(new SprintQuery()) + ->setPHID($project->getPHID()); + if ($sprintquery->getIsSprint()) { + return $project; + } + } + + } + } -- To view, visit https://gerrit.wikimedia.org/r/186217 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibcc25d3b0dac5e9b8f4a5809c2d8d12b226cd6f6 Gerrit-PatchSet: 1 Gerrit-Project: phabricator/extensions/Sprint Gerrit-Branch: master Gerrit-Owner: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits