Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/view/DrydockObjectAuthorizationView.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ($blueprint_phids) { | ||||
->withBlueprintPHIDs($blueprint_phids) | ->withBlueprintPHIDs($blueprint_phids) | ||||
->execute(); | ->execute(); | ||||
$authorizations = mpull($authorizations, null, 'getBlueprintPHID'); | $authorizations = mpull($authorizations, null, 'getBlueprintPHID'); | ||||
} else { | } else { | ||||
$handles = array(); | $handles = array(); | ||||
$authorizations = array(); | $authorizations = array(); | ||||
} | } | ||||
$warnings = array(); | |||||
$items = array(); | $items = array(); | ||||
foreach ($blueprint_phids as $phid) { | foreach ($blueprint_phids as $phid) { | ||||
$authorization = idx($authorizations, $phid); | $authorization = idx($authorizations, $phid); | ||||
if (!$authorization) { | if (!$authorization) { | ||||
continue; | continue; | ||||
} | } | ||||
$handle = $handles[$phid]; | $handle = $handles[$phid]; | ||||
$item = id(new PHUIStatusItemView()) | $item = id(new PHUIStatusItemView()) | ||||
->setTarget($handle->renderLink()); | ->setTarget($handle->renderLink()); | ||||
$state = $authorization->getBlueprintAuthorizationState(); | $state = $authorization->getBlueprintAuthorizationState(); | ||||
$item->setIcon( | $item->setIcon( | ||||
DrydockAuthorization::getBlueprintStateIcon($state), | DrydockAuthorization::getBlueprintStateIcon($state), | ||||
null, | null, | ||||
DrydockAuthorization::getBlueprintStateName($state)); | DrydockAuthorization::getBlueprintStateName($state)); | ||||
switch ($state) { | |||||
case DrydockAuthorization::BLUEPRINTAUTH_REQUESTED: | |||||
case DrydockAuthorization::BLUEPRINTAUTH_DECLINED: | |||||
$warnings[] = $authorization; | |||||
break; | |||||
} | |||||
$items[] = $item; | $items[] = $item; | ||||
} | } | ||||
$status = new PHUIStatusListView(); | $status = new PHUIStatusListView(); | ||||
if ($warnings) { | |||||
$status->addItem( | |||||
id(new PHUIStatusItemView()) | |||||
->setIcon('fa-exclamation-triangle', 'pink') | |||||
->setTarget( | |||||
pht( | |||||
'WARNING: There are %s unapproved authorization(s)!', | |||||
new PhutilNumber(count($warnings))))); | |||||
} | |||||
foreach ($items as $item) { | foreach ($items as $item) { | ||||
$status->addItem($item); | $status->addItem($item); | ||||
} | } | ||||
return $status; | return $status; | ||||
} | } | ||||
} | } |