1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Link to Harbormaster build targets from the Daemon worker page

Summary:
Fixes T7370. Two changes:

  - Make the default to show nothing, instead of showing all the data. This is a better default because the data is sometimes sensitive. Workers should have to opt in to revealing it.
  - For TargetWorkers, link to the target (technically the build, for now, since there's no dedicated target detail page).

Test Plan: {F698325}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7370

Differential Revision: https://secure.phabricator.com/D13845
This commit is contained in:
epriestley 2015-08-10 14:15:19 -07:00
parent a1499ceb8f
commit a1431e53cc
8 changed files with 52 additions and 27 deletions

View file

@ -149,9 +149,9 @@ final class PhabricatorWorkerTaskDetailController
$worker = $task->getWorkerInstance(); $worker = $task->getWorkerInstance();
$data = $worker->renderForDisplay($viewer); $data = $worker->renderForDisplay($viewer);
$view->addProperty( if ($data !== null) {
pht('Data'), $view->addProperty(pht('Data'), $data);
$data); }
return $view; return $view;
} }

View file

@ -27,12 +27,11 @@ final class HarbormasterBuildPHIDType extends PhabricatorPHIDType {
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$build = $objects[$phid]; $build = $objects[$phid];
$handles[$phid]->setName(pht( $build_id = $build->getID();
'Build %d: %s', $name = $build->getName();
$build->getID(),
$build->getName())); $handle->setName(pht('Build %d: %s', $build_id, $name));
$handles[$phid]->setURI( $handle->setURI("/harbormaster/build/{$build_id}/");
'/harbormaster/build/'.$build->getID());
} }
} }

View file

@ -26,7 +26,17 @@ final class HarbormasterBuildTargetPHIDType extends PhabricatorPHIDType {
array $objects) { array $objects) {
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$build_target = $objects[$phid]; $target = $objects[$phid];
$target_id = $target->getID();
// Build target don't currently have their own page, so just point
// the user at the build until we have one.
$build = $target->getBuild();
$build_id = $build->getID();
$uri = "/harbormaster/build/{$build_id}/";
$handle->setName(pht('Build Target %d', $target_id));
$handle->setURI($uri);
} }
} }

View file

@ -5,11 +5,31 @@
*/ */
final class HarbormasterBuildWorker extends HarbormasterWorker { final class HarbormasterBuildWorker extends HarbormasterWorker {
public function renderForDisplay(PhabricatorUser $viewer) {
try {
$build = $this->loadBuild();
} catch (Exception $ex) {
return null;
}
return $viewer->renderHandle($build->getPHID());
}
protected function doWork() { protected function doWork() {
$viewer = $this->getViewer();
$build = $this->loadBuild();
id(new HarbormasterBuildEngine())
->setViewer($viewer)
->setBuild($build)
->continueBuild();
}
private function loadBuild() {
$data = $this->getTaskData(); $data = $this->getTaskData();
$id = idx($data, 'buildID'); $id = idx($data, 'buildID');
$viewer = $this->getViewer();
$viewer = $this->getViewer();
$build = id(new HarbormasterBuildQuery()) $build = id(new HarbormasterBuildQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($id)) ->withIDs(array($id))
@ -19,10 +39,7 @@ final class HarbormasterBuildWorker extends HarbormasterWorker {
pht('Invalid build ID "%s".', $id)); pht('Invalid build ID "%s".', $id));
} }
id(new HarbormasterBuildEngine()) return $build;
->setViewer($viewer)
->setBuild($build)
->continueBuild();
} }
} }

View file

@ -11,6 +11,16 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
return phutil_units('24 hours in seconds'); return phutil_units('24 hours in seconds');
} }
public function renderForDisplay(PhabricatorUser $viewer) {
try {
$target = $this->loadBuildTarget();
} catch (Exception $ex) {
return null;
}
return $viewer->renderHandle($target->getPHID());
}
private function loadBuildTarget() { private function loadBuildTarget() {
$data = $this->getTaskData(); $data = $this->getTaskData();
$id = idx($data, 'targetID'); $id = idx($data, 'targetID');

View file

@ -130,11 +130,6 @@ final class PhabricatorRepositoryPushMailWorker
return $target->willSendMail($mail); return $target->willSendMail($mail);
} }
public function renderForDisplay(PhabricatorUser $viewer) {
// This data has some sensitive stuff, so don't show it.
return null;
}
private function renderRefs(array $logs) { private function renderRefs(array $logs) {
$ref_lines = array(); $ref_lines = array();
$ref_list = array(); $ref_list = array();

View file

@ -210,8 +210,7 @@ abstract class PhabricatorWorker extends Phobject {
} }
public function renderForDisplay(PhabricatorUser $viewer) { public function renderForDisplay(PhabricatorUser $viewer) {
$data = PhutilReadableSerializer::printableValue($this->data); return null;
return phutil_tag('pre', array(), $data);
} }
/** /**

View file

@ -3,9 +3,4 @@
abstract class PhabricatorSMSWorker abstract class PhabricatorSMSWorker
extends PhabricatorWorker { extends PhabricatorWorker {
public function renderForDisplay(PhabricatorUser $viewer) {
// This data has some sensitive stuff, so don't show it.
return null;
}
} }