@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add ViewController and SearchEngine for SSH Public Keys

Summary:
Ref T10917. This primarily prepares these for transactions by giving us a place to:

- review old deactivated keys; and
- review changes to keys.

Future changes will add transactions and a timeline so key changes are recorded exhaustively and can be more easily audited.

Test Plan:
{F1652089}

{F1652090}

{F1652091}

{F1652092}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10917

Differential Revision: https://secure.phabricator.com/D15946

+409 -91
+8 -2
src/__phutil_library_map__.php
··· 1876 1876 'PhabricatorAuthRevokeTokenController' => 'applications/auth/controller/PhabricatorAuthRevokeTokenController.php', 1877 1877 'PhabricatorAuthSSHKey' => 'applications/auth/storage/PhabricatorAuthSSHKey.php', 1878 1878 'PhabricatorAuthSSHKeyController' => 'applications/auth/controller/PhabricatorAuthSSHKeyController.php', 1879 - 'PhabricatorAuthSSHKeyDeleteController' => 'applications/auth/controller/PhabricatorAuthSSHKeyDeleteController.php', 1879 + 'PhabricatorAuthSSHKeyDeactivateController' => 'applications/auth/controller/PhabricatorAuthSSHKeyDeactivateController.php', 1880 1880 'PhabricatorAuthSSHKeyEditController' => 'applications/auth/controller/PhabricatorAuthSSHKeyEditController.php', 1881 1881 'PhabricatorAuthSSHKeyGenerateController' => 'applications/auth/controller/PhabricatorAuthSSHKeyGenerateController.php', 1882 + 'PhabricatorAuthSSHKeyListController' => 'applications/auth/controller/PhabricatorAuthSSHKeyListController.php', 1882 1883 'PhabricatorAuthSSHKeyPHIDType' => 'applications/auth/phid/PhabricatorAuthSSHKeyPHIDType.php', 1883 1884 'PhabricatorAuthSSHKeyQuery' => 'applications/auth/query/PhabricatorAuthSSHKeyQuery.php', 1885 + 'PhabricatorAuthSSHKeySearchEngine' => 'applications/auth/query/PhabricatorAuthSSHKeySearchEngine.php', 1884 1886 'PhabricatorAuthSSHKeyTableView' => 'applications/auth/view/PhabricatorAuthSSHKeyTableView.php', 1887 + 'PhabricatorAuthSSHKeyViewController' => 'applications/auth/controller/PhabricatorAuthSSHKeyViewController.php', 1885 1888 'PhabricatorAuthSSHPublicKey' => 'applications/auth/sshkey/PhabricatorAuthSSHPublicKey.php', 1886 1889 'PhabricatorAuthSession' => 'applications/auth/storage/PhabricatorAuthSession.php', 1887 1890 'PhabricatorAuthSessionEngine' => 'applications/auth/engine/PhabricatorAuthSessionEngine.php', ··· 6304 6307 'PhabricatorDestructibleInterface', 6305 6308 ), 6306 6309 'PhabricatorAuthSSHKeyController' => 'PhabricatorAuthController', 6307 - 'PhabricatorAuthSSHKeyDeleteController' => 'PhabricatorAuthSSHKeyController', 6310 + 'PhabricatorAuthSSHKeyDeactivateController' => 'PhabricatorAuthSSHKeyController', 6308 6311 'PhabricatorAuthSSHKeyEditController' => 'PhabricatorAuthSSHKeyController', 6309 6312 'PhabricatorAuthSSHKeyGenerateController' => 'PhabricatorAuthSSHKeyController', 6313 + 'PhabricatorAuthSSHKeyListController' => 'PhabricatorAuthSSHKeyController', 6310 6314 'PhabricatorAuthSSHKeyPHIDType' => 'PhabricatorPHIDType', 6311 6315 'PhabricatorAuthSSHKeyQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6316 + 'PhabricatorAuthSSHKeySearchEngine' => 'PhabricatorApplicationSearchEngine', 6312 6317 'PhabricatorAuthSSHKeyTableView' => 'AphrontView', 6318 + 'PhabricatorAuthSSHKeyViewController' => 'PhabricatorAuthSSHKeyController', 6313 6319 'PhabricatorAuthSSHPublicKey' => 'Phobject', 6314 6320 'PhabricatorAuthSession' => array( 6315 6321 'PhabricatorAuthDAO',
+4 -29
src/applications/almanac/controller/AlmanacDeviceViewController.php
··· 157 157 ->setShowTrusted(true) 158 158 ->setNoDataString(pht('This device has no associated SSH public keys.')); 159 159 160 - try { 161 - PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); 162 - $can_generate = true; 163 - } catch (Exception $ex) { 164 - $can_generate = false; 165 - } 166 - 167 - $generate_uri = '/auth/sshkey/generate/?objectPHID='.$device_phid; 168 - $upload_uri = '/auth/sshkey/upload/?objectPHID='.$device_phid; 160 + $menu_button = PhabricatorAuthSSHKeyTableView::newKeyActionsMenu( 161 + $viewer, 162 + $device); 169 163 170 164 $header = id(new PHUIHeaderView()) 171 165 ->setHeader(pht('SSH Public Keys')) 172 - ->addActionLink( 173 - id(new PHUIButtonView()) 174 - ->setTag('a') 175 - ->setHref($generate_uri) 176 - ->setWorkflow(true) 177 - ->setDisabled(!$can_edit || !$can_generate) 178 - ->setText(pht('Generate Keypair')) 179 - ->setIcon( 180 - id(new PHUIIconView()) 181 - ->setIcon('fa-lock'))) 182 - ->addActionLink( 183 - id(new PHUIButtonView()) 184 - ->setTag('a') 185 - ->setHref($upload_uri) 186 - ->setWorkflow(true) 187 - ->setDisabled(!$can_edit) 188 - ->setText(pht('Upload Public Key')) 189 - ->setIcon( 190 - id(new PHUIIconView()) 191 - ->setIcon('fa-upload'))); 166 + ->addActionLink($menu_button); 192 167 193 168 return id(new PHUIObjectBoxView()) 194 169 ->setHeader($header)
+5 -1
src/applications/auth/application/PhabricatorAuthApplication.php
··· 75 75 'multifactor/' 76 76 => 'PhabricatorAuthNeedsMultiFactorController', 77 77 'sshkey/' => array( 78 + $this->getQueryRoutePattern('for/(?P<forPHID>[^/]+)/') 79 + => 'PhabricatorAuthSSHKeyListController', 78 80 'generate/' => 'PhabricatorAuthSSHKeyGenerateController', 79 81 'upload/' => 'PhabricatorAuthSSHKeyEditController', 80 82 'edit/(?P<id>\d+)/' => 'PhabricatorAuthSSHKeyEditController', 81 - 'delete/(?P<id>\d+)/' => 'PhabricatorAuthSSHKeyDeleteController', 83 + 'deactivate/(?P<id>\d+)/' 84 + => 'PhabricatorAuthSSHKeyDeactivateController', 85 + 'view/(?P<id>\d+)/' => 'PhabricatorAuthSSHKeyViewController', 82 86 ), 83 87 ), 84 88
+53 -6
src/applications/auth/controller/PhabricatorAuthSSHKeyController.php
··· 3 3 abstract class PhabricatorAuthSSHKeyController 4 4 extends PhabricatorAuthController { 5 5 6 - protected function newKeyForObjectPHID($object_phid) { 6 + private $keyObject; 7 + 8 + public function setSSHKeyObject(PhabricatorSSHPublicKeyInterface $object) { 9 + $this->keyObject = $object; 10 + return $this; 11 + } 12 + 13 + public function getSSHKeyObject() { 14 + return $this->keyObject; 15 + } 16 + 17 + protected function loadSSHKeyObject($object_phid, $need_edit) { 7 18 $viewer = $this->getViewer(); 8 19 9 - $object = id(new PhabricatorObjectQuery()) 20 + $query = id(new PhabricatorObjectQuery()) 10 21 ->setViewer($viewer) 11 - ->withPHIDs(array($object_phid)) 12 - ->requireCapabilities( 22 + ->withPHIDs(array($object_phid)); 23 + 24 + if ($need_edit) { 25 + $query->requireCapabilities( 13 26 array( 14 27 PhabricatorPolicyCapability::CAN_VIEW, 15 28 PhabricatorPolicyCapability::CAN_EDIT, 16 - )) 17 - ->executeOne(); 29 + )); 30 + } 31 + 32 + $object = $query->executeOne(); 33 + 18 34 if (!$object) { 19 35 return null; 20 36 } ··· 25 41 return null; 26 42 } 27 43 44 + $this->keyObject = $object; 45 + 46 + return $object; 47 + } 48 + 49 + protected function newKeyForObjectPHID($object_phid) { 50 + $viewer = $this->getViewer(); 51 + 52 + $object = $this->loadSSHKeyObject($object_phid, true); 53 + if (!$object) { 54 + return null; 55 + } 56 + 28 57 return PhabricatorAuthSSHKey::initializeNewSSHKey($viewer, $object); 58 + } 59 + 60 + protected function buildApplicationCrumbs() { 61 + $crumbs = parent::buildApplicationCrumbs(); 62 + $viewer = $this->getViewer(); 63 + 64 + $key_object = $this->getSSHKeyObject(); 65 + if ($key_object) { 66 + $object_phid = $key_object->getPHID(); 67 + $handles = $viewer->loadHandles(array($object_phid)); 68 + $handle = $handles[$object_phid]; 69 + 70 + $uri = $key_object->getSSHPublicKeyManagementURI($viewer); 71 + 72 + $crumbs->addTextCrumb($handle->getObjectName(), $uri); 73 + } 74 + 75 + return $crumbs; 29 76 } 30 77 31 78 }
+7 -7
src/applications/auth/controller/PhabricatorAuthSSHKeyDeleteController.php src/applications/auth/controller/PhabricatorAuthSSHKeyDeactivateController.php
··· 1 1 <?php 2 2 3 - final class PhabricatorAuthSSHKeyDeleteController 3 + final class PhabricatorAuthSSHKeyDeactivateController 4 4 extends PhabricatorAuthSSHKeyController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { ··· 9 9 $key = id(new PhabricatorAuthSSHKeyQuery()) 10 10 ->setViewer($viewer) 11 11 ->withIDs(array($request->getURIData('id'))) 12 - ->withIsActive(true) 13 12 ->requireCapabilities( 14 13 array( 15 14 PhabricatorPolicyCapability::CAN_VIEW, ··· 20 19 return new Aphront404Response(); 21 20 } 22 21 23 - $cancel_uri = $key->getObject()->getSSHPublicKeyManagementURI($viewer); 22 + $cancel_uri = $key->getURI(); 24 23 25 24 $token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 26 25 $viewer, ··· 39 38 $name = phutil_tag('strong', array(), $key->getName()); 40 39 41 40 return $this->newDialog() 42 - ->setTitle(pht('Really delete SSH Public Key?')) 41 + ->setTitle(pht('Deactivate SSH Public Key')) 43 42 ->appendParagraph( 44 43 pht( 45 - 'The key "%s" will be permanently deleted, and you will not longer '. 46 - 'be able to use the corresponding private key to authenticate.', 44 + 'The key "%s" will be permanently deactivated, and you will no '. 45 + 'longer be able to use the corresponding private key to '. 46 + 'authenticate.', 47 47 $name)) 48 - ->addSubmitButton(pht('Delete Public Key')) 48 + ->addSubmitButton(pht('Deactivate Public Key')) 49 49 ->addCancelButton($cancel_uri); 50 50 } 51 51
+1 -2
src/applications/auth/controller/PhabricatorAuthSSHKeyEditController.php
··· 11 11 $key = id(new PhabricatorAuthSSHKeyQuery()) 12 12 ->setViewer($viewer) 13 13 ->withIDs(array($id)) 14 - ->withIsActive(true) 15 14 ->requireCapabilities( 16 15 array( 17 16 PhabricatorPolicyCapability::CAN_VIEW, ··· 97 96 if (!$errors) { 98 97 try { 99 98 $key->save(); 100 - return id(new AphrontRedirectResponse())->setURI($cancel_uri); 99 + return id(new AphrontRedirectResponse())->setURI($key->getURI()); 101 100 } catch (Exception $ex) { 102 101 $e_key = pht('Duplicate'); 103 102 $errors[] = pht(
+25
src/applications/auth/controller/PhabricatorAuthSSHKeyListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthSSHKeyListController 4 + extends PhabricatorAuthSSHKeyController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $object_phid = $request->getURIData('forPHID'); 12 + $object = $this->loadSSHKeyObject($object_phid, false); 13 + if (!$object) { 14 + return new Aphront404Response(); 15 + } 16 + 17 + $engine = id(new PhabricatorAuthSSHKeySearchEngine()) 18 + ->setSSHKeyObject($object); 19 + 20 + return id($engine) 21 + ->setController($this) 22 + ->buildResponse(); 23 + } 24 + 25 + }
+123
src/applications/auth/controller/PhabricatorAuthSSHKeyViewController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthSSHKeyViewController 4 + extends PhabricatorAuthSSHKeyController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $request->getViewer(); 12 + 13 + $id = $request->getURIData('id'); 14 + 15 + $ssh_key = id(new PhabricatorAuthSSHKeyQuery()) 16 + ->setViewer($viewer) 17 + ->withIDs(array($id)) 18 + ->executeOne(); 19 + if (!$ssh_key) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $this->setSSHKeyObject($ssh_key->getObject()); 24 + 25 + $title = pht('SSH Key %d', $ssh_key->getID()); 26 + 27 + $curtain = $this->buildCurtain($ssh_key); 28 + $details = $this->buildPropertySection($ssh_key); 29 + 30 + $header = id(new PHUIHeaderView()) 31 + ->setUser($viewer) 32 + ->setHeader($ssh_key->getName()) 33 + ->setHeaderIcon('fa-key'); 34 + 35 + if ($ssh_key->getIsActive()) { 36 + $header->setStatus('fa-check', 'bluegrey', pht('Active')); 37 + } else { 38 + $header->setStatus('fa-ban', 'dark', pht('Deactivated')); 39 + } 40 + 41 + $header->addActionLink( 42 + id(new PHUIButtonView()) 43 + ->setTag('a') 44 + ->setText(pht('View Active Keys')) 45 + ->setHref($ssh_key->getObject()->getSSHPublicKeyManagementURI($viewer)) 46 + ->setIcon('fa-list-ul')); 47 + 48 + $crumbs = $this->buildApplicationCrumbs(); 49 + $crumbs->addTextCrumb($title); 50 + $crumbs->setBorder(true); 51 + 52 + // TODO: This doesn't exist yet, build it. 53 + // $timeline = $this->buildTransactionTimeline( 54 + // $ssh_key, 55 + // new PhabricatorAuthSSHKeyTransactionQuery()); 56 + // $timeline->setShouldTerminate(true); 57 + $timeline = null; 58 + 59 + $view = id(new PHUITwoColumnView()) 60 + ->setHeader($header) 61 + ->setCurtain($curtain) 62 + ->setMainColumn( 63 + array( 64 + $details, 65 + $timeline, 66 + )); 67 + 68 + return $this->newPage() 69 + ->setTitle($title) 70 + ->setCrumbs($crumbs) 71 + ->appendChild($view); 72 + } 73 + 74 + private function buildCurtain(PhabricatorAuthSSHKey $ssh_key) { 75 + $viewer = $this->getViewer(); 76 + 77 + $can_edit = PhabricatorPolicyFilter::hasCapability( 78 + $viewer, 79 + $ssh_key, 80 + PhabricatorPolicyCapability::CAN_EDIT); 81 + 82 + $id = $ssh_key->getID(); 83 + 84 + $edit_uri = $this->getApplicationURI("sshkey/edit/{$id}/"); 85 + $deactivate_uri = $this->getApplicationURI("sshkey/deactivate/{$id}/"); 86 + 87 + $curtain = $this->newCurtainView($ssh_key); 88 + 89 + $curtain->addAction( 90 + id(new PhabricatorActionView()) 91 + ->setIcon('fa-pencil') 92 + ->setName(pht('Edit SSH Key')) 93 + ->setHref($edit_uri) 94 + ->setWorkflow(true) 95 + ->setDisabled(!$can_edit)); 96 + 97 + $curtain->addAction( 98 + id(new PhabricatorActionView()) 99 + ->setIcon('fa-times') 100 + ->setName(pht('Deactivate SSH Key')) 101 + ->setHref($deactivate_uri) 102 + ->setWorkflow(true) 103 + ->setDisabled(!$can_edit)); 104 + 105 + return $curtain; 106 + } 107 + 108 + private function buildPropertySection( 109 + PhabricatorAuthSSHKey $ssh_key) { 110 + $viewer = $this->getViewer(); 111 + 112 + $properties = id(new PHUIPropertyListView()) 113 + ->setUser($viewer); 114 + 115 + $properties->addProperty(pht('SSH Key Type'), $ssh_key->getKeyType()); 116 + 117 + return id(new PHUIObjectBoxView()) 118 + ->setHeaderText(pht('Details')) 119 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 120 + ->appendChild($properties); 121 + } 122 + 123 + }
+1 -1
src/applications/auth/phid/PhabricatorAuthSSHKeyPHIDType.php
··· 34 34 $handle->setName(pht('SSH Key %d', $key->getID())); 35 35 36 36 if (!$key->getIsActive()) { 37 - $handle->setClosed(pht('Inactive')); 37 + $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); 38 38 } 39 39 } 40 40 }
+105
src/applications/auth/query/PhabricatorAuthSSHKeySearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthSSHKeySearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + private $sshKeyObject; 7 + 8 + public function setSSHKeyObject(PhabricatorSSHPublicKeyInterface $object) { 9 + $this->sshKeyObject = $object; 10 + return $this; 11 + } 12 + 13 + public function getSSHKeyObject() { 14 + return $this->sshKeyObject; 15 + } 16 + 17 + public function canUseInPanelContext() { 18 + return false; 19 + } 20 + 21 + public function getResultTypeDescription() { 22 + return pht('SSH Keys'); 23 + } 24 + 25 + public function getApplicationClassName() { 26 + return 'PhabricatorAuthApplication'; 27 + } 28 + 29 + public function newQuery() { 30 + $object = $this->getSSHKeyObject(); 31 + $object_phid = $object->getPHID(); 32 + 33 + return id(new PhabricatorAuthSSHKeyQuery()) 34 + ->withObjectPHIDs(array($object_phid)); 35 + } 36 + 37 + protected function buildQueryFromParameters(array $map) { 38 + $query = $this->newQuery(); 39 + 40 + return $query; 41 + } 42 + 43 + 44 + protected function buildCustomSearchFields() { 45 + return array(); 46 + } 47 + 48 + protected function getURI($path) { 49 + $object = $this->getSSHKeyObject(); 50 + $object_phid = $object->getPHID(); 51 + 52 + return "/auth/sshkey/for/{$object_phid}/{$path}"; 53 + } 54 + 55 + protected function getBuiltinQueryNames() { 56 + $names = array( 57 + 'all' => pht('All Keys'), 58 + ); 59 + 60 + return $names; 61 + } 62 + 63 + public function buildSavedQueryFromBuiltin($query_key) { 64 + 65 + $query = $this->newSavedQuery(); 66 + $query->setQueryKey($query_key); 67 + 68 + switch ($query_key) { 69 + case 'all': 70 + return $query; 71 + } 72 + 73 + return parent::buildSavedQueryFromBuiltin($query_key); 74 + } 75 + 76 + protected function renderResultList( 77 + array $keys, 78 + PhabricatorSavedQuery $query, 79 + array $handles) { 80 + assert_instances_of($keys, 'PhabricatorAuthSSHKey'); 81 + 82 + $viewer = $this->requireViewer(); 83 + 84 + $list = new PHUIObjectItemListView(); 85 + $list->setUser($viewer); 86 + foreach ($keys as $key) { 87 + $item = id(new PHUIObjectItemView()) 88 + ->setObjectName(pht('SSH Key %d', $key->getID())) 89 + ->setHeader($key->getName()) 90 + ->setHref($key->getURI()); 91 + 92 + if (!$key->getIsActive()) { 93 + $item->setDisabled(true); 94 + } 95 + 96 + $list->addItem($item); 97 + } 98 + 99 + $result = new PhabricatorApplicationSearchResultView(); 100 + $result->setObjectList($list); 101 + $result->setNoDataString(pht('No matching SSH keys.')); 102 + 103 + return $result; 104 + } 105 + }
+20
src/applications/auth/storage/PhabricatorAuthSSHKey.php
··· 96 96 PhabricatorAuthSSHKeyPHIDType::TYPECONST); 97 97 } 98 98 99 + public function getURI() { 100 + $id = $this->getID(); 101 + return "/auth/sshkey/view/{$id}/"; 102 + } 103 + 99 104 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 100 105 101 106 ··· 107 112 } 108 113 109 114 public function getPolicy($capability) { 115 + if (!$this->getIsActive()) { 116 + if ($capability == PhabricatorPolicyCapability::CAN_EDIT) { 117 + return PhabricatorPolicies::POLICY_NOONE; 118 + } 119 + } 120 + 110 121 return $this->getObject()->getPolicy($capability); 111 122 } 112 123 113 124 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 125 + if (!$this->getIsActive()) { 126 + return false; 127 + } 128 + 114 129 return $this->getObject()->hasAutomaticCapability($capability, $viewer); 115 130 } 116 131 117 132 public function describeAutomaticCapability($capability) { 133 + if (!$this->getIsACtive()) { 134 + return pht( 135 + 'Deactivated SSH keys can not be edited or reactivated.'); 136 + } 137 + 118 138 return pht( 119 139 'SSH keys inherit the policies of the user or object they authenticate.'); 120 140 }
+53 -18
src/applications/auth/view/PhabricatorAuthSSHKeyTableView.php
··· 8 8 private $showTrusted; 9 9 private $showID; 10 10 11 + public static function newKeyActionsMenu( 12 + PhabricatorUser $viewer, 13 + PhabricatorSSHPublicKeyInterface $object) { 14 + 15 + $can_edit = PhabricatorPolicyFilter::hasCapability( 16 + $viewer, 17 + $object, 18 + PhabricatorPolicyCapability::CAN_EDIT); 19 + 20 + try { 21 + PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); 22 + $can_generate = true; 23 + } catch (Exception $ex) { 24 + $can_generate = false; 25 + } 26 + 27 + $object_phid = $object->getPHID(); 28 + 29 + $generate_uri = "/auth/sshkey/generate/?objectPHID={$object_phid}"; 30 + $upload_uri = "/auth/sshkey/upload/?objectPHID={$object_phid}"; 31 + $view_uri = "/auth/sshkey/for/{$object_phid}/"; 32 + 33 + $action_view = id(new PhabricatorActionListView()) 34 + ->setUser($viewer) 35 + ->addAction( 36 + id(new PhabricatorActionView()) 37 + ->setHref($upload_uri) 38 + ->setWorkflow(true) 39 + ->setDisabled(!$can_edit) 40 + ->setName(pht('Upload Public Key')) 41 + ->setIcon('fa-upload')) 42 + ->addAction( 43 + id(new PhabricatorActionView()) 44 + ->setHref($generate_uri) 45 + ->setWorkflow(true) 46 + ->setDisabled(!$can_edit || !$can_generate) 47 + ->setName(pht('Generate Keypair')) 48 + ->setIcon('fa-lock')) 49 + ->addAction( 50 + id(new PhabricatorActionView()) 51 + ->setHref($view_uri) 52 + ->setName(pht('View History')) 53 + ->setIcon('fa-list-ul')); 54 + 55 + return id(new PHUIButtonView()) 56 + ->setTag('a') 57 + ->setText(pht('SSH Key Actions')) 58 + ->setHref('#') 59 + ->setIcon('fa-gear') 60 + ->setDropdownMenu($action_view); 61 + } 62 + 11 63 public function setNoDataString($no_data_string) { 12 64 $this->noDataString = $no_data_string; 13 65 return $this; ··· 38 90 $keys = $this->keys; 39 91 $viewer = $this->getUser(); 40 92 41 - if ($this->canEdit) { 42 - $delete_class = 'small grey button'; 43 - } else { 44 - $delete_class = 'small grey button disabled'; 45 - } 46 - 47 93 $trusted_icon = id(new PHUIIconView()) 48 94 ->setIcon('fa-star blue'); 49 95 $untrusted_icon = id(new PHUIIconView()) ··· 56 102 javelin_tag( 57 103 'a', 58 104 array( 59 - 'href' => '/auth/sshkey/edit/'.$key->getID().'/', 60 - 'sigil' => 'workflow', 105 + 'href' => $key->getURI(), 61 106 ), 62 107 $key->getName()), 63 108 $key->getIsTrusted() ? $trusted_icon : $untrusted_icon, 64 109 $key->getKeyComment(), 65 110 $key->getKeyType(), 66 111 phabricator_datetime($key->getDateCreated(), $viewer), 67 - javelin_tag( 68 - 'a', 69 - array( 70 - 'href' => '/auth/sshkey/delete/'.$key->getID().'/', 71 - 'class' => $delete_class, 72 - 'sigil' => 'workflow', 73 - ), 74 - pht('Delete')), 75 112 ); 76 113 } 77 114 ··· 85 122 pht('Comment'), 86 123 pht('Type'), 87 124 pht('Added'), 88 - null, 89 125 )) 90 126 ->setColumnVisibility( 91 127 array( ··· 101 137 '', 102 138 '', 103 139 'right', 104 - 'action', 105 140 )); 106 141 107 142 return $table;
-2
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 98 98 return $this->navigationItems; 99 99 } 100 100 101 - 102 - 103 101 public function canUseInPanelContext() { 104 102 return true; 105 103 }
+4 -23
src/applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php
··· 45 45 $panel = new PHUIObjectBoxView(); 46 46 $header = new PHUIHeaderView(); 47 47 48 - $upload_button = id(new PHUIButtonView()) 49 - ->setText(pht('Upload Public Key')) 50 - ->setHref('/auth/sshkey/upload/?objectPHID='.$user->getPHID()) 51 - ->setWorkflow(true) 52 - ->setTag('a') 53 - ->setIcon('fa-upload'); 54 - 55 - try { 56 - PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); 57 - $can_generate = true; 58 - } catch (Exception $ex) { 59 - $can_generate = false; 60 - } 61 - 62 - $generate_button = id(new PHUIButtonView()) 63 - ->setText(pht('Generate Keypair')) 64 - ->setHref('/auth/sshkey/generate/?objectPHID='.$user->getPHID()) 65 - ->setTag('a') 66 - ->setWorkflow(true) 67 - ->setDisabled(!$can_generate) 68 - ->setIcon('fa-lock'); 48 + $ssh_actions = PhabricatorAuthSSHKeyTableView::newKeyActionsMenu( 49 + $viewer, 50 + $user); 69 51 70 52 $header->setHeader(pht('SSH Public Keys')); 71 - $header->addActionLink($generate_button); 72 - $header->addActionLink($upload_button); 53 + $header->addActionLink($ssh_actions); 73 54 74 55 $panel->setHeader($header); 75 56 $panel->setTable($table);