Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / settings / panel / PhabricatorTokensSettingsPanel.php
blob91064a432fa68d0cc565c7900cdbd67a78d53138
1 <?php
3 final class PhabricatorTokensSettingsPanel extends PhabricatorSettingsPanel {
5 public function getPanelKey() {
6 return 'tokens';
9 public function getPanelName() {
10 return pht('Temporary Tokens');
13 public function getPanelMenuIcon() {
14 return 'fa-ticket';
17 public function getPanelGroupKey() {
18 return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY;
21 public function processRequest(AphrontRequest $request) {
22 $viewer = $request->getUser();
24 $tokens = id(new PhabricatorAuthTemporaryTokenQuery())
25 ->setViewer($viewer)
26 ->withTokenResources(array($viewer->getPHID()))
27 ->execute();
29 $rows = array();
30 foreach ($tokens as $token) {
32 if ($token->isRevocable()) {
33 $button = javelin_tag(
34 'a',
35 array(
36 'href' => '/auth/token/revoke/'.$token->getID().'/',
37 'class' => 'small button button-grey',
38 'sigil' => 'workflow',
40 pht('Revoke'));
41 } else {
42 $button = javelin_tag(
43 'a',
44 array(
45 'class' => 'small button button-grey disabled',
47 pht('Revoke'));
50 if ($token->getTokenExpires() >= time()) {
51 $expiry = phabricator_datetime($token->getTokenExpires(), $viewer);
52 } else {
53 $expiry = pht('Expired');
56 $rows[] = array(
57 $token->getTokenReadableTypeName(),
58 $expiry,
59 $button,
63 $table = new AphrontTableView($rows);
64 $table->setNoDataString(pht("You don't have any active tokens."));
65 $table->setHeaders(
66 array(
67 pht('Type'),
68 pht('Expires'),
69 pht(''),
70 ));
71 $table->setColumnClasses(
72 array(
73 'wide',
74 'right',
75 'action',
76 ));
78 $button = id(new PHUIButtonView())
79 ->setTag('a')
80 ->setIcon('fa-warning')
81 ->setText(pht('Revoke All'))
82 ->setHref('/auth/token/revoke/all/')
83 ->setWorkflow(true)
84 ->setColor(PHUIButtonView::RED);
86 return $this->newBox(pht('Temporary Tokens'), $table, array($button));