1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 23:32:40 +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 $includeNoLanguage;
private $dateCreatedAfter; private $dateCreatedAfter;
private $dateCreatedBefore; private $dateCreatedBefore;
private $statuses;
public function withIDs(array $ids) { public function withIDs(array $ids) {
$this->ids = $ids; $this->ids = $ids;
@ -67,6 +69,11 @@ final class PhabricatorPasteQuery
return $this; return $this;
} }
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
public function newResultObject() { public function newResultObject() {
return new PhabricatorPaste(); return new PhabricatorPaste();
} }
@ -139,6 +146,13 @@ final class PhabricatorPasteQuery
$this->dateCreatedBefore); $this->dateCreatedBefore);
} }
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'status IN (%Ls)',
$this->statuses);
}
return $where; return $where;
} }

View file

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