1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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' =>
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',
'requires' =>
array(

View file

@ -9,153 +9,145 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$this->phid);
$file = id(new PhabricatorFileQuery())
->setViewer($user)
->withPHIDs(array($this->phid))
->executeOne();
if (!$file) {
return new Aphront404Response();
}
$author_child = null;
if ($file->getAuthorPHID()) {
$author = id(new PhabricatorUser())->loadOneWhere(
'phid = %s',
$file->getAuthorPHID());
$this->loadHandles(array($file->getAuthorPHID()));
if ($author) {
$author_child = id(new AphrontFormStaticControl())
->setLabel('Author')
->setName('author')
->setValue($author->getUserName());
}
$phid = $file->getPHID();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
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()) {
$submit->setValue('View File');
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('View File'))
->setIcon('preview')
->setHref($file->getViewURI()));
} 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()) ||
($user->getIsAdmin())) {
$submit->addCancelButton(
'/file/delete/'.$file->getID().'/',
'Delete File');
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Delete File'))
->setIcon('delete')
->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);
$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));
$view = id(new PhabricatorPropertyListView());
$panel = new AphrontPanelView();
$panel->setHeader('File Info - '.$file->getName());
if ($file->getAuthorPHID()) {
$view->addProperty(
pht('Author'),
$this->getHandle($file->getAuthorPHID())->renderLink());
}
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$view->addProperty(
pht('Created'),
phabricator_datetime($file->getDateCreated(), $user));
$xform_panel = null;
$view->addProperty(
pht('Size'),
phabricator_format_bytes($file->getByteSize()));
$transformations = id(new PhabricatorTransformedFile())->loadAllWhere(
'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');
$view->addSectionHeader(pht('Technical Details'));
$rows = array();
foreach ($transformations as $transformed) {
$phid = $transformed->getTransformedPHID();
$rows[] = array(
phutil_escape_html($transformed->getTransform()),
phutil_render_tag(
$view->addProperty(
pht('Mime Type'),
phutil_escape_html($file->getMimeType()));
$view->addProperty(
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',
array(
'href' => $transformed_map[$phid]->getBestURI(),
'href' => $file->getViewURI(),
),
$phid));
$image);
$view->addTextContent($linked_image);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Transform',
'File',
));
$xform_panel = new AphrontPanelView();
$xform_panel->appendChild($table);
$xform_panel->setWidth(AphrontPanelView::WIDTH_FORM);
$xform_panel->setHeader('Transformations');
return $view;
}
return $this->buildStandardPageResponse(
array($panel, $xform_panel),
array(
'title' => 'File Info - '.$file->getName(),
));
}
}

View file

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