1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

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
This commit is contained in:
epriestley 2018-09-11 08:35:22 -07:00
parent f5e90a363e
commit e19c555913
9 changed files with 130 additions and 4 deletions

View file

@ -146,7 +146,7 @@ return array(
'rsrc/css/phui/phui-comment-panel.css' => 'f50152ad',
'rsrc/css/phui/phui-crumbs-view.css' => '10728aaa',
'rsrc/css/phui/phui-curtain-view.css' => '2bdaf026',
'rsrc/css/phui/phui-document-pro.css' => '1a08ef4b',
'rsrc/css/phui/phui-document-pro.css' => 'd033e8d5',
'rsrc/css/phui/phui-document-summary.css' => '9ca48bdf',
'rsrc/css/phui/phui-document.css' => 'c4ac41f9',
'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9',
@ -814,7 +814,7 @@ return array(
'phui-curtain-view-css' => '2bdaf026',
'phui-document-summary-view-css' => '9ca48bdf',
'phui-document-view-css' => 'c4ac41f9',
'phui-document-view-pro-css' => '1a08ef4b',
'phui-document-view-pro-css' => 'd033e8d5',
'phui-feed-story-css' => '44a9c8e9',
'phui-font-icon-base-css' => '870a7360',
'phui-fontkit-css' => '1320ed01',

View file

@ -5021,6 +5021,7 @@ phutil_register_library_map(array(
'PhrictionDocumentController' => 'applications/phriction/controller/PhrictionDocumentController.php',
'PhrictionDocumentDatasource' => 'applications/phriction/typeahead/PhrictionDocumentDatasource.php',
'PhrictionDocumentDeleteTransaction' => 'applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php',
'PhrictionDocumentEditEngine' => 'applications/phriction/editor/PhrictionDocumentEditEngine.php',
'PhrictionDocumentFerretEngine' => 'applications/phriction/search/PhrictionDocumentFerretEngine.php',
'PhrictionDocumentFulltextEngine' => 'applications/phriction/search/PhrictionDocumentFulltextEngine.php',
'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php',
@ -5042,6 +5043,7 @@ phutil_register_library_map(array(
'PhrictionDocumentVersionTransaction' => 'applications/phriction/xaction/PhrictionDocumentVersionTransaction.php',
'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php',
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
'PhrictionEditEngineController' => 'applications/phriction/controller/PhrictionEditEngineController.php',
'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php',
'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php',
'PhrictionInfoConduitAPIMethod' => 'applications/phriction/conduit/PhrictionInfoConduitAPIMethod.php',
@ -11140,6 +11142,7 @@ phutil_register_library_map(array(
'PhrictionDocumentController' => 'PhrictionController',
'PhrictionDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentVersionTransaction',
'PhrictionDocumentEditEngine' => 'PhabricatorEditEngine',
'PhrictionDocumentFerretEngine' => 'PhabricatorFerretEngine',
'PhrictionDocumentFulltextEngine' => 'PhabricatorFulltextEngine',
'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter',
@ -11161,6 +11164,7 @@ phutil_register_library_map(array(
'PhrictionDocumentVersionTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod',
'PhrictionEditController' => 'PhrictionController',
'PhrictionEditEngineController' => 'PhrictionController',
'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod',
'PhrictionHistoryController' => 'PhrictionController',
'PhrictionInfoConduitAPIMethod' => 'PhrictionConduitAPIMethod',

View file

@ -63,6 +63,9 @@ final class PhabricatorPhrictionApplication extends PhabricatorApplication {
'preview/(?P<slug>.*/)' => 'PhrictionMarkupPreviewController',
'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController',
$this->getEditRoutePattern('document/edit/')
=> 'PhrictionEditEngineController',
),
);
}

View file

@ -352,6 +352,13 @@ final class PhrictionDocumentController
$document,
new PhrictionTransactionQuery());
$edit_engine = id(new PhrictionDocumentEditEngine())
->setViewer($viewer)
->setTargetObject($document);
$comment_view = $edit_engine
->buildEditEngineCommentView($document);
return $this->newPage()
->setTitle($page_title)
->setCrumbs($crumbs)
@ -368,6 +375,7 @@ final class PhrictionDocumentController
array(
$children,
$timeline,
$comment_view,
)),
));

View file

@ -0,0 +1,14 @@
<?php
final class PhrictionEditEngineController
extends PhrictionController {
public function handleRequest(AphrontRequest $request) {
// NOTE: For now, this controller is only used to handle comments.
return id(new PhrictionDocumentEditEngine())
->setController($this)
->buildResponse();
}
}

View file

@ -0,0 +1,85 @@
<?php
final class PhrictionDocumentEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'phriction.document';
public function isEngineConfigurable() {
return false;
}
public function getEngineName() {
return pht('Phriction Document');
}
public function getSummaryHeader() {
return pht('Edit Phriction Document Configurations');
}
public function getSummaryText() {
return pht('This engine is used to edit Phriction documents.');
}
public function getEngineApplicationClass() {
return 'PhabricatorPhrictionApplication';
}
protected function newEditableObject() {
$viewer = $this->getViewer();
return PhrictionDocument::initializeNewDocument(
$viewer,
'/');
}
protected function newObjectQuery() {
return id(new PhrictionDocumentQuery())
->needContent(true);
}
protected function getObjectCreateTitleText($object) {
return pht('Create Document');
}
protected function getObjectCreateButtonText($object) {
return pht('Create Document');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Document: %s', $object->getContent()->getTitle());
}
protected function getObjectEditShortText($object) {
return pht('Edit Document');
}
protected function getObjectCreateShortText() {
return pht('Create Document');
}
protected function getObjectName() {
return pht('Document');
}
protected function getEditorURI() {
return '/phriction/document/edit/';
}
protected function getObjectCreateCancelURI($object) {
return '/phriction/document/';
}
protected function getObjectViewURI($object) {
return $object->getURI();
}
protected function getCreateNewObjectPolicy() {
// NOTE: For now, this engine is only to support commenting.
return PhabricatorPolicies::POLICY_NOONE;
}
protected function buildCustomEditFields($object) {
return array();
}
}

View file

@ -243,6 +243,7 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
$comment_box = id(new PHUIObjectBoxView())
->setFlush(true)
->setNoBorder(true)
->addClass('phui-comment-form-view')
->addSigil('phui-comment-form')
->appendChild(

View file

@ -25,6 +25,7 @@ final class PHUIObjectBoxView extends AphrontTagView {
private $showHideHref;
private $showHideContent;
private $showHideOpen;
private $noBorder;
private $propertyLists = array();
@ -147,6 +148,11 @@ final class PHUIObjectBoxView extends AphrontTagView {
return $this;
}
public function setNoBorder($no_border) {
$this->noBorder = $no_border;
return $this;
}
public function setValidationException(
PhabricatorApplicationTransactionValidationException $ex = null) {
$this->validationException = $ex;
@ -156,7 +162,9 @@ final class PHUIObjectBoxView extends AphrontTagView {
protected function getTagAttributes() {
$classes = array();
$classes[] = 'phui-box';
$classes[] = 'phui-box-border';
if (!$this->noBorder) {
$classes[] = 'phui-box-border';
}
$classes[] = 'phui-object-box';
$classes[] = 'mlt mll mlr';

View file

@ -241,10 +241,13 @@ body.printable {
}
}
.phui-document-view-pro-box {
margin-bottom: 24px;
}
.phui-document-view-pro-box .phui-timeline-view {
padding: 16px 0 0 0;
background: none;
border-top: 1px solid rgba({$alphablue}, 0.20);
}
.phui-document-view-pro-box .phui-timeline-wedge {