Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / drydock / query / DrydockRepositoryOperationSearchEngine.php
blobeeb85329bfcce3fc3a302946159de176db8a2d87
1 <?php
3 final class DrydockRepositoryOperationSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getResultTypeDescription() {
7 return pht('Drydock Repository Operations');
10 public function getApplicationClassName() {
11 return 'PhabricatorDrydockApplication';
14 public function newQuery() {
15 return id(new DrydockRepositoryOperationQuery());
18 protected function buildQueryFromParameters(array $map) {
19 $query = $this->newQuery();
21 if ($map['repositoryPHIDs']) {
22 $query->withRepositoryPHIDs($map['repositoryPHIDs']);
25 if ($map['authorPHIDs']) {
26 $query->withAuthorPHIDs($map['authorPHIDs']);
29 if ($map['states']) {
30 $query->withOperationStates($map['states']);
33 return $query;
36 protected function buildCustomSearchFields() {
37 return array(
38 id(new PhabricatorSearchDatasourceField())
39 ->setLabel(pht('Repositories'))
40 ->setKey('repositoryPHIDs')
41 ->setAliases(array('repository', 'repositories', 'repositoryPHID'))
42 ->setDatasource(new DiffusionRepositoryFunctionDatasource()),
44 // NOTE: Repository operations aren't necessarily created by a real
45 // user, but for now they normally are. Just use a user typeahead until
46 // more use cases arise.
47 id(new PhabricatorUsersSearchField())
48 ->setLabel(pht('Authors'))
49 ->setKey('authorPHIDs')
50 ->setAliases(array('author', 'authors', 'authorPHID')),
51 id(new PhabricatorSearchCheckboxesField())
52 ->setLabel(pht('States'))
53 ->setKey('states')
54 ->setAliases(array('state'))
55 ->setOptions(DrydockRepositoryOperation::getOperationStateNameMap()),
59 protected function getURI($path) {
60 return '/drydock/operation/'.$path;
63 protected function getBuiltinQueryNames() {
64 return array(
65 'all' => pht('All Operations'),
69 public function buildSavedQueryFromBuiltin($query_key) {
70 $query = $this->newSavedQuery();
71 $query->setQueryKey($query_key);
73 switch ($query_key) {
74 case 'all':
75 return $query;
78 return parent::buildSavedQueryFromBuiltin($query_key);
81 protected function renderResultList(
82 array $operations,
83 PhabricatorSavedQuery $query,
84 array $handles) {
85 assert_instances_of($operations, 'DrydockRepositoryOperation');
87 $viewer = $this->requireViewer();
89 $view = new PHUIObjectItemListView();
90 foreach ($operations as $operation) {
91 $id = $operation->getID();
93 $item = id(new PHUIObjectItemView())
94 ->setHeader($operation->getOperationDescription($viewer))
95 ->setHref($this->getApplicationURI("operation/{$id}/"))
96 ->setObjectName(pht('Repository Operation %d', $id));
98 $state = $operation->getOperationState();
100 $icon = DrydockRepositoryOperation::getOperationStateIcon($state);
101 $name = DrydockRepositoryOperation::getOperationStateName($state);
103 $item->setStatusIcon($icon, $name);
106 $created = phabricator_datetime($operation->getDateCreated(), $viewer);
107 $item->addIcon(null, $created);
109 $item->addByline(
110 array(
111 pht('Via:'),
112 ' ',
113 $viewer->renderHandle($operation->getAuthorPHID()),
116 $object_phid = $operation->getObjectPHID();
117 $repository_phid = $operation->getRepositoryPHID();
119 $item->addAttribute($viewer->renderHandle($object_phid));
121 if ($repository_phid !== $object_phid) {
122 $item->addAttribute($viewer->renderHandle($repository_phid));
125 $view->addItem($item);
128 $result = id(new PhabricatorApplicationSearchResultView())
129 ->setObjectList($view)
130 ->setNoDataString(pht('No matching operations.'));
132 return $result;