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

Add a UI element for navigating between versions of a Phriction document

Summary: Depends on D19621. Ref T13077. Fixes T4815. This adds previous/current/next/draft buttons and makes navigation between unpublished and published versions of a document more clear.

Test Plan: {F5841997}

Reviewers: amckinley

Maniphest Tasks: T13077, T4815

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

+147 -21
+2 -2
resources/celerity/map.php
··· 148 148 'rsrc/css/phui/phui-curtain-view.css' => '2bdaf026', 149 149 'rsrc/css/phui/phui-document-pro.css' => '0e41dd91', 150 150 'rsrc/css/phui/phui-document-summary.css' => '9ca48bdf', 151 - 'rsrc/css/phui/phui-document.css' => '552493fa', 151 + 'rsrc/css/phui/phui-document.css' => 'c4ac41f9', 152 152 'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9', 153 153 'rsrc/css/phui/phui-fontkit.css' => '1320ed01', 154 154 'rsrc/css/phui/phui-form-view.css' => 'f808e5be', ··· 813 813 'phui-crumbs-view-css' => '10728aaa', 814 814 'phui-curtain-view-css' => '2bdaf026', 815 815 'phui-document-summary-view-css' => '9ca48bdf', 816 - 'phui-document-view-css' => '552493fa', 816 + 'phui-document-view-css' => 'c4ac41f9', 817 817 'phui-document-view-pro-css' => '0e41dd91', 818 818 'phui-feed-story-css' => '44a9c8e9', 819 819 'phui-font-icon-base-css' => '870a7360',
+139 -19
src/applications/phriction/controller/PhrictionDocumentController.php
··· 20 20 return id(new AphrontRedirectResponse())->setURI($uri); 21 21 } 22 22 23 - require_celerity_resource('phriction-document-css'); 24 - 25 23 $version_note = null; 26 24 $core_content = ''; 27 25 $move_notice = ''; 28 26 $properties = null; 29 27 $content = null; 30 28 $toc = null; 29 + 30 + $is_draft = false; 31 31 32 32 $document = id(new PhrictionDocumentQuery()) 33 33 ->setViewer($viewer) ··· 66 66 ->addAction($create_button); 67 67 68 68 } else { 69 - $version = $request->getInt('v'); 69 + $draft_content = id(new PhrictionContentQuery()) 70 + ->setViewer($viewer) 71 + ->withDocumentPHIDs(array($document->getPHID())) 72 + ->setLimit(1) 73 + ->executeOne(); 74 + $max_version = (int)$draft_content->getVersion(); 70 75 76 + $version = $request->getInt('v'); 71 77 if ($version) { 72 78 $content = id(new PhrictionContentQuery()) 73 79 ->setViewer($viewer) ··· 78 84 return new Aphront404Response(); 79 85 } 80 86 81 - if ($content->getPHID() != $document->getContentPHID()) { 82 - $version_note = id(new PHUIInfoView()) 83 - ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 84 - ->appendChild( 85 - pht( 86 - 'You are viewing an older version of this document, as it '. 87 - 'appeared on %s.', 88 - phabricator_datetime($content->getDateCreated(), $viewer))); 87 + // When the "v" parameter exists, the user is in history mode so we 88 + // show this header even if they're looking at the current version 89 + // of the document. This keeps the next/previous links working. 90 + 91 + $view_version = (int)$content->getVersion(); 92 + $published_version = (int)$document->getContent()->getVersion(); 93 + 94 + if ($view_version < $published_version) { 95 + $version_note = pht( 96 + 'You are viewing an older version of this document, as it '. 97 + 'appeared on %s.', 98 + phabricator_datetime($content->getDateCreated(), $viewer)); 99 + } else if ($view_version > $published_version) { 100 + $is_draft = true; 101 + $version_note = pht( 102 + 'You are viewing an unpublished draft of this document.'); 103 + } else { 104 + $version_note = pht( 105 + 'You are viewing the current published version of this document.'); 106 + } 107 + 108 + $version_note = array( 109 + phutil_tag( 110 + 'strong', 111 + array(), 112 + pht('Version %d of %d: ', $view_version, $max_version)), 113 + ' ', 114 + $version_note, 115 + ); 116 + 117 + $version_note = id(new PHUIInfoView()) 118 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 119 + ->appendChild($version_note); 120 + 121 + $document_uri = new PhutilURI($document->getURI()); 122 + 123 + if ($view_version > 1) { 124 + $previous_uri = $document_uri->alter('v', ($view_version - 1)); 125 + } else { 126 + $previous_uri = null; 127 + } 128 + 129 + if ($view_version !== $published_version) { 130 + $current_uri = $document_uri->alter('v', $published_version); 131 + } else { 132 + $current_uri = null; 133 + } 134 + 135 + if ($view_version < $max_version) { 136 + $next_uri = $document_uri->alter('v', ($view_version + 1)); 137 + } else { 138 + $next_uri = null; 139 + } 140 + 141 + if ($view_version !== $max_version) { 142 + $draft_uri = $document_uri->alter('v', $max_version); 143 + } else { 144 + $draft_uri = null; 89 145 } 146 + 147 + $button_bar = id(new PHUIButtonBarView()) 148 + ->addButton( 149 + id(new PHUIButtonView()) 150 + ->setTag('a') 151 + ->setColor('grey') 152 + ->setIcon('fa-backward') 153 + ->setDisabled(!$previous_uri) 154 + ->setHref($previous_uri) 155 + ->setText(pht('Previous'))) 156 + ->addButton( 157 + id(new PHUIButtonView()) 158 + ->setTag('a') 159 + ->setColor('grey') 160 + ->setIcon('fa-file-o') 161 + ->setDisabled(!$current_uri) 162 + ->setHref($current_uri) 163 + ->setText(pht('Published'))) 164 + ->addButton( 165 + id(new PHUIButtonView()) 166 + ->setTag('a') 167 + ->setColor('grey') 168 + ->setIcon('fa-forward', false) 169 + ->setDisabled(!$next_uri) 170 + ->setHref($next_uri) 171 + ->setText(pht('Next'))) 172 + ->addButton( 173 + id(new PHUIButtonView()) 174 + ->setTag('a') 175 + ->setColor('grey') 176 + ->setIcon('fa-fast-forward', false) 177 + ->setDisabled(!$draft_uri) 178 + ->setHref($draft_uri) 179 + ->setText(pht('Draft'))); 180 + 181 + require_celerity_resource('phui-document-view-css'); 182 + 183 + $version_note = array( 184 + $version_note, 185 + phutil_tag( 186 + 'div', 187 + array( 188 + 'class' => 'phui-document-version-navigation', 189 + ), 190 + $button_bar), 191 + ); 90 192 } else { 91 193 $content = $document->getContent(); 92 194 } ··· 218 320 ->setPolicyObject($document) 219 321 ->setHeader($page_title); 220 322 221 - if ($content) { 323 + if ($is_draft) { 324 + $draft_tag = id(new PHUITagView()) 325 + ->setName(pht('Draft')) 326 + ->setIcon('fa-spinner') 327 + ->setColor('pink') 328 + ->setType(PHUITagView::TYPE_SHADE); 329 + 330 + $header->addTag($draft_tag); 331 + } else if ($content) { 222 332 $header->setEpoch($content->getDateCreated()); 223 333 } 224 334 ··· 299 409 ->setIcon('fa-pencil') 300 410 ->setHref('/phriction/edit/'.$document->getID().'/')); 301 411 412 + $curtain->addAction( 413 + id(new PhabricatorActionView()) 414 + ->setName(pht('View History')) 415 + ->setIcon('fa-history') 416 + ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); 417 + 302 418 $is_current = false; 303 419 $content_id = null; 420 + $is_draft = false; 304 421 if ($content) { 305 422 if ($content->getPHID() == $document->getContentPHID()) { 306 423 $is_current = true; 307 424 } 308 425 $content_id = $content->getID(); 426 + 427 + $current_version = $document->getContent()->getVersion(); 428 + $is_draft = ($content->getVersion() >= $current_version); 309 429 } 310 430 $can_publish = ($can_edit && $content && !$is_current); 311 431 432 + if ($is_draft) { 433 + $publish_name = pht('Publish Draft'); 434 + } else { 435 + $publish_name = pht('Publish Revert'); 436 + } 437 + 312 438 $publish_uri = "/phriction/publish/{$id}/{$content_id}/"; 313 439 314 440 $curtain->addAction( 315 441 id(new PhabricatorActionView()) 316 - ->setName(pht('Publish')) 442 + ->setName($publish_name) 317 443 ->setIcon('fa-upload') 318 444 ->setDisabled(!$can_publish) 319 445 ->setWorkflow(true) ··· 336 462 ->setHref('/phriction/delete/'.$document->getID().'/') 337 463 ->setWorkflow(true)); 338 464 } 339 - 340 - $curtain->addAction( 341 - id(new PhabricatorActionView()) 342 - ->setName(pht('View History')) 343 - ->setIcon('fa-list') 344 - ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); 345 465 346 466 $print_uri = PhrictionDocument::getSlugURI($slug).'?__print__=1'; 347 467
+6
webroot/rsrc/css/phui/phui-document.css
··· 100 100 .remarkup-code { 101 101 font: 13px/18px "Menlo", "Consolas", "Monaco", monospace; 102 102 } 103 + 104 + .phui-document-version-navigation { 105 + text-align: center; 106 + padding: 8px; 107 + background-color: {$lightgreybackground}; 108 + }