Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
|
|
|
class PhabricatorApplicationTransactionView extends AphrontView {
|
|
|
|
|
|
|
|
private $transactions;
|
|
|
|
private $engine;
|
2012-12-11 14:02:12 -08:00
|
|
|
private $anchorOffset = 1;
|
2012-12-11 14:01:51 -08:00
|
|
|
private $showEditActions = true;
|
2012-12-21 05:51:33 -08:00
|
|
|
private $isPreview;
|
|
|
|
|
|
|
|
public function setIsPreview($is_preview) {
|
|
|
|
$this->isPreview = $is_preview;
|
|
|
|
return $this;
|
|
|
|
}
|
2012-12-11 14:01:51 -08:00
|
|
|
|
|
|
|
public function setShowEditActions($show_edit_actions) {
|
|
|
|
$this->showEditActions = $show_edit_actions;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShowEditActions() {
|
|
|
|
return $this->showEditActions;
|
|
|
|
}
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
|
|
|
|
public function setAnchorOffset($anchor_offset) {
|
|
|
|
$this->anchorOffset = $anchor_offset;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMarkupEngine(PhabricatorMarkupEngine $engine) {
|
|
|
|
$this->engine = $engine;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTransactions(array $transactions) {
|
|
|
|
assert_instances_of($transactions, 'PhabricatorApplicationTransaction');
|
|
|
|
$this->transactions = $transactions;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:02:12 -08:00
|
|
|
public function buildEvents() {
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
$field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT;
|
2012-12-11 14:02:12 -08:00
|
|
|
$engine = $this->getOrBuildEngine();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
|
2012-12-21 05:51:33 -08:00
|
|
|
$user = $this->getUser();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
|
|
|
|
$anchor = $this->anchorOffset;
|
2012-12-11 14:02:12 -08:00
|
|
|
$events = array();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
foreach ($this->transactions as $xaction) {
|
|
|
|
if ($xaction->shouldHide()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$event = id(new PhabricatorTimelineEventView())
|
2012-12-21 05:51:33 -08:00
|
|
|
->setUser($user)
|
2012-12-11 14:01:51 -08:00
|
|
|
->setTransactionPHID($xaction->getPHID())
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
->setUserHandle($xaction->getHandle($xaction->getAuthorPHID()))
|
|
|
|
->setIcon($xaction->getIcon())
|
|
|
|
->setColor($xaction->getColor())
|
2012-12-21 05:51:33 -08:00
|
|
|
->setTitle($xaction->getTitle());
|
|
|
|
|
|
|
|
if ($this->isPreview) {
|
|
|
|
$event->setIsPreview(true);
|
|
|
|
} else {
|
|
|
|
$event
|
|
|
|
->setDateCreated($xaction->getDateCreated())
|
|
|
|
->setContentSource($xaction->getContentSource())
|
|
|
|
->setAnchor($anchor);
|
|
|
|
|
|
|
|
$anchor++;
|
|
|
|
}
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
|
2012-12-11 14:02:12 -08:00
|
|
|
|
2012-12-11 14:01:51 -08:00
|
|
|
$has_deleted_comment = $xaction->getComment() &&
|
|
|
|
$xaction->getComment()->getIsDeleted();
|
|
|
|
|
2012-12-21 05:51:33 -08:00
|
|
|
if ($this->getShowEditActions() && !$this->isPreview) {
|
2012-12-11 14:01:51 -08:00
|
|
|
if ($xaction->getCommentVersion() > 1) {
|
|
|
|
$event->setIsEdited(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyCapability::CAN_EDIT;
|
|
|
|
|
|
|
|
if ($xaction->hasComment() || $has_deleted_comment) {
|
|
|
|
$has_edit_capability = PhabricatorPolicyFilter::hasCapability(
|
2012-12-21 05:51:33 -08:00
|
|
|
$user,
|
2012-12-11 14:01:51 -08:00
|
|
|
$xaction,
|
|
|
|
$can_edit);
|
|
|
|
if ($has_edit_capability) {
|
|
|
|
$event->setIsEditable(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
if ($xaction->hasComment()) {
|
|
|
|
$event->appendChild(
|
2012-12-11 14:02:12 -08:00
|
|
|
$engine->getOutput($xaction->getComment(), $field));
|
2012-12-11 14:01:51 -08:00
|
|
|
} else if ($has_deleted_comment) {
|
2013-02-13 14:50:15 -08:00
|
|
|
$event->appendChild(phutil_tag('em', array(), pht(
|
|
|
|
'This comment has been deleted.')));
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
}
|
|
|
|
|
2012-12-11 14:02:12 -08:00
|
|
|
$events[] = $event;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $events;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$view = new PhabricatorTimelineView();
|
2012-12-11 14:02:29 -08:00
|
|
|
$events = $this->buildEvents();
|
|
|
|
foreach ($events as $event) {
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
$view->addEvent($event);
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:02:12 -08:00
|
|
|
if ($this->getShowEditActions()) {
|
|
|
|
$list_id = celerity_generate_unique_node_id();
|
|
|
|
|
|
|
|
$view->setID($list_id);
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'phabricator-transaction-list',
|
|
|
|
array(
|
2012-12-11 14:02:29 -08:00
|
|
|
'listID' => $list_id,
|
|
|
|
'nextAnchor' => $this->anchorOffset + count($events),
|
2012-12-11 14:02:12 -08:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
return $view->render();
|
|
|
|
}
|
2012-12-11 14:02:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
private function getOrBuildEngine() {
|
|
|
|
if ($this->engine) {
|
|
|
|
return $this->engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
$field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT;
|
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
2012-12-21 05:51:33 -08:00
|
|
|
->setViewer($this->getUser());
|
2012-12-11 14:02:12 -08:00
|
|
|
foreach ($this->transactions as $xaction) {
|
|
|
|
if (!$xaction->hasComment()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$engine->addObject($xaction->getComment(), $field);
|
|
|
|
}
|
|
|
|
$engine->process();
|
|
|
|
|
|
|
|
return $engine;
|
|
|
|
}
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
}
|
|
|
|
|