@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

Support (basic) commenting on Phriction documents

Summary:
Depends on D19659. Fixes T1894. Ref T13077. See PHI840.

- Add an EditEngine, although it currently supports no fields.
- Add (basic, top-level-only) commenting (we already had the table in the database).

This will probably create some issues. I'm most concerned about documents accumulating a ton of old, irrelevant comments over time which are hard to keep track of and no longer relevant. But I think this is probably a step forward in almost all cases, and a good thing on the balance.

This also moves us incrementally toward putting all editing on top of EditEngine.

Test Plan: {F5877347}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13077, T1894

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

+130 -4
+2 -2
resources/celerity/map.php
··· 146 146 'rsrc/css/phui/phui-comment-panel.css' => 'f50152ad', 147 147 'rsrc/css/phui/phui-crumbs-view.css' => '10728aaa', 148 148 'rsrc/css/phui/phui-curtain-view.css' => '2bdaf026', 149 - 'rsrc/css/phui/phui-document-pro.css' => '1a08ef4b', 149 + 'rsrc/css/phui/phui-document-pro.css' => 'd033e8d5', 150 150 'rsrc/css/phui/phui-document-summary.css' => '9ca48bdf', 151 151 'rsrc/css/phui/phui-document.css' => 'c4ac41f9', 152 152 'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9', ··· 814 814 'phui-curtain-view-css' => '2bdaf026', 815 815 'phui-document-summary-view-css' => '9ca48bdf', 816 816 'phui-document-view-css' => 'c4ac41f9', 817 - 'phui-document-view-pro-css' => '1a08ef4b', 817 + 'phui-document-view-pro-css' => 'd033e8d5', 818 818 'phui-feed-story-css' => '44a9c8e9', 819 819 'phui-font-icon-base-css' => '870a7360', 820 820 'phui-fontkit-css' => '1320ed01',
+4
src/__phutil_library_map__.php
··· 5021 5021 'PhrictionDocumentController' => 'applications/phriction/controller/PhrictionDocumentController.php', 5022 5022 'PhrictionDocumentDatasource' => 'applications/phriction/typeahead/PhrictionDocumentDatasource.php', 5023 5023 'PhrictionDocumentDeleteTransaction' => 'applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php', 5024 + 'PhrictionDocumentEditEngine' => 'applications/phriction/editor/PhrictionDocumentEditEngine.php', 5024 5025 'PhrictionDocumentFerretEngine' => 'applications/phriction/search/PhrictionDocumentFerretEngine.php', 5025 5026 'PhrictionDocumentFulltextEngine' => 'applications/phriction/search/PhrictionDocumentFulltextEngine.php', 5026 5027 'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php', ··· 5042 5043 'PhrictionDocumentVersionTransaction' => 'applications/phriction/xaction/PhrictionDocumentVersionTransaction.php', 5043 5044 'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php', 5044 5045 'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php', 5046 + 'PhrictionEditEngineController' => 'applications/phriction/controller/PhrictionEditEngineController.php', 5045 5047 'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php', 5046 5048 'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php', 5047 5049 'PhrictionInfoConduitAPIMethod' => 'applications/phriction/conduit/PhrictionInfoConduitAPIMethod.php', ··· 11140 11142 'PhrictionDocumentController' => 'PhrictionController', 11141 11143 'PhrictionDocumentDatasource' => 'PhabricatorTypeaheadDatasource', 11142 11144 'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentVersionTransaction', 11145 + 'PhrictionDocumentEditEngine' => 'PhabricatorEditEngine', 11143 11146 'PhrictionDocumentFerretEngine' => 'PhabricatorFerretEngine', 11144 11147 'PhrictionDocumentFulltextEngine' => 'PhabricatorFulltextEngine', 11145 11148 'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter', ··· 11161 11164 'PhrictionDocumentVersionTransaction' => 'PhrictionDocumentTransactionType', 11162 11165 'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod', 11163 11166 'PhrictionEditController' => 'PhrictionController', 11167 + 'PhrictionEditEngineController' => 'PhrictionController', 11164 11168 'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod', 11165 11169 'PhrictionHistoryController' => 'PhrictionController', 11166 11170 'PhrictionInfoConduitAPIMethod' => 'PhrictionConduitAPIMethod',
+3
src/applications/phriction/application/PhabricatorPhrictionApplication.php
··· 63 63 64 64 'preview/(?P<slug>.*/)' => 'PhrictionMarkupPreviewController', 65 65 'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController', 66 + 67 + $this->getEditRoutePattern('document/edit/') 68 + => 'PhrictionEditEngineController', 66 69 ), 67 70 ); 68 71 }
+8
src/applications/phriction/controller/PhrictionDocumentController.php
··· 352 352 $document, 353 353 new PhrictionTransactionQuery()); 354 354 355 + $edit_engine = id(new PhrictionDocumentEditEngine()) 356 + ->setViewer($viewer) 357 + ->setTargetObject($document); 358 + 359 + $comment_view = $edit_engine 360 + ->buildEditEngineCommentView($document); 361 + 355 362 return $this->newPage() 356 363 ->setTitle($page_title) 357 364 ->setCrumbs($crumbs) ··· 368 375 array( 369 376 $children, 370 377 $timeline, 378 + $comment_view, 371 379 )), 372 380 )); 373 381
+14
src/applications/phriction/controller/PhrictionEditEngineController.php
··· 1 + <?php 2 + 3 + final class PhrictionEditEngineController 4 + extends PhrictionController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + // NOTE: For now, this controller is only used to handle comments. 8 + 9 + return id(new PhrictionDocumentEditEngine()) 10 + ->setController($this) 11 + ->buildResponse(); 12 + } 13 + 14 + }
+85
src/applications/phriction/editor/PhrictionDocumentEditEngine.php
··· 1 + <?php 2 + 3 + final class PhrictionDocumentEditEngine 4 + extends PhabricatorEditEngine { 5 + 6 + const ENGINECONST = 'phriction.document'; 7 + 8 + public function isEngineConfigurable() { 9 + return false; 10 + } 11 + 12 + public function getEngineName() { 13 + return pht('Phriction Document'); 14 + } 15 + 16 + public function getSummaryHeader() { 17 + return pht('Edit Phriction Document Configurations'); 18 + } 19 + 20 + public function getSummaryText() { 21 + return pht('This engine is used to edit Phriction documents.'); 22 + } 23 + 24 + public function getEngineApplicationClass() { 25 + return 'PhabricatorPhrictionApplication'; 26 + } 27 + 28 + protected function newEditableObject() { 29 + $viewer = $this->getViewer(); 30 + return PhrictionDocument::initializeNewDocument( 31 + $viewer, 32 + '/'); 33 + } 34 + 35 + protected function newObjectQuery() { 36 + return id(new PhrictionDocumentQuery()) 37 + ->needContent(true); 38 + } 39 + 40 + protected function getObjectCreateTitleText($object) { 41 + return pht('Create Document'); 42 + } 43 + 44 + protected function getObjectCreateButtonText($object) { 45 + return pht('Create Document'); 46 + } 47 + 48 + protected function getObjectEditTitleText($object) { 49 + return pht('Edit Document: %s', $object->getContent()->getTitle()); 50 + } 51 + 52 + protected function getObjectEditShortText($object) { 53 + return pht('Edit Document'); 54 + } 55 + 56 + protected function getObjectCreateShortText() { 57 + return pht('Create Document'); 58 + } 59 + 60 + protected function getObjectName() { 61 + return pht('Document'); 62 + } 63 + 64 + protected function getEditorURI() { 65 + return '/phriction/document/edit/'; 66 + } 67 + 68 + protected function getObjectCreateCancelURI($object) { 69 + return '/phriction/document/'; 70 + } 71 + 72 + protected function getObjectViewURI($object) { 73 + return $object->getURI(); 74 + } 75 + 76 + protected function getCreateNewObjectPolicy() { 77 + // NOTE: For now, this engine is only to support commenting. 78 + return PhabricatorPolicies::POLICY_NOONE; 79 + } 80 + 81 + protected function buildCustomEditFields($object) { 82 + return array(); 83 + } 84 + 85 + }
+1
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 243 243 244 244 $comment_box = id(new PHUIObjectBoxView()) 245 245 ->setFlush(true) 246 + ->setNoBorder(true) 246 247 ->addClass('phui-comment-form-view') 247 248 ->addSigil('phui-comment-form') 248 249 ->appendChild(
+9 -1
src/view/phui/PHUIObjectBoxView.php
··· 25 25 private $showHideHref; 26 26 private $showHideContent; 27 27 private $showHideOpen; 28 + private $noBorder; 28 29 29 30 private $propertyLists = array(); 30 31 ··· 147 148 return $this; 148 149 } 149 150 151 + public function setNoBorder($no_border) { 152 + $this->noBorder = $no_border; 153 + return $this; 154 + } 155 + 150 156 public function setValidationException( 151 157 PhabricatorApplicationTransactionValidationException $ex = null) { 152 158 $this->validationException = $ex; ··· 156 162 protected function getTagAttributes() { 157 163 $classes = array(); 158 164 $classes[] = 'phui-box'; 159 - $classes[] = 'phui-box-border'; 165 + if (!$this->noBorder) { 166 + $classes[] = 'phui-box-border'; 167 + } 160 168 $classes[] = 'phui-object-box'; 161 169 $classes[] = 'mlt mll mlr'; 162 170
+4 -1
webroot/rsrc/css/phui/phui-document-pro.css
··· 241 241 } 242 242 } 243 243 244 + .phui-document-view-pro-box { 245 + margin-bottom: 24px; 246 + } 247 + 244 248 .phui-document-view-pro-box .phui-timeline-view { 245 249 padding: 16px 0 0 0; 246 250 background: none; 247 - border-top: 1px solid rgba({$alphablue}, 0.20); 248 251 } 249 252 250 253 .phui-document-view-pro-box .phui-timeline-wedge {