mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-01 18:30:59 +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 $callsigns;
|
||||||
private $types;
|
private $types;
|
||||||
private $uuids;
|
private $uuids;
|
||||||
|
private $nameContains;
|
||||||
|
|
||||||
const STATUS_OPEN = 'status-open';
|
const STATUS_OPEN = 'status-open';
|
||||||
const STATUS_CLOSED = 'status-closed';
|
const STATUS_CLOSED = 'status-closed';
|
||||||
|
@ -53,6 +54,11 @@ final class PhabricatorRepositoryQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withNameContains($contains) {
|
||||||
|
$this->nameContains = $contains;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function needCommitCounts($need_counts) {
|
public function needCommitCounts($need_counts) {
|
||||||
$this->needCommitCounts = $need_counts;
|
$this->needCommitCounts = $need_counts;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -312,6 +318,13 @@ final class PhabricatorRepositoryQuery
|
||||||
$this->uuids);
|
$this->uuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($this->nameContains)) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'name LIKE %~',
|
||||||
|
$this->nameContains);
|
||||||
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
$where[] = $this->buildPagingClause($conn_r);
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$saved->setParameter('status', $request->getStr('status'));
|
$saved->setParameter('status', $request->getStr('status'));
|
||||||
$saved->setParameter('order', $request->getStr('order'));
|
$saved->setParameter('order', $request->getStr('order'));
|
||||||
$saved->setParameter('types', $request->getArr('types'));
|
$saved->setParameter('types', $request->getArr('types'));
|
||||||
|
$saved->setParameter('name', $request->getStr('name'));
|
||||||
|
|
||||||
return $saved;
|
return $saved;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +44,11 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$query->withTypes($types);
|
$query->withTypes($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = $saved->getParameter('name');
|
||||||
|
if (strlen($name)) {
|
||||||
|
$query->withNameContains($name);
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +59,7 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$callsigns = $saved_query->getParameter('callsigns', array());
|
$callsigns = $saved_query->getParameter('callsigns', array());
|
||||||
$types = $saved_query->getParameter('types', array());
|
$types = $saved_query->getParameter('types', array());
|
||||||
$types = array_fuse($types);
|
$types = array_fuse($types);
|
||||||
|
$name = $saved_query->getParameter('name');
|
||||||
|
|
||||||
$form
|
$form
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -60,6 +67,11 @@ final class PhabricatorRepositorySearchEngine
|
||||||
->setName('callsigns')
|
->setName('callsigns')
|
||||||
->setLabel(pht('Callsigns'))
|
->setLabel(pht('Callsigns'))
|
||||||
->setValue(implode(', ', $callsigns)))
|
->setValue(implode(', ', $callsigns)))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setName('name')
|
||||||
|
->setLabel(pht('Name Contains'))
|
||||||
|
->setValue($name))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSelectControl())
|
id(new AphrontFormSelectControl())
|
||||||
->setName('status')
|
->setName('status')
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class PhabricatorJumpNavHandler {
|
||||||
'/^@(.+)$/i' => 'user',
|
'/^@(.+)$/i' => 'user',
|
||||||
'/^task:\s*(.+)/i' => 'create-task',
|
'/^task:\s*(.+)/i' => 'create-task',
|
||||||
'/^(?:s|symbol)\s+(\S+)/i' => 'find-symbol',
|
'/^(?:s|symbol)\s+(\S+)/i' => 'find-symbol',
|
||||||
|
'/^r\s+(.+)$/i' => 'find-repository',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($patterns as $pattern => $effect) {
|
foreach ($patterns as $pattern => $effect) {
|
||||||
|
@ -53,6 +54,20 @@ final class PhabricatorJumpNavHandler {
|
||||||
}
|
}
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI("/diffusion/symbol/$symbol/?jump=true$context");
|
->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':
|
case 'create-task':
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI('/maniphest/task/create/?title='
|
->setURI('/maniphest/task/create/?title='
|
||||||
|
|
|
@ -18,6 +18,7 @@ a navigational command into the box and press return.
|
||||||
- **r** - Jump to Diffusion.
|
- **r** - Jump to Diffusion.
|
||||||
- **rXYZ** - Jump to Diffusion Repository XYZ.
|
- **rXYZ** - Jump to Diffusion Repository XYZ.
|
||||||
- **rXYZabcdef** - Jump to Diffusion Commit rXYZabcdef.
|
- **rXYZabcdef** - Jump to Diffusion Commit rXYZabcdef.
|
||||||
|
- **r <name>** - Search for repositories by name.
|
||||||
- **u** - Jump to People
|
- **u** - Jump to People
|
||||||
- **u username** - Jump to username's Profile
|
- **u username** - Jump to username's Profile
|
||||||
- **p** - Jump to Project
|
- **p** - Jump to Project
|
||||||
|
|
Loading…
Reference in a new issue