1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52: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) {
$style =
"margin: 1em 2em; width: 90%; height: 80em; font-family: monospace";
"border: none; width: 100%; height: 80em; font-family: monospace";
if (!$show_blame) {
$corpus = phutil_tag(
'textarea',
@ -301,13 +301,18 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
),
$corpus_table);
$corpus = id(new PHUIObjectBoxView())
->setHeaderText('File Contents')
->appendChild($corpus);
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;
}
@ -349,7 +354,6 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
->setUser($viewer)
->setRenderAsForm(true));
if ($show_color) {
$highlight_text = pht('Disable Highlighting');
$highlight_icon = 'highlight-grey';
@ -406,12 +410,10 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
->setIcon('file'));
}
$view->addAction($this->createEditAction());
return $view;
}
private function createEditAction() {
private function createEditButton() {
$request = $this->getRequest();
$user = $request->getUser();
@ -424,14 +426,17 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$callsign = $repository->getCallsign();
$editor_link = $user->loadEditorLink($path, $line, $callsign);
$action = id(new PhabricatorActionView())
->setName(pht('Open in Editor'))
->setIcon('edit');
$icon_edit = id(new PHUIIconView())
->setSpriteSheet(PHUIIconView::SPRITE_ICONS)
->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);
$action->setDisabled(!$editor_link);
return $action;
return $button;
}
private function buildDisplayRows(

View file

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