mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Add "r <name>" to jump nav to locate repositories by name
Summary: User request. Test Plan: Searched for `r ph`, `r poetry`. Reviewers: btrahan, bigo Reviewed By: bigo CC: aran Differential Revision: https://secure.phabricator.com/D7720
This commit is contained in:
parent
2ff5541fc5
commit
39b384041f
4 changed files with 41 additions and 0 deletions
|
@ -8,6 +8,7 @@ final class PhabricatorRepositoryQuery
|
|||
private $callsigns;
|
||||
private $types;
|
||||
private $uuids;
|
||||
private $nameContains;
|
||||
|
||||
const STATUS_OPEN = 'status-open';
|
||||
const STATUS_CLOSED = 'status-closed';
|
||||
|
@ -53,6 +54,11 @@ final class PhabricatorRepositoryQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withNameContains($contains) {
|
||||
$this->nameContains = $contains;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needCommitCounts($need_counts) {
|
||||
$this->needCommitCounts = $need_counts;
|
||||
return $this;
|
||||
|
@ -312,6 +318,13 @@ final class PhabricatorRepositoryQuery
|
|||
$this->uuids);
|
||||
}
|
||||
|
||||
if (strlen($this->nameContains)) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'name LIKE %~',
|
||||
$this->nameContains);
|
||||
}
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorRepositorySearchEngine
|
|||
$saved->setParameter('status', $request->getStr('status'));
|
||||
$saved->setParameter('order', $request->getStr('order'));
|
||||
$saved->setParameter('types', $request->getArr('types'));
|
||||
$saved->setParameter('name', $request->getStr('name'));
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
@ -43,6 +44,11 @@ final class PhabricatorRepositorySearchEngine
|
|||
$query->withTypes($types);
|
||||
}
|
||||
|
||||
$name = $saved->getParameter('name');
|
||||
if (strlen($name)) {
|
||||
$query->withNameContains($name);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -53,6 +59,7 @@ final class PhabricatorRepositorySearchEngine
|
|||
$callsigns = $saved_query->getParameter('callsigns', array());
|
||||
$types = $saved_query->getParameter('types', array());
|
||||
$types = array_fuse($types);
|
||||
$name = $saved_query->getParameter('name');
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
|
@ -60,6 +67,11 @@ final class PhabricatorRepositorySearchEngine
|
|||
->setName('callsigns')
|
||||
->setLabel(pht('Callsigns'))
|
||||
->setValue(implode(', ', $callsigns)))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('name')
|
||||
->setLabel(pht('Name Contains'))
|
||||
->setValue($name))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('status')
|
||||
|
|
|
@ -21,6 +21,7 @@ final class PhabricatorJumpNavHandler {
|
|||
'/^@(.+)$/i' => 'user',
|
||||
'/^task:\s*(.+)/i' => 'create-task',
|
||||
'/^(?:s|symbol)\s+(\S+)/i' => 'find-symbol',
|
||||
'/^r\s+(.+)$/i' => 'find-repository',
|
||||
);
|
||||
|
||||
foreach ($patterns as $pattern => $effect) {
|
||||
|
@ -53,6 +54,20 @@ final class PhabricatorJumpNavHandler {
|
|||
}
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI("/diffusion/symbol/$symbol/?jump=true$context");
|
||||
case 'find-repository':
|
||||
$name = $matches[1];
|
||||
$repositories = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer($viewer)
|
||||
->withNameContains($name)
|
||||
->execute();
|
||||
if (count($repositories) == 1) {
|
||||
// Just one match, jump to repository.
|
||||
$uri = '/diffusion/'.head($repositories)->getCallsign().'/';
|
||||
} else {
|
||||
// More than one match, jump to search.
|
||||
$uri = urisprintf('/diffusion/?order=name&name=%s', $name);
|
||||
}
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
case 'create-task':
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/maniphest/task/create/?title='
|
||||
|
|
|
@ -18,6 +18,7 @@ a navigational command into the box and press return.
|
|||
- **r** - Jump to Diffusion.
|
||||
- **rXYZ** - Jump to Diffusion Repository XYZ.
|
||||
- **rXYZabcdef** - Jump to Diffusion Commit rXYZabcdef.
|
||||
- **r <name>** - Search for repositories by name.
|
||||
- **u** - Jump to People
|
||||
- **u username** - Jump to username's Profile
|
||||
- **p** - Jump to Project
|
||||
|
|
Loading…
Reference in a new issue