1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Give user log types a tokenizer and datasource instead of a page of checkboxes

Summary: Depends on D20671. Ref T13343. Now that log types are modular, provide a datasource/tokenizer for selecting them since we already have a lot (even after I purged a few in D20670) and I'm planning to add at least one more ("Request password reset").

Test Plan: {F6608534}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13343

Differential Revision: https://secure.phabricator.com/D20672
This commit is contained in:
epriestley 2019-07-19 14:47:29 -07:00
parent 32dd13d434
commit 57799bc82b
3 changed files with 47 additions and 2 deletions

View file

@ -4940,6 +4940,7 @@ phutil_register_library_map(array(
'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php',
'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php',
'PhabricatorUserLogType' => 'applications/people/userlog/PhabricatorUserLogType.php',
'PhabricatorUserLogTypeDatasource' => 'applications/people/typeahead/PhabricatorUserLogTypeDatasource.php',
'PhabricatorUserLogView' => 'applications/people/view/PhabricatorUserLogView.php',
'PhabricatorUserMessageCountCacheType' => 'applications/people/cache/PhabricatorUserMessageCountCacheType.php',
'PhabricatorUserNotificationCountCacheType' => 'applications/people/cache/PhabricatorUserNotificationCountCacheType.php',
@ -11377,6 +11378,7 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface',
),
'PhabricatorUserLogType' => 'Phobject',
'PhabricatorUserLogTypeDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorUserLogView' => 'AphrontView',
'PhabricatorUserMessageCountCacheType' => 'PhabricatorUserCacheType',
'PhabricatorUserNotificationCountCacheType' => 'PhabricatorUserCacheType',

View file

@ -78,11 +78,11 @@ final class PhabricatorPeopleLogSearchEngine
->setAliases(array('actors', 'actor', 'actorPHID'))
->setLabel(pht('Actors'))
->setDescription(pht('Search for activity by specific users.')),
id(new PhabricatorSearchCheckboxesField())
id(new PhabricatorSearchDatasourceField())
->setKey('actions')
->setLabel(pht('Actions'))
->setDescription(pht('Search for particular types of activity.'))
->setOptions($types),
->setDatasource(new PhabricatorUserLogTypeDatasource()),
id(new PhabricatorSearchTextField())
->setKey('ip')
->setLabel(pht('Filter IP'))

View file

@ -0,0 +1,43 @@
<?php
final class PhabricatorUserLogTypeDatasource
extends PhabricatorTypeaheadDatasource {
public function getBrowseTitle() {
return pht('Browse Log Types');
}
public function getPlaceholderText() {
return pht('Type a log type name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorPeopleApplication';
}
public function loadResults() {
$results = $this->buildResults();
return $this->filterResultsAgainstTokens($results);
}
protected function renderSpecialTokens(array $values) {
return $this->renderTokensFromResults($this->buildResults(), $values);
}
private function buildResults() {
$results = array();
$type_map = PhabricatorUserLogType::getAllLogTypes();
foreach ($type_map as $type_key => $type) {
$result = id(new PhabricatorTypeaheadResult())
->setPHID($type_key)
->setName($type->getLogTypeName());
$results[$type_key] = $result;
}
return $results;
}
}