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:
parent
fb020ae27d
commit
675ce22bf4
5 changed files with 95 additions and 17 deletions
|
@ -25,9 +25,18 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
}
|
||||
|
||||
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(
|
||||
'Your Revisions',
|
||||
'User Revisions',
|
||||
'active' => array(
|
||||
'name' => 'Active Revisions',
|
||||
'queries' => array(
|
||||
|
@ -85,6 +94,7 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
'All Revisions',
|
||||
'allopen' => array(
|
||||
'name' => 'Open',
|
||||
'nofilter' => true,
|
||||
'queries' => array(
|
||||
array(
|
||||
'query' => DifferentialRevisionListData::QUERY_ALL_OPEN,
|
||||
|
@ -98,15 +108,14 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
$this->filter = 'active';
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$view_phid = nonempty($request->getStr('phid'), $user->getPHID());
|
||||
|
||||
$queries = array();
|
||||
$filter = $filters[$this->filter];
|
||||
foreach ($filter['queries'] as $query) {
|
||||
$query_object = new DifferentialRevisionListData(
|
||||
$query['query'],
|
||||
array($user->getPHID()));
|
||||
array($view_phid));
|
||||
$queries[] = array(
|
||||
'object' => $query_object,
|
||||
) + $query;
|
||||
|
@ -114,6 +123,10 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
|
||||
$side_nav = new AphrontSideNavView();
|
||||
|
||||
$query = null;
|
||||
if ($view_phid) {
|
||||
$query = '?phid='.$view_phid;
|
||||
}
|
||||
|
||||
foreach ($filters as $filter_name => $filter_desc) {
|
||||
if (is_int($filter_name)) {
|
||||
|
@ -129,13 +142,16 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/differential/filter/'.$filter_name.'/',
|
||||
'href' => '/differential/filter/'.$filter_name.'/'.$query,
|
||||
'class' => $selected ? 'aphront-side-nav-selected' : null,
|
||||
),
|
||||
phutil_escape_html($filter_desc['name'])));
|
||||
}
|
||||
|
||||
$phids = array();
|
||||
|
||||
$phids[$view_phid] = true;
|
||||
|
||||
$rev_ids = array();
|
||||
foreach ($queries as $key => $query) {
|
||||
$revisions = $query['object']->loadRevisions();
|
||||
|
@ -180,6 +196,25 @@ class DifferentialRevisionListController extends DifferentialController {
|
|||
$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) {
|
||||
$table = $this->renderRevisionTable(
|
||||
$query['revisions'],
|
||||
|
|
|
@ -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/controller/base');
|
||||
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', 'storage/queryfx');
|
||||
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/sidenav');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
|
|
@ -26,8 +26,20 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
|
||||
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(
|
||||
'Your Tasks',
|
||||
'User Tasks',
|
||||
'action' => 'Assigned',
|
||||
'created' => 'Created',
|
||||
'triage' => 'Need Triage',
|
||||
|
@ -43,8 +55,11 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
$this->view = 'action';
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$uri = $request->getRequestURI();
|
||||
$has_filter = array(
|
||||
'action' => true,
|
||||
'created' => true,
|
||||
'triage' => true,
|
||||
);
|
||||
|
||||
$nav = new AphrontSideNavView();
|
||||
foreach ($views as $view => $name) {
|
||||
|
@ -73,7 +88,10 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
list($grouping, $group_links) = $this->renderGroupLinks();
|
||||
list($order, $order_links) = $this->renderOrderLinks();
|
||||
|
||||
$view_phid = nonempty($request->getStr('phid'), $user->getPHID());
|
||||
|
||||
list($tasks, $handles) = $this->loadTasks(
|
||||
$view_phid,
|
||||
array(
|
||||
'status' => $status_map,
|
||||
'group' => $grouping,
|
||||
|
@ -82,7 +100,22 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
|
||||
|
||||
$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(
|
||||
id(new AphrontFormToggleButtonsControl())
|
||||
->setLabel('Status')
|
||||
|
@ -145,11 +178,8 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
));
|
||||
}
|
||||
|
||||
private function loadTasks(array $dict) {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$phids = array($user->getPHID());
|
||||
private function loadTasks($view_phid, array $dict) {
|
||||
$phids = array($view_phid);
|
||||
|
||||
$task = new ManiphestTask();
|
||||
|
||||
|
@ -211,6 +241,7 @@ class ManiphestTaskListController extends ManiphestController {
|
|||
$data = call_user_func_array(array($task, 'loadAllWhere'), $argv);
|
||||
|
||||
$handle_phids = mpull($data, 'getOwnerPHID');
|
||||
$handle_phids[] = $view_phid;
|
||||
$handles = id(new PhabricatorObjectHandleData($handle_phids))
|
||||
->loadHandles();
|
||||
|
||||
|
|
|
@ -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/status');
|
||||
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', 'view/form/base');
|
||||
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/sidenav');
|
||||
|
||||
|
|
|
@ -28,15 +28,21 @@ final class AphrontListFilterView extends AphrontView {
|
|||
public function render() {
|
||||
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
|
||||
'<table class="aphront-list-filter-view">'.
|
||||
'<tr>'.
|
||||
'<td class="aphront-list-filter-view-controls">'.
|
||||
$this->renderChildren().
|
||||
'</td>'.
|
||||
'<td class="aphront-list-filter-view-buttons">'.
|
||||
implode("\n", $this->buttons).
|
||||
'</td>'.
|
||||
$buttons.
|
||||
'</tr>'.
|
||||
'</table>';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue