2018-11-20 07:29:48 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import BreakoutRoomContainer from '/imports/ui/components/breakout-room/container';
|
|
|
|
import UserListContainer from '/imports/ui/components/user-list/container';
|
|
|
|
import ChatContainer from '/imports/ui/components/chat/container';
|
|
|
|
import PollContainer from '/imports/ui/components/poll/container';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import Resizable from 're-resizable';
|
|
|
|
import { styles } from '/imports/ui/components/app/styles';
|
2018-11-20 23:28:00 +08:00
|
|
|
import _ from 'lodash';
|
2018-11-20 07:29:48 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
chatLabel: {
|
|
|
|
id: 'app.chat.label',
|
|
|
|
description: 'Aria-label for Chat Section',
|
|
|
|
},
|
|
|
|
userListLabel: {
|
|
|
|
id: 'app.userList.label',
|
|
|
|
description: 'Aria-label for Userlist Nav',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class PanelManager extends Component {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2018-11-20 23:28:00 +08:00
|
|
|
|
2018-11-21 03:18:30 +08:00
|
|
|
this.padKey = _.uniqueId('resize-pad-');
|
|
|
|
this.userlistKey = _.uniqueId('userlist-');
|
|
|
|
this.breakoutroomKey = _.uniqueId('breakoutroom-');
|
|
|
|
this.chatKey = _.uniqueId('chat-');
|
|
|
|
this.pollKey = _.uniqueId('poll-');
|
2018-11-20 07:29:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renderUserList() {
|
|
|
|
const {
|
|
|
|
intl,
|
2018-11-21 03:18:30 +08:00
|
|
|
enableResize,
|
2018-11-20 07:29:48 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2018-11-21 03:18:30 +08:00
|
|
|
className={styles.userList}
|
2018-11-20 07:29:48 +08:00
|
|
|
aria-label={intl.formatMessage(intlMessages.userListLabel)}
|
2018-11-21 03:18:30 +08:00
|
|
|
key={enableResize ? null : this.userlistKey}
|
2018-11-20 07:29:48 +08:00
|
|
|
>
|
|
|
|
<UserListContainer />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderUserListResizable() {
|
|
|
|
// Variables for resizing user-list.
|
|
|
|
const USERLIST_MIN_WIDTH_PX = 150;
|
|
|
|
const USERLIST_MAX_WIDTH_PX = 240;
|
|
|
|
const USERLIST_DEFAULT_WIDTH_RELATIVE = 18;
|
|
|
|
|
|
|
|
// decide whether using pixel or percentage unit as a default width for userList
|
|
|
|
const USERLIST_DEFAULT_WIDTH = (window.innerWidth * (USERLIST_DEFAULT_WIDTH_RELATIVE / 100.0)) < USERLIST_MAX_WIDTH_PX ? `${USERLIST_DEFAULT_WIDTH_RELATIVE}%` : USERLIST_MAX_WIDTH_PX;
|
|
|
|
|
|
|
|
const resizableEnableOptions = {
|
|
|
|
top: false,
|
|
|
|
right: true,
|
|
|
|
bottom: false,
|
|
|
|
left: false,
|
|
|
|
topRight: false,
|
|
|
|
bottomRight: false,
|
|
|
|
bottomLeft: false,
|
|
|
|
topLeft: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Resizable
|
|
|
|
defaultSize={{ width: USERLIST_DEFAULT_WIDTH }}
|
|
|
|
minWidth={USERLIST_MIN_WIDTH_PX}
|
|
|
|
maxWidth={USERLIST_MAX_WIDTH_PX}
|
|
|
|
ref={(node) => { this.resizableUserList = node; }}
|
|
|
|
className={styles.resizableUserList}
|
|
|
|
enable={resizableEnableOptions}
|
2018-11-21 03:18:30 +08:00
|
|
|
key={this.userlistKey}
|
2018-11-20 07:29:48 +08:00
|
|
|
>
|
|
|
|
{this.renderUserList()}
|
|
|
|
</Resizable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderChat() {
|
2018-11-21 03:18:30 +08:00
|
|
|
const { intl, enableResize } = this.props;
|
2018-11-20 07:29:48 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<section
|
|
|
|
className={styles.chat}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.chatLabel)}
|
2018-11-21 03:18:30 +08:00
|
|
|
key={enableResize ? null : this.chatKey}
|
2018-11-20 07:29:48 +08:00
|
|
|
>
|
|
|
|
<ChatContainer />
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderChatResizable() {
|
|
|
|
// Variables for resizing chat.
|
|
|
|
const CHAT_MIN_WIDTH = '10%';
|
|
|
|
const CHAT_MAX_WIDTH = '25%';
|
|
|
|
const CHAT_DEFAULT_WIDTH = '15%';
|
|
|
|
|
|
|
|
const resizableEnableOptions = {
|
|
|
|
top: false,
|
|
|
|
right: true,
|
|
|
|
bottom: false,
|
|
|
|
left: false,
|
|
|
|
topRight: false,
|
|
|
|
bottomRight: false,
|
|
|
|
bottomLeft: false,
|
|
|
|
topLeft: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Resizable
|
|
|
|
defaultSize={{ width: CHAT_DEFAULT_WIDTH }}
|
|
|
|
minWidth={CHAT_MIN_WIDTH}
|
|
|
|
maxWidth={CHAT_MAX_WIDTH}
|
|
|
|
ref={(node) => { this.resizableChat = node; }}
|
|
|
|
className={styles.resizableChat}
|
|
|
|
enable={resizableEnableOptions}
|
2018-11-21 03:18:30 +08:00
|
|
|
key={this.chatKey}
|
2018-11-20 07:29:48 +08:00
|
|
|
>
|
|
|
|
{this.renderChat()}
|
|
|
|
</Resizable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderPoll() {
|
|
|
|
return (
|
2018-11-21 03:18:30 +08:00
|
|
|
<div className={styles.poll} key={this.pollKey}>
|
2018-11-20 07:29:48 +08:00
|
|
|
<PollContainer />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderBreakoutRoom() {
|
|
|
|
return (
|
2018-11-21 03:18:30 +08:00
|
|
|
<div className={styles.breakoutRoom} key={this.breakoutroomKey}>
|
|
|
|
<BreakoutRoomContainer />
|
2018-11-20 07:29:48 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-11-20 23:28:00 +08:00
|
|
|
const { enableResize } = this.props;
|
2018-11-21 03:18:30 +08:00
|
|
|
const resizePad = <div className={styles.userlistPad} key={this.padKey} />;
|
2018-11-20 23:28:00 +08:00
|
|
|
|
2018-11-20 07:29:48 +08:00
|
|
|
switch (this.props.openPanel) {
|
2018-11-20 23:28:00 +08:00
|
|
|
case 'chat': return enableResize ? [
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderUserListResizable(),
|
2018-11-21 03:18:30 +08:00
|
|
|
resizePad,
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderChatResizable(),
|
2018-11-20 23:28:00 +08:00
|
|
|
] : [
|
|
|
|
this.renderUserList(),
|
|
|
|
this.renderChat(),
|
2018-11-20 07:29:48 +08:00
|
|
|
];
|
2018-11-20 23:28:00 +08:00
|
|
|
case 'poll': return enableResize ? [
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderUserListResizable(),
|
2018-11-21 03:18:30 +08:00
|
|
|
resizePad,
|
2018-11-20 23:28:00 +08:00
|
|
|
this.renderPoll(),
|
|
|
|
] : [
|
|
|
|
this.renderUserList(),
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderPoll(),
|
|
|
|
];
|
2018-11-20 23:28:00 +08:00
|
|
|
case 'breakoutroom': return enableResize ? [
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderUserListResizable(),
|
2018-11-21 03:18:30 +08:00
|
|
|
resizePad,
|
2018-11-20 23:28:00 +08:00
|
|
|
this.renderBreakoutRoom(),
|
|
|
|
] : [
|
|
|
|
this.renderUserList(),
|
2018-11-20 07:29:48 +08:00
|
|
|
this.renderBreakoutRoom(),
|
|
|
|
];
|
2018-11-20 23:28:00 +08:00
|
|
|
case 'userlist': return enableResize ? this.renderUserListResizable() : this.renderUserList();
|
2018-11-20 07:29:48 +08:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(PanelManager);
|