mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Adds "Locate File" input to every browse directory view in Diffusion
Summary: Ref T15645 The very helpful "Locate File" input in Diffusion was so far only visible in the homepage route of any repository (`/repository`). With this revision you can now locate a file from every browsed directory and in any selected commit. The finder was already "directory sensitive" meaning: if you are trying to locate a file from within a browsed directory, only the children of this path will be searched. For the searching in a specified commit (for example: https://we.phorge.it/source/phorge/browse/master/src/;05f4d5071fdca02123bd1ff4c0935b847c7f9963), I had to do a little JS magic adding the commit to the URI on the client side. Test Plan: Checkout, browse through your repos with Diffusion trying to find files. (I tested only with Git repos.) Reviewers: O1 Blessed Committers, speck Reviewed By: O1 Blessed Committers, speck Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15645 Differential Revision: https://we.phorge.it/D25521
This commit is contained in:
parent
f8db94f2bf
commit
87db482897
5 changed files with 59 additions and 47 deletions
|
@ -391,7 +391,7 @@ return array(
|
||||||
'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'b7b73831',
|
'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'b7b73831',
|
||||||
'rsrc/js/application/diffusion/behavior-commit-branches.js' => '4b671572',
|
'rsrc/js/application/diffusion/behavior-commit-branches.js' => '4b671572',
|
||||||
'rsrc/js/application/diffusion/behavior-commit-graph.js' => 'ac10c917',
|
'rsrc/js/application/diffusion/behavior-commit-graph.js' => 'ac10c917',
|
||||||
'rsrc/js/application/diffusion/behavior-locate-file.js' => '87428eb2',
|
'rsrc/js/application/diffusion/behavior-locate-file.js' => '4c77f259',
|
||||||
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'c715c123',
|
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'c715c123',
|
||||||
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '6a85bc5a',
|
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '6a85bc5a',
|
||||||
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '47a0728b',
|
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '47a0728b',
|
||||||
|
@ -619,7 +619,7 @@ return array(
|
||||||
'javelin-behavior-differential-populate' => 'b86ef6c2',
|
'javelin-behavior-differential-populate' => 'b86ef6c2',
|
||||||
'javelin-behavior-diffusion-commit-branches' => '4b671572',
|
'javelin-behavior-diffusion-commit-branches' => '4b671572',
|
||||||
'javelin-behavior-diffusion-commit-graph' => 'ac10c917',
|
'javelin-behavior-diffusion-commit-graph' => 'ac10c917',
|
||||||
'javelin-behavior-diffusion-locate-file' => '87428eb2',
|
'javelin-behavior-diffusion-locate-file' => '4c77f259',
|
||||||
'javelin-behavior-diffusion-pull-lastmodified' => 'c715c123',
|
'javelin-behavior-diffusion-pull-lastmodified' => 'c715c123',
|
||||||
'javelin-behavior-document-engine' => '243d6c22',
|
'javelin-behavior-document-engine' => '243d6c22',
|
||||||
'javelin-behavior-doorkeeper-tag' => '6a85bc5a',
|
'javelin-behavior-doorkeeper-tag' => '6a85bc5a',
|
||||||
|
@ -1375,6 +1375,13 @@ return array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
),
|
),
|
||||||
|
'4c77f259' => array(
|
||||||
|
'javelin-behavior',
|
||||||
|
'javelin-diffusion-locate-file-source',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-typeahead',
|
||||||
|
'javelin-uri',
|
||||||
|
),
|
||||||
'4dffaeb2' => array(
|
'4dffaeb2' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
@ -1672,13 +1679,6 @@ return array(
|
||||||
'84f82dad' => array(
|
'84f82dad' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
),
|
),
|
||||||
'87428eb2' => array(
|
|
||||||
'javelin-behavior',
|
|
||||||
'javelin-diffusion-locate-file-source',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-typeahead',
|
|
||||||
'javelin-uri',
|
|
||||||
),
|
|
||||||
'876506b6' => array(
|
'876506b6' => array(
|
||||||
'javelin-view',
|
'javelin-view',
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
|
|
|
@ -326,9 +326,11 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
));
|
));
|
||||||
|
|
||||||
$crumbs->setBorder(true);
|
$crumbs->setBorder(true);
|
||||||
|
$locate_file = $this->buildLocateFile();
|
||||||
$tabs = $this->buildTabsView('code');
|
$tabs = $this->buildTabsView('code');
|
||||||
$owners_list = $this->buildOwnersList($drequest);
|
$owners_list = $this->buildOwnersList($drequest);
|
||||||
$bar = id(new PHUILeftRightView())
|
$bar = id(new PHUILeftRightView())
|
||||||
|
->setLeft($locate_file)
|
||||||
->setRight($this->corpusButtons)
|
->setRight($this->corpusButtons)
|
||||||
->addClass('diffusion-action-bar');
|
->addClass('diffusion-action-bar');
|
||||||
|
|
||||||
|
|
|
@ -554,4 +554,47 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PHUIBoxView|null
|
||||||
|
*/
|
||||||
|
protected function buildLocateFile() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
|
$form_box = null;
|
||||||
|
if ($repository->canUsePathTree()) {
|
||||||
|
Javelin::initBehavior(
|
||||||
|
'diffusion-locate-file',
|
||||||
|
array(
|
||||||
|
'controlID' => 'locate-control',
|
||||||
|
'inputID' => 'locate-input',
|
||||||
|
'symbolicCommit' => $drequest->getSymbolicCommit(),
|
||||||
|
'browseBaseURI' => (string)$drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'browse',
|
||||||
|
'commit' => '',
|
||||||
|
'path' => '',
|
||||||
|
)),
|
||||||
|
'uri' => (string)$drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'pathtree',
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTypeaheadControl())
|
||||||
|
->setHardpointID('locate-control')
|
||||||
|
->setID('locate-input')
|
||||||
|
->setPlaceholder(pht('Locate File')));
|
||||||
|
$form_box = id(new PHUIBoxView())
|
||||||
|
->appendChild($form->buildLayoutView())
|
||||||
|
->addClass('diffusion-profile-locate');
|
||||||
|
}
|
||||||
|
return $form_box;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,43 +433,6 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
return $button;
|
return $button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildLocateFile() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$viewer = $request->getUser();
|
|
||||||
$drequest = $this->getDiffusionRequest();
|
|
||||||
$repository = $drequest->getRepository();
|
|
||||||
|
|
||||||
$form_box = null;
|
|
||||||
if ($repository->canUsePathTree()) {
|
|
||||||
Javelin::initBehavior(
|
|
||||||
'diffusion-locate-file',
|
|
||||||
array(
|
|
||||||
'controlID' => 'locate-control',
|
|
||||||
'inputID' => 'locate-input',
|
|
||||||
'browseBaseURI' => (string)$drequest->generateURI(
|
|
||||||
array(
|
|
||||||
'action' => 'browse',
|
|
||||||
)),
|
|
||||||
'uri' => (string)$drequest->generateURI(
|
|
||||||
array(
|
|
||||||
'action' => 'pathtree',
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormTypeaheadControl())
|
|
||||||
->setHardpointID('locate-control')
|
|
||||||
->setID('locate-input')
|
|
||||||
->setPlaceholder(pht('Locate File')));
|
|
||||||
$form_box = id(new PHUIBoxView())
|
|
||||||
->appendChild($form->buildLayoutView())
|
|
||||||
->addClass('diffusion-profile-locate');
|
|
||||||
}
|
|
||||||
return $form_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildBrowseTable(
|
private function buildBrowseTable(
|
||||||
$browse_results,
|
$browse_results,
|
||||||
$browse_paths,
|
$browse_paths,
|
||||||
|
|
|
@ -17,7 +17,11 @@ JX.behavior('diffusion-locate-file', function(config) {
|
||||||
typeahead.setDatasource(datasource);
|
typeahead.setDatasource(datasource);
|
||||||
|
|
||||||
typeahead.listen('choose', function(r) {
|
typeahead.listen('choose', function(r) {
|
||||||
JX.$U(config.browseBaseURI + r.ref).go();
|
var browseURI = config.browseBaseURI + r.ref;
|
||||||
|
if (config.symbolicCommit) {
|
||||||
|
browseURI += ';' + config.symbolicCommit;
|
||||||
|
}
|
||||||
|
JX.$U(browseURI).go();
|
||||||
});
|
});
|
||||||
|
|
||||||
var started = false;
|
var started = false;
|
||||||
|
|
Loading…
Reference in a new issue