1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Allow Maniphest and Differential object lists to be filtered by user.

This commit is contained in:
epriestley 2011-04-11 02:03:30 -07:00
parent fb020ae27d
commit 675ce22bf4
5 changed files with 95 additions and 17 deletions

View file

@ -25,9 +25,18 @@ class DifferentialRevisionListController extends DifferentialController {
} }
public function processRequest() { public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$phid_arr = $request->getArr('view_user');
$view_target = head($phid_arr);
return id(new AphrontRedirectResponse())
->setURI($request->getRequestURI()->alter('phid', $view_target));
}
$filters = array( $filters = array(
'Your Revisions', 'User Revisions',
'active' => array( 'active' => array(
'name' => 'Active Revisions', 'name' => 'Active Revisions',
'queries' => array( 'queries' => array(
@ -85,6 +94,7 @@ class DifferentialRevisionListController extends DifferentialController {
'All Revisions', 'All Revisions',
'allopen' => array( 'allopen' => array(
'name' => 'Open', 'name' => 'Open',
'nofilter' => true,
'queries' => array( 'queries' => array(
array( array(
'query' => DifferentialRevisionListData::QUERY_ALL_OPEN, 'query' => DifferentialRevisionListData::QUERY_ALL_OPEN,
@ -98,15 +108,14 @@ class DifferentialRevisionListController extends DifferentialController {
$this->filter = 'active'; $this->filter = 'active';
} }
$request = $this->getRequest(); $view_phid = nonempty($request->getStr('phid'), $user->getPHID());
$user = $request->getUser();
$queries = array(); $queries = array();
$filter = $filters[$this->filter]; $filter = $filters[$this->filter];
foreach ($filter['queries'] as $query) { foreach ($filter['queries'] as $query) {
$query_object = new DifferentialRevisionListData( $query_object = new DifferentialRevisionListData(
$query['query'], $query['query'],
array($user->getPHID())); array($view_phid));
$queries[] = array( $queries[] = array(
'object' => $query_object, 'object' => $query_object,
) + $query; ) + $query;
@ -114,6 +123,10 @@ class DifferentialRevisionListController extends DifferentialController {
$side_nav = new AphrontSideNavView(); $side_nav = new AphrontSideNavView();
$query = null;
if ($view_phid) {
$query = '?phid='.$view_phid;
}
foreach ($filters as $filter_name => $filter_desc) { foreach ($filters as $filter_name => $filter_desc) {
if (is_int($filter_name)) { if (is_int($filter_name)) {
@ -129,13 +142,16 @@ class DifferentialRevisionListController extends DifferentialController {
phutil_render_tag( phutil_render_tag(
'a', 'a',
array( array(
'href' => '/differential/filter/'.$filter_name.'/', 'href' => '/differential/filter/'.$filter_name.'/'.$query,
'class' => $selected ? 'aphront-side-nav-selected' : null, 'class' => $selected ? 'aphront-side-nav-selected' : null,
), ),
phutil_escape_html($filter_desc['name']))); phutil_escape_html($filter_desc['name'])));
} }
$phids = array(); $phids = array();
$phids[$view_phid] = true;
$rev_ids = array(); $rev_ids = array();
foreach ($queries as $key => $query) { foreach ($queries as $key => $query) {
$revisions = $query['object']->loadRevisions(); $revisions = $query['object']->loadRevisions();
@ -180,6 +196,25 @@ class DifferentialRevisionListController extends DifferentialController {
$handles = array(); $handles = array();
} }
if (empty($filters[$this->filter]['nofilter'])) {
$filter_form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/')
->setLabel('View User')
->setName('view_user')
->setValue(
array(
$view_phid => $handles[$view_phid]->getFullName(),
))
->setLimit(1));
$filter_view = new AphrontListFilterView();
$filter_view->appendChild($filter_form);
$side_nav->appendChild($filter_view);
}
foreach ($queries as $query) { foreach ($queries as $query) {
$table = $this->renderRevisionTable( $table = $this->renderRevisionTable(
$query['revisions'], $query['revisions'],

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/data/revisionlist'); phutil_require_module('phabricator', 'applications/differential/data/revisionlist');
@ -13,6 +14,9 @@ phutil_require_module('phabricator', 'applications/differential/storage/revision
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/tokenizer');
phutil_require_module('phabricator', 'view/layout/listfilter');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phabricator', 'view/utils'); phutil_require_module('phabricator', 'view/utils');

View file

@ -26,8 +26,20 @@ class ManiphestTaskListController extends ManiphestController {
public function processRequest() { public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$uri = $request->getRequestURI();
if ($request->isFormPost()) {
$phid_arr = $request->getArr('view_user');
$view_target = head($phid_arr);
return id(new AphrontRedirectResponse())
->setURI($request->getRequestURI()->alter('phid', $view_target));
}
$views = array( $views = array(
'Your Tasks', 'User Tasks',
'action' => 'Assigned', 'action' => 'Assigned',
'created' => 'Created', 'created' => 'Created',
'triage' => 'Need Triage', 'triage' => 'Need Triage',
@ -43,8 +55,11 @@ class ManiphestTaskListController extends ManiphestController {
$this->view = 'action'; $this->view = 'action';
} }
$request = $this->getRequest(); $has_filter = array(
$uri = $request->getRequestURI(); 'action' => true,
'created' => true,
'triage' => true,
);
$nav = new AphrontSideNavView(); $nav = new AphrontSideNavView();
foreach ($views as $view => $name) { foreach ($views as $view => $name) {
@ -73,7 +88,10 @@ class ManiphestTaskListController extends ManiphestController {
list($grouping, $group_links) = $this->renderGroupLinks(); list($grouping, $group_links) = $this->renderGroupLinks();
list($order, $order_links) = $this->renderOrderLinks(); list($order, $order_links) = $this->renderOrderLinks();
$view_phid = nonempty($request->getStr('phid'), $user->getPHID());
list($tasks, $handles) = $this->loadTasks( list($tasks, $handles) = $this->loadTasks(
$view_phid,
array( array(
'status' => $status_map, 'status' => $status_map,
'group' => $grouping, 'group' => $grouping,
@ -82,7 +100,22 @@ class ManiphestTaskListController extends ManiphestController {
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($request->getUser()) ->setUser($user);
if (isset($has_filter[$this->view])) {
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setLimit(1)
->setDatasource('/typeahead/common/users/')
->setName('view_user')
->setLabel('View User')
->setValue(
array(
$view_phid => $handles[$view_phid]->getFullName(),
)));
}
$form
->appendChild( ->appendChild(
id(new AphrontFormToggleButtonsControl()) id(new AphrontFormToggleButtonsControl())
->setLabel('Status') ->setLabel('Status')
@ -145,11 +178,8 @@ class ManiphestTaskListController extends ManiphestController {
)); ));
} }
private function loadTasks(array $dict) { private function loadTasks($view_phid, array $dict) {
$request = $this->getRequest(); $phids = array($view_phid);
$user = $request->getUser();
$phids = array($user->getPHID());
$task = new ManiphestTask(); $task = new ManiphestTask();
@ -211,6 +241,7 @@ class ManiphestTaskListController extends ManiphestController {
$data = call_user_func_array(array($task, 'loadAllWhere'), $argv); $data = call_user_func_array(array($task, 'loadAllWhere'), $argv);
$handle_phids = mpull($data, 'getOwnerPHID'); $handle_phids = mpull($data, 'getOwnerPHID');
$handle_phids[] = $view_phid;
$handles = id(new PhabricatorObjectHandleData($handle_phids)) $handles = id(new PhabricatorObjectHandleData($handle_phids))
->loadHandles(); ->loadHandles();

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/status');
phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/controller/base');
@ -15,6 +16,7 @@ phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/togglebuttons'); phutil_require_module('phabricator', 'view/form/control/togglebuttons');
phutil_require_module('phabricator', 'view/form/control/tokenizer');
phutil_require_module('phabricator', 'view/layout/listfilter'); phutil_require_module('phabricator', 'view/layout/listfilter');
phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phabricator', 'view/layout/sidenav');

View file

@ -28,15 +28,21 @@ final class AphrontListFilterView extends AphrontView {
public function render() { public function render() {
require_celerity_resource('aphront-list-filter-view-css'); require_celerity_resource('aphront-list-filter-view-css');
$buttons = null;
if ($this->buttons) {
$buttons =
'<td class="aphront-list-filter-view-buttons">'.
implode("\n", $this->buttons).
'</td>';
}
return return
'<table class="aphront-list-filter-view">'. '<table class="aphront-list-filter-view">'.
'<tr>'. '<tr>'.
'<td class="aphront-list-filter-view-controls">'. '<td class="aphront-list-filter-view-controls">'.
$this->renderChildren(). $this->renderChildren().
'</td>'. '</td>'.
'<td class="aphront-list-filter-view-buttons">'. $buttons.
implode("\n", $this->buttons).
'</td>'.
'</tr>'. '</tr>'.
'</table>'; '</table>';
} }