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

Roughly implement "harbormaster.artifact.search"

Summary: Ref T13438. This is a sort of minimal plausible implementation.

Test Plan: Used "harbormaster.artifact.search" to query information about artifacts.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13438

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

+159 -5
+5
src/__phutil_library_map__.php
··· 1338 1338 'HarbormasterArcLintBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcLintBuildStepImplementation.php', 1339 1339 'HarbormasterArcUnitBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcUnitBuildStepImplementation.php', 1340 1340 'HarbormasterArtifact' => 'applications/harbormaster/artifact/HarbormasterArtifact.php', 1341 + 'HarbormasterArtifactSearchConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php', 1342 + 'HarbormasterArtifactSearchEngine' => 'applications/harbormaster/query/HarbormasterArtifactSearchEngine.php', 1341 1343 'HarbormasterAutotargetsTestCase' => 'applications/harbormaster/__tests__/HarbormasterAutotargetsTestCase.php', 1342 1344 'HarbormasterBuild' => 'applications/harbormaster/storage/build/HarbormasterBuild.php', 1343 1345 'HarbormasterBuildAbortedException' => 'applications/harbormaster/exception/HarbormasterBuildAbortedException.php', ··· 7369 7371 'HarbormasterArcLintBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 7370 7372 'HarbormasterArcUnitBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 7371 7373 'HarbormasterArtifact' => 'Phobject', 7374 + 'HarbormasterArtifactSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 7375 + 'HarbormasterArtifactSearchEngine' => 'PhabricatorApplicationSearchEngine', 7372 7376 'HarbormasterAutotargetsTestCase' => 'PhabricatorTestCase', 7373 7377 'HarbormasterBuild' => array( 7374 7378 'HarbormasterDAO', ··· 7384 7388 'HarbormasterDAO', 7385 7389 'PhabricatorPolicyInterface', 7386 7390 'PhabricatorDestructibleInterface', 7391 + 'PhabricatorConduitResultInterface', 7387 7392 ), 7388 7393 'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType', 7389 7394 'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+18
src/applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class HarbormasterArtifactSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'harbormaster.artifact.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new HarbormasterArtifactSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Query information about build artifacts.'); 16 + } 17 + 18 + }
+93
src/applications/harbormaster/query/HarbormasterArtifactSearchEngine.php
··· 1 + <?php 2 + 3 + final class HarbormasterArtifactSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Harbormaster Artifacts'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorHarbormasterApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new HarbormasterBuildArtifactQuery(); 16 + } 17 + 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorPHIDsSearchField()) 21 + ->setLabel(pht('Targets')) 22 + ->setKey('buildTargetPHIDs') 23 + ->setAliases( 24 + array( 25 + 'buildTargetPHID', 26 + 'buildTargets', 27 + 'buildTarget', 28 + 'targetPHIDs', 29 + 'targetPHID', 30 + 'targets', 31 + 'target', 32 + )) 33 + ->setDescription( 34 + pht('Search for artifacts attached to particular build targets.')), 35 + ); 36 + } 37 + 38 + protected function buildQueryFromParameters(array $map) { 39 + $query = $this->newQuery(); 40 + 41 + if ($map['buildTargetPHIDs']) { 42 + $query->withBuildTargetPHIDs($map['buildTargetPHIDs']); 43 + } 44 + 45 + return $query; 46 + } 47 + 48 + protected function getURI($path) { 49 + return '/harbormaster/artifact/'.$path; 50 + } 51 + 52 + protected function getBuiltinQueryNames() { 53 + return array( 54 + 'all' => pht('All Artifacts'), 55 + ); 56 + } 57 + 58 + public function buildSavedQueryFromBuiltin($query_key) { 59 + $query = $this->newSavedQuery(); 60 + $query->setQueryKey($query_key); 61 + 62 + switch ($query_key) { 63 + case 'all': 64 + return $query; 65 + } 66 + 67 + return parent::buildSavedQueryFromBuiltin($query_key); 68 + } 69 + 70 + protected function renderResultList( 71 + array $artifacts, 72 + PhabricatorSavedQuery $query, 73 + array $handles) { 74 + assert_instances_of($artifacts, 'HarbormasterBuildArtifact'); 75 + 76 + $viewer = $this->requireViewer(); 77 + 78 + $list = new PHUIObjectItemListView(); 79 + foreach ($artifacts as $artifact) { 80 + $id = $artifact->getID(); 81 + 82 + $item = id(new PHUIObjectItemView()) 83 + ->setObjectName(pht('Artifact %d', $id)); 84 + 85 + $list->addItem($item); 86 + } 87 + 88 + return id(new PhabricatorApplicationSearchResultView()) 89 + ->setObjectList($list) 90 + ->setNoDataString(pht('No artifacts found.')); 91 + } 92 + 93 + }
+43 -5
src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
··· 4 4 extends HarbormasterDAO 5 5 implements 6 6 PhabricatorPolicyInterface, 7 - PhabricatorDestructibleInterface { 7 + PhabricatorDestructibleInterface, 8 + PhabricatorConduitResultInterface { 8 9 9 10 protected $buildTargetPHID; 10 11 protected $artifactType; ··· 18 19 19 20 public static function initializeNewBuildArtifact( 20 21 HarbormasterBuildTarget $build_target) { 22 + 21 23 return id(new HarbormasterBuildArtifact()) 22 24 ->attachBuildTarget($build_target) 23 25 ->setBuildTargetPHID($build_target->getPHID()); ··· 53 55 ) + parent::getConfiguration(); 54 56 } 55 57 56 - public function generatePHID() { 57 - return PhabricatorPHID::generateNewPHID( 58 - HarbormasterBuildArtifactPHIDType::TYPECONST); 58 + public function getPHIDType() { 59 + return HarbormasterBuildArtifactPHIDType::TYPECONST; 59 60 } 60 61 61 62 public function attachBuildTarget(HarbormasterBuildTarget $build_target) { ··· 147 148 } 148 149 149 150 public function describeAutomaticCapability($capability) { 150 - return pht('Users must be able to see a buildable to see its artifacts.'); 151 + return pht( 152 + 'Users must be able to see a build target to see its artifacts.'); 151 153 } 152 154 153 155 ··· 165 167 $this->saveTransaction(); 166 168 } 167 169 170 + 171 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 172 + 173 + public function getFieldSpecificationsForConduit() { 174 + return array( 175 + id(new PhabricatorConduitSearchFieldSpecification()) 176 + ->setKey('buildTargetPHID') 177 + ->setType('phid') 178 + ->setDescription(pht('The build target this artifact is attached to.')), 179 + id(new PhabricatorConduitSearchFieldSpecification()) 180 + ->setKey('artifactType') 181 + ->setType('string') 182 + ->setDescription(pht('The artifact type.')), 183 + id(new PhabricatorConduitSearchFieldSpecification()) 184 + ->setKey('artifactKey') 185 + ->setType('string') 186 + ->setDescription(pht('The artifact key.')), 187 + id(new PhabricatorConduitSearchFieldSpecification()) 188 + ->setKey('isReleased') 189 + ->setType('bool') 190 + ->setDescription(pht('True if this artifact has been released.')), 191 + ); 192 + } 193 + 194 + public function getFieldValuesForConduit() { 195 + return array( 196 + 'buildTargetPHID' => $this->getBuildTargetPHID(), 197 + 'artifactType' => $this->getArtifactType(), 198 + 'artifactKey' => $this->getArtifactKey(), 199 + 'isReleased' => (bool)$this->getIsReleased(), 200 + ); 201 + } 202 + 203 + public function getConduitSearchAttachments() { 204 + return array(); 205 + } 168 206 }