mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 10:41:08 +01:00
Add datasources to allow search revisions by project.
Summary: When having lots of repos, seeing "all revisions in this project" is hard, and we ended up adding herald rules to basically copy project tags to the revisions on a per-project basis. Adding a "tagged: project" function to the Repositories search field allows users to find differentials within a project. Fix T10850. Test Plan: search differentials by tagging project and repository in the Repository field Reviewers: avivey, epriestley, #blessed_reviewers Reviewed By: avivey, epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T10850 Differential Revision: https://secure.phabricator.com/D16096
This commit is contained in:
parent
e78488f6eb
commit
aaf3698666
4 changed files with 130 additions and 1 deletions
|
@ -489,6 +489,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialReleephRequestFieldSpecification' => 'applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php',
|
||||
'DifferentialRemarkupRule' => 'applications/differential/remarkup/DifferentialRemarkupRule.php',
|
||||
'DifferentialReplyHandler' => 'applications/differential/mail/DifferentialReplyHandler.php',
|
||||
'DifferentialRepositoryDatasource' => 'applications/differential/typeahead/DifferentialRepositoryDatasource.php',
|
||||
'DifferentialRepositoryField' => 'applications/differential/customfield/DifferentialRepositoryField.php',
|
||||
'DifferentialRepositoryLookup' => 'applications/differential/query/DifferentialRepositoryLookup.php',
|
||||
'DifferentialRequiredSignaturesField' => 'applications/differential/customfield/DifferentialRequiredSignaturesField.php',
|
||||
|
@ -821,6 +822,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php',
|
||||
'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php',
|
||||
'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php',
|
||||
'DiffusionTaggedRepositoriesFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionTaggedRepositoriesFunctionDatasource.php',
|
||||
'DiffusionTagsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php',
|
||||
'DiffusionURIEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionURIEditConduitAPIMethod.php',
|
||||
'DiffusionURIEditEngine' => 'applications/diffusion/editor/DiffusionURIEditEngine.php',
|
||||
|
@ -4788,6 +4790,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialReleephRequestFieldSpecification' => 'Phobject',
|
||||
'DifferentialRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'DifferentialReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||
'DifferentialRepositoryDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'DifferentialRepositoryField' => 'DifferentialCoreCustomField',
|
||||
'DifferentialRepositoryLookup' => 'Phobject',
|
||||
'DifferentialRequiredSignaturesField' => 'DifferentialCoreCustomField',
|
||||
|
@ -5138,6 +5141,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery',
|
||||
'DiffusionTagListController' => 'DiffusionController',
|
||||
'DiffusionTagListView' => 'DiffusionView',
|
||||
'DiffusionTaggedRepositoriesFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'DiffusionTagsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||
'DiffusionURIEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||
'DiffusionURIEditEngine' => 'PhabricatorEditEngine',
|
||||
|
|
|
@ -75,7 +75,7 @@ final class DifferentialRevisionSearchEngine
|
|||
->setLabel(pht('Repositories'))
|
||||
->setKey('repositoryPHIDs')
|
||||
->setAliases(array('repository', 'repositories', 'repositoryPHID'))
|
||||
->setDatasource(new DiffusionRepositoryDatasource())
|
||||
->setDatasource(new DifferentialRepositoryDatasource())
|
||||
->setDescription(
|
||||
pht('Find revisions from specific repositories.')),
|
||||
id(new PhabricatorSearchSelectField())
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
final class DifferentialRepositoryDatasource
|
||||
extends PhabricatorTypeaheadCompositeDatasource {
|
||||
|
||||
public function getBrowseTitle() {
|
||||
return pht('Browse Repositories');
|
||||
}
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a repository name or function...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorDifferentialApplication';
|
||||
}
|
||||
|
||||
public function getComponentDatasources() {
|
||||
return array(
|
||||
new DiffusionTaggedRepositoriesFunctionDatasource(),
|
||||
new DiffusionRepositoryDatasource(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionTaggedRepositoriesFunctionDatasource
|
||||
extends PhabricatorTypeaheadCompositeDatasource {
|
||||
|
||||
public function getBrowseTitle() {
|
||||
return pht('Browse Repositories');
|
||||
}
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type tagged(<project>)...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorProjectApplication';
|
||||
}
|
||||
|
||||
public function getComponentDatasources() {
|
||||
return array(
|
||||
new PhabricatorProjectDatasource(),
|
||||
);
|
||||
}
|
||||
|
||||
public function getDatasourceFunctions() {
|
||||
return array(
|
||||
'tagged' => array(
|
||||
'name' => pht('Repositories: ...'),
|
||||
'arguments' => pht('project'),
|
||||
'summary' => pht('Find results for repositories of a project.'),
|
||||
'description' => pht(
|
||||
'This function allows you to find results for any of the `.
|
||||
`repositories of a project:'.
|
||||
"\n\n".
|
||||
'> tagged(engineering)'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
protected function didLoadResults(array $results) {
|
||||
foreach ($results as $result) {
|
||||
$result
|
||||
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
||||
->setColor(null)
|
||||
->setPHID('tagged('.$result->getPHID().')')
|
||||
->setDisplayName(pht('Tagged: %s', $result->getDisplayName()))
|
||||
->setName('tagged '.$result->getName());
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function evaluateFunction($function, array $argv_list) {
|
||||
$phids = array();
|
||||
foreach ($argv_list as $argv) {
|
||||
$phids[] = head($argv);
|
||||
}
|
||||
|
||||
$repositories = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withEdgeLogicPHIDs(
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
||||
PhabricatorQueryConstraint::OPERATOR_OR,
|
||||
$phids)
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach ($repositories as $repository) {
|
||||
$results[] = $repository->getPHID();
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function renderFunctionTokens($function, array $argv_list) {
|
||||
$phids = array();
|
||||
foreach ($argv_list as $argv) {
|
||||
$phids[] = head($argv);
|
||||
}
|
||||
|
||||
$tokens = $this->renderTokens($phids);
|
||||
foreach ($tokens as $token) {
|
||||
// Remove any project color on this token.
|
||||
$token->setColor(null);
|
||||
|
||||
if ($token->isInvalid()) {
|
||||
$token
|
||||
->setValue(pht('Repositories: Invalid Project'));
|
||||
} else {
|
||||
$token
|
||||
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
||||
->setKey('tagged('.$token->getKey().')')
|
||||
->setValue(pht('Tagged: %s', $token->getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue