mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Conpherence - get lots of rooms stuff hooked up nicely
Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
This commit is contained in:
parent
9005ce4e9f
commit
39fa190c15
4 changed files with 220 additions and 49 deletions
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue