mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Add Comments to Countdown
Summary: 3, 2, 1, Liftoff! (Adds basic commenting to countdown) Test Plan: asdf asdf asdf Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8895 Differential Revision: https://secure.phabricator.com/D13707
This commit is contained in:
parent
930b6fec25
commit
17fe8511d7
8 changed files with 130 additions and 5 deletions
18
resources/sql/autopatches/20150724.countdown.comments.1.sql
Normal file
18
resources/sql/autopatches/20150724.countdown.comments.1.sql
Normal file
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE {$NAMESPACE}_countdown.countdown_transaction_comment (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
phid VARCHAR(64) NOT NULL,
|
||||
transactionPHID VARCHAR(64),
|
||||
authorPHID VARCHAR(64) NOT NULL,
|
||||
viewPolicy VARCHAR(64) NOT NULL,
|
||||
editPolicy VARCHAR(64) NOT NULL,
|
||||
commentVersion INT UNSIGNED NOT NULL,
|
||||
content LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
|
||||
contentSource LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
|
||||
isDeleted BOOL NOT NULL,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
|
||||
UNIQUE KEY `key_phid` (phid),
|
||||
UNIQUE KEY `key_version` (transactionPHID, commentVersion)
|
||||
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -1820,6 +1820,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php',
|
||||
'PhabricatorCountdown' => 'applications/countdown/storage/PhabricatorCountdown.php',
|
||||
'PhabricatorCountdownApplication' => 'applications/countdown/application/PhabricatorCountdownApplication.php',
|
||||
'PhabricatorCountdownCommentController' => 'applications/countdown/controller/PhabricatorCountdownCommentController.php',
|
||||
'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php',
|
||||
'PhabricatorCountdownCountdownPHIDType' => 'applications/countdown/phid/PhabricatorCountdownCountdownPHIDType.php',
|
||||
'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php',
|
||||
|
@ -1835,6 +1836,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCountdownSchemaSpec' => 'applications/countdown/storage/PhabricatorCountdownSchemaSpec.php',
|
||||
'PhabricatorCountdownSearchEngine' => 'applications/countdown/query/PhabricatorCountdownSearchEngine.php',
|
||||
'PhabricatorCountdownTransaction' => 'applications/countdown/storage/PhabricatorCountdownTransaction.php',
|
||||
'PhabricatorCountdownTransactionComment' => 'applications/countdown/storage/PhabricatorCountdownTransactionComment.php',
|
||||
'PhabricatorCountdownTransactionQuery' => 'applications/countdown/query/PhabricatorCountdownTransactionQuery.php',
|
||||
'PhabricatorCountdownView' => 'applications/countdown/view/PhabricatorCountdownView.php',
|
||||
'PhabricatorCountdownViewController' => 'applications/countdown/controller/PhabricatorCountdownViewController.php',
|
||||
|
@ -5632,6 +5634,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectInterface',
|
||||
),
|
||||
'PhabricatorCountdownApplication' => 'PhabricatorApplication',
|
||||
'PhabricatorCountdownCommentController' => 'PhabricatorCountdownController',
|
||||
'PhabricatorCountdownController' => 'PhabricatorController',
|
||||
'PhabricatorCountdownCountdownPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO',
|
||||
|
@ -5647,6 +5650,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCountdownSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
'PhabricatorCountdownSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorCountdownTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhabricatorCountdownTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||
'PhabricatorCountdownTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhabricatorCountdownView' => 'AphrontTagView',
|
||||
'PhabricatorCountdownViewController' => 'PhabricatorCountdownController',
|
||||
|
|
|
@ -42,9 +42,14 @@ final class PhabricatorCountdownApplication extends PhabricatorApplication {
|
|||
'/countdown/' => array(
|
||||
'(?:query/(?P<queryKey>[^/]+)/)?'
|
||||
=> 'PhabricatorCountdownListController',
|
||||
'(?P<id>[1-9]\d*)/' => 'PhabricatorCountdownViewController',
|
||||
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'PhabricatorCountdownEditController',
|
||||
'delete/(?P<id>[1-9]\d*)/' => 'PhabricatorCountdownDeleteController',
|
||||
'(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorCountdownViewController',
|
||||
'comment/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorCountdownCommentController',
|
||||
'edit/(?:(?P<id>[1-9]\d*)/)?'
|
||||
=> 'PhabricatorCountdownEditController',
|
||||
'delete/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorCountdownDeleteController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCountdownCommentController
|
||||
extends PhabricatorCountdownController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if (!$request->isFormPost()) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$countdown = id(new PhabricatorCountdownQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$countdown) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$is_preview = $request->isPreviewRequest();
|
||||
$draft = PhabricatorDraft::buildFromRequest($request);
|
||||
|
||||
$view_uri = '/'.$countdown->getMonogram();
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhabricatorCountdownTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new PhabricatorCountdownTransactionComment())
|
||||
->setContent($request->getStr('comment')));
|
||||
|
||||
$editor = id(new PhabricatorCountdownEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSourceFromRequest($request)
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
try {
|
||||
$xactions = $editor->applyTransactions($countdown, $xactions);
|
||||
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
||||
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
||||
->setCancelURI($view_uri)
|
||||
->setException($ex);
|
||||
}
|
||||
|
||||
if ($draft) {
|
||||
$draft->replaceOrDelete();
|
||||
}
|
||||
|
||||
if ($request->isAjax() && $is_preview) {
|
||||
return id(new PhabricatorApplicationTransactionResponse())
|
||||
->setViewer($viewer)
|
||||
->setTransactions($xactions)
|
||||
->setIsPreview($is_preview);
|
||||
} else {
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($view_uri);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -58,19 +58,22 @@ final class PhabricatorCountdownViewController
|
|||
$timeline = $this->buildTransactionTimeline(
|
||||
$countdown,
|
||||
new PhabricatorCountdownTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
$add_comment = $this->buildCommentForm($countdown);
|
||||
|
||||
$content = array(
|
||||
$crumbs,
|
||||
$object_box,
|
||||
$countdown_view,
|
||||
$timeline,
|
||||
$add_comment,
|
||||
);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$content,
|
||||
array(
|
||||
'title' => $title,
|
||||
'pageObjects' => array($countdown->getPHID()),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -141,4 +144,25 @@ final class PhabricatorCountdownViewController
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function buildCommentForm(PhabricatorCountdown $countdown) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
||||
|
||||
$add_comment_header = $is_serious
|
||||
? pht('Add Comment')
|
||||
: pht('Last Words');
|
||||
|
||||
$draft = PhabricatorDraft::newFromUserAndKey(
|
||||
$viewer, $countdown->getPHID());
|
||||
|
||||
return id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($countdown->getPHID())
|
||||
->setDraft($draft)
|
||||
->setHeaderText($add_comment_header)
|
||||
->setAction($this->getApplicationURI('/comment/'.$countdown->getID().'/'))
|
||||
->setSubmitButtonName(pht('Add Comment'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ final class PhabricatorCountdownEditor
|
|||
$types[] = PhabricatorTransactions::TYPE_SPACE;
|
||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ final class PhabricatorCountdownTransaction
|
|||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
return null;
|
||||
return new PhabricatorCountdownTransactionComment();
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCountdownTransactionComment
|
||||
extends PhabricatorApplicationTransactionComment {
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return new PhabricatorCountdownTransaction();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue