1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10: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:
epriestley 2013-07-28 18:32:55 -07:00
parent cf9dc5d189
commit 644f377915
6 changed files with 174 additions and 0 deletions

View file

@ -1873,6 +1873,7 @@ phutil_register_library_map(array(
'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php',
'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php',
'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php',
'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php',
'PonderAnswerListView' => 'applications/ponder/view/PonderAnswerListView.php',
'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php',
'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php',
@ -1900,6 +1901,7 @@ phutil_register_library_map(array(
'PonderQuestionDetailView' => 'applications/ponder/view/PonderQuestionDetailView.php',
'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php',
'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php',
'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php',
'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php',
'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php',
'PonderQuestionPreviewController' => 'applications/ponder/controller/PonderQuestionPreviewController.php',
@ -3997,6 +3999,7 @@ phutil_register_library_map(array(
'PonderAnswerCommentController' => 'PonderController',
'PonderAnswerEditController' => 'PonderController',
'PonderAnswerEditor' => 'PhabricatorApplicationTransactionEditor',
'PonderAnswerHistoryController' => 'PonderController',
'PonderAnswerListView' => 'AphrontView',
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PonderAnswerSaveController' => 'PonderController',
@ -4035,6 +4038,7 @@ phutil_register_library_map(array(
'PonderQuestionDetailView' => 'AphrontView',
'PonderQuestionEditController' => 'PonderController',
'PonderQuestionEditor' => 'PhabricatorApplicationTransactionEditor',
'PonderQuestionHistoryController' => 'PonderController',
'PonderQuestionListController' =>
array(
0 => 'PonderController',

View file

@ -53,8 +53,10 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication {
'answer/add/' => 'PonderAnswerSaveController',
'answer/edit/(?P<id>\d+)/' => 'PonderAnswerEditController',
'answer/comment/(?P<id>\d+)/' => 'PonderAnswerCommentController',
'answer/history/(?P<id>\d+)/' => 'PonderAnswerHistoryController',
'question/edit/(?:(?P<id>\d+)/)?' => 'PonderQuestionEditController',
'question/comment/(?P<id>\d+)/' => 'PonderQuestionCommentController',
'question/history/(?P<id>\d+)/' => 'PonderQuestionHistoryController',
'question/preview/' => 'PonderQuestionPreviewController',
'question/(?P<status>open|close)/(?P<id>[1-9]\d*)/' =>
'PonderQuestionStatusController',

View file

@ -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,
));
}
}

View file

@ -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,
));
}
}

View file

@ -113,6 +113,12 @@ final class PonderQuestionViewController extends PonderController {
->setDisabled(!$can_edit)
->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;
}
@ -156,6 +162,7 @@ final class PonderQuestionViewController extends PonderController {
$xactions = id(new PonderQuestionTransactionQuery())
->setViewer($viewer)
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->withObjectPHIDs(array($question->getPHID()))
->execute();
@ -200,6 +207,7 @@ final class PonderQuestionViewController extends PonderController {
$xactions = id(new PonderAnswerTransactionQuery())
->setViewer($viewer)
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->withObjectPHIDs(mpull($answers, 'getPHID'))
->execute();
@ -274,6 +282,12 @@ final class PonderQuestionViewController extends PonderController {
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$view->addAction(
id(new PhabricatorActionView())
->setIcon('transcript')
->setName(pht('View History'))
->setHref($this->getApplicationURI("/answer/history/{$id}/")));
return $view;
}

View file

@ -6,6 +6,7 @@ abstract class PhabricatorApplicationTransactionQuery
private $phids;
private $objectPHIDs;
private $authorPHIDs;
private $transactionTypes;
private $needComments = true;
private $needHandles = true;
@ -35,6 +36,11 @@ abstract class PhabricatorApplicationTransactionQuery
return $this;
}
public function withTransactionTypes(array $transaction_types) {
$this->transactionTypes = $transaction_types;
return $this;
}
public function needComments($need) {
$this->needComments = $need;
return $this;
@ -133,6 +139,13 @@ abstract class PhabricatorApplicationTransactionQuery
$this->authorPHIDs);
}
if ($this->transactionTypes) {
$where[] = qsprintf(
$conn_r,
'transactionType IN (%Ls)',
$this->transactionTypes);
}
foreach ($this->buildMoreWhereClauses($conn_r) as $clause) {
$where[] = $clause;
}