Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14411617
D12149.id29207.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Referenced Files
None
Subscribers
None
D12149.id29207.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -49,7 +49,7 @@
'rsrc/css/application/conpherence/message-pane.css' => 'e78e9d3c',
'rsrc/css/application/conpherence/notification.css' => '04a6e10a',
'rsrc/css/application/conpherence/update.css' => '1099a660',
- 'rsrc/css/application/conpherence/widget-pane.css' => '9efbfed0',
+ 'rsrc/css/application/conpherence/widget-pane.css' => '9199d87c',
'rsrc/css/application/contentsource/content-source-view.css' => '4b8b05d4',
'rsrc/css/application/countdown/timer.css' => '86b7b0a0',
'rsrc/css/application/dashboard/dashboard.css' => '17937d22',
@@ -354,7 +354,7 @@
'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de',
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '24561adb',
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'eedc463c',
- 'rsrc/js/application/conpherence/behavior-menu.js' => 'c4151295',
+ 'rsrc/js/application/conpherence/behavior-menu.js' => 'be9207ed',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '21ba5861',
'rsrc/js/application/conpherence/behavior-quicksand-blacklist.js' => '7927a7d3',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => '2c1cd7f5',
@@ -519,7 +519,7 @@
'conpherence-notification-css' => '04a6e10a',
'conpherence-thread-manager' => '24561adb',
'conpherence-update-css' => '1099a660',
- 'conpherence-widget-pane-css' => '9efbfed0',
+ 'conpherence-widget-pane-css' => '9199d87c',
'differential-changeset-view-css' => '79c27a4c',
'differential-core-view-css' => '7ac3cabc',
'differential-inline-comment-editor' => 'f2431bc1',
@@ -556,7 +556,7 @@
'javelin-behavior-boards-dropdown' => '0ec56e1d',
'javelin-behavior-choose-control' => '6153c708',
'javelin-behavior-config-reorder-fields' => '14a827de',
- 'javelin-behavior-conpherence-menu' => 'c4151295',
+ 'javelin-behavior-conpherence-menu' => 'be9207ed',
'javelin-behavior-conpherence-pontificate' => '21ba5861',
'javelin-behavior-conpherence-widget-pane' => '2c1cd7f5',
'javelin-behavior-countdown-timer' => 'e4cc26b3',
@@ -1718,14 +1718,7 @@
'javelin-util',
'phabricator-shaped-request',
),
- 'c1700f6f' => array(
- 'javelin-install',
- 'javelin-util',
- 'javelin-stratcom',
- 'javelin-dom',
- 'javelin-vector',
- ),
- 'c4151295' => array(
+ 'be9207ed' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
@@ -1737,6 +1730,13 @@
'phabricator-shaped-request',
'conpherence-thread-manager',
),
+ 'c1700f6f' => array(
+ 'javelin-install',
+ 'javelin-util',
+ 'javelin-stratcom',
+ 'javelin-dom',
+ 'javelin-vector',
+ ),
'c51ae228' => array(
'javelin-behavior',
'javelin-util',
diff --git a/src/applications/conpherence/constants/ConpherenceUpdateActions.php b/src/applications/conpherence/constants/ConpherenceUpdateActions.php
--- a/src/applications/conpherence/constants/ConpherenceUpdateActions.php
+++ b/src/applications/conpherence/constants/ConpherenceUpdateActions.php
@@ -5,6 +5,7 @@
const METADATA = 'metadata';
const MESSAGE = 'message';
const DRAFT = 'draft';
+ const JOIN_ROOM = 'join_room';
const ADD_PERSON = 'add_person';
const REMOVE_PERSON = 'remove_person';
const NOTIFICATIONS = 'notifications';
diff --git a/src/applications/conpherence/controller/ConpherenceListController.php b/src/applications/conpherence/controller/ConpherenceListController.php
--- a/src/applications/conpherence/controller/ConpherenceListController.php
+++ b/src/applications/conpherence/controller/ConpherenceListController.php
@@ -69,11 +69,23 @@
if ($conpherence->getTitle()) {
$title = $conpherence->getTitle();
}
- $cursor = $conpherence->getParticipant($user->getPHID());
- $data = $this->loadParticipationWithMidCursor($cursor);
- $all_participation = $data['participation'];
- $scroll_up_participant = $data['scroll_up_participant'];
- $scroll_down_participant = $data['scroll_down_participant'];
+ $cursor = $conpherence->getParticipantIfExists($user->getPHID());
+ if ($cursor) {
+ $data = $this->loadParticipationWithMidCursor($cursor);
+ $all_participation = $data['all_participation'];
+ $scroll_up_participant = $data['scroll_up_participant'];
+ $scroll_down_participant = $data['scroll_down_participant'];
+ } else {
+ $data = $this->loadDefaultParticipation($too_many);
+ $all_participation = $data['all_participation'];
+ $scroll_down_participant = $data['scroll_down_participant'];
+ $menu_participation = $this->getEmptyParticipant()
+ ->setConpherencePHID($conpherence->getPHID())
+ ->setParticipantPHID($user->getPHID());
+ $all_participation =
+ array($conpherence->getPHID() => $menu_participation) +
+ $all_participation;
+ }
break;
case self::PAGING_MODE:
$direction = $request->getStr('direction');
@@ -108,16 +120,9 @@
break;
case self::UNSELECTED_MODE:
default:
- $too_many = ConpherenceParticipantQuery::LIMIT + 1;
- $all_participation = id(new ConpherenceParticipantQuery())
- ->withParticipantPHIDs(array($user->getPHID()))
- ->setLimit($too_many)
- ->execute();
- if (count($all_participation) == $too_many) {
- $node = end($all_participation);
- unset($all_participation[$node->getConpherencePHID()]);
- $scroll_down_participant = $node;
- }
+ $data = $this->loadDefaultParticipation($too_many);
+ $all_participation = $data['all_participation'];
+ $scroll_down_participant = $data['scroll_down_participant'];
break;
}
@@ -171,6 +176,26 @@
}
+ private function loadDefaultParticipation($too_many) {
+ $viewer = $this->getRequest()->getUser();
+
+ $scroll_down_participant = $this->getEmptyParticipant();
+
+ $all_participation = id(new ConpherenceParticipantQuery())
+ ->withParticipantPHIDs(array($viewer->getPHID()))
+ ->setLimit($too_many)
+ ->execute();
+ if (count($all_participation) == $too_many) {
+ $node = end($all_participation);
+ unset($all_participation[$node->getConpherencePHID()]);
+ $scroll_down_participant = $node;
+ }
+
+ return array(
+ 'all_participation' => $all_participation,
+ 'scroll_down_participant' => $scroll_down_participant,);
+ }
+
/**
* Handles the curious case when we are visiting a conpherence directly
* by issuing two separate queries. Otherwise, additional conpherences
@@ -224,7 +249,7 @@
return array(
'scroll_up_participant' => $scroll_up_participant,
'scroll_down_participant' => $scroll_down_participant,
- 'participation' => $participation,
+ 'all_participation' => $participation,
);
}
diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php
--- a/src/applications/conpherence/controller/ConpherenceUpdateController.php
+++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php
@@ -53,6 +53,28 @@
$draft->setDraft($request->getStr('text'));
$draft->replaceOrDelete();
return new AphrontAjaxResponse();
+ case ConpherenceUpdateActions::JOIN_ROOM:
+ PhabricatorPolicyFilter::requireCapability(
+ $user,
+ $conpherence,
+ PhabricatorPolicyCapability::CAN_JOIN);
+ $xactions[] = id(new ConpherenceTransaction())
+ ->setTransactionType(
+ ConpherenceTransactionType::TYPE_PARTICIPANTS)
+ ->setNewValue(array('+' => array($user->getPHID())));
+ $delete_draft = true;
+ $message = $request->getStr('text');
+ if ($message) {
+ $message_xactions = $editor->generateTransactionsFromText(
+ $user,
+ $conpherence,
+ $message);
+ $xactions = array_merge($xactions, $message_xactions);
+ }
+ // for now, just redirect back to the conpherence so everything
+ // will work okay...!
+ $response_mode = 'redirect';
+ break;
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
$xactions = $editor->generateTransactionsFromText(
@@ -86,7 +108,10 @@
break;
case ConpherenceUpdateActions::NOTIFICATIONS:
$notifications = $request->getStr('notifications');
- $participant = $conpherence->getParticipant($user->getPHID());
+ $participant = $conpherence->getParticipantIfExists($user->getPHID());
+ if (!$participant) {
+ return id(new Aphront404Response());
+ }
$participant->setSettings(array('notifications' => $notifications));
$participant->save();
$result = pht(
@@ -126,23 +151,23 @@
break;
}
- if ($xactions || ($action == ConpherenceUpdateActions::LOAD)) {
- if ($xactions) {
- try {
- $xactions = $editor->applyTransactions($conpherence, $xactions);
- if ($delete_draft) {
- $draft = PhabricatorDraft::newFromUserAndKey(
- $user,
- $conpherence->getPHID());
- $draft->delete();
- }
- } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
- return id(new PhabricatorApplicationTransactionNoEffectResponse())
- ->setCancelURI($this->getApplicationURI($conpherence_id.'/'))
- ->setException($ex);
+ if ($xactions) {
+ try {
+ $xactions = $editor->applyTransactions($conpherence, $xactions);
+ if ($delete_draft) {
+ $draft = PhabricatorDraft::newFromUserAndKey(
+ $user,
+ $conpherence->getPHID());
+ $draft->delete();
}
+ } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
+ return id(new PhabricatorApplicationTransactionNoEffectResponse())
+ ->setCancelURI($this->getApplicationURI($conpherence_id.'/'))
+ ->setException($ex);
}
+ }
+ if ($xactions || ($action == ConpherenceUpdateActions::LOAD)) {
switch ($response_mode) {
case 'ajax':
$latest_transaction_id = $request->getInt('latest_transaction_id');
diff --git a/src/applications/conpherence/controller/ConpherenceViewController.php b/src/applications/conpherence/controller/ConpherenceViewController.php
--- a/src/applications/conpherence/controller/ConpherenceViewController.php
+++ b/src/applications/conpherence/controller/ConpherenceViewController.php
@@ -27,12 +27,14 @@
}
$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);
+ $participant = $conpherence->getParticipantIfExists($user->getPHID());
+ if ($participant) {
+ $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
+ $participant->markUpToDate($conpherence, $latest_transaction);
+ unset($write_guard);
+ }
$data = ConpherenceTransactionView::renderTransactions(
$user,
@@ -85,9 +87,24 @@
$conpherence = $this->getConpherence();
$user = $this->getRequest()->getUser();
+ $can_join = PhabricatorPolicyFilter::hasCapability(
+ $user,
+ $conpherence,
+ PhabricatorPolicyCapability::CAN_JOIN);
+ $participating = $conpherence->getParticipantIfExists($user->getPHID());
+ if (!$can_join && !$participating) {
+ return null;
+ }
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
+ if ($participating) {
+ $action = ConpherenceUpdateActions::MESSAGE;
+ $button_text = pht('Send');
+ } else {
+ $action = ConpherenceUpdateActions::JOIN_ROOM;
+ $button_text = pht('Join');
+ }
$update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$this->initBehavior('conpherence-pontificate');
@@ -98,7 +115,7 @@
->addSigil('conpherence-pontificate')
->setWorkflow(true)
->setUser($user)
- ->addHiddenInput('action', 'message')
+ ->addHiddenInput('action', $action)
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
@@ -106,7 +123,7 @@
->setValue($draft->getDraft()))
->appendChild(
id(new AphrontFormSubmitControl())
- ->setValue(pht('Send')))
+ ->setValue($button_text))
->render();
return $form;
diff --git a/src/applications/conpherence/controller/ConpherenceWidgetController.php b/src/applications/conpherence/controller/ConpherenceWidgetController.php
--- a/src/applications/conpherence/controller/ConpherenceWidgetController.php
+++ b/src/applications/conpherence/controller/ConpherenceWidgetController.php
@@ -130,8 +130,24 @@
private function renderSettingsWidgetPaneContent() {
$viewer = $this->getViewer();
$conpherence = $this->getConpherence();
- $participants = $conpherence->getParticipants();
- $participant = $participants[$viewer->getPHID()];
+ $participant = $conpherence->getParticipantIfExists($viewer->getPHID());
+ if (!$participant) {
+ $can_join = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $conpherence,
+ PhabricatorPolicyCapability::CAN_JOIN);
+ if ($can_join) {
+ $text = pht('Settings are available after joining the room.');
+ } else {
+ $text = pht('Settings not applicable to rooms you can not join.');
+ }
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'no-settings',
+ ),
+ $text);
+ }
$default = ConpherenceSettings::EMAIL_ALWAYS;
$preference = $this->getUserPreferences();
if ($preference) {
diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php
--- a/src/applications/conpherence/editor/ConpherenceEditor.php
+++ b/src/applications/conpherence/editor/ConpherenceEditor.php
@@ -321,6 +321,15 @@
PhabricatorLiskDAO $object,
array $xactions) {
+ $message_count = 0;
+ foreach ($xactions as $xaction) {
+ switch ($xaction->getTransactionType()) {
+ case PhabricatorTransactions::TYPE_COMMENT:
+ $message_count++;
+ break;
+ }
+ }
+
// update everyone's participation status on the last xaction -only-
$xaction = end($xactions);
$xaction_phid = $xaction->getPHID();
@@ -333,8 +342,8 @@
if ($phid != $user->getPHID()) {
if ($participant->getParticipationStatus() != $behind) {
$participant->setBehindTransactionPHID($xaction_phid);
- // decrement one as this is the message putting them behind!
- $participant->setSeenMessageCount($object->getMessageCount() - 1);
+ $participant->setSeenMessageCount(
+ $object->getMessageCount() - $message_count);
}
$participant->setParticipationStatus($behind);
$participant->setDateTouched($time);
diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php
--- a/src/applications/conpherence/storage/ConpherenceThread.php
+++ b/src/applications/conpherence/storage/ConpherenceThread.php
@@ -98,9 +98,9 @@
$participants = $this->getParticipants();
return $participants[$phid];
}
- public function getParticipantIfExists($phid) {
+ public function getParticipantIfExists($phid, $default = null) {
$participants = $this->getParticipants();
- return idx($participants, $phid);
+ return idx($participants, $phid, $default);
}
public function getParticipantPHIDs() {
@@ -221,7 +221,10 @@
);
}
+
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
+
+
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -393,6 +393,10 @@
case PhabricatorTransactions::TYPE_EDIT_POLICY:
$object->setEditPolicy($xaction->getNewValue());
break;
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
+ $object->setJoinPolicy($xaction->getNewValue());
+ break;
+
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
$field = $this->getCustomFieldForTransaction($object, $xaction);
return $field->applyApplicationTransactionInternalEffects($xaction);
diff --git a/webroot/rsrc/css/application/conpherence/widget-pane.css b/webroot/rsrc/css/application/conpherence/widget-pane.css
--- a/webroot/rsrc/css/application/conpherence/widget-pane.css
+++ b/webroot/rsrc/css/application/conpherence/widget-pane.css
@@ -376,3 +376,15 @@
.conpherence-widget-pane .notifications-update {
margin: 3px 0px 0px 4px;
}
+
+.conpherence-widget-pane .no-settings {
+ width: 200px;
+ padding: 20px;
+ text-align: center;
+ color: {$greytext};
+}
+
+.device .conpherence-widget-pane .no-settings {
+ width: 60px;
+ margin: 0 auto 0 auto;
+}
diff --git a/webroot/rsrc/js/application/conpherence/behavior-menu.js b/webroot/rsrc/js/application/conpherence/behavior-menu.js
--- a/webroot/rsrc/js/application/conpherence/behavior-menu.js
+++ b/webroot/rsrc/js/application/conpherence/behavior-menu.js
@@ -321,13 +321,17 @@
function _focusTextarea() {
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
var form_root = JX.DOM.find(root, 'div', 'conpherence-form');
- var textarea = JX.DOM.find(form_root, 'textarea');
- // We may have a draft so do this JS trick so we end up focused at the
- // end of the draft.
- var textarea_value = textarea.value;
- textarea.value = '';
- JX.DOM.focus(textarea);
- textarea.value = textarea_value;
+ try {
+ var textarea = JX.DOM.find(form_root, 'textarea');
+ // We may have a draft so do this JS trick so we end up focused at the
+ // end of the draft.
+ var textarea_value = textarea.value;
+ textarea.value = '';
+ JX.DOM.focus(textarea);
+ textarea.value = textarea_value;
+ } catch (ex) {
+ // no textarea? no problem
+ }
}
JX.Stratcom.listen(
'conpherence-redraw-thread',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 11:46 AM (49 m, 59 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6925825
Default Alt Text
D12149.id29207.diff (18 KB)
Attached To
Mode
D12149: Conpherence - implement join / view rules for rooms
Attached
Detach File
Event Timeline
Log In to Comment