mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Make "subscribed" filter in Differential accept any mailable
Summary: In the Differential revision list views: - Allow you to filter by mailables (notably, mailing lists). - Allow you to filter by user (including disabled users). Test Plan: Filtered by a mailing list. Reviewers: btrahan, nh Reviewed By: nh CC: aran, epriestley Maniphest Tasks: T1031, T1034 Differential Revision: https://secure.phabricator.com/D1994
This commit is contained in:
commit
e722aa3f80
3 changed files with 38 additions and 8 deletions
|
@ -53,12 +53,20 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
if ($phid_arr) {
|
||||
$view_user = id(new PhabricatorUser())
|
||||
->loadOneWhere('phid = %s', head($phid_arr));
|
||||
if (!$view_user) {
|
||||
return new Aphront404Response();
|
||||
|
||||
$base_uri = '/differential/filter/'.$this->filter.'/';
|
||||
if ($view_user) {
|
||||
// This is a user, so generate a pretty URI.
|
||||
$uri = $base_uri.phutil_escape_uri($view_user->getUserName()).'/';
|
||||
} else {
|
||||
// We're assuming this is a mailing list, generate an ugly URI.
|
||||
$uri = $base_uri;
|
||||
$params['phid'] = head($phid_arr);
|
||||
}
|
||||
$uri = id(new PhutilURI('/differential/filter/'.$this->filter.'/'.
|
||||
phutil_escape_uri($view_user->getUserName()).'/'))
|
||||
->setQueryParams($params);
|
||||
|
||||
$uri = new PhutilURI($uri);
|
||||
$uri->setQueryParams($params);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
}
|
||||
|
||||
|
@ -75,6 +83,11 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
$username = phutil_escape_uri($this->username).'/';
|
||||
$uri->setPath('/differential/filter/'.$this->filter.'/'.$username);
|
||||
$params['phid'] = $view_user->getPHID();
|
||||
} else {
|
||||
$phid = $request->getStr('phid');
|
||||
if (strlen($phid)) {
|
||||
$params['phid'] = $phid;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in the defaults we'll actually use for calculations if any
|
||||
|
@ -278,7 +291,7 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
'active' => array('phid'),
|
||||
'revisions' => array('phid', 'status', 'order'),
|
||||
'reviews' => array('phid', 'status', 'order'),
|
||||
'subscribed' => array('phid', 'status', 'order'),
|
||||
'subscribed' => array('subscriber', 'status', 'order'),
|
||||
'drafts' => array('phid', 'status', 'order'),
|
||||
'all' => array('status', 'order'),
|
||||
);
|
||||
|
@ -325,6 +338,7 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
PhutilURI $uri,
|
||||
array $params) {
|
||||
switch ($control) {
|
||||
case 'subscriber':
|
||||
case 'phid':
|
||||
$view_phid = $params['phid'];
|
||||
$value = array();
|
||||
|
@ -333,9 +347,18 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
$view_phid => $handles[$view_phid]->getFullName(),
|
||||
);
|
||||
}
|
||||
|
||||
if ($control == 'subscriber') {
|
||||
$source = '/typeahead/common/allmailable/';
|
||||
$label = 'View Subscriber';
|
||||
} else {
|
||||
$source = '/typeahead/common/accounts/';
|
||||
$label = 'View User';
|
||||
}
|
||||
|
||||
return id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setLabel('View User')
|
||||
->setDatasource($source)
|
||||
->setLabel($label)
|
||||
->setName('view_user')
|
||||
->setValue($value)
|
||||
->setLimit(1);
|
||||
|
@ -369,6 +392,7 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
private function applyControlToQuery($control, $query, array $params) {
|
||||
switch ($control) {
|
||||
case 'phid':
|
||||
case 'subscriber':
|
||||
// Already applied by query construction.
|
||||
break;
|
||||
case 'status':
|
||||
|
|
|
@ -53,6 +53,11 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_users = true;
|
||||
$need_lists = true;
|
||||
break;
|
||||
case 'allmailable':
|
||||
$need_users = true;
|
||||
$need_all_users = true;
|
||||
$need_lists = true;
|
||||
break;
|
||||
case 'projects':
|
||||
$need_projs = true;
|
||||
break;
|
||||
|
|
|
@ -108,6 +108,7 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
|||
'searchowner' => 'Type a user name...',
|
||||
'accounts' => 'Type a user name...',
|
||||
'mailable' => 'Type a user or mailing list...',
|
||||
'allmailable' => 'Type a user or mailing list...',
|
||||
'searchproject' => 'Type a project name...',
|
||||
'projects' => 'Type a project name...',
|
||||
'repositories' => 'Type a repository name...',
|
||||
|
|
Loading…
Reference in a new issue