Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / controller / HarbormasterPlanRunController.php
blob5d80d421aabaf4553814c82a031bab8ff0f5592f
1 <?php
3 final class HarbormasterPlanRunController extends HarbormasterPlanController {
5 public function handleRequest(AphrontRequest $request) {
6 $viewer = $this->getViewer();
7 $plan_id = $request->getURIData('id');
9 $plan = id(new HarbormasterBuildPlanQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($plan_id))
12 ->executeOne();
13 if (!$plan) {
14 return new Aphront404Response();
17 $plan->assertHasRunCapability($viewer);
19 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/");
21 if (!$plan->canRunManually()) {
22 return $this->newDialog()
23 ->setTitle(pht('Can Not Run Plan'))
24 ->appendParagraph(pht('This plan can not be run manually.'))
25 ->addCancelButton($cancel_uri);
28 $e_name = true;
29 $v_name = null;
31 $errors = array();
32 if ($request->isFormPost()) {
33 $buildable = HarbormasterBuildable::initializeNewBuildable($viewer)
34 ->setIsManualBuildable(true);
36 $v_name = $request->getStr('buildablePHID');
38 if ($v_name) {
39 $object = id(new PhabricatorObjectQuery())
40 ->setViewer($viewer)
41 ->withNames(array($v_name))
42 ->executeOne();
44 if ($object instanceof HarbormasterBuildableInterface) {
45 $buildable
46 ->setBuildablePHID($object->getHarbormasterBuildablePHID())
47 ->setContainerPHID($object->getHarbormasterContainerPHID());
48 } else {
49 $e_name = pht('Invalid');
50 $errors[] = pht('Enter the name of a revision or commit.');
52 } else {
53 $e_name = pht('Required');
54 $errors[] = pht('You must choose a revision or commit to build.');
57 if (!$errors) {
58 $buildable->save();
60 $buildable->sendMessage(
61 $viewer,
62 HarbormasterMessageType::BUILDABLE_BUILD,
63 false);
65 $buildable->applyPlan($plan, array(), $viewer->getPHID());
67 $buildable_uri = '/B'.$buildable->getID();
68 return id(new AphrontRedirectResponse())->setURI($buildable_uri);
72 if ($errors) {
73 $errors = id(new PHUIInfoView())->setErrors($errors);
76 $title = pht('Run Build Plan Manually');
77 $save_button = pht('Run Plan Manually');
79 $form = id(new PHUIFormLayoutView())
80 ->setUser($viewer)
81 ->appendRemarkupInstructions(
82 pht(
83 "Enter the name of a commit or revision to run this plan on (for ".
84 "example, `rX123456` or `D123`).\n\n".
85 "For more detailed output, you can also run manual builds from ".
86 "the command line:\n\n".
87 " phabricator/ $ ./bin/harbormaster build <object> --plan %s",
88 $plan->getID()))
89 ->appendChild(
90 id(new AphrontFormTextControl())
91 ->setLabel(pht('Buildable Name'))
92 ->setName('buildablePHID')
93 ->setError($e_name)
94 ->setValue($v_name));
96 return $this->newDialog()
97 ->setWidth(AphrontDialogView::WIDTH_FULL)
98 ->setTitle($title)
99 ->appendChild($form)
100 ->addCancelButton($cancel_uri)
101 ->addSubmitButton($save_button);