@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.

Add a DiffusionRefDatasource for typeahead'ing branches, tags, bookmarks and refs

Summary: Ref T9952. This will let me put a "Branch: [____]" control on the "Land Revision" dialog so users can choose a branch to target.

Test Plan: Used `/typeahead/class/` to vet basic behavior.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9952

Differential Revision: https://secure.phabricator.com/D14732

+65
+2
src/__phutil_library_map__.php
··· 692 692 'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php', 693 693 'DiffusionRawDiffQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRawDiffQueryConduitAPIMethod.php', 694 694 'DiffusionReadmeView' => 'applications/diffusion/view/DiffusionReadmeView.php', 695 + 'DiffusionRefDatasource' => 'applications/diffusion/typeahead/DiffusionRefDatasource.php', 695 696 'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php', 696 697 'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php', 697 698 'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php', ··· 4566 4567 'DiffusionRawDiffQuery' => 'DiffusionQuery', 4567 4568 'DiffusionRawDiffQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 4568 4569 'DiffusionReadmeView' => 'DiffusionView', 4570 + 'DiffusionRefDatasource' => 'PhabricatorTypeaheadDatasource', 4569 4571 'DiffusionRefNotFoundException' => 'Exception', 4570 4572 'DiffusionRefTableController' => 'DiffusionController', 4571 4573 'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
+50
src/applications/diffusion/typeahead/DiffusionRefDatasource.php
··· 1 + <?php 2 + 3 + final class DiffusionRefDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Branches'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + // TODO: This is really "branch, tag, bookmark or ref" but we are only 12 + // using it to pick branches for now and sometimes the UI won't let you 13 + // pick some of these types. See also "Browse Branches" above. 14 + return pht('Type a branch name...'); 15 + } 16 + 17 + public function getDatasourceApplicationClass() { 18 + return 'PhabricatorDiffusionApplication'; 19 + } 20 + 21 + public function loadResults() { 22 + $viewer = $this->getViewer(); 23 + $raw_query = $this->getRawQuery(); 24 + 25 + $query = id(new PhabricatorRepositoryRefCursorQuery()) 26 + ->withDatasourceQuery($raw_query); 27 + 28 + $types = $this->getParameter('refTypes'); 29 + if ($types) { 30 + $query->withRefTypes($types); 31 + } 32 + 33 + $repository_phids = $this->getParameter('repositoryPHIDs'); 34 + if ($repository_phids) { 35 + $query->withRepositoryPHIDs($repository_phids); 36 + } 37 + 38 + $refs = $this->executeQuery($query); 39 + 40 + $results = array(); 41 + foreach ($refs as $ref) { 42 + $results[] = id(new PhabricatorTypeaheadResult()) 43 + ->setName($ref->getRefName()) 44 + ->setPHID($ref->getPHID()); 45 + } 46 + 47 + return $results; 48 + } 49 + 50 + }
+13
src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php
··· 8 8 private $repositoryPHIDs; 9 9 private $refTypes; 10 10 private $refNames; 11 + private $datasourceQuery; 11 12 12 13 public function withIDs(array $ids) { 13 14 $this->ids = $ids; ··· 31 32 32 33 public function withRefNames(array $names) { 33 34 $this->refNames = $names; 35 + return $this; 36 + } 37 + 38 + public function withDatasourceQuery($query) { 39 + $this->datasourceQuery = $query; 34 40 return $this; 35 41 } 36 42 ··· 106 112 $conn, 107 113 'refNameHash IN (%Ls)', 108 114 $name_hashes); 115 + } 116 + 117 + if (strlen($this->datasourceQuery)) { 118 + $where[] = qsprintf( 119 + $conn, 120 + 'refNameRaw LIKE %>', 121 + $this->datasourceQuery); 109 122 } 110 123 111 124 return $where;