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

Allow buildables to be queried by container and underlying buildable

Summary: Ref T1049. Adds "Repository", "Revision", "Diff" and "Commit" as searchable fields.

Test Plan: Used all the fields to filter things.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1049

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

+107
+1
src/applications/harbormaster/controller/HarbormasterBuildableListController.php
··· 37 37 38 38 $item = id(new PHUIObjectItemView()) 39 39 ->setHeader(pht('Buildable %d', $buildable->getID())); 40 + $item->addAttribute($buildable->getContainerHandle()->getName()); 40 41 $item->addAttribute($buildable->getBuildableHandle()->getFullName()); 41 42 42 43 if ($id) {
+106
src/applications/harbormaster/query/HarbormasterBuildableSearchEngine.php
··· 6 6 public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 7 $saved = new PhabricatorSavedQuery(); 8 8 9 + $revisions = $this->readPHIDsFromRequest( 10 + $request, 11 + 'revisions', 12 + array( 13 + DifferentialPHIDTypeRevision::TYPECONST, 14 + )); 15 + 16 + $repositories = $this->readPHIDsFromRequest( 17 + $request, 18 + 'repositories', 19 + array( 20 + PhabricatorRepositoryPHIDTypeRepository::TYPECONST, 21 + )); 22 + 23 + $container_phids = array_merge($revisions, $repositories); 24 + $saved->setParameter('containerPHIDs', $container_phids); 25 + 26 + $commits = $this->readPHIDsFromRequest( 27 + $request, 28 + 'commits', 29 + array( 30 + PhabricatorRepositoryPHIDTypeCommit::TYPECONST, 31 + )); 32 + 33 + $diffs = $this->readListFromRequest($request, 'diffs'); 34 + if ($diffs) { 35 + $diffs = id(new DifferentialDiffQuery()) 36 + ->setViewer($this->requireViewer()) 37 + ->withIDs($diffs) 38 + ->execute(); 39 + $diffs = mpull($diffs, 'getPHID', 'getPHID'); 40 + } 41 + 42 + $buildable_phids = array_merge($commits, $diffs); 43 + $saved->setParameter('buildablePHIDs', $buildable_phids); 44 + 45 + 9 46 return $saved; 10 47 } 11 48 12 49 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 50 $query = id(new HarbormasterBuildableQuery()) 51 + ->needContainerHandles(true) 14 52 ->needBuildableHandles(true) 15 53 ->needBuilds(true); 16 54 55 + $container_phids = $saved->getParameter('containerPHIDs', array()); 56 + if ($container_phids) { 57 + $query->withContainerPHIDs($container_phids); 58 + } 59 + 60 + $buildable_phids = $saved->getParameter('buildablePHIDs', array()); 61 + 62 + if ($buildable_phids) { 63 + $query->withBuildablePHIDs($buildable_phids); 64 + } 65 + 17 66 return $query; 18 67 } 19 68 ··· 21 70 AphrontFormView $form, 22 71 PhabricatorSavedQuery $saved_query) { 23 72 73 + $container_phids = $saved_query->getParameter('containerPHIDs', array()); 74 + $buildable_phids = $saved_query->getParameter('buildablePHIDs', array()); 75 + 76 + $all_phids = array_merge($container_phids, $buildable_phids); 77 + 78 + $revision_names = array(); 79 + $diff_names = array(); 80 + $repository_names = array(); 81 + $commit_names = array(); 82 + 83 + if ($all_phids) { 84 + $objects = id(new PhabricatorObjectQuery()) 85 + ->setViewer($this->requireViewer()) 86 + ->withPHIDs($all_phids) 87 + ->execute(); 88 + 89 + foreach ($all_phids as $phid) { 90 + $object = idx($objects, $phid); 91 + if (!$object) { 92 + continue; 93 + } 94 + 95 + if ($object instanceof DifferentialRevision) { 96 + $revision_names[] = 'D'.$object->getID(); 97 + } else if ($object instanceof DifferentialDiff) { 98 + $diff_names[] = $object->getID(); 99 + } else if ($object instanceof PhabricatorRepository) { 100 + $repository_names[] = 'r'.$object->getCallsign(); 101 + } else if ($object instanceof PhabricatorRepositoryCommit) { 102 + $repository = $object->getRepository(); 103 + $commit_names[] = $repository->formatCommitName( 104 + $object->getCommitIdentifier()); 105 + } 106 + } 107 + } 108 + 109 + $form 110 + ->appendChild( 111 + id(new AphrontFormTextControl()) 112 + ->setLabel(pht('Differential Revisions')) 113 + ->setName('revisions') 114 + ->setValue(implode(', ', $revision_names))) 115 + ->appendChild( 116 + id(new AphrontFormTextControl()) 117 + ->setLabel(pht('Differential Diffs')) 118 + ->setName('diffs') 119 + ->setValue(implode(', ', $diff_names))) 120 + ->appendChild( 121 + id(new AphrontFormTextControl()) 122 + ->setLabel(pht('Repositories')) 123 + ->setName('repositories') 124 + ->setValue(implode(', ', $repository_names))) 125 + ->appendChild( 126 + id(new AphrontFormTextControl()) 127 + ->setLabel(pht('Commits')) 128 + ->setName('commits') 129 + ->setValue(implode(', ', $commit_names))); 24 130 } 25 131 26 132 protected function getURI($path) {