Differential D14321 Diff 34619 src/applications/harbormaster/controller/HarbormasterPlanViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterPlanViewController.php
<?php | <?php | ||||
final class HarbormasterPlanViewController extends HarbormasterPlanController { | final class HarbormasterPlanViewController extends HarbormasterPlanController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getviewer(); | $viewer = $this->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
$plan = id(new HarbormasterBuildPlanQuery()) | $plan = id(new HarbormasterBuildPlanQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$plan) { | if (!$plan) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | private function buildStepList(HarbormasterBuildPlan $plan) { | ||||
$run_order = HarbormasterBuildGraph::determineDependencyExecution($plan); | $run_order = HarbormasterBuildGraph::determineDependencyExecution($plan); | ||||
$steps = id(new HarbormasterBuildStepQuery()) | $steps = id(new HarbormasterBuildStepQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withBuildPlanPHIDs(array($plan->getPHID())) | ->withBuildPlanPHIDs(array($plan->getPHID())) | ||||
->execute(); | ->execute(); | ||||
$steps = mpull($steps, null, 'getPHID'); | $steps = mpull($steps, null, 'getPHID'); | ||||
$has_manage = $this->hasApplicationCapability( | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
HarbormasterManagePlansCapability::CAPABILITY); | |||||
$has_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | $viewer, | ||||
$plan, | $plan, | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$can_edit = ($has_manage && $has_edit); | |||||
$step_list = id(new PHUIObjectItemListView()) | $step_list = id(new PHUIObjectItemListView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setNoDataString( | ->setNoDataString( | ||||
pht('This build plan does not have any build steps yet.')); | pht('This build plan does not have any build steps yet.')); | ||||
$i = 1; | $i = 1; | ||||
$last_depth = 0; | $last_depth = 0; | ||||
$has_any_conflicts = false; | $has_any_conflicts = false; | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | private function buildActionList(HarbormasterBuildPlan $plan) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$id = $plan->getID(); | $id = $plan->getID(); | ||||
$list = id(new PhabricatorActionListView()) | $list = id(new PhabricatorActionListView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setObject($plan) | ->setObject($plan) | ||||
->setObjectURI($this->getApplicationURI("plan/{$id}/")); | ->setObjectURI($this->getApplicationURI("plan/{$id}/")); | ||||
$has_manage = $this->hasApplicationCapability( | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
HarbormasterManagePlansCapability::CAPABILITY); | |||||
$has_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | $viewer, | ||||
$plan, | $plan, | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$can_edit = ($has_manage && $has_edit); | |||||
$list->addAction( | $list->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Edit Plan')) | ->setName(pht('Edit Plan')) | ||||
->setHref($this->getApplicationURI("plan/edit/{$id}/")) | ->setHref($this->getApplicationURI("plan/edit/{$id}/")) | ||||
->setWorkflow(!$can_edit) | ->setWorkflow(!$can_edit) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setIcon('fa-pencil')); | ->setIcon('fa-pencil')); | ||||
Show All 10 Lines | if ($plan->isDisabled()) { | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Disable Plan')) | ->setName(pht('Disable Plan')) | ||||
->setHref($this->getApplicationURI("plan/disable/{$id}/")) | ->setHref($this->getApplicationURI("plan/disable/{$id}/")) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setIcon('fa-ban')); | ->setIcon('fa-ban')); | ||||
} | } | ||||
$can_run = ($has_manage && $plan->canRunManually()); | $can_run = ($can_edit && $plan->canRunManually()); | ||||
$list->addAction( | $list->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Run Plan Manually')) | ->setName(pht('Run Plan Manually')) | ||||
->setHref($this->getApplicationURI("plan/run/{$id}/")) | ->setHref($this->getApplicationURI("plan/run/{$id}/")) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setDisabled(!$can_run) | ->setDisabled(!$can_run) | ||||
->setIcon('fa-play-circle')); | ->setIcon('fa-play-circle')); | ||||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |