mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Expand the power of user filtering
Summary: Ref T8387. This mostly merges D10565 + D10480. I'm going to touch this to add mailing list stuff shortly so I wanted to clean those up. This isn't super pretty but is fully flexible and consistent with other modern query UIs. This should be more-or-less backward compatible. Test Plan: Fiddled with the new options. Reviewers: btrahan Reviewed By: btrahan Subscribers: eadler, cburroughs, epriestley Maniphest Tasks: T8044, T8387 Differential Revision: https://secure.phabricator.com/D13122
This commit is contained in:
parent
8440b3efc0
commit
13f0dac0ed
2 changed files with 84 additions and 47 deletions
|
@ -312,10 +312,11 @@ final class PhabricatorPeopleQuery
|
|||
$this->dateCreatedBefore);
|
||||
}
|
||||
|
||||
if ($this->isAdmin) {
|
||||
if ($this->isAdmin !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'user.isAdmin = 1');
|
||||
'user.isAdmin = %d',
|
||||
(int)$this->isAdmin);
|
||||
}
|
||||
|
||||
if ($this->isDisabled !== null) {
|
||||
|
@ -332,10 +333,11 @@ final class PhabricatorPeopleQuery
|
|||
(int)$this->isApproved);
|
||||
}
|
||||
|
||||
if ($this->isSystemAgent) {
|
||||
if ($this->isSystemAgent !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'user.isSystemAgent = 1');
|
||||
'user.isSystemAgent = %d',
|
||||
(int)$this->isSystemAgent);
|
||||
}
|
||||
|
||||
if (strlen($this->nameLike)) {
|
||||
|
|
|
@ -20,10 +20,23 @@ final class PhabricatorPeopleSearchEngine
|
|||
|
||||
$saved->setParameter('usernames', $request->getStrList('usernames'));
|
||||
$saved->setParameter('nameLike', $request->getStr('nameLike'));
|
||||
$saved->setParameter('isAdmin', $request->getStr('isAdmin'));
|
||||
$saved->setParameter('isDisabled', $request->getStr('isDisabled'));
|
||||
$saved->setParameter('isSystemAgent', $request->getStr('isSystemAgent'));
|
||||
$saved->setParameter('needsApproval', $request->getStr('needsApproval'));
|
||||
|
||||
$saved->setParameter(
|
||||
'isAdmin',
|
||||
$this->readBoolFromRequest($request, 'isAdmin'));
|
||||
|
||||
$saved->setParameter(
|
||||
'isDisabled',
|
||||
$this->readBoolFromRequest($request, 'isDisabled'));
|
||||
|
||||
$saved->setParameter(
|
||||
'isSystemAgent',
|
||||
$this->readBoolFromRequest($request, 'isSystemAgent'));
|
||||
|
||||
$saved->setParameter(
|
||||
'needsApproval',
|
||||
$this->readBoolFromRequest($request, 'needsApproval'));
|
||||
|
||||
$saved->setParameter('createdStart', $request->getStr('createdStart'));
|
||||
$saved->setParameter('createdEnd', $request->getStr('createdEnd'));
|
||||
|
||||
|
@ -65,24 +78,21 @@ final class PhabricatorPeopleSearchEngine
|
|||
$is_disabled = $saved->getParameter('isDisabled');
|
||||
$is_system_agent = $saved->getParameter('isSystemAgent');
|
||||
$needs_approval = $saved->getParameter('needsApproval');
|
||||
$no_disabled = $saved->getParameter('noDisabled');
|
||||
|
||||
if ($is_admin) {
|
||||
$query->withIsAdmin(true);
|
||||
if ($is_admin !== null) {
|
||||
$query->withIsAdmin($is_admin);
|
||||
}
|
||||
|
||||
if ($is_disabled) {
|
||||
$query->withIsDisabled(true);
|
||||
} else if ($no_disabled) {
|
||||
$query->withIsDisabled(false);
|
||||
if ($is_disabled !== null) {
|
||||
$query->withIsDisabled($is_disabled);
|
||||
}
|
||||
|
||||
if ($is_system_agent) {
|
||||
$query->withIsSystemAgent(true);
|
||||
if ($is_system_agent !== null) {
|
||||
$query->withIsSystemAgent($is_system_agent);
|
||||
}
|
||||
|
||||
if ($needs_approval) {
|
||||
$query->withIsApproved(false);
|
||||
if ($needs_approval !== null) {
|
||||
$query->withIsApproved(!$needs_approval);
|
||||
}
|
||||
|
||||
$start = $this->parseDateTime($saved->getParameter('createdStart'));
|
||||
|
@ -108,10 +118,10 @@ final class PhabricatorPeopleSearchEngine
|
|||
$usernames = $saved->getParameter('usernames', array());
|
||||
$like = $saved->getParameter('nameLike');
|
||||
|
||||
$is_admin = $saved->getParameter('isAdmin');
|
||||
$is_disabled = $saved->getParameter('isDisabled');
|
||||
$is_system_agent = $saved->getParameter('isSystemAgent');
|
||||
$needs_approval = $saved->getParameter('needsApproval');
|
||||
$is_admin = $this->getBoolFromQuery($saved, 'isAdmin');
|
||||
$is_disabled = $this->getBoolFromQuery($saved, 'isDisabled');
|
||||
$is_system_agent = $this->getBoolFromQuery($saved, 'isSystemAgent');
|
||||
$needs_approval = $this->getBoolFromQuery($saved, 'needsApproval');
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
|
@ -125,28 +135,49 @@ final class PhabricatorPeopleSearchEngine
|
|||
->setLabel(pht('Name Contains'))
|
||||
->setValue($like))
|
||||
->appendChild(
|
||||
id(new AphrontFormCheckboxControl())
|
||||
->setLabel('Role')
|
||||
->addCheckbox(
|
||||
'isAdmin',
|
||||
1,
|
||||
pht('Show only administrators.'),
|
||||
$is_admin)
|
||||
->addCheckbox(
|
||||
'isDisabled',
|
||||
1,
|
||||
pht('Show only disabled users.'),
|
||||
$is_disabled)
|
||||
->addCheckbox(
|
||||
'isSystemAgent',
|
||||
1,
|
||||
pht('Show only bots.'),
|
||||
$is_system_agent)
|
||||
->addCheckbox(
|
||||
'needsApproval',
|
||||
1,
|
||||
pht('Show only users who need approval.'),
|
||||
$needs_approval));
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('isAdmin')
|
||||
->setLabel(pht('Administrators'))
|
||||
->setValue($is_admin)
|
||||
->setOptions(
|
||||
array(
|
||||
'' => pht('(Show All)'),
|
||||
'true' => pht('Show Only Administrators'),
|
||||
'false' => pht('Hide Administrators'),
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('isDisabled')
|
||||
->setLabel(pht('Disabled'))
|
||||
->setValue($is_disabled)
|
||||
->setOptions(
|
||||
array(
|
||||
'' => pht('(Show All)'),
|
||||
'true' => pht('Show Only Disabled Users'),
|
||||
'false' => pht('Hide Disabled Users'),
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('isSystemAgent')
|
||||
->setLabel(pht('Bots'))
|
||||
->setValue($is_system_agent)
|
||||
->setOptions(
|
||||
array(
|
||||
'' => pht('(Show All)'),
|
||||
'true' => pht('Show Only Bots'),
|
||||
'false' => pht('Hide Bots'),
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('needsApproval')
|
||||
->setLabel(pht('Needs Approval'))
|
||||
->setValue($needs_approval)
|
||||
->setOptions(
|
||||
array(
|
||||
'' => pht('(Show All)'),
|
||||
'true' => pht('Show Only Unapproved Users'),
|
||||
'false' => pht('Hide Unapproved Users'),
|
||||
)));
|
||||
|
||||
$this->appendCustomFieldsToForm($form, $saved);
|
||||
|
||||
|
@ -165,6 +196,7 @@ final class PhabricatorPeopleSearchEngine
|
|||
|
||||
protected function getBuiltinQueryNames() {
|
||||
$names = array(
|
||||
'active' => pht('Active'),
|
||||
'all' => pht('All'),
|
||||
);
|
||||
|
||||
|
@ -183,10 +215,13 @@ final class PhabricatorPeopleSearchEngine
|
|||
switch ($query_key) {
|
||||
case 'all':
|
||||
return $query;
|
||||
case 'active':
|
||||
return $query
|
||||
->setParameter('isDisabled', false);
|
||||
case 'approval':
|
||||
return $query
|
||||
->setParameter('needsApproval', true)
|
||||
->setParameter('noDisabled', true);
|
||||
->setParameter('isDisabled', true);
|
||||
}
|
||||
|
||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
|
@ -240,7 +275,7 @@ final class PhabricatorPeopleSearchEngine
|
|||
}
|
||||
|
||||
if ($user->getIsSystemAgent()) {
|
||||
$item->addIcon('fa-desktop', pht('Bot/Script'));
|
||||
$item->addIcon('fa-desktop', pht('Bot'));
|
||||
}
|
||||
|
||||
if ($viewer->getIsAdmin()) {
|
||||
|
|
Loading…
Reference in a new issue