mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +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:
parent
a1499ceb8f
commit
a1431e53cc
8 changed files with 52 additions and 27 deletions
|
@ -149,9 +149,9 @@ final class PhabricatorWorkerTaskDetailController
|
|||
$worker = $task->getWorkerInstance();
|
||||
$data = $worker->renderForDisplay($viewer);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Data'),
|
||||
$data);
|
||||
if ($data !== null) {
|
||||
$view->addProperty(pht('Data'), $data);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,11 @@ final class HarbormasterBuildPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$build = $objects[$phid];
|
||||
$handles[$phid]->setName(pht(
|
||||
'Build %d: %s',
|
||||
$build->getID(),
|
||||
$build->getName()));
|
||||
$handles[$phid]->setURI(
|
||||
'/harbormaster/build/'.$build->getID());
|
||||
$build_id = $build->getID();
|
||||
$name = $build->getName();
|
||||
|
||||
$handle->setName(pht('Build %d: %s', $build_id, $name));
|
||||
$handle->setURI("/harbormaster/build/{$build_id}/");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,17 @@ final class HarbormasterBuildTargetPHIDType extends PhabricatorPHIDType {
|
|||
array $objects) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,31 @@
|
|||
*/
|
||||
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() {
|
||||
$viewer = $this->getViewer();
|
||||
$build = $this->loadBuild();
|
||||
|
||||
id(new HarbormasterBuildEngine())
|
||||
->setViewer($viewer)
|
||||
->setBuild($build)
|
||||
->continueBuild();
|
||||
}
|
||||
|
||||
private function loadBuild() {
|
||||
$data = $this->getTaskData();
|
||||
$id = idx($data, 'buildID');
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$build = id(new HarbormasterBuildQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
|
@ -19,10 +39,7 @@ final class HarbormasterBuildWorker extends HarbormasterWorker {
|
|||
pht('Invalid build ID "%s".', $id));
|
||||
}
|
||||
|
||||
id(new HarbormasterBuildEngine())
|
||||
->setViewer($viewer)
|
||||
->setBuild($build)
|
||||
->continueBuild();
|
||||
return $build;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,16 @@ final class HarbormasterTargetWorker extends HarbormasterWorker {
|
|||
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() {
|
||||
$data = $this->getTaskData();
|
||||
$id = idx($data, 'targetID');
|
||||
|
|
|
@ -130,11 +130,6 @@ final class PhabricatorRepositoryPushMailWorker
|
|||
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) {
|
||||
$ref_lines = array();
|
||||
$ref_list = array();
|
||||
|
|
|
@ -210,8 +210,7 @@ abstract class PhabricatorWorker extends Phobject {
|
|||
}
|
||||
|
||||
public function renderForDisplay(PhabricatorUser $viewer) {
|
||||
$data = PhutilReadableSerializer::printableValue($this->data);
|
||||
return phutil_tag('pre', array(), $data);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,9 +3,4 @@
|
|||
abstract class PhabricatorSMSWorker
|
||||
extends PhabricatorWorker {
|
||||
|
||||
public function renderForDisplay(PhabricatorUser $viewer) {
|
||||
// This data has some sensitive stuff, so don't show it.
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue