private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction) { $command = $xaction->getNewValue(); switch ($command) { case HarbormasterBuildCommand::COMMAND_RESTART: $issuable = $build->canRestartBuild(); break; case HarbormasterBuildCommand::COMMAND_PAUSE: $issuable = $build->canPauseBuild(); break; case HarbormasterBuildCommand::COMMAND_RESUME: $issuable = $build->canResumeBuild(); break; case HarbormasterBuildCommand::COMMAND_ABORT: $issuable = $build->canAbortBuild(); break; default: throw new Exception(pht('Unknown command %s', $command)); } if (!$issuable) { return; } $actor = $this->getActor(); if (!$build->canIssueCommand($actor, $command)) { return; } id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save(); PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID()), array('objectPHID' => $build->getPHID())); }
private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction) { $command = $xaction->getNewValue(); switch ($command) { case HarbormasterBuildCommand::COMMAND_RESTART: $issuable = $build->canRestartBuild(); break; case HarbormasterBuildCommand::COMMAND_STOP: $issuable = $build->canStopBuild(); break; case HarbormasterBuildCommand::COMMAND_RESUME: $issuable = $build->canResumeBuild(); break; default: throw new Exception("Unknown command {$command}"); } if (!$issuable) { return; } id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save(); PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID())); }
private function buildActionList(HarbormasterBuild $build) { $request = $this->getRequest(); $viewer = $request->getUser(); $id = $build->getID(); $list = id(new PhabricatorActionListView())->setUser($viewer)->setObject($build)->setObjectURI("/build/{$id}"); $can_restart = $build->canRestartBuild(); $can_stop = $build->canStopBuild(); $can_resume = $build->canResumeBuild(); $list->addAction(id(new PhabricatorActionView())->setName(pht('Restart Build'))->setIcon('fa-repeat')->setHref($this->getApplicationURI('/build/restart/' . $id . '/'))->setDisabled(!$can_restart)->setWorkflow(true)); if ($build->canResumeBuild()) { $list->addAction(id(new PhabricatorActionView())->setName(pht('Resume Build'))->setIcon('fa-play')->setHref($this->getApplicationURI('/build/resume/' . $id . '/'))->setDisabled(!$can_resume)->setWorkflow(true)); } else { $list->addAction(id(new PhabricatorActionView())->setName(pht('Pause Build'))->setIcon('fa-pause')->setHref($this->getApplicationURI('/build/stop/' . $id . '/'))->setDisabled(!$can_stop)->setWorkflow(true)); } return $list; }
private function buildActionList(HarbormasterBuild $build) { $request = $this->getRequest(); $viewer = $request->getUser(); $id = $build->getID(); $list = id(new PhabricatorActionListView())->setUser($viewer)->setObject($build); $can_restart = $build->canRestartBuild() && $build->canIssueCommand($viewer, HarbormasterBuildCommand::COMMAND_RESTART); $can_pause = $build->canPauseBuild() && $build->canIssueCommand($viewer, HarbormasterBuildCommand::COMMAND_PAUSE); $can_resume = $build->canResumeBuild() && $build->canIssueCommand($viewer, HarbormasterBuildCommand::COMMAND_RESUME); $can_abort = $build->canAbortBuild() && $build->canIssueCommand($viewer, HarbormasterBuildCommand::COMMAND_ABORT); $list->addAction(id(new PhabricatorActionView())->setName(pht('Restart Build'))->setIcon('fa-repeat')->setHref($this->getApplicationURI('/build/restart/' . $id . '/'))->setDisabled(!$can_restart)->setWorkflow(true)); if ($build->canResumeBuild()) { $list->addAction(id(new PhabricatorActionView())->setName(pht('Resume Build'))->setIcon('fa-play')->setHref($this->getApplicationURI('/build/resume/' . $id . '/'))->setDisabled(!$can_resume)->setWorkflow(true)); } else { $list->addAction(id(new PhabricatorActionView())->setName(pht('Pause Build'))->setIcon('fa-pause')->setHref($this->getApplicationURI('/build/pause/' . $id . '/'))->setDisabled(!$can_pause)->setWorkflow(true)); } $list->addAction(id(new PhabricatorActionView())->setName(pht('Abort Build'))->setIcon('fa-exclamation-triangle')->setHref($this->getApplicationURI('/build/abort/' . $id . '/'))->setDisabled(!$can_abort)->setWorkflow(true)); return $list; }