1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-27 23:18:20 +01:00
phorge-phorge/src/applications/harbormaster/step/HarbormasterSleepBuildStepImplementation.php
epriestley 8860f4724f Lump Harbormaster build steps into groups
Summary:
Ref T8089. We have a lot of broken/confusing/prototype build steps that I want to hide from users when we unprototype Harbormaster.

The dialog is also just kind of unwieldy.

Organize this UI a little better and put all the sketchy junk in a "prototypes" group that you can't see unless prototypes are enabled.

This doesn't break anything (the old steps will still work fine), but should reduce user confusion.

Test Plan:
Old UI:

{F691439}

New UI (prototypes off):

{F691440}

New UI (prototypes on):

{F691441}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8089

Differential Revision: https://secure.phabricator.com/D13803
2015-08-06 04:19:42 -07:00

64 lines
1.4 KiB
PHP

<?php
final class HarbormasterSleepBuildStepImplementation
extends HarbormasterBuildStepImplementation {
public function getName() {
return pht('Sleep');
}
public function getGenericDescription() {
return pht('Sleep for a specified number of seconds.');
}
public function getBuildStepGroupKey() {
return HarbormasterTestBuildStepGroup::GROUPKEY;
}
public function getDescription() {
return pht(
'Sleep for %s seconds.',
$this->formatSettingForDescription('seconds'));
}
public function execute(
HarbormasterBuild $build,
HarbormasterBuildTarget $build_target) {
$settings = $this->getSettings();
$target = time() + $settings['seconds'];
// Use $build_update so that we only reload every 5 seconds, but
// the sleep mechanism remains accurate.
$build_update = 5;
while (time() < $target) {
sleep(1);
if ($build_update <= 0) {
$build->reload();
$build_update = 5;
if ($this->shouldAbort($build, $build_target)) {
throw new HarbormasterBuildAbortedException();
}
} else {
$build_update -= 1;
}
}
}
public function getFieldSpecifications() {
return array(
'seconds' => array(
'name' => pht('Seconds'),
'type' => 'int',
'required' => true,
'caption' => pht('The number of seconds to sleep for.'),
),
);
}
}