Take the first step on the long journey of fixing "Projects"
Summary: - Allow more than the 100 most recent projects to be viewed. - Provide some useful filters. - Default the view to your projects, not all projects. - Put query logic in a query object. - Put filter view logic in a view object. We can port more stuff to it later. Test Plan: Looked at active/owned/all projects. Set page size to 5 and paged through projects. Reviewers: btrahan, jungejason, zeeg Reviewed By: btrahan CC: aran, btrahan Differential Revision: 1227
This commit is contained in:
@@ -19,10 +19,54 @@
|
||||
class PhabricatorProjectListController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
public function processRequest() {
|
||||
private $filter;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->filter = idx($data, 'filter');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav
|
||||
->setBaseURI(new PhutilURI('/project/filter/'))
|
||||
->addLabel('User')
|
||||
->addFilter('active', 'Active')
|
||||
->addFilter('owned', 'Owned')
|
||||
->addSpacer()
|
||||
->addLabel('All')
|
||||
->addFilter('all', 'All Projects');
|
||||
$this->filter = $nav->selectFilter($this->filter, 'active');
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setPageSize(250);
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
$pager->setOffset($request->getInt('page'));
|
||||
|
||||
$query = new PhabricatorProjectQuery();
|
||||
$query->setOffset($pager->getOffset());
|
||||
$query->setLimit($pager->getPageSize() + 1);
|
||||
|
||||
$view_phid = $request->getUser()->getPHID();
|
||||
|
||||
switch ($this->filter) {
|
||||
case 'active':
|
||||
$table_header = 'Active Projects';
|
||||
$query->setMembers(array($view_phid));
|
||||
break;
|
||||
case 'owned':
|
||||
$table_header = 'Owned Projects';
|
||||
$query->setOwners(array($view_phid));
|
||||
break;
|
||||
case 'all':
|
||||
$table_header = 'All Projects';
|
||||
break;
|
||||
}
|
||||
|
||||
$projects = $query->execute();
|
||||
$projects = $pager->sliceResults($projects);
|
||||
|
||||
$projects = id(new PhabricatorProject())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC limit 100');
|
||||
$project_phids = mpull($projects, 'getPHID');
|
||||
|
||||
$profiles = array();
|
||||
@@ -121,12 +165,15 @@ class PhabricatorProjectListController
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->appendChild($table);
|
||||
$panel->setHeader('Project');
|
||||
$panel->setHeader($table_header);
|
||||
$panel->setCreateButton('Create New Project', '/project/create/');
|
||||
$panel->appendChild($table);
|
||||
$panel->appendChild($pager);
|
||||
|
||||
$nav->appendChild($panel);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'Projects',
|
||||
));
|
||||
|
||||
@@ -10,13 +10,16 @@ phutil_require_module('phabricator', 'applications/maniphest/query');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/project/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/project/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/project/query/project');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/affiliation');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/profile');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/project');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user