@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+118 -120
+1 -1
src/__celerity_resource_map__.php
··· 2753 2753 ), 2754 2754 'phabricator-property-list-view-css' => 2755 2755 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', 2757 2757 'type' => 'css', 2758 2758 'requires' => 2759 2759 array(
+111 -119
src/applications/files/controller/PhabricatorFileInfoController.php
··· 9 9 } 10 10 11 11 public function processRequest() { 12 - 13 12 $request = $this->getRequest(); 14 13 $user = $request->getUser(); 15 14 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 + 19 20 if (!$file) { 20 21 return new Aphront404Response(); 21 22 } 22 23 23 - $author_child = null; 24 - if ($file->getAuthorPHID()) { 25 - $author = id(new PhabricatorUser())->loadOneWhere( 26 - 'phid = %s', 27 - $file->getAuthorPHID()); 24 + $this->loadHandles(array($file->getAuthorPHID())); 28 25 29 - if ($author) { 30 - $author_child = id(new AphrontFormStaticControl()) 31 - ->setLabel('Author') 32 - ->setName('author') 33 - ->setValue($author->getUserName()); 34 - } 35 - } 26 + $phid = $file->getPHID(); 36 27 37 - $form = new AphrontFormView(); 28 + $crumbs = $this->buildApplicationCrumbs(); 29 + $crumbs->addCrumb( 30 + id(new PhabricatorCrumbView()) 31 + ->setName('F'.$file->getID()) 32 + ->setHref($this->getApplicationURI("/info/{$phid}/"))); 38 33 39 - $submit = new AphrontFormSubmitControl(); 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(); 57 + 58 + $id = $file->getID(); 59 + 60 + $view = id(new PhabricatorActionListView()) 61 + ->setUser($user) 62 + ->setObject($file); 40 63 41 - $form->setAction($file->getViewURI()); 42 64 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())); 44 70 } 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())); 46 78 } 47 79 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()); 53 100 } 54 101 55 - $file_id = 'F'.$file->getID(); 102 + $view->addProperty( 103 + pht('Created'), 104 + phabricator_datetime($file->getDateCreated(), $user)); 56 105 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)); 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())); 110 115 111 - $panel = new AphrontPanelView(); 112 - $panel->setHeader('File Info - '.$file->getName()); 116 + $view->addProperty( 117 + pht('Engine'), 118 + phutil_escape_html($file->getStorageEngine())); 113 119 114 - $panel->appendChild($form); 115 - $panel->setWidth(AphrontPanelView::WIDTH_FORM); 120 + $view->addProperty( 121 + pht('Format'), 122 + phutil_escape_html($file->getStorageFormat())); 116 123 117 - $xform_panel = null; 124 + $view->addProperty( 125 + pht('Handle'), 126 + phutil_escape_html($file->getStorageHandle())); 118 127 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 + if ($file->isViewableInBrowser()) { 128 129 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 - } 130 + // TODO: Clean this up after Pholio (dark backgrounds, standardization, 131 + // etc.) 141 132 142 - $table = new AphrontTableView($rows); 143 - $table->setHeaders( 133 + $image = phutil_render_tag( 134 + 'img', 144 135 array( 145 - 'Transform', 146 - 'File', 136 + 'src' => $file->getViewURI(), 137 + 'class' => 'phabricator-property-list-image', 147 138 )); 148 139 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); 153 148 } 154 149 155 - return $this->buildStandardPageResponse( 156 - array($panel, $xform_panel), 157 - array( 158 - 'title' => 'File Info - '.$file->getName(), 159 - )); 150 + return $view; 160 151 } 152 + 161 153 }
+6
webroot/rsrc/css/layout/phabricator-property-list-view.css
··· 106 106 + .phabricator-property-list-view { 107 107 margin-top: 0px; 108 108 } 109 + 110 + 111 + .phabricator-property-list-image { 112 + margin: auto; 113 + max-width: 95%; 114 + }