mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 22:40:55 +01:00
Move non-comment transactions to a separate history view in Ponder
Summary: Ref T3373. Most edits aren't too interesting, put them on a separate history page. Test Plan: Viewed question page; viewed history page for question and answer. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3373 Differential Revision: https://secure.phabricator.com/D6612
This commit is contained in:
parent
cf9dc5d189
commit
644f377915
6 changed files with 174 additions and 0 deletions
|
@ -1873,6 +1873,7 @@ phutil_register_library_map(array(
|
||||||
'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php',
|
'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php',
|
||||||
'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php',
|
'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php',
|
||||||
'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php',
|
'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php',
|
||||||
|
'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php',
|
||||||
'PonderAnswerListView' => 'applications/ponder/view/PonderAnswerListView.php',
|
'PonderAnswerListView' => 'applications/ponder/view/PonderAnswerListView.php',
|
||||||
'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php',
|
'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php',
|
||||||
'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php',
|
'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php',
|
||||||
|
@ -1900,6 +1901,7 @@ phutil_register_library_map(array(
|
||||||
'PonderQuestionDetailView' => 'applications/ponder/view/PonderQuestionDetailView.php',
|
'PonderQuestionDetailView' => 'applications/ponder/view/PonderQuestionDetailView.php',
|
||||||
'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php',
|
'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php',
|
||||||
'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php',
|
'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php',
|
||||||
|
'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php',
|
||||||
'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php',
|
'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php',
|
||||||
'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php',
|
'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php',
|
||||||
'PonderQuestionPreviewController' => 'applications/ponder/controller/PonderQuestionPreviewController.php',
|
'PonderQuestionPreviewController' => 'applications/ponder/controller/PonderQuestionPreviewController.php',
|
||||||
|
@ -3997,6 +3999,7 @@ phutil_register_library_map(array(
|
||||||
'PonderAnswerCommentController' => 'PonderController',
|
'PonderAnswerCommentController' => 'PonderController',
|
||||||
'PonderAnswerEditController' => 'PonderController',
|
'PonderAnswerEditController' => 'PonderController',
|
||||||
'PonderAnswerEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PonderAnswerEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
'PonderAnswerHistoryController' => 'PonderController',
|
||||||
'PonderAnswerListView' => 'AphrontView',
|
'PonderAnswerListView' => 'AphrontView',
|
||||||
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PonderAnswerSaveController' => 'PonderController',
|
'PonderAnswerSaveController' => 'PonderController',
|
||||||
|
@ -4035,6 +4038,7 @@ phutil_register_library_map(array(
|
||||||
'PonderQuestionDetailView' => 'AphrontView',
|
'PonderQuestionDetailView' => 'AphrontView',
|
||||||
'PonderQuestionEditController' => 'PonderController',
|
'PonderQuestionEditController' => 'PonderController',
|
||||||
'PonderQuestionEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PonderQuestionEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
'PonderQuestionHistoryController' => 'PonderController',
|
||||||
'PonderQuestionListController' =>
|
'PonderQuestionListController' =>
|
||||||
array(
|
array(
|
||||||
0 => 'PonderController',
|
0 => 'PonderController',
|
||||||
|
|
|
@ -53,8 +53,10 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication {
|
||||||
'answer/add/' => 'PonderAnswerSaveController',
|
'answer/add/' => 'PonderAnswerSaveController',
|
||||||
'answer/edit/(?P<id>\d+)/' => 'PonderAnswerEditController',
|
'answer/edit/(?P<id>\d+)/' => 'PonderAnswerEditController',
|
||||||
'answer/comment/(?P<id>\d+)/' => 'PonderAnswerCommentController',
|
'answer/comment/(?P<id>\d+)/' => 'PonderAnswerCommentController',
|
||||||
|
'answer/history/(?P<id>\d+)/' => 'PonderAnswerHistoryController',
|
||||||
'question/edit/(?:(?P<id>\d+)/)?' => 'PonderQuestionEditController',
|
'question/edit/(?:(?P<id>\d+)/)?' => 'PonderQuestionEditController',
|
||||||
'question/comment/(?P<id>\d+)/' => 'PonderQuestionCommentController',
|
'question/comment/(?P<id>\d+)/' => 'PonderQuestionCommentController',
|
||||||
|
'question/history/(?P<id>\d+)/' => 'PonderQuestionHistoryController',
|
||||||
'question/preview/' => 'PonderQuestionPreviewController',
|
'question/preview/' => 'PonderQuestionPreviewController',
|
||||||
'question/(?P<status>open|close)/(?P<id>[1-9]\d*)/' =>
|
'question/(?P<status>open|close)/(?P<id>[1-9]\d*)/' =>
|
||||||
'PonderQuestionStatusController',
|
'PonderQuestionStatusController',
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PonderAnswerHistoryController extends PonderController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$answer = id(new PonderAnswerQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($this->id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$answer) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$xactions = id(new PonderAnswerTransactionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withObjectPHIDs(array($answer->getPHID()))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$engine = id(new PhabricatorMarkupEngine())
|
||||||
|
->setViewer($viewer);
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
if ($xaction->getComment()) {
|
||||||
|
$engine->addObject(
|
||||||
|
$xaction->getComment(),
|
||||||
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$engine->process();
|
||||||
|
|
||||||
|
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObjectPHID($answer->getPHID())
|
||||||
|
->setTransactions($xactions)
|
||||||
|
->setMarkupEngine($engine);
|
||||||
|
|
||||||
|
$qid = $answer->getQuestion()->getID();
|
||||||
|
$aid = $answer->getID();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName("Q{$qid}")
|
||||||
|
->setHref("/Q{$qid}"));
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName("A{$aid}")
|
||||||
|
->setHref("/Q{$qid}#{$aid}"));
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName(pht('History')));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$timeline,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => pht('Answer History'),
|
||||||
|
'dust' => true,
|
||||||
|
'device' => true,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PonderQuestionHistoryController extends PonderController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$question = id(new PonderQuestionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($this->id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$question) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$xactions = id(new PonderQuestionTransactionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withObjectPHIDs(array($question->getPHID()))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$engine = id(new PhabricatorMarkupEngine())
|
||||||
|
->setViewer($viewer);
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
if ($xaction->getComment()) {
|
||||||
|
$engine->addObject(
|
||||||
|
$xaction->getComment(),
|
||||||
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$engine->process();
|
||||||
|
|
||||||
|
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObjectPHID($question->getPHID())
|
||||||
|
->setTransactions($xactions)
|
||||||
|
->setMarkupEngine($engine);
|
||||||
|
|
||||||
|
$qid = $question->getID();
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName("Q{$qid}")
|
||||||
|
->setHref("/Q{$qid}"));
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName(pht('History')));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$timeline,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => pht('Question History'),
|
||||||
|
'dust' => true,
|
||||||
|
'device' => true,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -113,6 +113,12 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setHref($this->getApplicationURI("/question/{$href}/{$id}/")));
|
->setHref($this->getApplicationURI("/question/{$href}/{$id}/")));
|
||||||
|
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('transcript')
|
||||||
|
->setName(pht('View History'))
|
||||||
|
->setHref($this->getApplicationURI("/question/history/{$id}/")));
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +162,7 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
|
|
||||||
$xactions = id(new PonderQuestionTransactionQuery())
|
$xactions = id(new PonderQuestionTransactionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
|
||||||
->withObjectPHIDs(array($question->getPHID()))
|
->withObjectPHIDs(array($question->getPHID()))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
@ -200,6 +207,7 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
|
|
||||||
$xactions = id(new PonderAnswerTransactionQuery())
|
$xactions = id(new PonderAnswerTransactionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
|
||||||
->withObjectPHIDs(mpull($answers, 'getPHID'))
|
->withObjectPHIDs(mpull($answers, 'getPHID'))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
@ -274,6 +282,12 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('transcript')
|
||||||
|
->setName(pht('View History'))
|
||||||
|
->setHref($this->getApplicationURI("/answer/history/{$id}/")));
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ abstract class PhabricatorApplicationTransactionQuery
|
||||||
private $phids;
|
private $phids;
|
||||||
private $objectPHIDs;
|
private $objectPHIDs;
|
||||||
private $authorPHIDs;
|
private $authorPHIDs;
|
||||||
|
private $transactionTypes;
|
||||||
|
|
||||||
private $needComments = true;
|
private $needComments = true;
|
||||||
private $needHandles = true;
|
private $needHandles = true;
|
||||||
|
@ -35,6 +36,11 @@ abstract class PhabricatorApplicationTransactionQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withTransactionTypes(array $transaction_types) {
|
||||||
|
$this->transactionTypes = $transaction_types;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function needComments($need) {
|
public function needComments($need) {
|
||||||
$this->needComments = $need;
|
$this->needComments = $need;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -133,6 +139,13 @@ abstract class PhabricatorApplicationTransactionQuery
|
||||||
$this->authorPHIDs);
|
$this->authorPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->transactionTypes) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'transactionType IN (%Ls)',
|
||||||
|
$this->transactionTypes);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->buildMoreWhereClauses($conn_r) as $clause) {
|
foreach ($this->buildMoreWhereClauses($conn_r) as $clause) {
|
||||||
$where[] = $clause;
|
$where[] = $clause;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue