3 final class HarbormasterStepAddController
4 extends HarbormasterPlanController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
9 $plan = id(new HarbormasterBuildPlanQuery())
11 ->withIDs(array($request->getURIData('id')))
12 ->requireCapabilities(
14 PhabricatorPolicyCapability
::CAN_VIEW
,
15 PhabricatorPolicyCapability
::CAN_EDIT
,
19 return new Aphront404Response();
22 $plan_id = $plan->getID();
23 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/");
24 $plan_title = pht('Plan %d', $plan_id);
26 $all = HarbormasterBuildStepImplementation
::getImplementations();
27 $all = msort($all, 'getName');
29 $all_groups = HarbormasterBuildStepGroup
::getAllGroups();
30 foreach ($all as $impl) {
31 $group_key = $impl->getBuildStepGroupKey();
32 if (empty($all_groups[$group_key])) {
35 'Build step "%s" has step group key "%s", but no step group '.
36 'with that key exists.',
42 $groups = mgroup($all, 'getBuildStepGroupKey');
45 $enabled_groups = HarbormasterBuildStepGroup
::getAllEnabledGroups();
46 foreach ($enabled_groups as $group) {
47 $list = id(new PHUIObjectItemListView())
49 pht('This group has no available build steps.'));
51 $steps = idx($groups, $group->getGroupKey(), array());
53 foreach ($steps as $key => $impl) {
54 if ($impl->shouldRequireAutotargeting()) {
60 if (!$steps && !$group->shouldShowIfEmpty()) {
64 foreach ($steps as $key => $impl) {
65 $class = get_class($impl);
67 $new_uri = $this->getApplicationURI("step/new/{$plan_id}/{$class}/");
69 $item = id(new PHUIObjectItemView())
70 ->setHeader($impl->getName())
72 ->addAttribute($impl->getGenericDescription());
74 $list->addItem($item);
77 $box = id(new PHUIObjectBoxView())
78 ->setHeaderText($group->getGroupName())
79 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
85 $crumbs = $this->buildApplicationCrumbs()
86 ->addTextCrumb($plan_title, $cancel_uri)
87 ->addTextCrumb(pht('Add Build Step'))
90 $title = array($plan_title, pht('Add Build Step'));
92 $header = id(new PHUIHeaderView())
93 ->setHeader(pht('Add Build Step'))
94 ->setHeaderIcon('fa-plus-square');
96 $view = id(new PHUITwoColumnView())
102 return $this->newPage()
105 ->appendChild($view);