Skip to content

Commit c654683

Browse files
author
epriestley
committed
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
1 parent 6f0c872 commit c654683

File tree

3 files changed

+126
-128
lines changed

3 files changed

+126
-128
lines changed

src/__celerity_resource_map__.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@
27532753
),
27542754
'phabricator-property-list-view-css' =>
27552755
array(
2756-
'uri' => '/res/90ed3b02/rsrc/css/layout/phabricator-property-list-view.css',
2756+
'uri' => '/res/9f4d6640/rsrc/css/layout/phabricator-property-list-view.css',
27572757
'type' => 'css',
27582758
'requires' =>
27592759
array(

src/applications/files/controller/PhabricatorFileInfoController.php

Lines changed: 119 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -9,153 +9,145 @@ public function willProcessRequest(array $data) {
99
}
1010

1111
public function processRequest() {
12-
1312
$request = $this->getRequest();
1413
$user = $request->getUser();
1514

16-
$file = id(new PhabricatorFile())->loadOneWhere(
17-
'phid = %s',
18-
$this->phid);
15+
$file = id(new PhabricatorFileQuery())
16+
->setViewer($user)
17+
->withPHIDs(array($this->phid))
18+
->executeOne();
19+
1920
if (!$file) {
2021
return new Aphront404Response();
2122
}
2223

23-
$author_child = null;
24-
if ($file->getAuthorPHID()) {
25-
$author = id(new PhabricatorUser())->loadOneWhere(
26-
'phid = %s',
27-
$file->getAuthorPHID());
28-
29-
if ($author) {
30-
$author_child = id(new AphrontFormStaticControl())
31-
->setLabel('Author')
32-
->setName('author')
33-
->setValue($author->getUserName());
34-
}
35-
}
24+
$this->loadHandles(array($file->getAuthorPHID()));
25+
26+
$phid = $file->getPHID();
27+
28+
$crumbs = $this->buildApplicationCrumbs();
29+
$crumbs->addCrumb(
30+
id(new PhabricatorCrumbView())
31+
->setName('F'.$file->getID())
32+
->setHref($this->getApplicationURI("/info/{$phid}/")));
33+
34+
$header = id(new PhabricatorHeaderView())
35+
->setObjectName('F'.$file->getID())
36+
->setHeader($file->getName());
37+
38+
$actions = $this->buildActionView($file);
39+
$properties = $this->buildPropertyView($file);
40+
41+
return $this->buildApplicationPage(
42+
array(
43+
$crumbs,
44+
$header,
45+
$actions,
46+
$properties,
47+
),
48+
array(
49+
'title' => $file->getName(),
50+
'device' => true,
51+
));
52+
}
53+
54+
private function buildActionView(PhabricatorFile $file) {
55+
$request = $this->getRequest();
56+
$user = $request->getUser();
3657

37-
$form = new AphrontFormView();
58+
$id = $file->getID();
3859

39-
$submit = new AphrontFormSubmitControl();
60+
$view = id(new PhabricatorActionListView())
61+
->setUser($user)
62+
->setObject($file);
4063

41-
$form->setAction($file->getViewURI());
4264
if ($file->isViewableInBrowser()) {
43-
$submit->setValue('View File');
65+
$view->addAction(
66+
id(new PhabricatorActionView())
67+
->setName(pht('View File'))
68+
->setIcon('preview')
69+
->setHref($file->getViewURI()));
4470
} else {
45-
$submit->setValue('Download File');
71+
$view->addAction(
72+
id(new PhabricatorActionView())
73+
->setUser($user)
74+
->setRenderAsForm(true)
75+
->setName(pht('Download File'))
76+
->setIcon('download')
77+
->setHref($file->getViewURI()));
4678
}
4779

48-
if (($user->getPHID() == $file->getAuthorPHID()) ||
49-
($user->getIsAdmin())) {
50-
$submit->addCancelButton(
51-
'/file/delete/'.$file->getID().'/',
52-
'Delete File');
80+
$view->addAction(
81+
id(new PhabricatorActionView())
82+
->setName(pht('Delete File'))
83+
->setIcon('delete')
84+
->setHref($this->getApplicationURI("/delete/{$id}/"))
85+
->setWorkflow(true));
86+
87+
return $view;
88+
}
89+
90+
private function buildPropertyView(PhabricatorFile $file) {
91+
$request = $this->getRequest();
92+
$user = $request->getUser();
93+
94+
$view = id(new PhabricatorPropertyListView());
95+
96+
if ($file->getAuthorPHID()) {
97+
$view->addProperty(
98+
pht('Author'),
99+
$this->getHandle($file->getAuthorPHID())->renderLink());
53100
}
54101

55-
$file_id = 'F'.$file->getID();
56-
57-
$form->setUser($user);
58-
$form
59-
->appendChild(
60-
id(new AphrontFormStaticControl())
61-
->setLabel('Name')
62-
->setName('name')
63-
->setValue($file->getName()))
64-
->appendChild(
65-
id(new AphrontFormStaticControl())
66-
->setLabel('ID')
67-
->setName('id')
68-
->setValue($file_id)
69-
->setCaption(
70-
'Download this file with: <tt>arc download '.
71-
phutil_escape_html($file_id).'</tt>'))
72-
->appendChild(
73-
id(new AphrontFormStaticControl())
74-
->setLabel('PHID')
75-
->setName('phid')
76-
->setValue($file->getPHID()))
77-
->appendChild($author_child)
78-
->appendChild(
79-
id(new AphrontFormStaticControl())
80-
->setLabel('Created')
81-
->setName('created')
82-
->setValue(phabricator_datetime($file->getDateCreated(), $user)))
83-
->appendChild(
84-
id(new AphrontFormStaticControl())
85-
->setLabel('Mime Type')
86-
->setName('mime')
87-
->setValue($file->getMimeType()))
88-
->appendChild(
89-
id(new AphrontFormStaticControl())
90-
->setLabel('Size')
91-
->setName('size')
92-
->setValue($file->getByteSize().' bytes'))
93-
->appendChild(
94-
id(new AphrontFormStaticControl())
95-
->setLabel('Engine')
96-
->setName('storageEngine')
97-
->setValue($file->getStorageEngine()))
98-
->appendChild(
99-
id(new AphrontFormStaticControl())
100-
->setLabel('Format')
101-
->setName('storageFormat')
102-
->setValue($file->getStorageFormat()))
103-
->appendChild(
104-
id(new AphrontFormStaticControl())
105-
->setLabel('Handle')
106-
->setName('storageHandle')
107-
->setValue($file->getStorageHandle()))
108-
->appendChild(
109-
id($submit));
110-
111-
$panel = new AphrontPanelView();
112-
$panel->setHeader('File Info - '.$file->getName());
113-
114-
$panel->appendChild($form);
115-
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
116-
117-
$xform_panel = null;
118-
119-
$transformations = id(new PhabricatorTransformedFile())->loadAllWhere(
120-
'originalPHID = %s',
121-
$file->getPHID());
122-
if ($transformations) {
123-
$transformed_phids = mpull($transformations, 'getTransformedPHID');
124-
$transformed_files = id(new PhabricatorFile())->loadAllWhere(
125-
'phid in (%Ls)',
126-
$transformed_phids);
127-
$transformed_map = mpull($transformed_files, null, 'getPHID');
128-
129-
$rows = array();
130-
foreach ($transformations as $transformed) {
131-
$phid = $transformed->getTransformedPHID();
132-
$rows[] = array(
133-
phutil_escape_html($transformed->getTransform()),
134-
phutil_render_tag(
135-
'a',
136-
array(
137-
'href' => $transformed_map[$phid]->getBestURI(),
138-
),
139-
$phid));
140-
}
141-
142-
$table = new AphrontTableView($rows);
143-
$table->setHeaders(
102+
$view->addProperty(
103+
pht('Created'),
104+
phabricator_datetime($file->getDateCreated(), $user));
105+
106+
$view->addProperty(
107+
pht('Size'),
108+
phabricator_format_bytes($file->getByteSize()));
109+
110+
$view->addSectionHeader(pht('Technical Details'));
111+
112+
$view->addProperty(
113+
pht('Mime Type'),
114+
phutil_escape_html($file->getMimeType()));
115+
116+
$view->addProperty(
117+
pht('Engine'),
118+
phutil_escape_html($file->getStorageEngine()));
119+
120+
$view->addProperty(
121+
pht('Format'),
122+
phutil_escape_html($file->getStorageFormat()));
123+
124+
$view->addProperty(
125+
pht('Handle'),
126+
phutil_escape_html($file->getStorageHandle()));
127+
128+
if ($file->isViewableInBrowser()) {
129+
130+
// TODO: Clean this up after Pholio (dark backgrounds, standardization,
131+
// etc.)
132+
133+
$image = phutil_render_tag(
134+
'img',
144135
array(
145-
'Transform',
146-
'File',
136+
'src' => $file->getViewURI(),
137+
'class' => 'phabricator-property-list-image',
147138
));
148139

149-
$xform_panel = new AphrontPanelView();
150-
$xform_panel->appendChild($table);
151-
$xform_panel->setWidth(AphrontPanelView::WIDTH_FORM);
152-
$xform_panel->setHeader('Transformations');
140+
$linked_image = phutil_render_tag(
141+
'a',
142+
array(
143+
'href' => $file->getViewURI(),
144+
),
145+
$image);
146+
147+
$view->addTextContent($linked_image);
153148
}
154149

155-
return $this->buildStandardPageResponse(
156-
array($panel, $xform_panel),
157-
array(
158-
'title' => 'File Info - '.$file->getName(),
159-
));
150+
return $view;
160151
}
152+
161153
}

webroot/rsrc/css/layout/phabricator-property-list-view.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,9 @@
106106
+ .phabricator-property-list-view {
107107
margin-top: 0px;
108108
}
109+
110+
111+
.phabricator-property-list-image {
112+
margin: auto;
113+
max-width: 95%;
114+
}

0 commit comments

Comments
 (0)