Christopher Johnson (WMDE) has submitted this change and it was merged. Change subject: overrides /tag/ routes for all projects ......................................................................
overrides /tag/ routes for all projects this is a bold commit that overrides the project board controllers in favor of Sprint the behavior and appearance of the boards vary depending on whether the project has been enabled as a Sprint or not As far as is possible, the Sprint controllers are identical to Projects. The main difference is the conditional logic that allows different views. The primary benefit is navigation clarity for Sprint users. Also, this removes the Sprint UI Event Listener which is not needed since the routing now occurs at the board controller includes updated ProjectProfileController Change-Id: I57fd399a495d991801632640824f6413bf231750 --- M src/__phutil_library_map__.php M src/application/SprintApplication.php M src/controller/SprintController.php M src/controller/SprintProjectProfileController.php M src/controller/board/SprintBoardViewController.php D src/events/SprintUIEventListener.php M src/view/SprintBoardTaskCard.php 7 files changed, 88 insertions(+), 217 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 aa3d66b..e5d565b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -64,7 +64,6 @@ 'SprintTaskStoryPointsField' => 'customfield/SprintTaskStoryPointsField.php', 'SprintTestCase' => 'tests/SprintTestCase.php', 'SprintTransaction' => 'storage/SprintTransaction.php', - 'SprintUIEventListener' => 'events/SprintUIEventListener.php', 'SprintValidator' => 'util/SprintValidator.php', 'SprintView' => 'view/SprintView.php', 'TasksTableView' => 'view/burndown/TasksTableView.php', @@ -120,7 +119,6 @@ 'PhabricatorStandardCustomFieldInterface', ), 'SprintTestCase' => 'PHPUnit_Framework_TestCase', - 'SprintUIEventListener' => 'PhabricatorEventListener', 'SprintView' => 'AphrontView', 'UserOpenTasksView' => 'OpenTasksView', ), diff --git a/src/application/SprintApplication.php b/src/application/SprintApplication.php index 3bc612b..dfbb6b7 100644 --- a/src/application/SprintApplication.php +++ b/src/application/SprintApplication.php @@ -26,7 +26,6 @@ public function getEventListeners() { return array( new BurndownActionMenuEventListener(), - new SprintUIEventListener() ); } @@ -37,7 +36,8 @@ } public function getRoutes() { - return array( + + return array( '/project/sprint/' => array( 'archive/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectArchiveController', @@ -54,7 +54,7 @@ => 'SprintBoardReorderController', ), 'board/task/edit/(?P<id>[1-9]\d*)/' - => 'SprintBoardTaskEditController', + => 'SprintBoardTaskEditController', 'board/task/create/' => 'SprintBoardTaskEditController', 'board/(?P<id>[1-9]\d*)/'. @@ -64,8 +64,6 @@ 'burn/(?P<id>\d+)/' => 'SprintDataViewController', 'details/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectEditDetailsController', - 'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectEditMainController', - '' => 'SprintListController', 'feed/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectFeedController', 'icon/(?P<id>[1-9]\d*)/' @@ -82,17 +80,14 @@ 'report/' => 'SprintListController', 'report/list/' => 'SprintListController', 'report/(?:(?P<view>\w+)/)?' => 'SprintReportController', - 'sboard/(?P<id>[1-9]\d*)/'. - '(?P<filter>filter/)?'. - '(?:query/(?P<queryKey>[^/]+)/)?' - => 'SprintBoardViewController', 'view/(?P<id>\d+)/' => 'SprintDataViewController', ), '/tag/' => array( - '(?P<slug>[^/]+)/sboard/' => 'SprintBoardViewController', + '(?P<slug>[^/]+)/' => 'SprintBoardViewController', + '(?P<slug>[^/]+)/board/' => 'SprintBoardViewController', ), ); - } + } protected function getCustomCapabilities() { return array( diff --git a/src/controller/SprintController.php b/src/controller/SprintController.php index 7c79deb..96531d9 100644 --- a/src/controller/SprintController.php +++ b/src/controller/SprintController.php @@ -137,14 +137,27 @@ $nav = new AphrontSideNavFilterView(); $nav->setIconNav(true); - $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); + if ($this->isSprint($project) !== false) { + $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); + } else { + $nav->setBaseURI(new PhutilURI($this->getProjectsURI())); + $nav->addIcon("profile/{$id}/", $name, null, $picture); + $nav->addIcon("board/{$id}/", pht('Workboard'), $board_icon); + } $nav->addIcon("feed/{$id}/", pht('Feed'), 'fa-newspaper-o'); $nav->addIcon("members/{$id}/", pht('Members'), 'fa-group'); $nav->addIcon("edit/{$id}/", pht('Edit'), 'fa-pencil'); return $nav; } + + protected function isSprint($object) { + $validator = new SprintValidator(); + $issprint = call_user_func(array($validator, 'checkForSprint'), + array($validator, 'isSprint'), $object->getPHID()); + return $issprint; + } } diff --git a/src/controller/SprintProjectProfileController.php b/src/controller/SprintProjectProfileController.php index 6dd92af..b043bad 100644 --- a/src/controller/SprintProjectProfileController.php +++ b/src/controller/SprintProjectProfileController.php @@ -33,26 +33,12 @@ } $picture = $project->getProfileImageURI(); - require_celerity_resource('phabricator-profile-css'); - $tasks = $this->renderTasksPage($project); - $content = phutil_tag_div('phabricator-project-layout', $tasks); - - $phid = $project->getPHID(); - $create_uri = '/maniphest/task/create/?projects='.$phid; - $icon_new = id(new PHUIIconView()) - ->setIconFont('fa-plus'); - $button_add = id(new PHUIButtonView()) - ->setTag('a') - ->setText(pht('New Task')) - ->setHref($create_uri) - ->setIcon($icon_new); $header = id(new PHUIHeaderView()) ->setHeader($project->getName()) ->setUser($user) ->setPolicyObject($project) - ->setImage($picture) - ->addActionLink($button_add); + ->setImage($picture); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); @@ -67,10 +53,15 @@ ->setHeader($header) ->addPropertyList($properties); + $timeline = $this->buildTransactionTimeline( + $project, + new PhabricatorProjectTransactionQuery()); + $timeline->setShouldTerminate(true); + $nav = $this->buildIconNavView($project); $nav->selectFilter("profile/{$id}/"); $nav->appendChild($object_box); - $nav->appendChild($content); + $nav->appendChild($timeline); return $this->buildApplicationPage( array( @@ -79,66 +70,6 @@ array( 'title' => $project->getName(), )); - } - - private function renderTasksPage(PhabricatorProject $project) { - - $user = $this->getRequest()->getUser(); - $limit = 50; - - $query = id(new ManiphestTaskQuery()) - ->setViewer($user) - ->withAnyProjects(array($project->getPHID())) - ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) - ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) - ->needProjectPHIDs(true) - ->setLimit(($limit + 1)); - $tasks = $query->execute(); - $count = count($tasks); - if ($count == ($limit + 1)) { - array_pop($tasks); - } - - $phids = mpull($tasks, 'getOwnerPHID'); - $phids = array_merge( - $phids, - array_mergev(mpull($tasks, 'getProjectPHIDs'))); - $phids = array_filter($phids); - $handles = $this->loadViewerHandles($phids); - - $task_list = new ManiphestTaskListView(); - $task_list->setUser($user); - $task_list->setTasks($tasks); - $task_list->setHandles($handles); - $task_list->setNoDataString(pht('This project has no open tasks.')); - - $phid = $project->getPHID(); - $view_uri = urisprintf( - '/maniphest/?statuses=%s&allProjects=%s#R', - implode(',', ManiphestTaskStatus::getOpenStatusConstants()), - $phid); - $icon = id(new PHUIIconView()) - ->setIconFont('fa-search'); - $button_view = id(new PHUIButtonView()) - ->setTag('a') - ->setText(pht('View Query')) - ->setHref($view_uri) - ->setIcon($icon); - - $header = id(new PHUIHeaderView()) - ->addActionLink($button_view); - - if ($count > $limit) { - $header->setHeader(pht('Highest Priority (some)')); - } else { - $header->setHeader(pht('Highest Priority (all)')); - } - - $content = id(new PHUIObjectBoxView()) - ->setHeader($header) - ->appendChild($task_list); - - return $content; } private function buildActionListView(PhabricatorProject $project) { @@ -158,11 +89,36 @@ PhabricatorPolicyCapability::CAN_EDIT); $view->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Edit Project')) - ->setIcon('fa-pencil') - ->setHref($this->getApplicationURI("edit/{$id}/"))); + id(new PhabricatorActionView()) + ->setName(pht('Edit Details')) + ->setIcon('fa-pencil') + ->setHref($this->getApplicationURI("details/{$id}/"))); + $view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Edit Picture')) + ->setIcon('fa-picture-o') + ->setHref($this->getApplicationURI("picture/{$id}/")) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit)); + + if ($project->isArchived()) { + $view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Activate Project')) + ->setIcon('fa-check') + ->setHref($this->getApplicationURI("archive/{$id}/")) + ->setDisabled(!$can_edit) + ->setWorkflow(true)); + } else { + $view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Archive Project')) + ->setIcon('fa-ban') + ->setHref($this->getApplicationURI("archive/{$id}/")) + ->setDisabled(!$can_edit) + ->setWorkflow(true)); + } $action = null; if (!$project->isUserMember($viewer->getPHID())) { @@ -244,6 +200,20 @@ ? $this->renderHandlesForPHIDs($project->getWatcherPHIDs(), ',') : phutil_tag('em', array(), pht('None'))); + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $viewer, + $project); + + $this->loadHandles(array($project->getPHID())); + + $view->addProperty( + pht('Looks Like'), + $this->getHandle($project->getPHID())->renderTag()); + + $view->addProperty( + pht('Joinable By'), + $descriptions[PhabricatorPolicyCapability::CAN_JOIN]); + $field_list = PhabricatorCustomField::getObjectFields( $project, PhabricatorCustomField::ROLE_VIEW); diff --git a/src/controller/board/SprintBoardViewController.php b/src/controller/board/SprintBoardViewController.php index 013ffff..1a16c46 100644 --- a/src/controller/board/SprintBoardViewController.php +++ b/src/controller/board/SprintBoardViewController.php @@ -269,6 +269,7 @@ } $can_edit = idx($task_can_edit_map, $task->getPHID(), false); $cards->addItem(id(new SprintBoardTaskCard()) + ->setProject($project) ->setViewer($viewer) ->setTask($task) ->setOwner($owner) diff --git a/src/events/SprintUIEventListener.php b/src/events/SprintUIEventListener.php deleted file mode 100644 index f67c9c4..0000000 --- a/src/events/SprintUIEventListener.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php - -final class SprintUIEventListener - extends PhabricatorEventListener { - - public function register() { - $this->listen(PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES); - } - - public function handleEvent(PhutilEvent $event) { - switch ($event->getType()) { - case PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES: - $this->handlePropertyEvent($event); - break; - } - } - - private function filterSprints ($phandles) { - $handles = array(); - if (is_array($phandles) && count($phandles) > 0) { - foreach($phandles as $handle) { - $phid = $handle->getPHID(); - if ($this->isSprint($phid) == true) { - $handles[$handle->getPHID()] = $phandles[$handle->getPHID()]; - } - } - } - return $handles; - } - - protected function isSprint($phid) { - $validator = new SprintValidator(); - $issprint = call_user_func(array($validator, 'checkForSprint'), - array($validator, 'isSprint'), $phid); - return $issprint; - } - - private function handlePropertyEvent($event) - { - $user = $event->getUser(); - $object = $event->getValue('object'); - $handles = array(); - - if (!$object || !$object->getPHID()) { - // No object, or the object has no PHID yet.. - return; - } - - if (!($object instanceof PhabricatorProjectInterface)) { - // This object doesn't have projects. - return; - } - - $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( - $object->getPHID(), - PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); - if ($project_phids) { - $project_phids = array_reverse($project_phids); - $phandles = id(new PhabricatorHandleQuery()) - ->setViewer($user) - ->withPHIDs($project_phids) - ->execute(); - $handles = $this->filterSprints($phandles); - } - - // If this object can appear on boards, build the workboard annotations. - // Some day, this might be a generic interface. For now, only tasks can - // appear on boards. - $can_appear_on_boards = ($object instanceof ManiphestTask); - - $annotations = array(); - if ($handles && $can_appear_on_boards) { - - // TDOO: Generalize this UI and move it out of Maniphest. - - require_celerity_resource('maniphest-task-summary-css'); - - $positions = id(new PhabricatorProjectColumnPositionQuery()) - ->setViewer($user) - ->withBoardPHIDs($project_phids) - ->withObjectPHIDs(array($object->getPHID())) - ->needColumns(true) - ->execute(); - $positions = mpull($positions, null, 'getBoardPHID'); - - foreach ($handles as $handle) { - $project_phid = $handle->getPHID(); - $uri = $handle->getURI().'sboard/'; - $handle->setURI($uri); - $position = idx($positions, $project_phid); - if ($position) { - $column = $position->getColumn(); - - $column_name = pht('(%s)', $column->getDisplayName()); - $column_link = phutil_tag( - 'a', - array( - 'href' => $uri, - 'class' => 'maniphest-board-link', - ), - $column_name); - - $annotations[$project_phid] = array( - ' ', - $column_link); - } - } - $list = id(new PHUIHandleTagListView()) - ->setHandles($handles) - ->setAnnotations($annotations); - - $view = $event->getValue('view'); - $view->addProperty(pht('Sprints'), $list); - } - } -} diff --git a/src/view/SprintBoardTaskCard.php b/src/view/SprintBoardTaskCard.php index 59ec215..2b8d0d3 100644 --- a/src/view/SprintBoardTaskCard.php +++ b/src/view/SprintBoardTaskCard.php @@ -101,6 +101,13 @@ )); } + protected function isSprint($object) { + $validator = new SprintValidator(); + $issprint = call_user_func(array($validator, 'checkForSprint'), + array($validator, 'isSprint'), $object->getPHID()); + return $issprint; + } + public function getItem() { require_celerity_resource('phui-workboard-view-css', 'sprint'); @@ -112,6 +119,7 @@ $task_phid = $task->getPHID(); $can_edit = $this->getCanEdit(); $this->points = $query->getStoryPointsForTask($task_phid); + $color_map = ManiphestTaskPriority::getColorMap(); $bar_color = idx($color_map, $task->getPriority(), 'grey'); @@ -138,11 +146,13 @@ .'/')) ->setBarColor($bar_color); - $card->addAttribute($this->getPointList()); - - if ($owner) { - $card->setImageIcon($this->getUserImage()); + if ($this->isSprint($this->project) !== false) { + $card->addAttribute($this->getPointList()); + if ($owner) { + $card->setImageIcon($this->getUserImage()); + } } + return $card; } -- To view, visit https://gerrit.wikimedia.org/r/185988 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I57fd399a495d991801632640824f6413bf231750 Gerrit-PatchSet: 5 Gerrit-Project: phabricator/extensions/Sprint Gerrit-Branch: master Gerrit-Owner: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> Gerrit-Reviewer: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits