Page MenuHomePhabricator

D7544.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
@@ -700,6 +700,7 @@
'HarbormasterStepAddController' => 'applications/harbormaster/controller/HarbormasterStepAddController.php',
'HarbormasterStepDeleteController' => 'applications/harbormaster/controller/HarbormasterStepDeleteController.php',
'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php',
+ 'HarbormasterUIEventListener' => 'applications/harbormaster/event/HarbormasterUIEventListener.php',
'HeraldAction' => 'applications/herald/storage/HeraldAction.php',
'HeraldAdapter' => 'applications/herald/adapter/HeraldAdapter.php',
'HeraldApplyTranscript' => 'applications/herald/storage/transcript/HeraldApplyTranscript.php',
@@ -3002,6 +3003,7 @@
'HarbormasterStepAddController' => 'HarbormasterController',
'HarbormasterStepDeleteController' => 'HarbormasterController',
'HarbormasterStepEditController' => 'HarbormasterController',
+ 'HarbormasterUIEventListener' => 'PhabricatorEventListener',
'HeraldAction' => 'HeraldDAO',
'HeraldApplyTranscript' => 'HeraldDAO',
'HeraldCapabilityManageGlobalRules' => 'PhabricatorPolicyCapability',
diff --git a/src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php b/src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
--- a/src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
+++ b/src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
@@ -26,6 +26,12 @@
return self::GROUP_UTILITIES;
}
+ public function getEventListeners() {
+ return array(
+ new HarbormasterUIEventListener(),
+ );
+ }
+
public function isBeta() {
return true;
}
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
@@ -187,6 +187,21 @@
pht('Status'),
$this->getStatus($build));
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array(
+ $build->getBuildablePHID(),
+ $build->getBuildPlanPHID()))
+ ->execute();
+
+ $properties->addProperty(
+ pht('Buildable'),
+ $handles[$build->getBuildablePHID()]->renderLink());
+
+ $properties->addProperty(
+ pht('Build Plan'),
+ $handles[$build->getBuildPlanPHID()]->renderLink());
+
}
private function getStatus(HarbormasterBuild $build) {
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
@@ -28,7 +28,6 @@
$builds = id(new HarbormasterBuildQuery())
->setViewer($viewer)
->withBuildablePHIDs(array($buildable->getPHID()))
- ->needBuildPlans(true)
->execute();
$build_list = id(new PHUIObjectItemListView())
diff --git a/src/applications/harbormaster/event/HarbormasterUIEventListener.php b/src/applications/harbormaster/event/HarbormasterUIEventListener.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/event/HarbormasterUIEventListener.php
@@ -0,0 +1,106 @@
+<?php
+
+final class HarbormasterUIEventListener
+ extends PhabricatorEventListener {
+
+ public function register() {
+ $this->listen(PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES);
+ }
+
+ public function handleEvent(PhutilEvent $event) {
+ switch ($event->getType()) {
+ case PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES:
+ $this->handlePropertyEvent($event);
+ break;
+ }
+ }
+
+ private function handlePropertyEvent($ui_event) {
+ $user = $ui_event->getUser();
+ $object = $ui_event->getValue('object');
+
+ if (!$object || !$object->getPHID()) {
+ // No object, or the object has no PHID yet..
+ return;
+ }
+
+ $target = null;
+ if ($object instanceof PhabricatorRepositoryCommit) {
+ $target = $object;
+ } elseif ($object instanceof DifferentialRevision) {
+ $target = $object->loadActiveDiff();
+ } else {
+ return;
+ }
+
+ if (!$this->canUseApplication($ui_event->getUser())) {
+ return;
+ }
+
+ $buildables = id(new HarbormasterBuildableQuery())
+ ->setViewer($user)
+ ->withBuildablePHIDs(array($target->getPHID()))
+ ->execute();
+ if (!$buildables) {
+ return;
+ }
+
+ $builds = id(new HarbormasterBuildQuery())
+ ->setViewer($user)
+ ->withBuildablePHIDs(mpull($buildables, 'getPHID'))
+ ->execute();
+ if (!$builds) {
+ return;
+ }
+
+ $build_handles = id(new PhabricatorHandleQuery())
+ ->setViewer($user)
+ ->withPHIDs(mpull($builds, 'getPHID'))
+ ->execute();
+
+ $status_view = new PHUIStatusListView();
+
+ foreach ($builds as $build) {
+ $item = new PHUIStatusItemView();
+ $item->setTarget(
+ $build_handles[$build->getPHID()]->renderLink());
+
+ switch ($build->getBuildStatus()) {
+ case HarbormasterBuild::STATUS_INACTIVE:
+ $item->setIcon('open-dark', pht('Inactive'));
+ break;
+ case HarbormasterBuild::STATUS_PENDING:
+ $item->setIcon('open-blue', pht('Pending'));
+ break;
+ case HarbormasterBuild::STATUS_WAITING:
+ $item->setIcon('up-blue', pht('Waiting on Resource'));
+ break;
+ case HarbormasterBuild::STATUS_BUILDING:
+ $item->setIcon('right-blue', pht('Building'));
+ break;
+ case HarbormasterBuild::STATUS_PASSED:
+ $item->setIcon('accept-green', pht('Passed'));
+ break;
+ case HarbormasterBuild::STATUS_FAILED:
+ $item->setIcon('reject-red', pht('Failed'));
+ break;
+ case HarbormasterBuild::STATUS_ERROR:
+ $item->setIcon('minus-red', pht('Unexpected Error'));
+ break;
+ case HarbormasterBuild::STATUS_CANCELLED:
+ $item->setIcon('minus-dark', pht('Cancelled'));
+ break;
+ default:
+ $item->setIcon('question', pht('Unknown'));
+ break;
+ }
+
+
+ $status_view->addItem($item);
+ }
+
+ $view = $ui_event->getValue('view');
+ $view->addProperty(pht('Build Status'), $status_view);
+ }
+
+}
diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php
--- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php
+++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php
@@ -30,7 +30,13 @@
array $objects) {
foreach ($handles as $phid => $handle) {
- $build_plan = $objects[$phid];
+ $build = $objects[$phid];
+ $handles[$phid]->setName(pht(
+ 'Build %d: %s',
+ $build->getID(),
+ $build->getName()));
+ $handles[$phid]->setURI(
+ '/harbormaster/build/'.$build->getID());
}
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildQuery.php b/src/applications/harbormaster/query/HarbormasterBuildQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildQuery.php
@@ -9,8 +9,6 @@
private $buildablePHIDs;
private $buildPlanPHIDs;
- private $needBuildPlans;
-
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
@@ -36,11 +34,6 @@
return $this;
}
- public function needBuildPlans($need_plans) {
- $this->needBuildPlans = $need_plans;
- return $this;
- }
-
protected function loadPage() {
$table = new HarbormasterBuild();
$conn_r = $table->establishConnection('r');
@@ -82,23 +75,21 @@
}
protected function didFilterPage(array $page) {
- if ($this->needBuildPlans) {
- $plans = array();
-
- $plan_phids = array_filter(mpull($page, 'getBuildPlanPHID'));
- if ($plan_phids) {
- $plans = id(new PhabricatorObjectQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs($plan_phids)
- ->setParentQuery($this)
- ->execute();
- $plans = mpull($plans, null, 'getPHID');
- }
+ $plans = array();
- foreach ($page as $key => $build) {
- $plan_phid = $build->getBuildPlanPHID();
- $build->attachBuildPlan(idx($plans, $plan_phid));
- }
+ $plan_phids = array_filter(mpull($page, 'getBuildPlanPHID'));
+ if ($plan_phids) {
+ $plans = id(new PhabricatorObjectQuery())
+ ->setViewer($this->getViewer())
+ ->withPHIDs($plan_phids)
+ ->setParentQuery($this)
+ ->execute();
+ $plans = mpull($plans, null, 'getPHID');
+ }
+
+ foreach ($page as $key => $build) {
+ $plan_phid = $build->getBuildPlanPHID();
+ $build->attachBuildPlan(idx($plans, $plan_phid));
}
return $page;
diff --git a/src/applications/harbormaster/step/VariableBuildStepImplementation.php b/src/applications/harbormaster/step/VariableBuildStepImplementation.php
--- a/src/applications/harbormaster/step/VariableBuildStepImplementation.php
+++ b/src/applications/harbormaster/step/VariableBuildStepImplementation.php
@@ -16,9 +16,10 @@
$object = $buildable->getBuildableObject();
$repo = null;
- if ($object instanceof DifferentialRevision) {
- $results['buildable.revision'] = $object->getID();
- $repo = $object->getRepository();
+ if ($object instanceof DifferentialDiff) {
+ $revision = $object->getRevision();
+ $results['buildable.revision'] = $revision->getID();
+ $repo = $revision->getRepository();
} else if ($object instanceof PhabricatorRepositoryCommit) {
$results['buildable.commit'] = $object->getCommitIdentifier();
$repo = $object->getRepository();
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
@@ -65,7 +65,7 @@
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
- HarbormasterPHIDTypeBuildPlan::TYPECONST);
+ HarbormasterPHIDTypeBuild::TYPECONST);
}
public function attachBuildable(HarbormasterBuildable $buildable) {
diff --git a/src/applications/harbormaster/worker/HarbormasterBuildWorker.php b/src/applications/harbormaster/worker/HarbormasterBuildWorker.php
--- a/src/applications/harbormaster/worker/HarbormasterBuildWorker.php
+++ b/src/applications/harbormaster/worker/HarbormasterBuildWorker.php
@@ -18,7 +18,6 @@
->setViewer(PhabricatorUser::getOmnipotentUser())
->withBuildStatuses(array(HarbormasterBuild::STATUS_PENDING))
->withIDs(array($id))
- ->needBuildPlans(true)
->executeOne();
if (!$build) {
throw new PhabricatorWorkerPermanentFailureException(

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/li/j5/ey62y7i6sysgekqz
Default Alt Text
D7544.diff (11 KB)

Event Timeline