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

Modernize file detail view

Summary:
Use modern elements for file detail view.

For the "Technical Details", maybe we should implement a disclosure triangle element? I'd guess there are other cases we could use it.

This makes two small practical changes:

  - We show "Delete File" even if you can't delete it; I'm going to align this properly with CAN_EDIT shortly.
  - We no longer show the feature discovery hint about using "arc download".

Test Plan:
{F27179}
{F27180}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4199
This commit is contained in:
epriestley 2012-12-16 16:33:24 -08:00
parent 6f0c87269b
commit c65468371f
3 changed files with 133 additions and 135 deletions

View file

@ -2753,7 +2753,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-property-list-view-css' => 'phabricator-property-list-view-css' =>
array( array(
'uri' => '/res/90ed3b02/rsrc/css/layout/phabricator-property-list-view.css', 'uri' => '/res/9f4d6640/rsrc/css/layout/phabricator-property-list-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -9,153 +9,145 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
} }
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$file = id(new PhabricatorFile())->loadOneWhere( $file = id(new PhabricatorFileQuery())
'phid = %s', ->setViewer($user)
$this->phid); ->withPHIDs(array($this->phid))
->executeOne();
if (!$file) { if (!$file) {
return new Aphront404Response(); return new Aphront404Response();
} }
$author_child = null; $this->loadHandles(array($file->getAuthorPHID()));
if ($file->getAuthorPHID()) {
$author = id(new PhabricatorUser())->loadOneWhere(
'phid = %s',
$file->getAuthorPHID());
if ($author) { $phid = $file->getPHID();
$author_child = id(new AphrontFormStaticControl())
->setLabel('Author') $crumbs = $this->buildApplicationCrumbs();
->setName('author') $crumbs->addCrumb(
->setValue($author->getUserName()); id(new PhabricatorCrumbView())
} ->setName('F'.$file->getID())
->setHref($this->getApplicationURI("/info/{$phid}/")));
$header = id(new PhabricatorHeaderView())
->setObjectName('F'.$file->getID())
->setHeader($file->getName());
$actions = $this->buildActionView($file);
$properties = $this->buildPropertyView($file);
return $this->buildApplicationPage(
array(
$crumbs,
$header,
$actions,
$properties,
),
array(
'title' => $file->getName(),
'device' => true,
));
} }
$form = new AphrontFormView(); private function buildActionView(PhabricatorFile $file) {
$request = $this->getRequest();
$user = $request->getUser();
$submit = new AphrontFormSubmitControl(); $id = $file->getID();
$view = id(new PhabricatorActionListView())
->setUser($user)
->setObject($file);
$form->setAction($file->getViewURI());
if ($file->isViewableInBrowser()) { if ($file->isViewableInBrowser()) {
$submit->setValue('View File'); $view->addAction(
id(new PhabricatorActionView())
->setName(pht('View File'))
->setIcon('preview')
->setHref($file->getViewURI()));
} else { } else {
$submit->setValue('Download File'); $view->addAction(
id(new PhabricatorActionView())
->setUser($user)
->setRenderAsForm(true)
->setName(pht('Download File'))
->setIcon('download')
->setHref($file->getViewURI()));
} }
if (($user->getPHID() == $file->getAuthorPHID()) || $view->addAction(
($user->getIsAdmin())) { id(new PhabricatorActionView())
$submit->addCancelButton( ->setName(pht('Delete File'))
'/file/delete/'.$file->getID().'/', ->setIcon('delete')
'Delete File'); ->setHref($this->getApplicationURI("/delete/{$id}/"))
->setWorkflow(true));
return $view;
} }
$file_id = 'F'.$file->getID(); private function buildPropertyView(PhabricatorFile $file) {
$request = $this->getRequest();
$user = $request->getUser();
$form->setUser($user); $view = id(new PhabricatorPropertyListView());
$form
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Name')
->setName('name')
->setValue($file->getName()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setName('id')
->setValue($file_id)
->setCaption(
'Download this file with: <tt>arc download '.
phutil_escape_html($file_id).'</tt>'))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('PHID')
->setName('phid')
->setValue($file->getPHID()))
->appendChild($author_child)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Created')
->setName('created')
->setValue(phabricator_datetime($file->getDateCreated(), $user)))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Mime Type')
->setName('mime')
->setValue($file->getMimeType()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Size')
->setName('size')
->setValue($file->getByteSize().' bytes'))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Engine')
->setName('storageEngine')
->setValue($file->getStorageEngine()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Format')
->setName('storageFormat')
->setValue($file->getStorageFormat()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Handle')
->setName('storageHandle')
->setValue($file->getStorageHandle()))
->appendChild(
id($submit));
$panel = new AphrontPanelView(); if ($file->getAuthorPHID()) {
$panel->setHeader('File Info - '.$file->getName()); $view->addProperty(
pht('Author'),
$this->getHandle($file->getAuthorPHID())->renderLink());
}
$panel->appendChild($form); $view->addProperty(
$panel->setWidth(AphrontPanelView::WIDTH_FORM); pht('Created'),
phabricator_datetime($file->getDateCreated(), $user));
$xform_panel = null; $view->addProperty(
pht('Size'),
phabricator_format_bytes($file->getByteSize()));
$transformations = id(new PhabricatorTransformedFile())->loadAllWhere( $view->addSectionHeader(pht('Technical Details'));
'originalPHID = %s',
$file->getPHID());
if ($transformations) {
$transformed_phids = mpull($transformations, 'getTransformedPHID');
$transformed_files = id(new PhabricatorFile())->loadAllWhere(
'phid in (%Ls)',
$transformed_phids);
$transformed_map = mpull($transformed_files, null, 'getPHID');
$rows = array(); $view->addProperty(
foreach ($transformations as $transformed) { pht('Mime Type'),
$phid = $transformed->getTransformedPHID(); phutil_escape_html($file->getMimeType()));
$rows[] = array(
phutil_escape_html($transformed->getTransform()), $view->addProperty(
phutil_render_tag( pht('Engine'),
phutil_escape_html($file->getStorageEngine()));
$view->addProperty(
pht('Format'),
phutil_escape_html($file->getStorageFormat()));
$view->addProperty(
pht('Handle'),
phutil_escape_html($file->getStorageHandle()));
if ($file->isViewableInBrowser()) {
// TODO: Clean this up after Pholio (dark backgrounds, standardization,
// etc.)
$image = phutil_render_tag(
'img',
array(
'src' => $file->getViewURI(),
'class' => 'phabricator-property-list-image',
));
$linked_image = phutil_render_tag(
'a', 'a',
array( array(
'href' => $transformed_map[$phid]->getBestURI(), 'href' => $file->getViewURI(),
), ),
$phid)); $image);
$view->addTextContent($linked_image);
} }
$table = new AphrontTableView($rows); return $view;
$table->setHeaders(
array(
'Transform',
'File',
));
$xform_panel = new AphrontPanelView();
$xform_panel->appendChild($table);
$xform_panel->setWidth(AphrontPanelView::WIDTH_FORM);
$xform_panel->setHeader('Transformations');
} }
return $this->buildStandardPageResponse(
array($panel, $xform_panel),
array(
'title' => 'File Info - '.$file->getName(),
));
}
} }

View file

@ -106,3 +106,9 @@
+ .phabricator-property-list-view { + .phabricator-property-list-view {
margin-top: 0px; margin-top: 0px;
} }
.phabricator-property-list-image {
margin: auto;
max-width: 95%;
}