private function buildPropertyListView(DrydockAuthorization $authorization)
 {
     $viewer = $this->getViewer();
     $object_phid = $authorization->getObjectPHID();
     $handles = $viewer->loadHandles(array($object_phid));
     $handle = $handles[$object_phid];
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Authorized Object'), $handle->renderLink($handle->getFullName()));
     $view->addProperty(pht('Object Type'), $handle->getTypeName());
     $object_state = $authorization->getObjectAuthorizationState();
     $view->addProperty(pht('Authorization State'), DrydockAuthorization::getObjectStateName($object_state));
     return $view;
 }
 public function render()
 {
     $viewer = $this->getUser();
     $blueprint_phids = $this->getBlueprintPHIDs();
     $object_phid = $this->getObjectPHID();
     // NOTE: We're intentionally letting you see the authorization state on
     // blueprints you can't see because this has a tremendous potential to
     // be extremely confusing otherwise. You still can't see the blueprints
     // themselves, but you can know if the object is authorized on something.
     if ($blueprint_phids) {
         $handles = $viewer->loadHandles($blueprint_phids);
         $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($blueprint_phids)->execute();
         $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     } else {
         $handles = array();
         $authorizations = array();
     }
     $items = array();
     foreach ($blueprint_phids as $phid) {
         $authorization = idx($authorizations, $phid);
         if (!$authorization) {
             continue;
         }
         $handle = $handles[$phid];
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         $state = $authorization->getBlueprintAuthorizationState();
         $item->setIcon(DrydockAuthorization::getBlueprintStateIcon($state), null, DrydockAuthorization::getBlueprintStateName($state));
         $items[] = $item;
     }
     $status = new PHUIStatusListView();
     foreach ($items as $item) {
         $status->addItem($item);
     }
     return $status;
 }
 public function render()
 {
     $viewer = $this->getUser();
     $authorizations = $this->authorizations;
     $view = new PHUIObjectItemListView();
     $nodata = $this->getNoDataString();
     if ($nodata) {
         $view->setNoDataString($nodata);
     }
     $handles = $viewer->loadHandles(mpull($authorizations, 'getObjectPHID'));
     foreach ($authorizations as $authorization) {
         $id = $authorization->getID();
         $object_phid = $authorization->getObjectPHID();
         $handle = $handles[$object_phid];
         $item = id(new PHUIObjectItemView())->setHref("/drydock/authorization/{$id}/")->setObjectName(pht('Authorization %d', $id))->setHeader($handle->getFullName());
         $item->addAttribute($handle->getTypeName());
         $object_state = $authorization->getObjectAuthorizationState();
         $item->addAttribute(DrydockAuthorization::getObjectStateName($object_state));
         $state = $authorization->getBlueprintAuthorizationState();
         $icon = DrydockAuthorization::getBlueprintStateIcon($state);
         $name = DrydockAuthorization::getBlueprintStateName($state);
         $item->setStatusIcon($icon, $name);
         $view->addItem($item);
     }
     return $view;
 }
 public function render()
 {
     $viewer = $this->getUser();
     $blueprint_phids = $this->getBlueprintPHIDs();
     $object_phid = $this->getObjectPHID();
     // NOTE: We're intentionally letting you see the authorization state on
     // blueprints you can't see because this has a tremendous potential to
     // be extremely confusing otherwise. You still can't see the blueprints
     // themselves, but you can know if the object is authorized on something.
     if ($blueprint_phids) {
         $handles = $viewer->loadHandles($blueprint_phids);
         $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($blueprint_phids)->execute();
         $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     } else {
         $handles = array();
         $authorizations = array();
     }
     $warnings = array();
     $items = array();
     foreach ($blueprint_phids as $phid) {
         $authorization = idx($authorizations, $phid);
         if (!$authorization) {
             continue;
         }
         $handle = $handles[$phid];
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         $state = $authorization->getBlueprintAuthorizationState();
         $item->setIcon(DrydockAuthorization::getBlueprintStateIcon($state), null, DrydockAuthorization::getBlueprintStateName($state));
         switch ($state) {
             case DrydockAuthorization::BLUEPRINTAUTH_REQUESTED:
             case DrydockAuthorization::BLUEPRINTAUTH_DECLINED:
                 $warnings[] = $authorization;
                 break;
         }
         $items[] = $item;
     }
     $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) {
         $status->addItem($item);
     }
     return $status;
 }
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhabricatorRepositoryTransaction::TYPE_CREDENTIAL:
             // Adjust the object <-> credential edge for this repository.
             $old_phid = $xaction->getOldValue();
             $new_phid = $xaction->getNewValue();
             $editor = new PhabricatorEdgeEditor();
             $edge_type = PhabricatorObjectUsesCredentialsEdgeType::EDGECONST;
             $src_phid = $object->getPHID();
             if ($old_phid) {
                 $editor->removeEdge($src_phid, $edge_type, $old_phid);
             }
             if ($new_phid) {
                 $editor->addEdge($src_phid, $edge_type, $new_phid);
             }
             $editor->save();
             break;
         case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS:
             DrydockAuthorization::applyAuthorizationChanges($this->getActor(), $object->getPHID(), $xaction->getOldValue(), $xaction->getNewValue());
             break;
     }
 }
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS:
             DrydockAuthorization::applyAuthorizationChanges($this->getActor(), $object->getPHID(), $xaction->getOldValue(), $xaction->getNewValue());
             break;
     }
 }
 public function applyApplicationTransactionExternalEffects(PhabricatorApplicationTransaction $xaction)
 {
     $old = $this->decodeValue($xaction->getOldValue());
     $new = $this->decodeValue($xaction->getNewValue());
     DrydockAuthorization::applyAuthorizationChanges($this->getViewer(), $xaction->getObjectPHID(), $old, $new);
 }