mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Make the Drydock repository operation page slightly richer
Summary: Ref T13164. See PHI788. The issue requests a "created" timestamp. Also add filtering for repository, state, and author. Test Plan: Used all filters. {F5795085} Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13164 Differential Revision: https://secure.phabricator.com/D19574
This commit is contained in:
parent
fb3ae72e36
commit
92a29f72c1
3 changed files with 57 additions and 7 deletions
|
@ -9,6 +9,7 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||
private $operationStates;
|
||||
private $operationTypes;
|
||||
private $isDismissed;
|
||||
private $authorPHIDs;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->ids = $ids;
|
||||
|
@ -45,6 +46,11 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withAuthorPHIDs(array $phids) {
|
||||
$this->authorPHIDs = $phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function newResultObject() {
|
||||
return new DrydockRepositoryOperation();
|
||||
}
|
||||
|
@ -165,6 +171,13 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||
(int)$this->isDismissed);
|
||||
}
|
||||
|
||||
if ($this->authorPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'authorPHID IN (%Ls)',
|
||||
$this->authorPHIDs);
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,41 @@ final class DrydockRepositoryOperationSearchEngine
|
|||
protected function buildQueryFromParameters(array $map) {
|
||||
$query = $this->newQuery();
|
||||
|
||||
if ($map['repositoryPHIDs']) {
|
||||
$query->withRepositoryPHIDs($map['repositoryPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['authorPHIDs']) {
|
||||
$query->withAuthorPHIDs($map['authorPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['states']) {
|
||||
$query->withOperationStates($map['states']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function buildCustomSearchFields() {
|
||||
return array(
|
||||
id(new PhabricatorSearchDatasourceField())
|
||||
->setLabel(pht('Repositories'))
|
||||
->setKey('repositoryPHIDs')
|
||||
->setAliases(array('repository', 'repositories', 'repositoryPHID'))
|
||||
->setDatasource(new DiffusionRepositoryFunctionDatasource()),
|
||||
|
||||
// NOTE: Repository operations aren't necessarily created by a real
|
||||
// user, but for now they normally are. Just use a user typeahead until
|
||||
// more use cases arise.
|
||||
id(new PhabricatorUsersSearchField())
|
||||
->setLabel(pht('Authors'))
|
||||
->setKey('authorPHIDs')
|
||||
->setAliases(array('author', 'authors', 'authorPHID')),
|
||||
id(new PhabricatorSearchCheckboxesField())
|
||||
->setLabel(pht('States'))
|
||||
->setKey('states')
|
||||
->setAliases(array('state'))
|
||||
->setOptions(DrydockRepositoryOperation::getOperationStateNameMap()),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -72,6 +102,10 @@ final class DrydockRepositoryOperationSearchEngine
|
|||
|
||||
$item->setStatusIcon($icon, $name);
|
||||
|
||||
|
||||
$created = phabricator_datetime($operation->getDateCreated(), $viewer);
|
||||
$item->addIcon(null, $created);
|
||||
|
||||
$item->addByline(
|
||||
array(
|
||||
pht('Via:'),
|
||||
|
|
|
@ -99,6 +99,15 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationStateNameMap() {
|
||||
return array(
|
||||
self::STATE_WAIT => pht('Waiting'),
|
||||
self::STATE_WORK => pht('Working'),
|
||||
self::STATE_DONE => pht('Done'),
|
||||
self::STATE_FAIL => pht('Failed'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getOperationStateIcon($state) {
|
||||
$map = array(
|
||||
self::STATE_WAIT => 'fa-clock-o',
|
||||
|
@ -111,13 +120,7 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
}
|
||||
|
||||
public static function getOperationStateName($state) {
|
||||
$map = array(
|
||||
self::STATE_WAIT => pht('Waiting'),
|
||||
self::STATE_WORK => pht('Working'),
|
||||
self::STATE_DONE => pht('Done'),
|
||||
self::STATE_FAIL => pht('Failed'),
|
||||
);
|
||||
|
||||
$map = self::getOperationStateNameMap();
|
||||
return idx($map, $state, pht('<Unknown: %s>', $state));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue