diff --git a/src/applications/conpherence/controller/ConpherenceListController.php b/src/applications/conpherence/controller/ConpherenceListController.php index e637c1a668..de79d1c720 100644 --- a/src/applications/conpherence/controller/ConpherenceListController.php +++ b/src/applications/conpherence/controller/ConpherenceListController.php @@ -6,20 +6,6 @@ final class ConpherenceListController extends ConpherenceController { const UNSELECTED_MODE = 'unselected'; const PAGING_MODE = 'paging'; - private $conpherenceID; - - 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')); - } - /** * Three main modes of operation... * @@ -44,8 +30,8 @@ final class ConpherenceListController extends ConpherenceController { return $mode; } - public function processRequest() { - $request = $this->getRequest(); + + public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $title = pht('Conpherence'); $conpherence = null; @@ -58,7 +44,7 @@ final class ConpherenceListController extends ConpherenceController { $mode = $this->determineMode(); switch ($mode) { case self::SELECTED_MODE: - $conpherence_id = $this->getConpherenceID(); + $conpherence_id = $request->getURIData('id'); $conpherence = id(new ConpherenceThreadQuery()) ->setViewer($user) ->withIDs(array($conpherence_id)) @@ -70,12 +56,7 @@ final class ConpherenceListController extends ConpherenceController { $title = $conpherence->getTitle(); } $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 { + if (!$cursor || $conpherence->getIsRoom()) { $data = $this->loadDefaultParticipation($too_many); $all_participation = $data['all_participation']; $scroll_down_participant = $data['scroll_down_participant']; @@ -85,6 +66,12 @@ final class ConpherenceListController extends ConpherenceController { $all_participation = array($conpherence->getPHID() => $menu_participation) + $all_participation; + + } else { + $data = $this->loadParticipationWithMidCursor($cursor); + $all_participation = $data['all_participation']; + $scroll_up_participant = $data['scroll_up_participant']; + $scroll_down_participant = $data['scroll_down_participant']; } break; case self::PAGING_MODE: diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index 7813273f40..0f5be65547 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -135,6 +135,9 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { case ConpherenceTransactionType::TYPE_TITLE: return $object->getTitle(); case ConpherenceTransactionType::TYPE_PARTICIPANTS: + if ($this->getIsNewObject()) { + return array(); + } return $object->getParticipantPHIDs(); case ConpherenceTransactionType::TYPE_FILES: return $object->getFilePHIDs(); diff --git a/src/applications/conpherence/storage/ConpherenceTransaction.php b/src/applications/conpherence/storage/ConpherenceTransaction.php index d7f90974c4..464e8da57b 100644 --- a/src/applications/conpherence/storage/ConpherenceTransaction.php +++ b/src/applications/conpherence/storage/ConpherenceTransaction.php @@ -53,24 +53,15 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { switch ($this->getTransactionType()) { case ConpherenceTransactionType::TYPE_TITLE: - if ($old && $new) { - $title = pht( - '%s renamed this thread from "%s" to "%s".', - $this->renderHandleLink($author_phid), - $old, - $new); - } else if ($old) { - $title = pht( - '%s deleted the thread name "%s".', - $this->renderHandleLink($author_phid), - $old); + case PhabricatorTransactions::TYPE_VIEW_POLICY: + case PhabricatorTransactions::TYPE_EDIT_POLICY: + case PhabricatorTransactions::TYPE_JOIN_POLICY: + if ($this->getObject()->getIsRoom()) { + return $this->getRoomTitle(); } else { - $title = pht( - '%s named this thread "%s".', - $this->renderHandleLink($author_phid), - $new); + return $this->getThreadTitle(); } - return $title; + break; case ConpherenceTransactionType::TYPE_FILES: $add = array_diff($new, $old); $rem = array_diff($old, $new); @@ -126,6 +117,108 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { return parent::getTitle(); } + private function getRoomTitle() { + $author_phid = $this->getAuthorPHID(); + + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + switch ($this->getTransactionType()) { + case ConpherenceTransactionType::TYPE_TITLE: + if ($old && $new) { + $title = pht( + '%s renamed this room from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $old, + $new); + } else if ($old) { + $title = pht( + '%s deleted the room name "%s".', + $this->renderHandleLink($author_phid), + $old); + } else { + $title = pht( + '%s named this room "%s".', + $this->renderHandleLink($author_phid), + $new); + } + return $title; + break; + case PhabricatorTransactions::TYPE_VIEW_POLICY: + return pht( + '%s changed the visibility of this room from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + case PhabricatorTransactions::TYPE_EDIT_POLICY: + return pht( + '%s changed the edit policy of this room from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + case PhabricatorTransactions::TYPE_JOIN_POLICY: + return pht( + '%s changed the join policy of this room from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + } + } + + private function getThreadTitle() { + $author_phid = $this->getAuthorPHID(); + + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + switch ($this->getTransactionType()) { + case ConpherenceTransactionType::TYPE_TITLE: + if ($old && $new) { + $title = pht( + '%s renamed this thread from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $old, + $new); + } else if ($old) { + $title = pht( + '%s deleted the thread name "%s".', + $this->renderHandleLink($author_phid), + $old); + } else { + $title = pht( + '%s named this thread "%s".', + $this->renderHandleLink($author_phid), + $new); + } + return $title; + break; + case PhabricatorTransactions::TYPE_VIEW_POLICY: + return pht( + '%s changed the visibility of this thread from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + case PhabricatorTransactions::TYPE_EDIT_POLICY: + return pht( + '%s changed the edit policy of this thread from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + case PhabricatorTransactions::TYPE_JOIN_POLICY: + return pht( + '%s changed the join policy of this thread from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderPolicyName($old, 'old'), + $this->renderPolicyName($new, 'new')); + break; + } + } + public function getRequiredHandlePHIDs() { $phids = parent::getRequiredHandlePHIDs(); @@ -146,5 +239,4 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { return $phids; } - } diff --git a/src/applications/conpherence/view/ConpherenceThreadListView.php b/src/applications/conpherence/view/ConpherenceThreadListView.php index 38ee054141..66ded65c4d 100644 --- a/src/applications/conpherence/view/ConpherenceThreadListView.php +++ b/src/applications/conpherence/view/ConpherenceThreadListView.php @@ -33,17 +33,39 @@ final class ConpherenceThreadListView extends AphrontView { public function render() { require_celerity_resource('conpherence-menu-css'); + $grouped = mgroup($this->threads, 'getIsRoom'); + $rooms = idx($grouped, true, array()); + $rooms = array_slice($grouped[true], 0, 5); + + $policies = array(); + foreach ($rooms as $room) { + $policies[] = $room->getViewPolicy(); + } + $policy_objects = array(); + if ($policies) { + $policy_objects = id(new PhabricatorPolicyQuery()) + ->setViewer($this->getUser()) + ->withPHIDs($policies) + ->execute(); + } + $menu = id(new PHUIListView()) ->addClass('conpherence-menu') ->setID('conpherence-menu'); - $this->addThreadsToMenu($menu, $this->threads); + $this->addRoomsToMenu($menu, $rooms, $policy_objects); + $messages = idx($grouped, false, array()); + $this->addThreadsToMenu($menu, $messages); return $menu; } public function renderSingleThread(ConpherenceThread $thread) { - return $this->renderThread($thread); + $policy_objects = id(new PhabricatorPolicyQuery()) + ->setViewer($this->getUser()) + ->setObject($thread) + ->execute(); + return $this->renderThread($thread, $policy_objects); } public function renderThreadsHTML() { @@ -68,18 +90,31 @@ final class ConpherenceThreadListView extends AphrontView { return phutil_implode_html('', $thread_html); } - private function renderThreadItem(ConpherenceThread $thread) { + private function renderThreadItem( + ConpherenceThread $thread, + $policy_objects = array()) { return id(new PHUIListItemView()) ->setType(PHUIListItemView::TYPE_CUSTOM) - ->setName($this->renderThread($thread)); + ->setName($this->renderThread($thread, $policy_objects)); } - private function renderThread(ConpherenceThread $thread) { + private function renderThread( + ConpherenceThread $thread, + array $policy_objects) { + $user = $this->getUser(); $uri = $this->baseURI.$thread->getID().'/'; $data = $thread->getDisplayData($user); - $title = $data['title']; + $title = phutil_tag( + 'span', + array(), + array( + id(new PHUIIconView()) + ->addClass('mmr') + ->setIconFont($thread->getPolicyIconName($policy_objects)), + $data['title'], + )); $subtitle = $data['subtitle']; $unread_count = $data['unread_count']; $epoch = $data['epoch']; @@ -104,6 +139,46 @@ final class ConpherenceThreadListView extends AphrontView { )); } + private function addRoomsToMenu( + PHUIListView $menu, + array $conpherences, + array $policy_objects) { + + $header = $this->renderMenuItemHeader(pht('Rooms')); + $menu->addMenuItem($header); + + if (empty($conpherences)) { + $join_item = id(new PHUIListItemView()) + ->setType(PHUIListItemView::TYPE_LINK) + ->setHref('/conpherence/room/') + ->setName(pht('Join a Room')); + $menu->addMenuItem($join_item); + + $create_item = id(new PHUIListItemView()) + ->setType(PHUIListItemView::TYPE_LINK) + ->setHref('/conpherence/room/new/') + ->setWorkflow(true) + ->setName(pht('Create a Room')); + $menu->addMenuItem($create_item); + + return $menu; + } + + foreach ($conpherences as $conpherence) { + $item = $this->renderThreadItem($conpherence, $policy_objects); + $menu->addMenuItem($item); + } + + $more_item = id(new PHUIListItemView()) + ->setType(PHUIListItemView::TYPE_LINK) + ->setHref('/conpherence/room/query/participant/') + ->setName(pht('See More')); + $menu->addMenuItem($more_item); + + return $menu; + } + + private function addThreadsToMenu( PHUIListView $menu, array $conpherences) { @@ -113,7 +188,7 @@ final class ConpherenceThreadListView extends AphrontView { $menu->addMenuItem($item); } - $header = $this->renderMenuItemHeader(pht('Recent')); + $header = $this->renderMenuItemHeader(pht('Messages')); $menu->addMenuItem($header); foreach ($conpherences as $conpherence) { @@ -163,17 +238,31 @@ final class ConpherenceThreadListView extends AphrontView { return $item; } - private function getNoConpherencesMenuItem() { + private function getNoMessagesMenuItem() { $message = phutil_tag( 'div', array( 'class' => 'no-conpherences-menu-item', ), - pht('No Conpherences')); + pht('No Messages')); return id(new PHUIListItemView()) ->setType(PHUIListItemView::TYPE_CUSTOM) ->setName($message); } + private function getNoRoomsMenuItem() { + $message = phutil_tag( + 'div', + array( + 'class' => 'no-conpherences-menu-item', + ), + pht('No Rooms')); + + return id(new PHUIListItemView()) + ->setType(PHUIListItemView::TYPE_CUSTOM) + ->setName($message); + } + + }