Conpherence - make the durable column kind of work and stuff
Summary: Ref T7014. This hooks up the durable column such that when you open it up it loads your most recent Conpherence. You can then switch amongst the various widgets and stuff and everything works nicely. Except... - scroll bar does not work - also doesn't work at HEAD when I add a ton of text to the UI with no changes? (wrapped $copy in array_fill(0, 1000, $copy)) - "widget selector" does not collapse when you select something else - this part wasn't really specified so I used the aphlict dropdown stuff. didn't want to keep working on that if this was the wrong UI choice - can not edit title - do we still want that to be done by clicking on the title, which pops a dialogue? - can not add participants or calendar events - what should this UI be? maybe just a button on the top for "participants" and a button on the bottom for calendar? both on top? - this is not pixel perfect to the mock or two I've seen around. Aside from generally being bad at that, I definitely didn't get the name + timestamps formatting correctly, because the standard DOM of that has timestamp FIRST which appears second due to a "float right". Seemed like a lot of special-casing for what might not even be that important in the UI so I punted. (And again, there's likely many unknown ways in which this isn't pixel perfect) There's also code quality issues - `ConpherenceWidgetConfigConstants` is hopefully temporary or at least gets more sleek as we keep progressing here - copied some CSS from main Conpherence app - DOM structure is pretty different - there's some minor CSS tweaks too given the different width (not to mention the DOM structure being different) - copied some JS from behavior-pontificate.js to sync threads relative to aphlict updates - JS in general is like a better version of existing JS; these should collapse I'd hope? - maybe the aphlict-behavior-dropdown change was badsauce? ...but all that said, this definitely feels really nice and I feel like adding stuff is going to be really easy compared to how normal Conpherence is. Also includes a bonus bug fix - we now correctly update participation. The user would encounter this issue if they were in a conpherence that got some updates and then they went to a different page; they would have unread status for the messages that were ajax'd in. This patch fixes that by making sure we mark participation up to date with the proper transaction in all cases. Test Plan: hit "\" to invoke the column and saw nice loading UI and my latest conpherence load. sent messages and verified they received A-OK by looking in DOM console. toggled various widges and verified they rendered correctly. opened up a second browser with a second user on the thread, sent a message, and it was received in a nice asynchronous fashion Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7014 Differential Revision: https://secure.phabricator.com/D11968
This commit is contained in:
@@ -221,6 +221,7 @@ phutil_register_library_map(array(
|
||||
'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php',
|
||||
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
||||
'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php',
|
||||
'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php',
|
||||
'ConpherenceConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceConduitAPIMethod.php',
|
||||
'ConpherenceConfigOptions' => 'applications/conpherence/config/ConpherenceConfigOptions.php',
|
||||
'ConpherenceConstants' => 'applications/conpherence/constants/ConpherenceConstants.php',
|
||||
@@ -263,6 +264,7 @@ phutil_register_library_map(array(
|
||||
'ConpherenceUpdateController' => 'applications/conpherence/controller/ConpherenceUpdateController.php',
|
||||
'ConpherenceUpdateThreadConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php',
|
||||
'ConpherenceViewController' => 'applications/conpherence/controller/ConpherenceViewController.php',
|
||||
'ConpherenceWidgetConfigConstants' => 'applications/conpherence/constants/ConpherenceWidgetConfigConstants.php',
|
||||
'ConpherenceWidgetController' => 'applications/conpherence/controller/ConpherenceWidgetController.php',
|
||||
'ConpherenceWidgetView' => 'applications/conpherence/view/ConpherenceWidgetView.php',
|
||||
'DarkConsoleController' => 'applications/console/controller/DarkConsoleController.php',
|
||||
@@ -3361,6 +3363,7 @@ phutil_register_library_map(array(
|
||||
'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
||||
'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||
'ConpherenceColumnViewController' => 'ConpherenceController',
|
||||
'ConpherenceConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'ConpherenceConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'ConpherenceController' => 'PhabricatorController',
|
||||
@@ -3405,6 +3408,7 @@ phutil_register_library_map(array(
|
||||
'ConpherenceUpdateController' => 'ConpherenceController',
|
||||
'ConpherenceUpdateThreadConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
|
||||
'ConpherenceViewController' => 'ConpherenceController',
|
||||
'ConpherenceWidgetConfigConstants' => 'ConpherenceConstants',
|
||||
'ConpherenceWidgetController' => 'ConpherenceController',
|
||||
'ConpherenceWidgetView' => 'AphrontView',
|
||||
'DarkConsoleController' => 'PhabricatorController',
|
||||
|
||||
@@ -34,6 +34,7 @@ final class PhabricatorConpherenceApplication extends PhabricatorApplication {
|
||||
'' => 'ConpherenceListController',
|
||||
'thread/(?P<id>[1-9]\d*)/' => 'ConpherenceListController',
|
||||
'(?P<id>[1-9]\d*)/' => 'ConpherenceViewController',
|
||||
'columnview/' => 'ConpherenceColumnViewController',
|
||||
'new/' => 'ConpherenceNewController',
|
||||
'panel/' => 'ConpherenceNotificationPanelController',
|
||||
'widget/(?P<id>[1-9]\d*)/' => 'ConpherenceWidgetController',
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
final class ConpherenceWidgetConfigConstants extends ConpherenceConstants {
|
||||
|
||||
const UPDATE_URI = '/conpherence/update/';
|
||||
|
||||
public static function getWidgetPaneBehaviorConfig() {
|
||||
return array(
|
||||
'widgetBaseUpdateURI' => self::UPDATE_URI,
|
||||
'widgetRegistry' => self::getWidgetRegistry(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getWidgetRegistry() {
|
||||
return array(
|
||||
'conpherence-message-pane' => array(
|
||||
'name' => pht('Thread'),
|
||||
'icon' => 'fa-comment',
|
||||
'deviceOnly' => true,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
'widgets-people' => array(
|
||||
'name' => pht('Participants'),
|
||||
'icon' => 'fa-users',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => true,
|
||||
'createData' => array(
|
||||
'refreshFromResponse' => true,
|
||||
'action' => ConpherenceUpdateActions::ADD_PERSON,
|
||||
'customHref' => null,
|
||||
),
|
||||
),
|
||||
'widgets-files' => array(
|
||||
'name' => pht('Files'),
|
||||
'icon' => 'fa-files-o',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
'widgets-calendar' => array(
|
||||
'name' => pht('Calendar'),
|
||||
'icon' => 'fa-calendar',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => true,
|
||||
'createData' => array(
|
||||
'refreshFromResponse' => false,
|
||||
'action' => ConpherenceUpdateActions::ADD_STATUS,
|
||||
'customHref' => '/calendar/event/create/',
|
||||
),
|
||||
),
|
||||
'widgets-settings' => array(
|
||||
'name' => pht('Settings'),
|
||||
'icon' => 'fa-wrench',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
final class ConpherenceColumnViewController extends
|
||||
ConpherenceController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
|
||||
$conpherence = null;
|
||||
if ($request->getInt('id')) {
|
||||
$conpherence = id(new ConpherenceThreadQuery())
|
||||
->setViewer($user)
|
||||
->withIDs(array($request->getInt('id')))
|
||||
->needTransactions(true)
|
||||
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
|
||||
->executeOne();
|
||||
} else {
|
||||
// TODO - should be pulling more data than this to build the
|
||||
// icon bar, etc, kind of always
|
||||
$latest_participant = id(new ConpherenceParticipantQuery())
|
||||
->withParticipantPHIDs(array($user->getPHID()))
|
||||
->setLimit(1)
|
||||
->execute();
|
||||
$participant = head($latest_participant);
|
||||
$conpherence = id(new ConpherenceThreadQuery())
|
||||
->setViewer($user)
|
||||
->withPHIDs(array($participant->getConpherencePHID()))
|
||||
->needTransactions(true)
|
||||
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
|
||||
->executeOne();
|
||||
}
|
||||
|
||||
if (!$conpherence) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$this->setConpherence($conpherence);
|
||||
|
||||
$participant = $conpherence->getParticipant($user->getPHID());
|
||||
$transactions = $conpherence->getTransactions();
|
||||
$latest_transaction = head($transactions);
|
||||
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$participant->markUpToDate($conpherence, $latest_transaction);
|
||||
unset($write_guard);
|
||||
|
||||
$durable_column = id(new ConpherenceDurableColumnView())
|
||||
->setUser($user)
|
||||
->setSelectedConpherence($conpherence)
|
||||
->setStyle(null);
|
||||
|
||||
$response = array(
|
||||
'content' => hsprintf('%s', $durable_column),
|
||||
'threadID' => $conpherence->getID(),
|
||||
'threadPHID' => $conpherence->getPHID(),
|
||||
'latestTransactionID' => $latest_transaction->getID(),);
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent($response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,15 @@
|
||||
|
||||
abstract class ConpherenceController extends PhabricatorController {
|
||||
|
||||
private $conpherences;
|
||||
private $conpherence;
|
||||
|
||||
public function setConpherence(ConpherenceThread $conpherence) {
|
||||
$this->conpherence = $conpherence;
|
||||
return $this;
|
||||
}
|
||||
public function getConpherence() {
|
||||
return $this->conpherence;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
$nav = new PHUIListView();
|
||||
@@ -77,80 +85,4 @@ abstract class ConpherenceController extends PhabricatorController {
|
||||
$crumbs,
|
||||
));
|
||||
}
|
||||
|
||||
protected function renderConpherenceTransactions(
|
||||
ConpherenceThread $conpherence) {
|
||||
|
||||
$user = $this->getRequest()->getUser();
|
||||
$transactions = $conpherence->getTransactions();
|
||||
$oldest_transaction_id = 0;
|
||||
$too_many = ConpherenceThreadQuery::TRANSACTION_LIMIT + 1;
|
||||
if (count($transactions) == $too_many) {
|
||||
$last_transaction = end($transactions);
|
||||
unset($transactions[$last_transaction->getID()]);
|
||||
$oldest_transaction = end($transactions);
|
||||
$oldest_transaction_id = $oldest_transaction->getID();
|
||||
}
|
||||
$transactions = array_reverse($transactions);
|
||||
$handles = $conpherence->getHandles();
|
||||
$rendered_transactions = array();
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($user);
|
||||
foreach ($transactions as $key => $transaction) {
|
||||
if ($transaction->shouldHide()) {
|
||||
unset($transactions[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($transaction->getComment()) {
|
||||
$engine->addObject(
|
||||
$transaction->getComment(),
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
}
|
||||
}
|
||||
$engine->process();
|
||||
// we're going to insert a dummy date marker transaction for breaks
|
||||
// between days. some setup required!
|
||||
$previous_transaction = null;
|
||||
$date_marker_transaction = id(new ConpherenceTransaction())
|
||||
->setTransactionType(ConpherenceTransactionType::TYPE_DATE_MARKER)
|
||||
->makeEphemeral();
|
||||
$date_marker_transaction_view = id(new ConpherenceTransactionView())
|
||||
->setUser($user)
|
||||
->setConpherenceTransaction($date_marker_transaction)
|
||||
->setHandles($handles)
|
||||
->setMarkupEngine($engine);
|
||||
foreach ($transactions as $transaction) {
|
||||
if ($previous_transaction) {
|
||||
$previous_day = phabricator_format_local_time(
|
||||
$previous_transaction->getDateCreated(),
|
||||
$user,
|
||||
'Ymd');
|
||||
$current_day = phabricator_format_local_time(
|
||||
$transaction->getDateCreated(),
|
||||
$user,
|
||||
'Ymd');
|
||||
// date marker transaction time!
|
||||
if ($previous_day != $current_day) {
|
||||
$date_marker_transaction->setDateCreated(
|
||||
$transaction->getDateCreated());
|
||||
$rendered_transactions[] = $date_marker_transaction_view->render();
|
||||
}
|
||||
}
|
||||
$rendered_transactions[] = id(new ConpherenceTransactionView())
|
||||
->setUser($user)
|
||||
->setConpherenceTransaction($transaction)
|
||||
->setHandles($handles)
|
||||
->setMarkupEngine($engine)
|
||||
->render();
|
||||
$previous_transaction = $transaction;
|
||||
}
|
||||
$latest_transaction_id = $transaction->getID();
|
||||
|
||||
return array(
|
||||
'transactions' => $rendered_transactions,
|
||||
'latest_transaction_id' => $latest_transaction_id,
|
||||
'oldest_transaction_id' => $oldest_transaction_id,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -309,7 +309,12 @@ final class ConpherenceUpdateController
|
||||
->executeOne();
|
||||
|
||||
if ($need_transactions) {
|
||||
$data = $this->renderConpherenceTransactions($conpherence);
|
||||
$data = ConpherenceTransactionView::renderTransactions(
|
||||
$user,
|
||||
$conpherence,
|
||||
!$this->getRequest()->getExists('minimal_display'));
|
||||
$participant_obj = $conpherence->getParticipant($user->getPHID());
|
||||
$participant_obj->markUpToDate($conpherence, $data['latest_transaction']);
|
||||
} else {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
@@ -3,34 +3,10 @@
|
||||
final class ConpherenceViewController extends
|
||||
ConpherenceController {
|
||||
|
||||
private $conpherenceID;
|
||||
private $conpherence;
|
||||
|
||||
public function setConpherence(ConpherenceThread $conpherence) {
|
||||
$this->conpherence = $conpherence;
|
||||
return $this;
|
||||
}
|
||||
public function getConpherence() {
|
||||
return $this->conpherence;
|
||||
}
|
||||
|
||||
public function setConpherenceID($conpherence_id) {
|
||||
$this->conpherenceID = $conpherence_id;
|
||||
return $this;
|
||||
}
|
||||
public function getConpherenceID() {
|
||||
return $this->conpherenceID;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->setConpherenceID(idx($data, 'id'));
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
|
||||
$conpherence_id = $this->getConpherenceID();
|
||||
$conpherence_id = $request->getURIData('id');
|
||||
if (!$conpherence_id) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
@@ -53,13 +29,15 @@ final class ConpherenceViewController extends
|
||||
|
||||
$participant = $conpherence->getParticipant($user->getPHID());
|
||||
$transactions = $conpherence->getTransactions();
|
||||
$latest_transaction = end($transactions);
|
||||
$latest_transaction = head($transactions);
|
||||
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$participant->markUpToDate($conpherence, $latest_transaction);
|
||||
unset($write_guard);
|
||||
|
||||
$data = $this->renderConpherenceTransactions($conpherence);
|
||||
$messages = $this->renderMessagePaneContent(
|
||||
$data = ConpherenceTransactionView::renderTransactions(
|
||||
$user,
|
||||
$conpherence);
|
||||
$messages = ConpherenceTransactionView::renderMessagePaneContent(
|
||||
$data['transactions'],
|
||||
$data['oldest_transaction_id']);
|
||||
if ($before_transaction_id) {
|
||||
@@ -76,6 +54,12 @@ final class ConpherenceViewController extends
|
||||
);
|
||||
}
|
||||
|
||||
$title = $conpherence->getTitle();
|
||||
if (!$title) {
|
||||
$title = pht('[No Title]');
|
||||
}
|
||||
$content['title'] = $title;
|
||||
|
||||
if ($request->isAjax()) {
|
||||
return id(new AphrontAjaxResponse())->setContent($content);
|
||||
}
|
||||
@@ -88,11 +72,7 @@ final class ConpherenceViewController extends
|
||||
->setReplyForm($form)
|
||||
->setRole('thread');
|
||||
|
||||
$title = $conpherence->getTitle();
|
||||
if (!$title) {
|
||||
$title = pht('[No Title]');
|
||||
}
|
||||
return $this->buildApplicationPage(
|
||||
return $this->buildApplicationPage(
|
||||
$layout,
|
||||
array(
|
||||
'title' => $title,
|
||||
@@ -100,29 +80,6 @@ final class ConpherenceViewController extends
|
||||
));
|
||||
}
|
||||
|
||||
private function renderMessagePaneContent(
|
||||
array $transactions,
|
||||
$oldest_transaction_id) {
|
||||
|
||||
$scrollbutton = '';
|
||||
if ($oldest_transaction_id) {
|
||||
$scrollbutton = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#',
|
||||
'mustcapture' => true,
|
||||
'sigil' => 'show-older-messages',
|
||||
'class' => 'conpherence-show-older-messages',
|
||||
'meta' => array(
|
||||
'oldest_transaction_id' => $oldest_transaction_id,
|
||||
),
|
||||
),
|
||||
pht('Show Older Messages'));
|
||||
}
|
||||
|
||||
return hsprintf('%s%s', $scrollbutton, $transactions);
|
||||
}
|
||||
|
||||
private function renderFormContent($latest_transaction_id) {
|
||||
|
||||
$conpherence = $this->getConpherence();
|
||||
@@ -168,4 +125,5 @@ final class ConpherenceViewController extends
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
final class ConpherenceWidgetController extends ConpherenceController {
|
||||
|
||||
private $conpherenceID;
|
||||
private $conpherence;
|
||||
private $userPreferences;
|
||||
|
||||
public function setUserPreferences(PhabricatorUserPreferences $pref) {
|
||||
@@ -15,33 +13,11 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
return $this->userPreferences;
|
||||
}
|
||||
|
||||
public function setConpherence(ConpherenceThread $conpherence) {
|
||||
$this->conpherence = $conpherence;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConpherence() {
|
||||
return $this->conpherence;
|
||||
}
|
||||
|
||||
public function setConpherenceID($conpherence_id) {
|
||||
$this->conpherenceID = $conpherence_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConpherenceID() {
|
||||
return $this->conpherenceID;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->setConpherenceID(idx($data, 'id'));
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$conpherence_id = $this->getConpherenceID();
|
||||
$conpherence_id = $request->getURIData('id');
|
||||
if (!$conpherence_id) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
@@ -54,8 +30,25 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
|
||||
$this->setUserPreferences($user->loadPreferences());
|
||||
|
||||
$widgets = $this->renderWidgetPaneContent();
|
||||
$content = $widgets;
|
||||
switch ($request->getStr('widget')) {
|
||||
case 'widgets-people':
|
||||
$content = $this->renderPeopleWidgetPaneContent();
|
||||
break;
|
||||
case 'widgets-files':
|
||||
$content = $this->renderFileWidgetPaneContent();
|
||||
break;
|
||||
case 'widgets-calendar':
|
||||
$widget = $this->renderCalendarWidgetPaneContent();
|
||||
$content = phutil_implode_html('', $widget);
|
||||
break;
|
||||
case 'widgets-settings':
|
||||
$content = $this->renderSettingsWidgetPaneContent();
|
||||
break;
|
||||
default:
|
||||
$widgets = $this->renderWidgetPaneContent();
|
||||
$content = $widgets;
|
||||
break;
|
||||
}
|
||||
return id(new AphrontAjaxResponse())->setContent($content);
|
||||
}
|
||||
|
||||
@@ -89,11 +82,8 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
'id' => 'widgets-people',
|
||||
'sigil' => 'widgets-people',
|
||||
),
|
||||
id(new ConpherencePeopleWidgetView())
|
||||
->setUser($user)
|
||||
->setConpherence($conpherence)
|
||||
->setUpdateURI($this->getWidgetURI()));
|
||||
$widgets[] = javelin_tag(
|
||||
$this->renderPeopleWidgetPaneContent());
|
||||
$widgets[] = javelin_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'widgets-body',
|
||||
@@ -101,11 +91,8 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
'sigil' => 'widgets-files',
|
||||
'style' => 'display: none;',
|
||||
),
|
||||
id(new ConpherenceFileWidgetView())
|
||||
->setUser($user)
|
||||
->setConpherence($conpherence)
|
||||
->setUpdateURI($this->getWidgetURI()));
|
||||
$widgets[] = phutil_tag(
|
||||
$this->renderFileWidgetPaneContent());
|
||||
$widgets[] = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'widgets-body',
|
||||
@@ -127,11 +114,25 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
return array('widgets' => phutil_implode_html('', $widgets));
|
||||
}
|
||||
|
||||
private function renderPeopleWidgetPaneContent() {
|
||||
return id(new ConpherencePeopleWidgetView())
|
||||
->setUser($this->getViewer())
|
||||
->setConpherence($this->getConpherence())
|
||||
->setUpdateURI($this->getWidgetURI());
|
||||
}
|
||||
|
||||
private function renderFileWidgetPaneContent() {
|
||||
return id(new ConpherenceFileWidgetView())
|
||||
->setUser($this->getViewer())
|
||||
->setConpherence($this->getConpherence())
|
||||
->setUpdateURI($this->getWidgetURI());
|
||||
}
|
||||
|
||||
private function renderSettingsWidgetPaneContent() {
|
||||
$user = $this->getRequest()->getUser();
|
||||
$viewer = $this->getViewer();
|
||||
$conpherence = $this->getConpherence();
|
||||
$participants = $conpherence->getParticipants();
|
||||
$participant = $participants[$user->getPHID()];
|
||||
$participant = $participants[$viewer->getPHID()];
|
||||
$default = ConpherenceSettings::EMAIL_ALWAYS;
|
||||
$preference = $this->getUserPreferences();
|
||||
if ($preference) {
|
||||
@@ -177,7 +178,7 @@ final class ConpherenceWidgetController extends ConpherenceController {
|
||||
);
|
||||
|
||||
return phabricator_form(
|
||||
$user,
|
||||
$viewer,
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'action' => $this->getWidgetURI(),
|
||||
|
||||
@@ -2,45 +2,76 @@
|
||||
|
||||
final class ConpherenceDurableColumnView extends AphrontTagView {
|
||||
|
||||
private $conpherences;
|
||||
private $selectedConpherence;
|
||||
private $transactions;
|
||||
|
||||
public function setConpherences(array $conpherences) {
|
||||
assert_instances_of($conpherences, 'ConpherenceThread');
|
||||
$this->conpherences = $conpherences;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConpherences() {
|
||||
return $this->conpherences;
|
||||
}
|
||||
|
||||
public function setSelectedConpherence(
|
||||
ConpherenceThread $conpherence = null) {
|
||||
$this->selectedConpherence = $conpherence;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSelectedConpherence() {
|
||||
return $this->selectedConpherence;
|
||||
}
|
||||
|
||||
public function setTransactions(array $transactions) {
|
||||
assert_instances_of($transactions, 'ConpherenceTransaction');
|
||||
$this->transactions = $transactions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTransactions() {
|
||||
return $this->transactions;
|
||||
}
|
||||
|
||||
protected function getTagAttributes() {
|
||||
return array(
|
||||
'id' => 'durable-column',
|
||||
'id' => 'conpherence-durable-column',
|
||||
'class' => 'conpherence-durable-column',
|
||||
'style' => 'display: none;',
|
||||
'sigil' => 'conpherence-durable-column',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTagContent() {
|
||||
Javelin::initBehavior('durable-column');
|
||||
|
||||
$classes = array();
|
||||
$classes[] = 'conpherence-durable-column-header';
|
||||
$classes[] = 'sprite-main-header';
|
||||
$classes[] = 'main-header-'.PhabricatorEnv::getEnvConfig('ui.header-color');
|
||||
|
||||
$loading_mask = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'loading-mask',
|
||||
),
|
||||
'');
|
||||
|
||||
$header = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $classes),
|
||||
),
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-header-text',
|
||||
),
|
||||
pht('Column Prototype')));
|
||||
|
||||
$this->buildHeader());
|
||||
$icon_bar = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-icon-bar',
|
||||
),
|
||||
null); // <-- TODO: Icon buttons go here.
|
||||
$this->buildIconBar());
|
||||
|
||||
$copy = pht(
|
||||
'This is a very early prototype of a persistent column. It is not '.
|
||||
'expected to work yet, and leaving it open will activate other new '.
|
||||
'features which will break things. Press "\\" (backslash) on your '.
|
||||
'keyboard to close it now.');
|
||||
$transactions = $this->buildTransactions();
|
||||
|
||||
$content = phutil_tag(
|
||||
'div',
|
||||
@@ -53,19 +84,15 @@ final class ConpherenceDurableColumnView extends AphrontTagView {
|
||||
'id' => 'conpherence-durable-column-content',
|
||||
'class' => 'conpherence-durable-column-frame',
|
||||
),
|
||||
phutil_tag(
|
||||
javelin_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-content',
|
||||
'class' => 'conpherence-durable-column-transactions',
|
||||
'sigil' => 'conpherence-durable-column-transactions',
|
||||
),
|
||||
$copy)));
|
||||
$transactions)));
|
||||
|
||||
$input = phutil_tag(
|
||||
'textarea',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-textarea',
|
||||
'placeholder' => pht('Box for text...'),
|
||||
));
|
||||
$input = $this->buildTextInput();
|
||||
|
||||
$footer = phutil_tag(
|
||||
'div',
|
||||
@@ -73,26 +100,23 @@ final class ConpherenceDurableColumnView extends AphrontTagView {
|
||||
'class' => 'conpherence-durable-column-footer',
|
||||
),
|
||||
array(
|
||||
phutil_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'grey',
|
||||
),
|
||||
pht('Send')),
|
||||
$this->buildSendButton(),
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-status',
|
||||
),
|
||||
pht('Status Text')),
|
||||
$this->buildStatusText()),
|
||||
));
|
||||
|
||||
return array(
|
||||
$loading_mask,
|
||||
$header,
|
||||
phutil_tag(
|
||||
javelin_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-body',
|
||||
'sigil' => 'conpherence-durable-column-body',
|
||||
),
|
||||
array(
|
||||
$icon_bar,
|
||||
@@ -103,4 +127,161 @@ final class ConpherenceDurableColumnView extends AphrontTagView {
|
||||
);
|
||||
}
|
||||
|
||||
private function buildIconBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function buildHeader() {
|
||||
$conpherence = $this->getSelectedConpherence();
|
||||
|
||||
if (!$conpherence) {
|
||||
|
||||
$title = pht('Loading...');
|
||||
$settings_button = null;
|
||||
$settings_menu = null;
|
||||
|
||||
} else {
|
||||
|
||||
$bubble_id = celerity_generate_unique_node_id();
|
||||
$dropdown_id = celerity_generate_unique_node_id();
|
||||
|
||||
$settings_list = new PHUIListView();
|
||||
$cw_registry =
|
||||
ConpherenceWidgetConfigConstants::getWidgetRegistry();
|
||||
$first = true;
|
||||
foreach ($cw_registry as $widget => $config) {
|
||||
$settings_list->addMenuItem(
|
||||
id(new PHUIListItemView())
|
||||
->setHref('#')
|
||||
->setDisabled($first)
|
||||
->setName($config['name'])
|
||||
->setIcon($config['icon'])
|
||||
->addSigil('conpherence-durable-column-widget-selected')
|
||||
->setMetadata(array(
|
||||
'widget' => $widget,
|
||||
)));
|
||||
$first = false;
|
||||
}
|
||||
|
||||
$settings_menu = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'id' => $dropdown_id,
|
||||
'class' => 'phabricator-main-menu-dropdown phui-list-sidenav '.
|
||||
'conpherence-settings-dropdown',
|
||||
'sigil' => 'phabricator-notification-menu',
|
||||
'style' => 'display: none',
|
||||
),
|
||||
$settings_list);
|
||||
|
||||
Javelin::initBehavior(
|
||||
'aphlict-dropdown',
|
||||
array(
|
||||
'bubbleID' => $bubble_id,
|
||||
'dropdownID' => $dropdown_id,
|
||||
'local' => true,
|
||||
'containerDivID' => 'conpherence-durable-column',
|
||||
));
|
||||
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('Settings'))
|
||||
->setIcon('fa-bars')
|
||||
->addClass('core-menu-item')
|
||||
->addSigil('conpherence-settings-menu')
|
||||
->setID($bubble_id)
|
||||
->setAural(pht('Settings'))
|
||||
->setOrder(300);
|
||||
$settings_button = id(new PHUIListView())
|
||||
->addMenuItem($item)
|
||||
->addClass('phabricator-dark-menu')
|
||||
->addClass('phabricator-application-menu');
|
||||
|
||||
$title = $conpherence->getTitle();
|
||||
if (!$title) {
|
||||
$title = pht('[No Title]');
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-header',
|
||||
),
|
||||
array(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'conpherence-durable-column-header-text',
|
||||
),
|
||||
$title),
|
||||
$settings_button,
|
||||
$settings_menu,));
|
||||
|
||||
}
|
||||
|
||||
private function buildTransactions() {
|
||||
$conpherence = $this->getSelectedConpherence();
|
||||
if (!$conpherence) {
|
||||
return pht('Loading...');
|
||||
}
|
||||
|
||||
$data = ConpherenceTransactionView::renderTransactions(
|
||||
$this->getUser(),
|
||||
$conpherence,
|
||||
$full_display = false);
|
||||
$messages = ConpherenceTransactionView::renderMessagePaneContent(
|
||||
$data['transactions'],
|
||||
$data['oldest_transaction_id']);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
private function buildTextInput() {
|
||||
$conpherence = $this->getSelectedConpherence();
|
||||
$textarea = javelin_tag(
|
||||
'textarea',
|
||||
array(
|
||||
'name' => 'text',
|
||||
'class' => 'conpherence-durable-column-textarea',
|
||||
'sigil' => 'conpherence-durable-column-textarea',
|
||||
'placeholder' => pht('Send a message...'),
|
||||
));
|
||||
if (!$conpherence) {
|
||||
return $textarea;
|
||||
}
|
||||
|
||||
$id = $conpherence->getID();
|
||||
return phabricator_form(
|
||||
$this->getUser(),
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'action' => '/conpherence/update/'.$id.'/',
|
||||
'sigil' => 'conpherence-message-form',
|
||||
),
|
||||
array(
|
||||
$textarea,
|
||||
phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'action',
|
||||
'value' => ConpherenceUpdateActions::MESSAGE,
|
||||
)),));
|
||||
}
|
||||
|
||||
private function buildStatusText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function buildSendButton() {
|
||||
return javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'grey',
|
||||
'sigil' => 'conpherence-send-message',
|
||||
),
|
||||
pht('Send'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,52 +79,7 @@ final class ConpherenceLayoutView extends AphrontView {
|
||||
|
||||
$this->initBehavior(
|
||||
'conpherence-widget-pane',
|
||||
array(
|
||||
'widgetBaseUpdateURI' => $this->baseURI.'update/',
|
||||
'widgetRegistry' => array(
|
||||
'conpherence-message-pane' => array(
|
||||
'name' => pht('Thread'),
|
||||
'icon' => 'fa-comment',
|
||||
'deviceOnly' => true,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
'widgets-people' => array(
|
||||
'name' => pht('Participants'),
|
||||
'icon' => 'fa-users',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => true,
|
||||
'createData' => array(
|
||||
'refreshFromResponse' => true,
|
||||
'action' => ConpherenceUpdateActions::ADD_PERSON,
|
||||
'customHref' => null,
|
||||
),
|
||||
),
|
||||
'widgets-files' => array(
|
||||
'name' => pht('Files'),
|
||||
'icon' => 'fa-files-o',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
'widgets-calendar' => array(
|
||||
'name' => pht('Calendar'),
|
||||
'icon' => 'fa-calendar',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => true,
|
||||
'createData' => array(
|
||||
'refreshFromResponse' => false,
|
||||
'action' => ConpherenceUpdateActions::ADD_STATUS,
|
||||
'customHref' => '/calendar/event/create/',
|
||||
),
|
||||
),
|
||||
'widgets-settings' => array(
|
||||
'name' => pht('Settings'),
|
||||
'icon' => 'fa-wrench',
|
||||
'deviceOnly' => false,
|
||||
'hasCreate' => false,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
ConpherenceWidgetConfigConstants::getWidgetPaneBehaviorConfig());
|
||||
|
||||
return javelin_tag(
|
||||
'div',
|
||||
|
||||
@@ -5,6 +5,8 @@ final class ConpherenceTransactionView extends AphrontView {
|
||||
private $conpherenceTransaction;
|
||||
private $handles;
|
||||
private $markupEngine;
|
||||
private $showImages = true;
|
||||
private $showContentSource = true;
|
||||
|
||||
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
|
||||
$this->markupEngine = $markup_engine;
|
||||
@@ -30,6 +32,24 @@ final class ConpherenceTransactionView extends AphrontView {
|
||||
return $this->conpherenceTransaction;
|
||||
}
|
||||
|
||||
public function setShowImages($bool) {
|
||||
$this->showImages = $bool;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getShowImages() {
|
||||
return $this->showImages;
|
||||
}
|
||||
|
||||
public function setShowContentSource($bool) {
|
||||
$this->showContentSource = $bool;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getShowContentSource() {
|
||||
return $this->showContentSource;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$user = $this->getUser();
|
||||
$transaction = $this->getConpherenceTransaction();
|
||||
@@ -59,8 +79,10 @@ final class ConpherenceTransactionView extends AphrontView {
|
||||
$author = $handles[$transaction->getAuthorPHID()];
|
||||
$transaction_view = id(new PhabricatorTransactionView())
|
||||
->setUser($user)
|
||||
->setEpoch($transaction->getDateCreated())
|
||||
->setContentSource($transaction->getContentSource());
|
||||
->setEpoch($transaction->getDateCreated());
|
||||
if ($this->getShowContentSource()) {
|
||||
$transaction_view->setContentSource($transaction->getContentSource());
|
||||
}
|
||||
|
||||
$content = null;
|
||||
$content_class = null;
|
||||
@@ -83,9 +105,10 @@ final class ConpherenceTransactionView extends AphrontView {
|
||||
$comment,
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
$content_class = 'conpherence-message phabricator-remarkup';
|
||||
$transaction_view
|
||||
->setImageURI($author->getImageURI())
|
||||
->setActions(array($author->renderLink()));
|
||||
if ($this->getShowImages()) {
|
||||
$transaction_view->setImageURI($author->getImageURI());
|
||||
}
|
||||
$transaction_view->setActions(array($author->renderLink()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -100,4 +123,108 @@ final class ConpherenceTransactionView extends AphrontView {
|
||||
return $transaction_view->render();
|
||||
}
|
||||
|
||||
public static function renderTransactions(
|
||||
PhabricatorUser $user,
|
||||
ConpherenceThread $conpherence,
|
||||
$full_display = true) {
|
||||
|
||||
$transactions = $conpherence->getTransactions();
|
||||
$oldest_transaction_id = 0;
|
||||
$too_many = ConpherenceThreadQuery::TRANSACTION_LIMIT + 1;
|
||||
if (count($transactions) == $too_many) {
|
||||
$last_transaction = end($transactions);
|
||||
unset($transactions[$last_transaction->getID()]);
|
||||
$oldest_transaction = end($transactions);
|
||||
$oldest_transaction_id = $oldest_transaction->getID();
|
||||
}
|
||||
$transactions = array_reverse($transactions);
|
||||
$handles = $conpherence->getHandles();
|
||||
$rendered_transactions = array();
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($user);
|
||||
foreach ($transactions as $key => $transaction) {
|
||||
if ($transaction->shouldHide()) {
|
||||
unset($transactions[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($transaction->getComment()) {
|
||||
$engine->addObject(
|
||||
$transaction->getComment(),
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
}
|
||||
}
|
||||
$engine->process();
|
||||
// we're going to insert a dummy date marker transaction for breaks
|
||||
// between days. some setup required!
|
||||
$previous_transaction = null;
|
||||
$date_marker_transaction = id(new ConpherenceTransaction())
|
||||
->setTransactionType(ConpherenceTransactionType::TYPE_DATE_MARKER)
|
||||
->makeEphemeral();
|
||||
$date_marker_transaction_view = id(new ConpherenceTransactionView())
|
||||
->setUser($user)
|
||||
->setConpherenceTransaction($date_marker_transaction)
|
||||
->setHandles($handles)
|
||||
->setShowImages($full_display)
|
||||
->setShowContentSource($full_display)
|
||||
->setMarkupEngine($engine);
|
||||
foreach ($transactions as $transaction) {
|
||||
if ($previous_transaction) {
|
||||
$previous_day = phabricator_format_local_time(
|
||||
$previous_transaction->getDateCreated(),
|
||||
$user,
|
||||
'Ymd');
|
||||
$current_day = phabricator_format_local_time(
|
||||
$transaction->getDateCreated(),
|
||||
$user,
|
||||
'Ymd');
|
||||
// date marker transaction time!
|
||||
if ($previous_day != $current_day) {
|
||||
$date_marker_transaction->setDateCreated(
|
||||
$transaction->getDateCreated());
|
||||
$rendered_transactions[] = $date_marker_transaction_view->render();
|
||||
}
|
||||
}
|
||||
$rendered_transactions[] = id(new ConpherenceTransactionView())
|
||||
->setUser($user)
|
||||
->setConpherenceTransaction($transaction)
|
||||
->setHandles($handles)
|
||||
->setMarkupEngine($engine)
|
||||
->setShowImages($full_display)
|
||||
->setShowContentSource($full_display)
|
||||
->render();
|
||||
$previous_transaction = $transaction;
|
||||
}
|
||||
$latest_transaction_id = $transaction->getID();
|
||||
|
||||
return array(
|
||||
'transactions' => $rendered_transactions,
|
||||
'latest_transaction' => $transaction,
|
||||
'latest_transaction_id' => $latest_transaction_id,
|
||||
'oldest_transaction_id' => $oldest_transaction_id,
|
||||
);
|
||||
}
|
||||
|
||||
public static function renderMessagePaneContent(
|
||||
array $transactions,
|
||||
$oldest_transaction_id) {
|
||||
|
||||
$scrollbutton = '';
|
||||
if ($oldest_transaction_id) {
|
||||
$scrollbutton = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#',
|
||||
'mustcapture' => true,
|
||||
'sigil' => 'show-older-messages',
|
||||
'class' => 'conpherence-show-older-messages',
|
||||
'meta' => array(
|
||||
'oldest_transaction_id' => $oldest_transaction_id,
|
||||
),
|
||||
),
|
||||
pht('Show Older Messages'));
|
||||
}
|
||||
|
||||
return hsprintf('%s%s', $scrollbutton, $transactions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,14 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
||||
}
|
||||
|
||||
public function getShowDurableColumn() {
|
||||
return $this->showDurableColumn;
|
||||
$request = $this->getRequest();
|
||||
if ($request) {
|
||||
$viewer = $request->getUser();
|
||||
return PhabricatorApplication::isClassInstalledForViewer(
|
||||
'PhabricatorConpherenceApplication',
|
||||
$viewer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
@@ -391,7 +398,12 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
||||
|
||||
$durable_column = null;
|
||||
if ($this->getShowDurableColumn()) {
|
||||
$durable_column = new ConpherenceDurableColumnView();
|
||||
$durable_column = id(new ConpherenceDurableColumnView())
|
||||
->setSelectedConpherence(null)
|
||||
->setUser($user);
|
||||
Javelin::initBehavior(
|
||||
'durable-column',
|
||||
array());
|
||||
}
|
||||
|
||||
return phutil_tag(
|
||||
|
||||
Reference in New Issue
Block a user