1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Move raw file download icon to file box in Diffusion

Summary: For images and text, show the "Raw" buttons on the file's ObjectBox

Test Plan: View an image and a text file in Diffusion, click on the download link in each.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4467

Differential Revision: https://secure.phabricator.com/D8302
This commit is contained in:
Chad Little 2014-02-21 15:21:38 -08:00
parent d94c33b61a
commit 8662b27f89

View file

@ -104,8 +104,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$view, $view,
$drequest, $drequest,
$show_blame, $show_blame,
$show_color, $show_color);
$binary_uri);
$properties = $this->buildPropertyView($drequest, $action_list); $properties = $this->buildPropertyView($drequest, $action_list);
$object_box = id(new PHUIObjectBoxView()) $object_box = id(new PHUIObjectBoxView())
@ -304,10 +303,12 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
Javelin::initBehavior('load-blame', array('id' => $id)); Javelin::initBehavior('load-blame', array('id' => $id));
} }
$button = $this->createEditButton(); $edit = $this->renderEditButton();
$file = $this->renderFileButton();
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader(pht('File Contents')) ->setHeader(pht('File Contents'))
->addActionLink($button); ->addActionLink($edit)
->addActionLink($file);
$corpus = id(new PHUIObjectBoxView()) $corpus = id(new PHUIObjectBoxView())
->setHeader($header) ->setHeader($header)
@ -320,8 +321,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
PhabricatorActionListView $view, PhabricatorActionListView $view,
DiffusionRequest $drequest, DiffusionRequest $drequest,
$show_blame, $show_blame,
$show_color, $show_color) {
$binary_uri) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
$base_uri = $this->getRequest()->getRequestURI(); $base_uri = $this->getRequest()->getRequestURI();
@ -396,24 +396,10 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
->setIcon('warning') ->setIcon('warning')
->setDisabled(!$href)); ->setDisabled(!$href));
if ($binary_uri) {
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Download Raw File'))
->setHref($binary_uri)
->setIcon('download'));
} else {
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('View Raw File'))
->setHref($base_uri->alter('view', 'raw'))
->setIcon('file'));
}
return $view; return $view;
} }
private function createEditButton() { private function renderEditButton() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
@ -439,6 +425,33 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
return $button; return $button;
} }
private function renderFileButton($file_uri = null) {
$base_uri = $this->getRequest()->getRequestURI();
if ($file_uri) {
$text = pht('Download Raw File');
$href = $file_uri;
$icon = 'download';
} else {
$text = pht('View Raw File');
$href = $base_uri->alter('view', 'raw');
$icon = 'file';
}
$iconview = id(new PHUIIconView())
->setSpriteSheet(PHUIIconView::SPRITE_ICONS)
->setSpriteIcon($icon);
$button = id(new PHUIButtonView())
->setTag('a')
->setText($text)
->setHref($href)
->setIcon($iconview);
return $button;
}
private function buildDisplayRows( private function buildDisplayRows(
array $text_list, array $text_list,
array $rev_list, array $rev_list,
@ -847,8 +860,13 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
'src' => $file_uri, 'src' => $file_uri,
))); )));
$file = $this->renderFileButton($file_uri);
$header = id(new PHUIHeaderView())
->setHeader(pht('Image'))
->addActionLink($file);
return id(new PHUIObjectBoxView()) return id(new PHUIObjectBoxView())
->setHeaderText(pht('Image')) ->setHeader($header)
->addPropertyList($properties); ->addPropertyList($properties);
} }