Page MenuHomePhabricator

D8795.id20894.diff
No OneTemporary

D8795.id20894.diff

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
@@ -191,6 +191,7 @@
'ConduitAPI_flag_query_Method' => 'applications/flag/conduit/ConduitAPI_flag_query_Method.php',
'ConduitAPI_harbormaster_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_Method.php',
'ConduitAPI_harbormaster_querybuildables_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuildables_Method.php',
+ 'ConduitAPI_harbormaster_querybuilds_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuilds_Method.php',
'ConduitAPI_harbormaster_sendmessage_Method' => 'applications/harbormaster/conduit/ConduitAPI_harbormaster_sendmessage_Method.php',
'ConduitAPI_macro_Method' => 'applications/macro/conduit/ConduitAPI_macro_Method.php',
'ConduitAPI_macro_creatememe_Method' => 'applications/macro/conduit/ConduitAPI_macro_creatememe_Method.php',
@@ -2781,6 +2782,7 @@
'ConduitAPI_flag_query_Method' => 'ConduitAPI_flag_Method',
'ConduitAPI_harbormaster_Method' => 'ConduitAPIMethod',
'ConduitAPI_harbormaster_querybuildables_Method' => 'ConduitAPI_harbormaster_Method',
+ 'ConduitAPI_harbormaster_querybuilds_Method' => 'ConduitAPI_harbormaster_Method',
'ConduitAPI_harbormaster_sendmessage_Method' => 'ConduitAPI_harbormaster_Method',
'ConduitAPI_macro_Method' => 'ConduitAPIMethod',
'ConduitAPI_macro_creatememe_Method' => 'ConduitAPI_macro_Method',
diff --git a/src/applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuilds_Method.php b/src/applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuilds_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/conduit/ConduitAPI_harbormaster_querybuilds_Method.php
@@ -0,0 +1,90 @@
+<?php
+
+final class ConduitAPI_harbormaster_querybuilds_Method
+ extends ConduitAPI_harbormaster_Method {
+
+ public function getMethodDescription() {
+ return pht('Query Harbormaster builds.');
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'ids' => 'optional list<id>',
+ 'phids' => 'optional list<phid>',
+ 'buildStatuses' => 'optional list<string>',
+ 'buildablePHIDs' => 'optional list<phid>',
+ 'buildPlanPHIDs' => 'optional list<phid>',
+ ) + self::getPagerParamTypes();
+ }
+
+ public function defineReturnType() {
+ return 'wild';
+ }
+
+ public function defineErrorTypes() {
+ return array();
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $viewer = $request->getUser();
+
+ $query = id(new HarbormasterBuildQuery())
+ ->setViewer($viewer);
+
+ $ids = $request->getValue('ids');
+ if ($ids !== null) {
+ $query->withIDs($ids);
+ }
+
+ $phids = $request->getValue('phids');
+ if ($phids !== null) {
+ $query->withPHIDs($phids);
+ }
+
+ $statuses = $request->getValue('buildStatuses');
+ if ($statuses !== null) {
+ $query->withBuildStatuses($statuses);
+ }
+
+ $buildable_phids = $request->getValue('buildablePHIDs');
+ if ($buildable_phids !== null) {
+ $query->withBuildablePHIDs($buildable_phids);
+ }
+
+ $build_plan_phids = $request->getValue('buildPlanPHIDs');
+ if ($build_plan_phids !== null) {
+ $query->withBuildPlanPHIDs($build_plan_phids);
+ }
+
+ $pager = $this->newPager($request);
+
+ $builds = $query->executeWithCursorPager($pager);
+
+ $data = array();
+ foreach ($builds as $build) {
+
+ $id = $build->getID();
+ $uri = '/harbormaster/build/'.$id.'/';
+ $status = $build->getBuildStatus();
+
+ $data[] = array(
+ 'id' => $id,
+ 'phid' => $build->getPHID(),
+ 'uri' => PhabricatorEnv::getProductionURI($uri),
+ 'name' => $build->getBuildPlan()->getName(),
+ 'buildablePHID' => $build->getBuildablePHID(),
+ 'buildPlanPHID' => $build->getBuildPlanPHID(),
+ 'buildStatus' => $status,
+ 'buildStatusName' => HarbormasterBuild::getBuildStatusName($status),
+ );
+ }
+
+ $results = array(
+ 'data' => $data,
+ );
+
+ $results = $this->addPagerResults($results, $pager);
+ return $results;
+ }
+
+}
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
@@ -308,26 +308,8 @@
if ($build->isStopping()) {
return pht('Stopping');
}
- switch ($build->getBuildStatus()) {
- case HarbormasterBuild::STATUS_INACTIVE:
- return pht('Inactive');
- case HarbormasterBuild::STATUS_PENDING:
- return pht('Pending');
- case HarbormasterBuild::STATUS_WAITING:
- return pht('Waiting');
- case HarbormasterBuild::STATUS_BUILDING:
- return pht('Building');
- case HarbormasterBuild::STATUS_PASSED:
- return pht('Passed');
- case HarbormasterBuild::STATUS_FAILED:
- return pht('Failed');
- case HarbormasterBuild::STATUS_ERROR:
- return pht('Unexpected Error');
- case HarbormasterBuild::STATUS_STOPPED:
- return pht('Stopped');
- default:
- return pht('Unknown');
- }
+
+ return HarbormasterBuild::getBuildStatusName($build->getBuildStatus());
}
private function buildMessages(array $messages) {
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
@@ -169,41 +169,33 @@
->setHeader($build->getName())
->setHref($view_uri);
- switch ($build->getBuildStatus()) {
+ $status = $build->getBuildStatus();
+ switch ($status) {
case HarbormasterBuild::STATUS_INACTIVE:
$item->setBarColor('grey');
- $item->addAttribute(pht('Inactive'));
break;
case HarbormasterBuild::STATUS_PENDING:
$item->setBarColor('blue');
- $item->addAttribute(pht('Pending'));
- break;
- case HarbormasterBuild::STATUS_WAITING:
- $item->setBarColor('violet');
- $item->addAttribute(pht('Waiting'));
break;
case HarbormasterBuild::STATUS_BUILDING:
$item->setBarColor('yellow');
- $item->addAttribute(pht('Building'));
break;
case HarbormasterBuild::STATUS_PASSED:
$item->setBarColor('green');
- $item->addAttribute(pht('Passed'));
break;
case HarbormasterBuild::STATUS_FAILED:
$item->setBarColor('red');
- $item->addAttribute(pht('Failed'));
break;
case HarbormasterBuild::STATUS_ERROR:
$item->setBarColor('red');
- $item->addAttribute(pht('Unexpected Error'));
break;
case HarbormasterBuild::STATUS_STOPPED:
$item->setBarColor('black');
- $item->addAttribute(pht('Stopped'));
break;
}
+ $item->addAttribute(HarbormasterBuild::getBuildStatusName($status));
+
if ($build->isRestarting()) {
$item->addIcon('backward', pht('Restarting'));
} else if ($build->isStopping()) {
diff --git a/src/applications/harbormaster/event/HarbormasterUIEventListener.php b/src/applications/harbormaster/event/HarbormasterUIEventListener.php
--- a/src/applications/harbormaster/event/HarbormasterUIEventListener.php
+++ b/src/applications/harbormaster/event/HarbormasterUIEventListener.php
@@ -72,36 +72,38 @@
$item = new PHUIStatusItemView();
$item->setTarget($build_handles[$build->getPHID()]->renderLink());
- switch ($build->getBuildStatus()) {
+ $status = $build->getBuildStatus();
+ $status_name = HarbormasterBuild::getBuildStatusName($status);
+
+ switch ($status) {
case HarbormasterBuild::STATUS_INACTIVE:
- $item->setIcon('open-dark', pht('Inactive'));
+ $icon = 'open-dark';
break;
case HarbormasterBuild::STATUS_PENDING:
- $item->setIcon('open-blue', pht('Pending'));
- break;
- case HarbormasterBuild::STATUS_WAITING:
- $item->setIcon('up-blue', pht('Waiting on Resource'));
+ $icon = 'open-blue';
break;
case HarbormasterBuild::STATUS_BUILDING:
- $item->setIcon('right-blue', pht('Building'));
+ $icon = 'right-blue';
break;
case HarbormasterBuild::STATUS_PASSED:
- $item->setIcon('accept-green', pht('Passed'));
+ $icon = 'accept-green';
break;
case HarbormasterBuild::STATUS_FAILED:
- $item->setIcon('reject-red', pht('Failed'));
+ $icon = 'reject-red';
break;
case HarbormasterBuild::STATUS_ERROR:
- $item->setIcon('minus-red', pht('Unexpected Error'));
+ $icon = 'minus-red';
break;
case HarbormasterBuild::STATUS_STOPPED:
- $item->setIcon('minus-dark', pht('Stopped'));
+ $icon = 'minus-dark';
break;
default:
- $item->setIcon('question', pht('Unknown'));
+ $icon = 'question';
break;
}
+ $item->setIcon($icon, $status_name);
+
$status_view->addItem($item);
}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -23,11 +23,6 @@
const STATUS_PENDING = 'pending';
/**
- * Waiting for a resource to be allocated (not yet relevant).
- */
- const STATUS_WAITING = 'waiting';
-
- /**
* Current building the buildable.
*/
const STATUS_BUILDING = 'building';
@@ -52,6 +47,34 @@
*/
const STATUS_STOPPED = 'stopped';
+
+ /**
+ * Get a human readable name for a build status constant.
+ *
+ * @param const Build status constant.
+ * @return string Human-readable name.
+ */
+ public static function getBuildStatusName($status) {
+ switch ($status) {
+ case self::STATUS_INACTIVE:
+ return pht('Inactive');
+ case self::STATUS_PENDING:
+ return pht('Pending');
+ case self::STATUS_BUILDING:
+ return pht('Building');
+ case self::STATUS_PASSED:
+ return pht('Passed');
+ case self::STATUS_FAILED:
+ return pht('Failed');
+ case self::STATUS_ERROR:
+ return pht('Unexpected Error');
+ case self::STATUS_STOPPED:
+ return pht('Stopped');
+ default:
+ return pht('Unknown');
+ }
+ }
+
public static function initializeNewBuild(PhabricatorUser $actor) {
return id(new HarbormasterBuild())
->setBuildStatus(self::STATUS_INACTIVE);
@@ -114,7 +137,6 @@
public function isBuilding() {
return $this->getBuildStatus() === self::STATUS_PENDING ||
- $this->getBuildStatus() === self::STATUS_WAITING ||
$this->getBuildStatus() === self::STATUS_BUILDING;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 29, 9:58 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712074
Default Alt Text
D8795.id20894.diff (11 KB)

Event Timeline