mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
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
This commit is contained in:
parent
e1da1d86d6
commit
114166dd32
4 changed files with 159 additions and 5 deletions
|
@ -1338,6 +1338,8 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterArcLintBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcLintBuildStepImplementation.php',
|
'HarbormasterArcLintBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcLintBuildStepImplementation.php',
|
||||||
'HarbormasterArcUnitBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcUnitBuildStepImplementation.php',
|
'HarbormasterArcUnitBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcUnitBuildStepImplementation.php',
|
||||||
'HarbormasterArtifact' => 'applications/harbormaster/artifact/HarbormasterArtifact.php',
|
'HarbormasterArtifact' => 'applications/harbormaster/artifact/HarbormasterArtifact.php',
|
||||||
|
'HarbormasterArtifactSearchConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php',
|
||||||
|
'HarbormasterArtifactSearchEngine' => 'applications/harbormaster/query/HarbormasterArtifactSearchEngine.php',
|
||||||
'HarbormasterAutotargetsTestCase' => 'applications/harbormaster/__tests__/HarbormasterAutotargetsTestCase.php',
|
'HarbormasterAutotargetsTestCase' => 'applications/harbormaster/__tests__/HarbormasterAutotargetsTestCase.php',
|
||||||
'HarbormasterBuild' => 'applications/harbormaster/storage/build/HarbormasterBuild.php',
|
'HarbormasterBuild' => 'applications/harbormaster/storage/build/HarbormasterBuild.php',
|
||||||
'HarbormasterBuildAbortedException' => 'applications/harbormaster/exception/HarbormasterBuildAbortedException.php',
|
'HarbormasterBuildAbortedException' => 'applications/harbormaster/exception/HarbormasterBuildAbortedException.php',
|
||||||
|
@ -7369,6 +7371,8 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterArcLintBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterArcLintBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
'HarbormasterArcUnitBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
'HarbormasterArcUnitBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||||
'HarbormasterArtifact' => 'Phobject',
|
'HarbormasterArtifact' => 'Phobject',
|
||||||
|
'HarbormasterArtifactSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
|
'HarbormasterArtifactSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'HarbormasterAutotargetsTestCase' => 'PhabricatorTestCase',
|
'HarbormasterAutotargetsTestCase' => 'PhabricatorTestCase',
|
||||||
'HarbormasterBuild' => array(
|
'HarbormasterBuild' => array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
|
@ -7384,6 +7388,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorConduitResultInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterArtifactSearchConduitAPIMethod
|
||||||
|
extends PhabricatorSearchEngineAPIMethod {
|
||||||
|
|
||||||
|
public function getAPIMethodName() {
|
||||||
|
return 'harbormaster.artifact.search';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newSearchEngine() {
|
||||||
|
return new HarbormasterArtifactSearchEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethodSummary() {
|
||||||
|
return pht('Query information about build artifacts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class HarbormasterArtifactSearchEngine
|
||||||
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getResultTypeDescription() {
|
||||||
|
return pht('Harbormaster Artifacts');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorHarbormasterApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newQuery() {
|
||||||
|
return new HarbormasterBuildArtifactQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildCustomSearchFields() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorPHIDsSearchField())
|
||||||
|
->setLabel(pht('Targets'))
|
||||||
|
->setKey('buildTargetPHIDs')
|
||||||
|
->setAliases(
|
||||||
|
array(
|
||||||
|
'buildTargetPHID',
|
||||||
|
'buildTargets',
|
||||||
|
'buildTarget',
|
||||||
|
'targetPHIDs',
|
||||||
|
'targetPHID',
|
||||||
|
'targets',
|
||||||
|
'target',
|
||||||
|
))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for artifacts attached to particular build targets.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQueryFromParameters(array $map) {
|
||||||
|
$query = $this->newQuery();
|
||||||
|
|
||||||
|
if ($map['buildTargetPHIDs']) {
|
||||||
|
$query->withBuildTargetPHIDs($map['buildTargetPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getURI($path) {
|
||||||
|
return '/harbormaster/artifact/'.$path;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBuiltinQueryNames() {
|
||||||
|
return array(
|
||||||
|
'all' => pht('All Artifacts'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildSavedQueryFromBuiltin($query_key) {
|
||||||
|
$query = $this->newSavedQuery();
|
||||||
|
$query->setQueryKey($query_key);
|
||||||
|
|
||||||
|
switch ($query_key) {
|
||||||
|
case 'all':
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $artifacts,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
assert_instances_of($artifacts, 'HarbormasterBuildArtifact');
|
||||||
|
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
$list = new PHUIObjectItemListView();
|
||||||
|
foreach ($artifacts as $artifact) {
|
||||||
|
$id = $artifact->getID();
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setObjectName(pht('Artifact %d', $id));
|
||||||
|
|
||||||
|
$list->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id(new PhabricatorApplicationSearchResultView())
|
||||||
|
->setObjectList($list)
|
||||||
|
->setNoDataString(pht('No artifacts found.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ final class HarbormasterBuildArtifact
|
||||||
extends HarbormasterDAO
|
extends HarbormasterDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorDestructibleInterface {
|
PhabricatorDestructibleInterface,
|
||||||
|
PhabricatorConduitResultInterface {
|
||||||
|
|
||||||
protected $buildTargetPHID;
|
protected $buildTargetPHID;
|
||||||
protected $artifactType;
|
protected $artifactType;
|
||||||
|
@ -18,6 +19,7 @@ final class HarbormasterBuildArtifact
|
||||||
|
|
||||||
public static function initializeNewBuildArtifact(
|
public static function initializeNewBuildArtifact(
|
||||||
HarbormasterBuildTarget $build_target) {
|
HarbormasterBuildTarget $build_target) {
|
||||||
|
|
||||||
return id(new HarbormasterBuildArtifact())
|
return id(new HarbormasterBuildArtifact())
|
||||||
->attachBuildTarget($build_target)
|
->attachBuildTarget($build_target)
|
||||||
->setBuildTargetPHID($build_target->getPHID());
|
->setBuildTargetPHID($build_target->getPHID());
|
||||||
|
@ -53,9 +55,8 @@ final class HarbormasterBuildArtifact
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generatePHID() {
|
public function getPHIDType() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return HarbormasterBuildArtifactPHIDType::TYPECONST;
|
||||||
HarbormasterBuildArtifactPHIDType::TYPECONST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachBuildTarget(HarbormasterBuildTarget $build_target) {
|
public function attachBuildTarget(HarbormasterBuildTarget $build_target) {
|
||||||
|
@ -147,7 +148,8 @@ final class HarbormasterBuildArtifact
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAutomaticCapability($capability) {
|
public function describeAutomaticCapability($capability) {
|
||||||
return pht('Users must be able to see a buildable to see its artifacts.');
|
return pht(
|
||||||
|
'Users must be able to see a build target to see its artifacts.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,4 +167,40 @@ final class HarbormasterBuildArtifact
|
||||||
$this->saveTransaction();
|
$this->saveTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorConduitResultInterface )---------------------------------- */
|
||||||
|
|
||||||
|
public function getFieldSpecificationsForConduit() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('buildTargetPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('The build target this artifact is attached to.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('artifactType')
|
||||||
|
->setType('string')
|
||||||
|
->setDescription(pht('The artifact type.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('artifactKey')
|
||||||
|
->setType('string')
|
||||||
|
->setDescription(pht('The artifact key.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('isReleased')
|
||||||
|
->setType('bool')
|
||||||
|
->setDescription(pht('True if this artifact has been released.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldValuesForConduit() {
|
||||||
|
return array(
|
||||||
|
'buildTargetPHID' => $this->getBuildTargetPHID(),
|
||||||
|
'artifactType' => $this->getArtifactType(),
|
||||||
|
'artifactKey' => $this->getArtifactKey(),
|
||||||
|
'isReleased' => (bool)$this->getIsReleased(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConduitSearchAttachments() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue