@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+59 -47
+9 -9
resources/celerity/map.php
··· 391 391 'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'b7b73831', 392 392 'rsrc/js/application/diffusion/behavior-commit-branches.js' => '4b671572', 393 393 'rsrc/js/application/diffusion/behavior-commit-graph.js' => 'ac10c917', 394 - 'rsrc/js/application/diffusion/behavior-locate-file.js' => '87428eb2', 394 + 'rsrc/js/application/diffusion/behavior-locate-file.js' => '4c77f259', 395 395 'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'c715c123', 396 396 'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '6a85bc5a', 397 397 'rsrc/js/application/drydock/drydock-live-operation-status.js' => '47a0728b', ··· 619 619 'javelin-behavior-differential-populate' => 'b86ef6c2', 620 620 'javelin-behavior-diffusion-commit-branches' => '4b671572', 621 621 'javelin-behavior-diffusion-commit-graph' => 'ac10c917', 622 - 'javelin-behavior-diffusion-locate-file' => '87428eb2', 622 + 'javelin-behavior-diffusion-locate-file' => '4c77f259', 623 623 'javelin-behavior-diffusion-pull-lastmodified' => 'c715c123', 624 624 'javelin-behavior-document-engine' => '243d6c22', 625 625 'javelin-behavior-doorkeeper-tag' => '6a85bc5a', ··· 1375 1375 'javelin-install', 1376 1376 'javelin-dom', 1377 1377 ), 1378 + '4c77f259' => array( 1379 + 'javelin-behavior', 1380 + 'javelin-diffusion-locate-file-source', 1381 + 'javelin-dom', 1382 + 'javelin-typeahead', 1383 + 'javelin-uri', 1384 + ), 1378 1385 '4dffaeb2' => array( 1379 1386 'javelin-behavior', 1380 1387 'javelin-stratcom', ··· 1671 1678 ), 1672 1679 '84f82dad' => array( 1673 1680 'javelin-install', 1674 - ), 1675 - '87428eb2' => array( 1676 - 'javelin-behavior', 1677 - 'javelin-diffusion-locate-file-source', 1678 - 'javelin-dom', 1679 - 'javelin-typeahead', 1680 - 'javelin-uri', 1681 1681 ), 1682 1682 '876506b6' => array( 1683 1683 'javelin-view',
+2
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 326 326 )); 327 327 328 328 $crumbs->setBorder(true); 329 + $locate_file = $this->buildLocateFile(); 329 330 $tabs = $this->buildTabsView('code'); 330 331 $owners_list = $this->buildOwnersList($drequest); 331 332 $bar = id(new PHUILeftRightView()) 333 + ->setLeft($locate_file) 332 334 ->setRight($this->corpusButtons) 333 335 ->addClass('diffusion-action-bar'); 334 336
+43
src/applications/diffusion/controller/DiffusionController.php
··· 554 554 555 555 } 556 556 557 + /** 558 + * @return PHUIBoxView|null 559 + */ 560 + protected function buildLocateFile() { 561 + $request = $this->getRequest(); 562 + $viewer = $request->getUser(); 563 + $drequest = $this->getDiffusionRequest(); 564 + $repository = $drequest->getRepository(); 565 + 566 + $form_box = null; 567 + if ($repository->canUsePathTree()) { 568 + Javelin::initBehavior( 569 + 'diffusion-locate-file', 570 + array( 571 + 'controlID' => 'locate-control', 572 + 'inputID' => 'locate-input', 573 + 'symbolicCommit' => $drequest->getSymbolicCommit(), 574 + 'browseBaseURI' => (string)$drequest->generateURI( 575 + array( 576 + 'action' => 'browse', 577 + 'commit' => '', 578 + 'path' => '', 579 + )), 580 + 'uri' => (string)$drequest->generateURI( 581 + array( 582 + 'action' => 'pathtree', 583 + )), 584 + )); 585 + 586 + $form = id(new AphrontFormView()) 587 + ->setUser($viewer) 588 + ->appendChild( 589 + id(new AphrontFormTypeaheadControl()) 590 + ->setHardpointID('locate-control') 591 + ->setID('locate-input') 592 + ->setPlaceholder(pht('Locate File'))); 593 + $form_box = id(new PHUIBoxView()) 594 + ->appendChild($form->buildLayoutView()) 595 + ->addClass('diffusion-profile-locate'); 596 + } 597 + return $form_box; 598 + } 599 + 557 600 }
-37
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 433 433 return $button; 434 434 } 435 435 436 - private function buildLocateFile() { 437 - $request = $this->getRequest(); 438 - $viewer = $request->getUser(); 439 - $drequest = $this->getDiffusionRequest(); 440 - $repository = $drequest->getRepository(); 441 - 442 - $form_box = null; 443 - if ($repository->canUsePathTree()) { 444 - Javelin::initBehavior( 445 - 'diffusion-locate-file', 446 - array( 447 - 'controlID' => 'locate-control', 448 - 'inputID' => 'locate-input', 449 - 'browseBaseURI' => (string)$drequest->generateURI( 450 - array( 451 - 'action' => 'browse', 452 - )), 453 - 'uri' => (string)$drequest->generateURI( 454 - array( 455 - 'action' => 'pathtree', 456 - )), 457 - )); 458 - 459 - $form = id(new AphrontFormView()) 460 - ->setUser($viewer) 461 - ->appendChild( 462 - id(new AphrontFormTypeaheadControl()) 463 - ->setHardpointID('locate-control') 464 - ->setID('locate-input') 465 - ->setPlaceholder(pht('Locate File'))); 466 - $form_box = id(new PHUIBoxView()) 467 - ->appendChild($form->buildLayoutView()) 468 - ->addClass('diffusion-profile-locate'); 469 - } 470 - return $form_box; 471 - } 472 - 473 436 private function buildBrowseTable( 474 437 $browse_results, 475 438 $browse_paths,
+5 -1
webroot/rsrc/js/application/diffusion/behavior-locate-file.js
··· 17 17 typeahead.setDatasource(datasource); 18 18 19 19 typeahead.listen('choose', function(r) { 20 - JX.$U(config.browseBaseURI + r.ref).go(); 20 + var browseURI = config.browseBaseURI + r.ref; 21 + if (config.symbolicCommit) { 22 + browseURI += ';' + config.symbolicCommit; 23 + } 24 + JX.$U(browseURI).go(); 21 25 }); 22 26 23 27 var started = false;