1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Use PHUIListItemView in ConpherenceThreadList

Summary: Fixes T12556 Uses more common components in ConpherenceThreadList by moving to PHUIListItemView. Reduces clutter by moving privacy into the header. Gets ride of "See More" double interchanges.

Test Plan:
I need to test this more, doesn't seem to auto-select top room any more, also might build a lipsum generator.

 - Create lots of rooms with various policies
 - Test clicking on policy object
 - Click on different rooms
 - Post in rooms
 - Load up second account, see room numbers
 - Clear room message count by clicking on room

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12556

Differential Revision: https://secure.phabricator.com/D17698
This commit is contained in:
Chad Little 2017-04-17 10:59:11 -07:00
parent f801c7ae29
commit 2d00f56837
12 changed files with 169 additions and 227 deletions

View file

@ -7,8 +7,8 @@
*/
return array(
'names' => array(
'conpherence.pkg.css' => '437d3b5a',
'conpherence.pkg.js' => '281b1a73',
'conpherence.pkg.css' => '1b8422e1',
'conpherence.pkg.js' => '5f86c17d',
'core.pkg.css' => 'b2ad82f4',
'core.pkg.js' => 'deabcef7',
'darkconsole.pkg.js' => 'e7393ebb',
@ -46,11 +46,11 @@ return array(
'rsrc/css/application/config/setup-issue.css' => 'f794cfc3',
'rsrc/css/application/config/unhandled-exception.css' => '4c96257a',
'rsrc/css/application/conpherence/durable-column.css' => '89ea6bef',
'rsrc/css/application/conpherence/header-pane.css' => '4082233d',
'rsrc/css/application/conpherence/menu.css' => '3d8e5c9c',
'rsrc/css/application/conpherence/message-pane.css' => 'd1fc13e1',
'rsrc/css/application/conpherence/header-pane.css' => '92d50767',
'rsrc/css/application/conpherence/menu.css' => '88100764',
'rsrc/css/application/conpherence/message-pane.css' => '14199428',
'rsrc/css/application/conpherence/notification.css' => 'cef0a3fc',
'rsrc/css/application/conpherence/participant-pane.css' => '604a8b02',
'rsrc/css/application/conpherence/participant-pane.css' => '26a3ce56',
'rsrc/css/application/conpherence/transaction.css' => '85129c68',
'rsrc/css/application/contentsource/content-source-view.css' => '4b8b05d4',
'rsrc/css/application/countdown/timer.css' => '16c52f5c',
@ -373,7 +373,7 @@ return array(
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => 'c8b5ee6f',
'rsrc/js/application/conpherence/behavior-conpherence-search.js' => '9bbf3762',
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3bd034',
'rsrc/js/application/conpherence/behavior-menu.js' => '7524fcfa',
'rsrc/js/application/conpherence/behavior-menu.js' => '80dda04a',
'rsrc/js/application/conpherence/behavior-participant-pane.js' => '8604caa8',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '55616e04',
'rsrc/js/application/conpherence/behavior-quicksand-blacklist.js' => '7927a7d3',
@ -553,11 +553,11 @@ return array(
'config-options-css' => '0ede4c9b',
'config-page-css' => 'c1d5121b',
'conpherence-durable-column-view' => '89ea6bef',
'conpherence-header-pane-css' => '4082233d',
'conpherence-menu-css' => '3d8e5c9c',
'conpherence-message-pane-css' => 'd1fc13e1',
'conpherence-header-pane-css' => '92d50767',
'conpherence-menu-css' => '88100764',
'conpherence-message-pane-css' => '14199428',
'conpherence-notification-css' => 'cef0a3fc',
'conpherence-participant-pane-css' => '604a8b02',
'conpherence-participant-pane-css' => '26a3ce56',
'conpherence-thread-manager' => 'c8b5ee6f',
'conpherence-transaction-css' => '85129c68',
'd3' => 'a11a5ff2',
@ -598,7 +598,7 @@ return array(
'javelin-behavior-choose-control' => '327a00d1',
'javelin-behavior-comment-actions' => '9a6dd75c',
'javelin-behavior-config-reorder-fields' => 'b6993408',
'javelin-behavior-conpherence-menu' => '7524fcfa',
'javelin-behavior-conpherence-menu' => '80dda04a',
'javelin-behavior-conpherence-participant-pane' => '8604caa8',
'javelin-behavior-conpherence-pontificate' => '55616e04',
'javelin-behavior-conpherence-search' => '9bbf3762',
@ -1430,20 +1430,6 @@ return array(
'javelin-vector',
'javelin-dom',
),
'7524fcfa' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'javelin-behavior-device',
'javelin-history',
'javelin-vector',
'javelin-scrollbar',
'phabricator-title',
'phabricator-shaped-request',
'conpherence-thread-manager',
),
'76b9fc3e' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1503,6 +1489,20 @@ return array(
'javelin-vector',
'javelin-stratcom',
),
'80dda04a' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'javelin-behavior-device',
'javelin-history',
'javelin-vector',
'javelin-scrollbar',
'phabricator-title',
'phabricator-shaped-request',
'conpherence-thread-manager',
),
'834a1173' => array(
'javelin-behavior',
'javelin-scrollbar',

View file

@ -54,17 +54,23 @@ abstract class ConpherenceController extends PhabricatorController {
}
protected function buildHeaderPaneContent(
ConpherenceThread $conpherence,
array $policy_objects) {
assert_instances_of($policy_objects, 'PhabricatorPolicy');
ConpherenceThread $conpherence) {
$viewer = $this->getViewer();
$header = null;
if ($conpherence->getID()) {
$data = $conpherence->getDisplayData($this->getViewer());
$topic = id(new PHUITagView())
->setName($data['topic'])
->setShade(PHUITagView::COLOR_VIOLET)
->setType(PHUITagView::TYPE_SHADE)
->addClass('conpherence-header-topic');
$header = id(new PHUIHeaderView())
->setViewer($viewer)
->setHeader($data['title'])
->setSubheader($data['topic'])
->addTag($topic)
->setPolicyObject($conpherence)
->setImage($data['image']);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -34,7 +34,7 @@ final class ConpherenceListController extends ConpherenceController {
$title = pht('Conpherence');
$conpherence = null;
$limit = (ConpherenceThreadListView::SEE_MORE_LIMIT * 2) + 1;
$limit = ConpherenceThreadListView::SEE_ALL_LIMIT + 1;
$all_participation = array();
$mode = $this->determineMode();
@ -64,7 +64,7 @@ final class ConpherenceListController extends ConpherenceController {
}
// check to see if the loaded conpherence is going to show up
// within the SEE_MORE_LIMIT amount of conpherences.
// within the SEE_ALL_LIMIT amount of conpherences.
// If its not there, then we just pre-pend it as the "first"
// conpherence so folks have a navigation item in the menu.
$count = 0;
@ -75,7 +75,7 @@ final class ConpherenceListController extends ConpherenceController {
break;
}
$count++;
if ($count > ConpherenceThreadListView::SEE_MORE_LIMIT) {
if ($count > ConpherenceThreadListView::SEE_ALL_LIMIT) {
break;
}
}
@ -89,11 +89,18 @@ final class ConpherenceListController extends ConpherenceController {
default:
$data = $this->loadDefaultParticipation($limit);
$all_participation = $data['all_participation'];
$conpherence_id = head($all_participation)->getConpherencePHID();
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array($conpherence_id))
->needProfileImage(true)
->executeOne();
// If $conpherence is null, NUX state will render
break;
}
$threads = $this->loadConpherenceThreadData(
$all_participation);
$threads = $this->loadConpherenceThreadData($all_participation);
$thread_view = id(new ConpherenceThreadListView())
->setUser($user)

View file

@ -522,18 +522,12 @@ final class ConpherenceUpdateController
$people_widget = null;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$header = $this->buildHeaderPaneContent(
$conpherence,
$policy_objects);
$header = $this->buildHeaderPaneContent($conpherence);
$header = hsprintf('%s', $header);
$nav_item = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->renderSingleThread($conpherence, $policy_objects);
->renderThreadItem($conpherence);
$nav_item = hsprintf('%s', $nav_item);
break;
case ConpherenceUpdateActions::ADD_PERSON:

View file

@ -82,11 +82,7 @@ final class ConpherenceViewController extends
$form = null;
$content = array('transactions' => $messages);
} else {
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$header = $this->buildHeaderPaneContent($conpherence, $policy_objects);
$header = $this->buildHeaderPaneContent($conpherence);
$search = $this->buildSearchForm();
$form = $this->renderFormContent();
$content = array(

View file

@ -2,7 +2,7 @@
final class ConpherenceThreadListView extends AphrontView {
const SEE_MORE_LIMIT = 15;
const SEE_ALL_LIMIT = 16;
private $baseURI;
private $threads;
@ -25,84 +25,11 @@ final class ConpherenceThreadListView extends AphrontView {
->addClass('conpherence-menu')
->setID('conpherence-menu');
$policy_objects = ConpherenceThread::loadViewPolicyObjects(
$this->getUser(),
$this->threads);
$this->addRoomsToMenu($menu, $this->threads, $policy_objects);
$menu = phutil_tag_div('phabricator-side-menu', $menu);
$menu = phutil_tag_div('phui-basic-nav', $menu);
return $menu;
}
public function renderSingleThread(
ConpherenceThread $thread,
array $policy_objects) {
assert_instances_of($policy_objects, 'PhabricatorPolicy');
return $this->renderThread($thread, $policy_objects);
}
private function renderThreadItem(
ConpherenceThread $thread,
array $policy_objects) {
return id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_CUSTOM)
->setName($this->renderThread($thread, $policy_objects));
}
private function renderThread(
ConpherenceThread $thread,
array $policy_objects) {
$user = $this->getUser();
$uri = '/'.$thread->getMonogram();
$data = $thread->getDisplayData($user);
$icon = id(new PHUIIconView())
->addClass('msr')
->setIcon($thread->getPolicyIconName($policy_objects));
$title = phutil_tag(
'span',
array(),
array(
$icon,
$data['title'],
));
$subtitle = $data['subtitle'];
$unread_count = $data['unread_count'];
$epoch = $data['epoch'];
$image = $data['image'];
$dom_id = $thread->getPHID().'-nav-item';
return id(new ConpherenceMenuItemView())
->setUser($user)
->setTitle($title)
->setSubtitle($subtitle)
->setHref($uri)
->setEpoch($epoch)
->setImageURI($image)
->setUnreadCount($unread_count)
->setID($thread->getPHID().'-nav-item')
->addSigil('conpherence-menu-click')
->setMetadata(
array(
'title' => $data['title'],
'id' => $dom_id,
'threadID' => $thread->getID(),
));
}
private function addRoomsToMenu(
PHUIListView $menu,
array $rooms,
array $policy_objects) {
$header = $this->renderMenuItemHeader();
$header = $this->buildHeaderItemView();
$menu->addMenuItem($header);
if (empty($rooms)) {
// Blank State NUX
if (empty($this->threads)) {
$join_item = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref('/conpherence/search/')
@ -115,79 +42,69 @@ final class ConpherenceThreadListView extends AphrontView {
->setWorkflow(true)
->setName(pht('Create a Room'));
$menu->addMenuItem($create_item);
}
$rooms = $this->buildRoomItems($this->threads);
foreach ($rooms as $room) {
$menu->addMenuItem($room);
}
$menu = phutil_tag_div('phabricator-side-menu', $menu);
$menu = phutil_tag_div('phui-basic-nav', $menu);
return $menu;
}
$this->addThreadsToMenu($menu, $rooms, $policy_objects);
return $menu;
private function renderThreadItem(
ConpherenceThread $thread) {
$user = $this->getUser();
$data = $thread->getDisplayData($user);
$dom_id = $thread->getPHID().'-nav-item';
return id(new PHUIListItemView())
->setName($data['title'])
->setHref('/'.$thread->getMonogram())
->setProfileImage($data['image'])
->setCount($data['unread_count'])
->setType(PHUIListItemView::TYPE_CUSTOM)
->setID($thread->getPHID().'-nav-item')
->addSigil('conpherence-menu-click')
->setMetadata(
array(
'title' => $data['title'],
'id' => $dom_id,
'threadID' => $thread->getID(),
));
}
private function addThreadsToMenu(
PHUIListView $menu,
array $threads,
array $policy_objects) {
private function buildRoomItems(array $threads) {
// If we have self::SEE_MORE_LIMIT or less, we can just render
// all the threads at once. Otherwise, we render a "See more"
// UI element, which toggles a show / hide on the remaining rooms
$items = array();
$show_threads = $threads;
$more_threads = array();
if (count($threads) > self::SEE_MORE_LIMIT) {
$show_threads = array_slice($threads, 0, self::SEE_MORE_LIMIT);
$more_threads = array_slice($threads, self::SEE_MORE_LIMIT);
$all_threads = false;
if (count($threads) > self::SEE_ALL_LIMIT) {
$show_threads = array_slice($threads, 0, self::SEE_ALL_LIMIT);
$all_threads = true;
}
foreach ($show_threads as $thread) {
$item = $this->renderThreadItem($thread, $policy_objects);
$menu->addMenuItem($item);
$items[] = $this->renderThreadItem($thread);
}
if ($more_threads) {
$search_uri = '/conpherence/search/query/participant/';
$sigil = 'more-room';
$more_item = id(new PHUIListItemView())
// Send them to application search here
if ($all_threads) {
$items[] = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref($search_uri)
->addSigil('conpherence-menu-see-more')
->setMetadata(array('moreSigil' => $sigil))
->setName(pht('See More'));
$menu->addMenuItem($more_item);
$show_more_threads = $more_threads;
$even_more_threads = array();
if (count($more_threads) > self::SEE_MORE_LIMIT) {
$show_more_threads = array_slice(
$more_threads,
0,
self::SEE_MORE_LIMIT);
$even_more_threads = array_slice(
$more_threads,
self::SEE_MORE_LIMIT);
}
foreach ($show_more_threads as $thread) {
$item = $this->renderThreadItem($thread, $policy_objects)
->addSigil($sigil)
->addClass('hidden');
$menu->addMenuItem($item);
->setHref('/conpherence/search/query/participant/')
->setIcon('fa-external-link')
->setName(pht('See All Joined'));
}
if ($even_more_threads) {
// kick them to application search here
$even_more_item = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref($search_uri)
->addSigil($sigil)
->addClass('hidden')
->setName(pht('See More'));
$menu->addMenuItem($even_more_item);
}
return $items;
}
return $menu;
}
private function renderMenuItemHeader() {
private function buildHeaderItemView() {
$rooms = phutil_tag(
'a',
array(

View file

@ -33,6 +33,7 @@ final class PHUIListItemView extends AphrontTagView {
private $tooltip;
private $actionIcon;
private $actionIconHref;
private $count;
public function setOpenInNewWindow($open_in_new_window) {
$this->openInNewWindow = $open_in_new_window;
@ -111,6 +112,11 @@ final class PHUIListItemView extends AphrontTagView {
return $this->icon;
}
public function setCount($count) {
$this->count = $count;
return $this;
}
public function setIndented($indented) {
$this->indented = $indented;
return $this;
@ -337,6 +343,16 @@ final class PHUIListItemView extends AphrontTagView {
$action_icon);
}
$count = null;
if ($this->count) {
$count = phutil_tag(
'span',
array(
'class' => 'phui-list-item-count',
),
$this->count);
}
$icons = $this->getIcons();
$list_item = javelin_tag(
@ -354,6 +370,7 @@ final class PHUIListItemView extends AphrontTagView {
$icons,
$this->renderChildren(),
$name,
$count,
));
return array($list_item, $action_link);

View file

@ -2,6 +2,10 @@
* @provides conpherence-header-pane-css
*/
.conpherence-header-pane {
background-color: #f9f9f9;
}
.conpherence-header-pane .phui-header-shell {
padding: 8px 16px 10px;
min-height: 38px;
@ -10,16 +14,23 @@
.conpherence-header-pane .phui-header-header {
font-size: 16px;
color: #000;
display: block;
}
.conpherence-header-pane .phui-header-subheader {
color: {$lightgreytext};
padding: 0;
margin: 0;
}
.conpherence-header-pane .conpherence-header-topic .phui-tag-core {
color: {$sh-indigotext};
padding: 0;
font-size: 12px;
margin: 0;
margin: 0 8px 0 0;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
font-style: italic;
}
.conpherence-header-pane .phui-header-col1 {
@ -36,6 +47,29 @@
left: 0;
}
.conpherence-header-pane .policy-header-callout,
.conpherence-header-pane .phui-tag-core {
background: transparent;
font-size: 12px;
margin: 0 8px 0 0;
padding: 3px 0;
font-style: normal;
}
.conpherence-header-pane .phui-header-subheader .policy-link {
color: {$lightbluetext};
}
.conpherence-header-pane .phui-header-subheader .policy-header-callout
.phui-icon-view {
font-size: 12px;
color: {$lightbluetext};
}
.conpherence-header-pane .phui-header-subheader .policy-link:hover {
color: {$darkbluetext};
}
.conpherence-header-pane .phui-header-image-href {
position: inherit;
}

View file

@ -21,19 +21,6 @@
background-color: {$page.sidenav};
}
.conpherence-menu-pane .phui-basic-nav .phabricator-side-menu
.phui-list-item-href {
padding: 4px 0 4px 8px;
}
.conpherence-menu-pane.phabricator-side-menu .phui-list-item-view.hidden {
display: none;
}
.phui-list-view.conpherence-menu {
margin-bottom: 20px;
}
.conpherence-menu-pane.phabricator-side-menu .room-list-href {
padding: 10px 0 9px 8px;
display: inline-block;
@ -117,20 +104,10 @@
padding: 4px;
}
.conpherence-menu .conpherence-selected {
background: rgba({$alphablack},0.05);
border-left: 4px solid {$sky};
}
.conpherence-menu .phui-list-item-type-link .phui-list-item-href {
padding: 8px 0 8px 8px;
}
.device-desktop .conpherence-menu
.conpherence-selected.conpherence-menu-item-view:hover {
background-color: rgba({$alphablack},0.07);
}
.conpherence-menu .loading {
font-style: italic;
}
@ -179,11 +156,19 @@
font-size: {$smallestfontsize};
}
.conpherence-menu .hide-unread-count .conpherence-menu-item-unread-count,
.conpherence-menu .conpherence-selected .conpherence-menu-item-unread-count {
.conpherence-menu .hide-unread-count .phui-list-item-count {
display: none;
}
.phui-basic-nav .phabricator-side-menu .conpherence-menu
.phui-list-item-icon.phuihead-small {
display: block;
float: left;
height: 20px;
width: 20px;
margin: 0 7px 0 0;
}
.conpherence-menu .conpherence-menu-item-view .conpherence-menu-item-date {
position: absolute;
top: 15px;

View file

@ -57,7 +57,7 @@
position: fixed;
left: 240px;
right: 240px;
top: 103px;
top: 104px;
bottom: 142px;
overflow-x: hidden;
overflow-y: auto;

View file

@ -5,7 +5,7 @@
.conpherence-participant-pane {
position: fixed;
right: 0px;
top: 103px;
top: 106px;
bottom: 0;
width: 240px;
border-width: 0 0 0 1px;
@ -45,7 +45,7 @@
position: fixed;
overflow-y: auto;
bottom: 0;
top: 102px;
top: 105px;
width: 240px;
}

View file

@ -125,10 +125,10 @@ JX.behavior('conpherence-menu', function(config) {
function selectThread(node, update_page_data) {
if (_thread.node) {
JX.DOM.alterClass(_thread.node, 'conpherence-selected', false);
JX.DOM.alterClass(_thread.node, 'phui-list-item-selected', false);
}
JX.DOM.alterClass(node, 'conpherence-selected', true);
JX.DOM.alterClass(node, 'phui-list-item-selected', true);
JX.DOM.alterClass(node, 'hide-unread-count', true);
_thread.node = node;
@ -425,20 +425,6 @@ JX.behavior('conpherence-menu', function(config) {
}
}
JX.Stratcom.listen(
['click'],
'conpherence-menu-see-more',
function (e) {
e.kill();
var sigil = e.getNodeData('conpherence-menu-see-more').moreSigil;
var root = JX.$('conpherence-menu-pane');
var more = JX.DOM.scry(root, 'li', sigil);
for (var i = 0; i < more.length; i++) {
JX.DOM.alterClass(more[i], 'hidden', false);
}
JX.DOM.hide(e.getNode('conpherence-menu-see-more'));
});
JX.Stratcom.listen(
['keydown'],
'conpherence-pontificate',