Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
3.3 kB · 124 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125<?php
final class PhabricatorAuthSSHKeyViewController extends PhabricatorAuthSSHKeyController {
public function shouldAllowPublic() { return true; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer();
$id = $request->getURIData('id');
$ssh_key = id(new PhabricatorAuthSSHKeyQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$ssh_key) { return new Aphront404Response(); }
$this->setSSHKeyObject($ssh_key->getObject());
$title = pht('SSH Key %d', $ssh_key->getID());
$curtain = $this->buildCurtain($ssh_key); $details = $this->buildPropertySection($ssh_key);
$header = id(new PHUIHeaderView()) ->setUser($viewer) ->setHeader($ssh_key->getName()) ->setHeaderIcon('fa-key');
if ($ssh_key->getIsActive()) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'dark', pht('Revoked')); }
$header->addActionLink( id(new PHUIButtonView()) ->setTag('a') ->setText(pht('View Active Keys')) ->setHref($ssh_key->getObject()->getSSHPublicKeyManagementURI($viewer)) ->setIcon('fa-list-ul'));
$crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true);
$timeline = $this->buildTransactionTimeline( $ssh_key, new PhabricatorAuthSSHKeyTransactionQuery()); $timeline->setShouldTerminate(true);
$view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->setMainColumn( array( $details, $timeline, ));
return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); }
private function buildCurtain(PhabricatorAuthSSHKey $ssh_key) { $viewer = $this->getViewer();
$can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $ssh_key, PhabricatorPolicyCapability::CAN_EDIT);
$id = $ssh_key->getID();
$edit_uri = $this->getApplicationURI("sshkey/edit/{$id}/"); $revoke_uri = $this->getApplicationURI("sshkey/revoke/{$id}/");
$curtain = $this->newCurtainView($ssh_key);
$curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-pencil') ->setName(pht('Edit SSH Key')) ->setHref($edit_uri) ->setWorkflow(true) ->setDisabled(!$can_edit));
$curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-times') ->setName(pht('Revoke SSH Key')) ->setHref($revoke_uri) ->setWorkflow(true) ->setDisabled(!$can_edit));
return $curtain; }
private function buildPropertySection( PhabricatorAuthSSHKey $ssh_key) { $viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView()) ->setUser($viewer);
$properties->addProperty(pht('Public Key'), $ssh_key->getEntireKey()); $properties->addProperty( pht('Created'), phabricator_datetime($ssh_key->getDateCreated(), $viewer));
return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Details')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($properties); }
}