Added per-project categories to the side bar of maniphest

Currently adds all the projects there, and at this moment
current project is not being highlighted, it's only get
displayed on the top anchor bar.

TODO:
- We would probably wouldn't want all the projects there,
  need to add some filter there.
- Make it ore clear which project is currently active.
This commit is contained in:
2013-10-24 00:14:02 +02:00
parent aeaf0902e1
commit 7dd7673fb3
11 changed files with 65 additions and 10 deletions

View File

@@ -50,7 +50,7 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
return array(
'/T(?P<id>[1-9]\d*)' => 'ManiphestTaskDetailController',
'/maniphest/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ManiphestTaskListController',
'(?:project/(?P<projectKey>[^/]+)/)?(?:query/(?P<queryKey>[^/]+)/)?' => 'ManiphestTaskListController',
'report/(?:(?P<view>\w+)/)?' => 'ManiphestReportController',
'batch/' => 'ManiphestBatchEditController',
'task/' => array(

View File

@@ -2,6 +2,12 @@
abstract class ManiphestController extends PhabricatorController {
protected $projectKey;
public function willProcessRequest(array $data) {
$this->projectKey = idx($data, 'projectKey');
}
public function buildApplicationMenu() {
return $this->buildSideNavView(true)->getMenu();
}
@@ -16,8 +22,19 @@ abstract class ManiphestController extends PhabricatorController {
$nav->addFilter('create', pht('Create Task'));
}
$nav->addLabel(pht('Projects'));
$nav->addFilter('', 'All Projects');
$projects = id(new PhabricatorProjectQuery())
->setViewer($user)
->execute();
foreach ($projects as $project) {
$nav->addFilter('project/' . $project->getID(), pht($project->getName()));
}
id(new ManiphestTaskSearchEngine())
->setViewer($user)
->setProjectKey($this->projectKey)
->addNavigationItems($nav->getMenu());
if ($user->isLoggedIn()) {
@@ -34,6 +51,19 @@ abstract class ManiphestController extends PhabricatorController {
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
if ($this->projectKey) {
$user = $this->getRequest()->getUser();
$project = id(new PhabricatorProjectQuery())
->setViewer($user)
->withIDs(array($this->projectKey))
->executeOne();
if ($project) {
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht($project->getName())));
}
}
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Task'))

View File

@@ -8,6 +8,7 @@ final class ManiphestExportController extends ManiphestController {
private $key;
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->key = $data['key'];
return $this;
}
@@ -61,7 +62,8 @@ final class ManiphestExportController extends ManiphestController {
->executeOne();
if (!$saved) {
$engine = id(new ManiphestTaskSearchEngine())
->setViewer($user);
->setViewer($user)
->setProjectKey($this->projectKey);
if ($engine->isBuiltinQuery($this->key)) {
$saved = $engine->buildSavedQueryFromBuiltin($this->key);
}

View File

@@ -8,6 +8,7 @@ final class ManiphestReportController extends ManiphestController {
private $view;
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->view = idx($data, 'view');
}

View File

@@ -6,6 +6,7 @@ final class ManiphestSubscribeController extends ManiphestController {
private $action;
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->id = $data['id'];
$this->action = $data['action'];
}

View File

@@ -9,6 +9,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
}
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->id = $data['id'];
}

View File

@@ -5,6 +5,7 @@ final class ManiphestTaskEditController extends ManiphestController {
private $id;
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->id = idx($data, 'id');
}

View File

@@ -11,6 +11,7 @@ final class ManiphestTaskListController
}
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->queryKey = idx($data, 'queryKey');
}
@@ -18,7 +19,7 @@ final class ManiphestTaskListController
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new ManiphestTaskSearchEngine())
->setSearchEngine((new ManiphestTaskSearchEngine())->setProjectKey($this->projectKey))
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);

View File

@@ -8,6 +8,7 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
private $id;
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->id = $data['id'];
}

View File

@@ -3,6 +3,8 @@
final class ManiphestTaskSearchEngine
extends PhabricatorApplicationSearchEngine {
private $projectKey;
public function getCustomFieldObject() {
return new ManiphestTask();
}
@@ -134,6 +136,14 @@ final class ManiphestTaskSearchEngine
$query->withFullTextSearch($fulltext);
}
if ($this->projectKey) {
$project = id(new PhabricatorProjectQuery())
->setViewer($this->requireViewer())
->withIDs(array($this->projectKey))
->executeOne();
$query->withAllProjects(array($project->getPHID()));
} else {
$with_no_project = $saved->getParameter('withNoProject');
if ($with_no_project) {
$query->withAllProjects(array(ManiphestTaskOwner::PROJECT_NO_PROJECT));
@@ -143,6 +153,7 @@ final class ManiphestTaskSearchEngine
$query->withAllProjects($project_phids);
}
}
}
$any_project_phids = $saved->getParameter('anyProjectPHIDs');
if ($any_project_phids) {
@@ -353,6 +364,8 @@ final class ManiphestTaskSearchEngine
}
protected function getURI($path) {
if ($this->projectKey)
return '/maniphest/project/' . $this->projectKey . '/'.$path;
return '/maniphest/'.$path;
}
@@ -435,4 +448,8 @@ final class ManiphestTaskSearchEngine
);
}
function setProjectKey($projectKey) {
$this->projectKey = $projectKey;
return $this;
}
}

View File

@@ -2,6 +2,6 @@
<h1><a href="maniphest/">Blender 2.6 Bug tracker</a></h1>
<div style="padding-left: 16pt">
<a href="maniphest/task/create/">submit</a> Blender 2.6x bugs<br>
<a href="maniphest/">browse</a> Blender 2.6x bugs
<a href="maniphest/project/1/">browse</a> Blender 2.6x bugs
</div>
</div>