Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15448823
D7544.id17035.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D7544.id17035.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ 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',
Index: src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
===================================================================
--- src/applications/harbormaster/application/PhabricatorApplicationHarbormaster.php
+++ 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;
}
Index: src/applications/harbormaster/controller/HarbormasterBuildViewController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterBuildViewController.php
+++ 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) {
Index: src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
+++ 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())
Index: src/applications/harbormaster/event/HarbormasterUIEventListener.php
===================================================================
--- /dev/null
+++ 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);
+ }
+
+}
Index: src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php
===================================================================
--- src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php
+++ 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());
}
}
Index: src/applications/harbormaster/query/HarbormasterBuildQuery.php
===================================================================
--- src/applications/harbormaster/query/HarbormasterBuildQuery.php
+++ 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;
Index: src/applications/harbormaster/step/VariableBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/VariableBuildStepImplementation.php
+++ 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();
Index: src/applications/harbormaster/storage/build/HarbormasterBuild.php
===================================================================
--- src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ 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) {
Index: src/applications/harbormaster/worker/HarbormasterBuildWorker.php
===================================================================
--- src/applications/harbormaster/worker/HarbormasterBuildWorker.php
+++ 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
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 29, 7:04 AM (2 w, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7693914
Default Alt Text
D7544.id17035.diff (11 KB)
Attached To
Mode
D7544: Render build status on revisions and commits
Attached
Detach File
Event Timeline
Log In to Comment