1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

Clean up display of clone URIs a little bit

Summary:
Ref T10923. This makes the "Clone URI" UI a little nicer:

  - Show whether each URI is read-only, read-write, or external.
  - Clicking the button selects the URI.
  - Add a link to manage the appropriate credentials.

Test Plan: {F1308302, size=full}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10923

Differential Revision: https://secure.phabricator.com/D15891
This commit is contained in:
epriestley 2016-05-11 10:17:33 -07:00
parent fc654f8996
commit b21b43131c
6 changed files with 191 additions and 15 deletions

View file

@ -12,7 +12,7 @@ return array(
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '7ba78475',
'differential.pkg.js' => 'd0cd0df6',
'diffusion.pkg.css' => 'dc8e0cc2',
'diffusion.pkg.css' => '91c5d3a6',
'diffusion.pkg.js' => '3a9a8bfa',
'maniphest.pkg.css' => '4845691a',
'maniphest.pkg.js' => '949a7498',
@ -64,7 +64,7 @@ return array(
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55',
'rsrc/css/application/diffusion/diffusion-icons.css' => '3311444d',
'rsrc/css/application/diffusion/diffusion-icons.css' => 'd678600a',
'rsrc/css/application/diffusion/diffusion-readme.css' => '297373eb',
'rsrc/css/application/diffusion/diffusion-source.css' => '68b30fd3',
'rsrc/css/application/feed/feed.css' => 'ecd4ec57',
@ -504,6 +504,7 @@ return array(
'rsrc/js/core/behavior-reveal-content.js' => '60821bc7',
'rsrc/js/core/behavior-scrollbar.js' => '834a1173',
'rsrc/js/core/behavior-search-typeahead.js' => '06c32383',
'rsrc/js/core/behavior-select-content.js' => 'bf5374ef',
'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6',
'rsrc/js/core/behavior-time-typeahead.js' => '522431f7',
'rsrc/js/core/behavior-toggle-class.js' => '92b9ec77',
@ -557,7 +558,7 @@ return array(
'differential-revision-history-css' => '0e8eb855',
'differential-revision-list-css' => 'f3c47d33',
'differential-table-of-contents-css' => 'ae4b7a55',
'diffusion-icons-css' => '3311444d',
'diffusion-icons-css' => 'd678600a',
'diffusion-readme-css' => '297373eb',
'diffusion-source-css' => '68b30fd3',
'diviner-shared-css' => 'aa3656aa',
@ -685,6 +686,7 @@ return array(
'javelin-behavior-repository-crossreference' => 'e5339c43',
'javelin-behavior-scrollbar' => '834a1173',
'javelin-behavior-search-reorder-queries' => 'e9581f08',
'javelin-behavior-select-content' => 'bf5374ef',
'javelin-behavior-select-on-click' => '4e3e79a6',
'javelin-behavior-slowvote-embed' => '887ad43f',
'javelin-behavior-stripe-payment-form' => '3f5d6dbf',
@ -1837,6 +1839,11 @@ return array(
'javelin-util',
'javelin-request',
),
'bf5374ef' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
),
'bff6884b' => array(
'javelin-install',
'javelin-dom',

View file

@ -573,6 +573,7 @@ phutil_register_library_map(array(
'DiffusionCachedResolveRefsQuery' => 'applications/diffusion/query/DiffusionCachedResolveRefsQuery.php',
'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php',
'DiffusionChangeHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionChangeHeraldFieldGroup.php',
'DiffusionCloneURIView' => 'applications/diffusion/view/DiffusionCloneURIView.php',
'DiffusionCommandEngine' => 'applications/diffusion/protocol/DiffusionCommandEngine.php',
'DiffusionCommandEngineTestCase' => 'applications/diffusion/protocol/__tests__/DiffusionCommandEngineTestCase.php',
'DiffusionCommitAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php',
@ -4792,6 +4793,7 @@ phutil_register_library_map(array(
'DiffusionCachedResolveRefsQuery' => 'DiffusionLowLevelQuery',
'DiffusionChangeController' => 'DiffusionController',
'DiffusionChangeHeraldFieldGroup' => 'HeraldFieldGroup',
'DiffusionCloneURIView' => 'AphrontView',
'DiffusionCommandEngine' => 'Phobject',
'DiffusionCommandEngineTestCase' => 'PhabricatorTestCase',
'DiffusionCommitAffectedFilesHeraldField' => 'DiffusionCommitHeraldField',

View file

@ -669,8 +669,6 @@ final class DiffusionRepositoryController extends DiffusionController {
PhabricatorRepository $repository,
PhabricatorRepositoryURI $uri) {
require_celerity_resource('diffusion-icons-css');
if ($repository->isSVN()) {
$display = csprintf(
'svn checkout %R %R',
@ -681,17 +679,13 @@ final class DiffusionRepositoryController extends DiffusionController {
}
$display = (string)$display;
$viewer = $this->getViewer();
$input = javelin_tag(
'input',
array(
'type' => 'text',
'value' => $display,
'class' => 'diffusion-clone-uri',
'readonly' => 'true',
));
return $input;
return id(new DiffusionCloneURIView())
->setViewer($viewer)
->setRepository($repository)
->setRepositoryURI($uri)
->setDisplayURI($display);
}
}

View file

@ -0,0 +1,131 @@
<?php
final class DiffusionCloneURIView extends AphrontView {
private $repository;
private $repositoryURI;
private $displayURI;
public function setRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
return $this;
}
public function getRepository() {
return $this->repository;
}
public function setRepositoryURI(PhabricatorRepositoryURI $repository_uri) {
$this->repositoryURI = $repository_uri;
return $this;
}
public function getRepositoryURI() {
return $this->repositoryURI;
}
public function setDisplayURI($display_uri) {
$this->displayURI = $display_uri;
return $this;
}
public function getDisplayURI() {
return $this->displayURI;
}
public function render() {
require_celerity_resource('diffusion-icons-css');
Javelin::initBehavior('select-content');
$uri_id = celerity_generate_unique_node_id();
$display = $this->getDisplayURI();
$input = javelin_tag(
'input',
array(
'id' => $uri_id,
'type' => 'text',
'value' => $display,
'class' => 'diffusion-clone-uri',
'readonly' => 'true',
));
$uri = $this->getRepositoryURI();
switch ($uri->getEffectiveIOType()) {
case PhabricatorRepositoryURI::IO_READ:
$io_icon = 'fa-eye';
$io_tip = pht('Read-Only');
break;
case PhabricatorRepositoryURI::IO_READWRITE:
$io_icon = 'fa-download';
$io_tip = pht('Read / Write');
break;
default:
$io_icon = 'fa-cloud';
$io_tip = pht('External');
break;
}
$io = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::GREY)
->setIcon($io_icon)
->setHref('#')
->addSigil('select-content')
->addSigil('has-tooltip')
->setMetadata(
array(
'tip' => $io_tip,
'selectID' => $uri_id,
));
switch ($uri->getEffectiveIOType()) {
case PhabricatorRepositoryURI::IO_READ:
case PhabricatorRepositoryURI::IO_READWRITE:
switch ($uri->getBuiltinProtocol()) {
case PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH:
$auth_uri = '/settings/panel/ssh/';
$auth_tip = pht('Manage SSH Keys');
$auth_disabled = false;
break;
default:
$auth_uri = '/settings/panel/vcspassword';
$auth_tip = pht('Manage Password');
$auth_disabled = false;
break;
}
break;
default:
$auth_disabled = true;
$auth_tip = pht('External');
$auth_uri = '#';
break;
}
$credentials = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::GREY)
->setIcon('fa-key')
->setTooltip($auth_tip)
->setHref($auth_uri)
->setDisabled($auth_disabled);
$cells = array();
$cells[] = phutil_tag('td', array(), $input);
$cells[] = phutil_tag('th', array(), $io);
$cells[] = phutil_tag('th', array(), $credentials);
$row = phutil_tag('tr', array(), $cells);
return phutil_tag(
'table',
array(
'class' => 'diffusion-clone-uri-table',
),
$row);
}
}

View file

@ -28,3 +28,22 @@ input.diffusion-clone-uri {
.diffusion-search-boxen .phui-form-view {
padding: 0;
}
.diffusion-clone-uri-table {
width: 100%;
}
.diffusion-clone-uri-table th {
width: 24px;
padding: 0 0 0 4px;
}
.diffusion-clone-uri-table th a.button {
width: 12px;
height: 19px;
}
.diffusion-clone-uri-table th a.button .phui-icon-view {
left: 12px;
top: 7px;
}

View file

@ -0,0 +1,23 @@
/**
* @provides javelin-behavior-select-content
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
* @javelin
*/
JX.behavior('select-content', function() {
JX.Stratcom.listen(
'click',
'select-content',
function(e) {
e.kill();
var node = e.getNode('select-content');
var data = JX.Stratcom.getData(node);
var target = JX.$(data.selectID);
JX.DOM.focus(target);
target.select();
});
});