Changeset View
Changeset View
Standalone View
Standalone View
src/applications/tokens/query/PhabricatorTokenSearchEngine.php
- This file was added.
<?php | |||||
final class PhabricatorTokenSearchEngine | |||||
extends PhabricatorApplicationSearchEngine { | |||||
public function getResultTypeDescription() { | |||||
return pht('Token'); | |||||
} | |||||
public function getApplicationClassName() { | |||||
return 'PhabricatorTokensApplication'; | |||||
} | |||||
public function newQuery() { | |||||
return new PhabricatorTokenQuery(); | |||||
} | |||||
protected function buildCustomSearchFields() { | |||||
return array( | |||||
id(new PhabricatorSearchCheckboxesField()) | |||||
->setKey('statuses') | |||||
->setLabel(pht('Status')) | |||||
->setOptions( | |||||
id(new PhabricatorTokensToken()) | |||||
->getStatusNameMap()), | |||||
); | |||||
} | |||||
protected function buildQueryFromParameters(array $map) { | |||||
$query = $this->newQuery(); | |||||
if ($map['statuses']) { | |||||
$query->withStatuses($map['statuses']); | |||||
} | |||||
return $query; | |||||
} | |||||
protected function getURI($path) { | |||||
return '/tokens/'.$path; | |||||
} | |||||
protected function getBuiltinQueryNames() { | |||||
$names = array(); | |||||
$names['open'] = pht('Active Tokens'); | |||||
$names['all'] = pht('All Tokens'); | |||||
return $names; | |||||
} | |||||
public function buildSavedQueryFromBuiltin($query_key) { | |||||
$query = $this->newSavedQuery(); | |||||
$query->setQueryKey($query_key); | |||||
switch ($query_key) { | |||||
case 'all': | |||||
return $query; | |||||
case 'open': | |||||
return $query->setParameter( | |||||
'statuses', | |||||
array( | |||||
PhabricatorBadgesBadge::STATUS_ACTIVE, | |||||
)); | |||||
} | |||||
return parent::buildSavedQueryFromBuiltin($query_key); | |||||
} | |||||
protected function getRequiredHandlePHIDsForResultList( | |||||
array $tokens, | |||||
PhabricatorSavedQuery $query) { | |||||
$phids = array(); | |||||
return $phids; | |||||
} | |||||
epriestley: You can just omit this method. | |||||
protected function renderResultList( | |||||
array $tokens, | |||||
PhabricatorSavedQuery $query, | |||||
array $handles) { | |||||
assert_instances_of($tokens, 'PhabricatorTokensToken'); | |||||
$viewer = $this->requireViewer(); | |||||
$list = id(new PHUIObjectItemListView()); | |||||
foreach ($tokens as $token) { | |||||
$item = id(new PHUIObjectItemView()) | |||||
->setHeader($token->getName()) | |||||
->setHref('/tokens/view/'.$token->getID().'/') | |||||
->addAttribute($token->getFlavor()); | |||||
Not Done Inline ActionsSlightly simpler as $token->getViewURI(), I think. epriestley: Slightly simpler as `$token->getViewURI()`, I think. | |||||
if ($token->isArchived()) { | |||||
$item->setDisabled(true); | |||||
$item->addIcon('fa-ban', pht('Archived')); | |||||
} | |||||
$list->addItem($item); | |||||
} | |||||
$result = new PhabricatorApplicationSearchResultView(); | |||||
$result->setObjectList($list); | |||||
$result->setNoDataString(pht('No tokens found.')); | |||||
return $result; | |||||
} | |||||
protected function getNewUserBody() { | |||||
$create_button = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setText(pht('Create a Token')) | |||||
->setHref('/tokens/edit/') | |||||
->setColor(PHUIButtonView::GREEN); | |||||
$icon = $this->getApplication()->getIcon(); | |||||
$app_name = $this->getApplication()->getName(); | |||||
$view = id(new PHUIBigInfoView()) | |||||
->setIcon($icon) | |||||
->setTitle(pht('Welcome to %s', $app_name)) | |||||
->setDescription( | |||||
Not Done Inline ActionsI think we have this issue elsewhere, but this probably isn't translatable. For example, in Spanish, I think it has two gender variants:
epriestley: I think we have this issue elsewhere, but this probably isn't translatable. For example, in… | |||||
pht('Tokens let you award and distinguish objects and comments '. | |||||
'throughout your instance.')) | |||||
->addAction($create_button); | |||||
return $view; | |||||
} | |||||
} |
You can just omit this method.