Differential D9637 Diff 23125 src/applications/chronicle/controller/ChronicleTriggerAddController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/chronicle/controller/ChronicleTriggerAddController.php
- This file was added.
<?php | |||||
final class ChronicleTriggerAddController | |||||
extends ChronicleTriggerController { | |||||
public function processRequest() { | |||||
$request = $this->getRequest(); | |||||
$viewer = $request->getUser(); | |||||
$cancel_uri = $this->getApplicationURI('/'); | |||||
$errors = array(); | |||||
if ($request->isFormPost()) { | |||||
$class = $request->getStr('class'); | |||||
if (!ChronicleAction::getImplementation($class)) { | |||||
$errors[] = pht( | |||||
'Choose the type of build step you want to add.'); | |||||
} | |||||
if (!$errors) { | |||||
$new_uri = $this->getApplicationURI("trigger/new/{$class}/"); | |||||
return id(new AphrontRedirectResponse())->setURI($new_uri); | |||||
} | |||||
} | |||||
$control = id(new AphrontFormRadioButtonControl()) | |||||
->setName('class'); | |||||
$all = ChronicleAction::getImplementations(); | |||||
foreach ($all as $class => $implementation) { | |||||
$allowed = !$implementation->canCreateOrEdit($viewer); | |||||
$control->addButton( | |||||
$class, | |||||
$implementation->getName(), | |||||
$implementation->getDescription(), | |||||
null, | |||||
$allowed); | |||||
} | |||||
if ($errors) { | |||||
$errors = id(new AphrontErrorView()) | |||||
->setErrors($errors); | |||||
} | |||||
return $this->newDialog() | |||||
->setTitle(pht('Create New Trigger')) | |||||
->addSubmitButton(pht('Create New Trigger')) | |||||
->addCancelButton($cancel_uri) | |||||
->appendChild($errors) | |||||
->appendParagraph(pht('Choose a type of build step to add:')) | |||||
->appendChild($control); | |||||
} | |||||
} |