Summary: Update the infrastructure and UI of the client list.
Test Plan: {F131570}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Differential Revision: https://secure.phabricator.com/D8563
80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class PhabricatorOAuthServerClientSearchEngine
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
$saved->setParameter(
|
|
'creatorPHIDs',
|
|
$this->readUsersFromRequest($request, 'creators'));
|
|
|
|
return $saved;
|
|
}
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
$query = id(new PhabricatorOAuthServerClientQuery());
|
|
|
|
$creator_phids = $saved->getParameter('creatorPHIDs', array());
|
|
if ($creator_phids) {
|
|
$query->withCreatorPHIDs($saved->getParameter('creatorPHIDs', array()));
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function buildSearchForm(
|
|
AphrontFormView $form,
|
|
PhabricatorSavedQuery $saved_query) {
|
|
|
|
$phids = $saved_query->getParameter('creatorPHIDs', array());
|
|
$creator_handles = id(new PhabricatorHandleQuery())
|
|
->setViewer($this->requireViewer())
|
|
->withPHIDs($phids)
|
|
->execute();
|
|
|
|
$form
|
|
->appendChild(
|
|
id(new AphrontFormTokenizerControl())
|
|
->setDatasource('/typeahead/common/users/')
|
|
->setName('creators')
|
|
->setLabel(pht('Creators'))
|
|
->setValue($creator_handles));
|
|
|
|
}
|
|
|
|
protected function getURI($path) {
|
|
return '/oauthserver/'.$path;
|
|
}
|
|
|
|
public function getBuiltinQueryNames() {
|
|
$names = array();
|
|
|
|
if ($this->requireViewer()->isLoggedIn()) {
|
|
$names['created'] = pht('Created');
|
|
}
|
|
|
|
$names['all'] = pht('All Applications');
|
|
|
|
return $names;
|
|
}
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
$query = $this->newSavedQuery();
|
|
$query->setQueryKey($query_key);
|
|
|
|
switch ($query_key) {
|
|
case 'all':
|
|
return $query;
|
|
case 'created':
|
|
return $query->setParameter(
|
|
'creatorPHIDs',
|
|
array($this->requireViewer()->getPHID()));
|
|
}
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
}
|
|
|
|
}
|