@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.

Pholio - finish off history view

Summary:
...bsasically add a "view mode" and play with that throughout the stack. Differences are...

- normal mode has comments; history mode does not
- normal mode has inline comments; history mode does not
- page uris are correct with respect to either mode

...and that's about it. I played around (wasted too much time) trying to make this cuter. I think just jamming this mode in here is the easiest / cleanest thing at the end. Feel free to tell me otherwise!

This largely gets even better via T3612. However, this fixes T3572.

Test Plan: played around with a mock with some history. noted correct uris on images. noted no errors in js console.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3572

Differential Revision: https://secure.phabricator.com/D6638

+54 -20
+4 -4
src/applications/pholio/controller/PholioImageHistoryController.php
··· 27 27 // note while we have a mock object, its missing images we need to show 28 28 // the history of what's happened here. 29 29 // fetch the real deal 30 - // 30 + 31 31 $mock = id(new PholioMockQuery()) 32 32 ->setViewer($user) 33 33 ->needImages(true) ··· 44 44 45 45 46 46 $images = $mock->getImageHistorySet($this->imageID); 47 - // TODO - this is a hack until we specialize the view object 48 47 $mock->attachImages($images); 49 48 $latest_image = last($images); 50 49 ··· 59 58 require_celerity_resource('pholio-css'); 60 59 require_celerity_resource('pholio-inline-comments-css'); 61 60 62 - $comment_form_id = celerity_generate_unique_node_id(); 61 + $comment_form_id = null; 63 62 $output = id(new PholioMockImagesView()) 64 63 ->setRequestURI($request->getRequestURI()) 65 64 ->setCommentFormID($comment_form_id) 66 65 ->setUser($user) 67 66 ->setMock($mock) 68 - ->setImageID($this->imageID); 67 + ->setImageID($this->imageID) 68 + ->setViewMode('history'); 69 69 70 70 $crumbs = $this->buildApplicationCrumbs(); 71 71 $crumbs
+31 -5
src/applications/pholio/view/PholioMockImagesView.php
··· 9 9 private $imageID; 10 10 private $requestURI; 11 11 private $commentFormID; 12 + private $viewMode = 'normal'; 13 + 14 + /** 15 + * Supports normal (/MX, /MX/Y/) and history (/pholio/image/history/Y/) 16 + * modes. The former has handy dandy commenting functionality and the 17 + * latter does not. 18 + */ 19 + public function setViewMode($view_mode) { 20 + $this->viewMode = $view_mode; 21 + return $this; 22 + } 23 + public function getViewMode() { 24 + return $this->viewMode; 25 + } 12 26 13 27 public function setCommentFormID($comment_form_id) { 14 28 $this->commentFormID = $comment_form_id; ··· 66 80 $x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH); 67 81 $y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT); 68 82 83 + $history_uri = '/pholio/image/history/'.$image->getID().'/'; 69 84 $images[] = array( 70 85 'id' => $image->getID(), 71 - 'fullURI' => $image->getFile()->getBestURI(), 72 - 'pageURI' => '/M'.$mock->getID().'/'.$image->getID().'/', 73 - 'historyURI' => '/pholio/image/history/'.$image->getID().'/', 86 + 'fullURI' => $file->getBestURI(), 87 + 'pageURI' => $this->getImagePageURI($image, $mock), 88 + 'historyURI' => $history_uri, 74 89 'width' => $x, 75 90 'height' => $y, 76 91 'title' => $image->getName(), 77 92 'desc' => $image->getDescription(), 93 + 'isObsolete' => (bool) $image->getIsObsolete(), 78 94 ); 79 95 } 80 96 ··· 88 104 'images' => $images, 89 105 'selectedID' => $selected_id, 90 106 'loggedIn' => $this->getUser()->isLoggedIn(), 91 - 'logInLink' => (string) $login_uri 107 + 'logInLink' => (string) $login_uri, 108 + 'viewMode' => $this->getViewMode() 92 109 ); 93 110 Javelin::initBehavior('pholio-mock-view', $config); 94 111 ··· 146 163 array( 147 164 'sigil' => 'mock-thumbnail', 148 165 'class' => 'pholio-mock-carousel-thumb-item', 149 - 'href' => '/M'.$mock->getID().'/'.$image->getID().'/', 166 + 'href' => $this->getImagePageURI($image, $mock), 150 167 'meta' => array( 151 168 'imageID' => $image->getID(), 152 169 ), ··· 172 189 array($mock_wrapper, $carousel_holder, $inline_comments_holder)); 173 190 174 191 return $mockview; 192 + } 193 + 194 + private function getImagePageURI(PholioImage $image, PholioMock $mock) { 195 + if ($this->getViewMode() == 'normal') { 196 + $uri = '/M'.$mock->getID().'/'.$image->getID().'/'; 197 + } else { 198 + $uri = '/pholio/image/history/'.$image->getID().'/'; 199 + } 200 + return $uri; 175 201 } 176 202 }
+19 -11
webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js
··· 264 264 return; 265 265 } 266 266 267 + if (config.viewMode == 'history') { 268 + return; 269 + } 270 + 267 271 if (drag_begin) { 268 272 return; 269 273 } ··· 631 635 } 632 636 633 637 load_inline_comments(); 634 - if (config.loggedIn) { 638 + if (config.loggedIn && config.commentFormID) { 635 639 JX.DOM.invoke(JX.$(config.commentFormID), 'shouldRefresh'); 636 640 } 637 641 ··· 683 687 image.desc); 684 688 info.push(desc); 685 689 686 - var embed = JX.$N( 687 - 'div', 688 - {className: 'pholio-image-embedding'}, 689 - JX.$H('Embed this image:<br />{M' + config.mockID + 690 + if (!image.isObsolete) { 691 + var embed = JX.$N( 692 + 'div', 693 + {className: 'pholio-image-embedding'}, 694 + JX.$H('Embed this image:<br />{M' + config.mockID + 690 695 ', image=' + image.id + '}')); 691 - info.push(embed); 696 + info.push(embed); 697 + } 692 698 693 699 // Render image dimensions and visible size. If we have this infomation 694 700 // from the server we can display some of it immediately; otherwise, we need ··· 728 734 'View Full Image'); 729 735 info.push(full_link); 730 736 731 - var history_link = JX.$N( 732 - 'a', 733 - { href: image.historyURI }, 734 - 'View Image History'); 735 - info.push(history_link); 737 + if (config.viewMode != 'history') { 738 + var history_link = JX.$N( 739 + 'a', 740 + { href: image.historyURI }, 741 + 'View Image History'); 742 + info.push(history_link); 743 + } 736 744 737 745 738 746 for (var ii = 0; ii < info.length; ii++) {