mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-15 16:28:38 +01:00
Summary: Converts most all tables to be directly set via `setTable` to an ObjectBox. I think this path is more flexible design wise, as we can change the box based on children, and not just CSS. We also already do this with PropertyList, Forms, ObjectList, and Header. `setCollapsed` is added to ObjectBox to all children objects to bleed to the edges (like diffs). Test Plan: I did a grep of `appendChild($table)` as well as searches for `PHUIObjectBoxView`, also with manual opening of hundreds of files. I'm sure I missed 5-8 places. If you just appendChild($table) nothing breaks, it just looks a little funny. Reviewers: epriestley, btrahan Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12955
79 lines
2 KiB
PHP
79 lines
2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSSHKeysSettingsPanel extends PhabricatorSettingsPanel {
|
|
|
|
public function isEditableByAdministrators() {
|
|
return true;
|
|
}
|
|
|
|
public function getPanelKey() {
|
|
return 'ssh';
|
|
}
|
|
|
|
public function getPanelName() {
|
|
return pht('SSH Public Keys');
|
|
}
|
|
|
|
public function getPanelGroup() {
|
|
return pht('Authentication');
|
|
}
|
|
|
|
public function isEnabled() {
|
|
return true;
|
|
}
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
|
$user = $this->getUser();
|
|
$viewer = $request->getUser();
|
|
|
|
$keys = id(new PhabricatorAuthSSHKeyQuery())
|
|
->setViewer($viewer)
|
|
->withObjectPHIDs(array($user->getPHID()))
|
|
->execute();
|
|
|
|
$table = id(new PhabricatorAuthSSHKeyTableView())
|
|
->setUser($viewer)
|
|
->setKeys($keys)
|
|
->setCanEdit(true)
|
|
->setNoDataString("You haven't added any SSH Public Keys.");
|
|
|
|
$panel = new PHUIObjectBoxView();
|
|
$header = new PHUIHeaderView();
|
|
|
|
$upload_icon = id(new PHUIIconView())
|
|
->setIconFont('fa-upload');
|
|
$upload_button = id(new PHUIButtonView())
|
|
->setText(pht('Upload Public Key'))
|
|
->setHref('/auth/sshkey/upload/?objectPHID='.$user->getPHID())
|
|
->setWorkflow(true)
|
|
->setTag('a')
|
|
->setIcon($upload_icon);
|
|
|
|
try {
|
|
PhabricatorSSHKeyGenerator::assertCanGenerateKeypair();
|
|
$can_generate = true;
|
|
} catch (Exception $ex) {
|
|
$can_generate = false;
|
|
}
|
|
|
|
$generate_icon = id(new PHUIIconView())
|
|
->setIconFont('fa-lock');
|
|
$generate_button = id(new PHUIButtonView())
|
|
->setText(pht('Generate Keypair'))
|
|
->setHref('/auth/sshkey/generate/?objectPHID='.$user->getPHID())
|
|
->setTag('a')
|
|
->setWorkflow(true)
|
|
->setDisabled(!$can_generate)
|
|
->setIcon($generate_icon);
|
|
|
|
$header->setHeader(pht('SSH Public Keys'));
|
|
$header->addActionLink($generate_button);
|
|
$header->addActionLink($upload_button);
|
|
|
|
$panel->setHeader($header);
|
|
$panel->setTable($table);
|
|
|
|
return $panel;
|
|
}
|
|
|
|
}
|