1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Add application search for Paste status

Summary: Fixes T9076. This adds the ability to search for active, archived, or all Pastes.

Test Plan: Search for active, archived, all Pastes.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9076

Differential Revision: https://secure.phabricator.com/D13809
This commit is contained in:
Chad Little 2015-08-08 09:46:21 -07:00
parent da1e711abb
commit 3d1783b2da
2 changed files with 35 additions and 0 deletions

View file

@ -14,6 +14,8 @@ final class PhabricatorPasteQuery
private $includeNoLanguage;
private $dateCreatedAfter;
private $dateCreatedBefore;
private $statuses;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -67,6 +69,11 @@ final class PhabricatorPasteQuery
return $this;
}
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
public function newResultObject() {
return new PhabricatorPaste();
}
@ -139,6 +146,13 @@ final class PhabricatorPasteQuery
$this->dateCreatedBefore);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'status IN (%Ls)',
$this->statuses);
}
return $where;
}

View file

@ -35,6 +35,10 @@ final class PhabricatorPasteSearchEngine
$query->withDateCreatedBefore($map['createdEnd']);
}
if ($map['statuses']) {
$query->withStatuses($map['statuses']);
}
return $query;
}
@ -53,6 +57,12 @@ final class PhabricatorPasteSearchEngine
id(new PhabricatorSearchDateField())
->setKey('createdEnd')
->setLabel(pht('Created Before')),
id(new PhabricatorSearchCheckboxesField())
->setKey('statuses')
->setLabel(pht('Status'))
->setOptions(
id(new PhabricatorPaste())
->getStatusNameMap()),
);
}
@ -70,6 +80,7 @@ final class PhabricatorPasteSearchEngine
protected function getBuiltinQueryNames() {
$names = array(
'active' => pht('Active Pastes'),
'all' => pht('All Pastes'),
);
@ -86,6 +97,12 @@ final class PhabricatorPasteSearchEngine
$query->setQueryKey($query_key);
switch ($query_key) {
case 'active':
return $query->setParameter(
'statuses',
array(
PhabricatorPaste::STATUS_ACTIVE,
));
case 'all':
return $query;
case 'authored':
@ -151,6 +168,10 @@ final class PhabricatorPasteSearchEngine
->addIcon('none', $line_count)
->appendChild($source_code);
if ($paste->isArchived()) {
$item->setDisabled(true);
}
$lang_name = $paste->getLanguage();
if ($lang_name) {
$lang_name = idx($lang_map, $lang_name, $lang_name);