Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15383230
D20878.id49773.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D20878.id49773.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1338,6 +1338,8 @@
'HarbormasterArcLintBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcLintBuildStepImplementation.php',
'HarbormasterArcUnitBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcUnitBuildStepImplementation.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',
'HarbormasterBuild' => 'applications/harbormaster/storage/build/HarbormasterBuild.php',
'HarbormasterBuildAbortedException' => 'applications/harbormaster/exception/HarbormasterBuildAbortedException.php',
@@ -7369,6 +7371,8 @@
'HarbormasterArcLintBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterArcUnitBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterArtifact' => 'Phobject',
+ 'HarbormasterArtifactSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
+ 'HarbormasterArtifactSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HarbormasterAutotargetsTestCase' => 'PhabricatorTestCase',
'HarbormasterBuild' => array(
'HarbormasterDAO',
@@ -7384,6 +7388,7 @@
'HarbormasterDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorConduitResultInterface',
),
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
diff --git a/src/applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/conduit/HarbormasterArtifactSearchConduitAPIMethod.php
@@ -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.');
+ }
+
+}
diff --git a/src/applications/harbormaster/query/HarbormasterArtifactSearchEngine.php b/src/applications/harbormaster/query/HarbormasterArtifactSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/query/HarbormasterArtifactSearchEngine.php
@@ -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.'));
+ }
+
+}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
@@ -4,7 +4,8 @@
extends HarbormasterDAO
implements
PhabricatorPolicyInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorConduitResultInterface {
protected $buildTargetPHID;
protected $artifactType;
@@ -18,6 +19,7 @@
public static function initializeNewBuildArtifact(
HarbormasterBuildTarget $build_target) {
+
return id(new HarbormasterBuildArtifact())
->attachBuildTarget($build_target)
->setBuildTargetPHID($build_target->getPHID());
@@ -53,9 +55,8 @@
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(
- HarbormasterBuildArtifactPHIDType::TYPECONST);
+ public function getPHIDType() {
+ return HarbormasterBuildArtifactPHIDType::TYPECONST;
}
public function attachBuildTarget(HarbormasterBuildTarget $build_target) {
@@ -147,7 +148,8 @@
}
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 @@
$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();
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 3:54 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7659783
Default Alt Text
D20878.id49773.diff (8 KB)
Attached To
Mode
D20878: Roughly implement "harbormaster.artifact.search"
Attached
Detach File
Event Timeline
Log In to Comment