1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Move "Open in Editor" to File Box

Summary: Moves this single action to the File Contents box in Diffusion Browse. Also fixes a PHUIObjectBox missing when enable highlighting is on.

Test Plan: Enable/Disable Highlighting. See disabled Editor button.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4467

Differential Revision: https://secure.phabricator.com/D8300
This commit is contained in:
Chad Little 2014-02-21 14:43:24 -08:00
parent 2a277bbc03
commit ce5eafe7f1
2 changed files with 31 additions and 16 deletions

View file

@ -208,7 +208,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
if (!$show_color) { if (!$show_color) {
$style = $style =
"margin: 1em 2em; width: 90%; height: 80em; font-family: monospace"; "border: none; width: 100%; height: 80em; font-family: monospace";
if (!$show_blame) { if (!$show_blame) {
$corpus = phutil_tag( $corpus = phutil_tag(
'textarea', 'textarea',
@ -301,13 +301,18 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
), ),
$corpus_table); $corpus_table);
$corpus = id(new PHUIObjectBoxView())
->setHeaderText('File Contents')
->appendChild($corpus);
Javelin::initBehavior('load-blame', array('id' => $id)); Javelin::initBehavior('load-blame', array('id' => $id));
} }
$button = $this->createEditButton();
$header = id(new PHUIHeaderView())
->setHeader(pht('File Contents'))
->addActionLink($button);
$corpus = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($corpus);
return $corpus; return $corpus;
} }
@ -349,7 +354,6 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
->setUser($viewer) ->setUser($viewer)
->setRenderAsForm(true)); ->setRenderAsForm(true));
if ($show_color) { if ($show_color) {
$highlight_text = pht('Disable Highlighting'); $highlight_text = pht('Disable Highlighting');
$highlight_icon = 'highlight-grey'; $highlight_icon = 'highlight-grey';
@ -406,12 +410,10 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
->setIcon('file')); ->setIcon('file'));
} }
$view->addAction($this->createEditAction());
return $view; return $view;
} }
private function createEditAction() { private function createEditButton() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
@ -424,14 +426,17 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$callsign = $repository->getCallsign(); $callsign = $repository->getCallsign();
$editor_link = $user->loadEditorLink($path, $line, $callsign); $editor_link = $user->loadEditorLink($path, $line, $callsign);
$action = id(new PhabricatorActionView()) $icon_edit = id(new PHUIIconView())
->setName(pht('Open in Editor')) ->setSpriteSheet(PHUIIconView::SPRITE_ICONS)
->setIcon('edit'); ->setSpriteIcon('edit');
$button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Open in Editor'))
->setHref($editor_link)
->setIcon($icon_edit)
->setDisabled(!$editor_link);
$action->setHref($editor_link); return $button;
$action->setDisabled(!$editor_link);
return $action;
} }
private function buildDisplayRows( private function buildDisplayRows(

View file

@ -20,6 +20,7 @@ final class PHUIButtonView extends AphrontTagView {
private $icon; private $icon;
private $href = null; private $href = null;
private $title = null; private $title = null;
private $disabled;
public function setText($text) { public function setText($text) {
$this->text = $text; $this->text = $text;
@ -46,6 +47,11 @@ final class PHUIButtonView extends AphrontTagView {
return $this; return $this;
} }
public function setDisabled($disabled) {
$this->disabled = $disabled;
return $this;
}
public function setTag($tag) { public function setTag($tag) {
$this->tag = $tag; $this->tag = $tag;
return $this; return $this;
@ -93,6 +99,10 @@ final class PHUIButtonView extends AphrontTagView {
$classes[] = 'has-icon'; $classes[] = 'has-icon';
} }
if ($this->disabled) {
$classes[] = 'disabled';
}
return array('class' => $classes, return array('class' => $classes,
'href' => $this->href, 'href' => $this->href,
'title' => $this->title); 'title' => $this->title);