Differential D20220 Diff 48333 src/applications/harbormaster/controller/HarbormasterPlanViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterPlanViewController.php
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| if ($error) { | if ($error) { | ||||
| $error = id(new PHUIInfoView()) | $error = id(new PHUIInfoView()) | ||||
| ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ||||
| ->appendChild($error); | ->appendChild($error); | ||||
| } | } | ||||
| $builds_view = $this->newBuildsView($plan); | $builds_view = $this->newBuildsView($plan); | ||||
| $options_view = $this->newOptionsView($plan); | |||||
| $timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
| $plan, | $plan, | ||||
| new HarbormasterBuildPlanTransactionQuery()); | new HarbormasterBuildPlanTransactionQuery()); | ||||
| $timeline->setShouldTerminate(true); | $timeline->setShouldTerminate(true); | ||||
| $view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->setCurtain($curtain) | ->setCurtain($curtain) | ||||
| ->setMainColumn( | ->setMainColumn( | ||||
| array( | array( | ||||
| $error, | $error, | ||||
| $step_list, | $step_list, | ||||
| $options_view, | |||||
| $builds_view, | $builds_view, | ||||
| $timeline, | $timeline, | ||||
| )); | )); | ||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->setPageObjectPHIDs(array($plan->getPHID())) | ->setPageObjectPHIDs(array($plan->getPHID())) | ||||
| ▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | $header = id(new PHUIHeaderView()) | ||||
| ->addActionLink($more_link); | ->addActionLink($more_link); | ||||
| return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
| ->appendChild($list); | ->appendChild($list); | ||||
| } | } | ||||
| private function newOptionsView(HarbormasterBuildPlan $plan) { | |||||
| $viewer = $this->getViewer(); | |||||
| $can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
| $viewer, | |||||
| $plan, | |||||
| PhabricatorPolicyCapability::CAN_EDIT); | |||||
| $behaviors = HarbormasterBuildPlanBehavior::newPlanBehaviors(); | |||||
| $rows = array(); | |||||
| foreach ($behaviors as $behavior) { | |||||
| $option = $behavior->getPlanOption($plan); | |||||
| $icon = $option->getIcon(); | |||||
| $icon = id(new PHUIIconView())->setIcon($icon); | |||||
| $edit_uri = new PhutilURI( | |||||
| $this->getApplicationURI( | |||||
| urisprintf( | |||||
| 'plan/behavior/%d/%s/', | |||||
| $plan->getID(), | |||||
| $behavior->getKey()))); | |||||
| $edit_button = id(new PHUIButtonView()) | |||||
| ->setTag('a') | |||||
| ->setColor(PHUIButtonView::GREY) | |||||
| ->setSize(PHUIButtonView::SMALL) | |||||
| ->setDisabled(!$can_edit) | |||||
| ->setWorkflow(true) | |||||
| ->setText(pht('Edit')) | |||||
| ->setHref($edit_uri); | |||||
| $rows[] = array( | |||||
| $icon, | |||||
| $behavior->getName(), | |||||
| $option->getName(), | |||||
| $option->getDescription(), | |||||
| $edit_button, | |||||
| ); | |||||
| } | |||||
| $table = id(new AphrontTableView($rows)) | |||||
| ->setHeaders( | |||||
| array( | |||||
| null, | |||||
| pht('Name'), | |||||
| pht('Behavior'), | |||||
| pht('Details'), | |||||
| null, | |||||
| )) | |||||
| ->setColumnClasses( | |||||
| array( | |||||
| null, | |||||
| 'pri', | |||||
| null, | |||||
| 'wide', | |||||
| null, | |||||
| )); | |||||
| $header = id(new PHUIHeaderView()) | |||||
| ->setHeader(pht('Plan Behaviors')); | |||||
| return id(new PHUIObjectBoxView()) | |||||
| ->setHeader($header) | |||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
| ->setTable($table); | |||||
| } | |||||
| } | } | ||||