1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Replace Differential hard-coded status "<select />" with tokenizer

Summary:
Ref T2543. This updates the UI control in the web UI. Also:

  - This implicitly makes this queryable with the API (`differential.revision.search`); it previously was not.
  - This does NOT migrate existing saved queries. I'll do those in the next change, and hold this until it happens.
  - This will break some existing `/differential/?status=XYZ` links. For example, `status=open` now needs to be `status=open()`. I couldn't find any of these in the upstream, and I suspect these are rare in the wild (users would normally link directly to saved queries, not use URI query construction).

Test Plan: {F5093611}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18393
This commit is contained in:
epriestley 2017-08-11 08:10:28 -07:00
parent 8160baec2a
commit 53516093ae
3 changed files with 26 additions and 8 deletions

View file

@ -28,8 +28,12 @@ final class DifferentialLegacyQuery
$status)); $status));
} }
return self::getLegacyValues($map[$status]);
}
public static function getLegacyValues(array $modern_values) {
$values = array(); $values = array();
foreach ($map[$status] as $status_constant) { foreach ($modern_values as $status_constant) {
$status_object = DifferentialRevisionStatus::newForStatus( $status_object = DifferentialRevisionStatus::newForStatus(
$status_constant); $status_constant);

View file

@ -25,6 +25,7 @@ final class DifferentialRevisionQuery
private $repositoryPHIDs; private $repositoryPHIDs;
private $updatedEpochMin; private $updatedEpochMin;
private $updatedEpochMax; private $updatedEpochMax;
private $statuses;
const ORDER_MODIFIED = 'order-modified'; const ORDER_MODIFIED = 'order-modified';
const ORDER_CREATED = 'order-created'; const ORDER_CREATED = 'order-created';
@ -146,6 +147,11 @@ final class DifferentialRevisionQuery
return $this; return $this;
} }
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
/** /**
* Filter results to revisions on given branches. * Filter results to revisions on given branches.
@ -705,6 +711,13 @@ final class DifferentialRevisionQuery
$statuses); $statuses);
} }
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
'r.status in (%Ls)',
DifferentialLegacyQuery::getLegacyValues($this->statuses));
}
$where[] = $this->buildWhereClauseParts($conn_r); $where[] = $this->buildWhereClauseParts($conn_r);
return $this->formatWhereClause($where); return $this->formatWhereClause($where);
} }

View file

@ -41,8 +41,8 @@ final class DifferentialRevisionSearchEngine
$query->withRepositoryPHIDs($map['repositoryPHIDs']); $query->withRepositoryPHIDs($map['repositoryPHIDs']);
} }
if ($map['status']) { if ($map['statuses']) {
$query->withStatus($map['status']); $query->withStatuses($map['statuses']);
} }
return $query; return $query;
@ -77,10 +77,11 @@ final class DifferentialRevisionSearchEngine
->setDatasource(new DiffusionRepositoryFunctionDatasource()) ->setDatasource(new DiffusionRepositoryFunctionDatasource())
->setDescription( ->setDescription(
pht('Find revisions from specific repositories.')), pht('Find revisions from specific repositories.')),
id(new PhabricatorSearchSelectField()) id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Status')) ->setLabel(pht('Statuses'))
->setKey('status') ->setKey('statuses')
->setOptions($this->getStatusOptions()) ->setAliases(array('status'))
->setDatasource(new DifferentialRevisionStatusFunctionDatasource())
->setDescription( ->setDescription(
pht('Find revisions with particular statuses.')), pht('Find revisions with particular statuses.')),
); );
@ -115,7 +116,7 @@ final class DifferentialRevisionSearchEngine
return $query return $query
->setParameter('responsiblePHIDs', array($viewer->getPHID())) ->setParameter('responsiblePHIDs', array($viewer->getPHID()))
->setParameter('status', DifferentialLegacyQuery::STATUS_OPEN) ->setParameter('statuses', array('open()'))
->setParameter('bucket', $bucket_key); ->setParameter('bucket', $bucket_key);
case 'authored': case 'authored':
return $query return $query