This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
channel_controller.jsx
91 lines (79 loc) · 3.49 KB
/
channel_controller.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {Route} from 'react-router-dom';
import AnnouncementBarController from 'components/announcement_bar';
import Pluggable from 'plugins/pluggable';
import SystemNotice from 'components/system_notice';
import EditPostModal from 'components/edit_post_modal';
import GetPostLinkModal from 'components/get_post_link_modal';
import GetPublicLinkModal from 'components/get_public_link_modal';
import LeavePrivateChannelModal from 'components/leave_private_channel_modal';
import ResetStatusModal from 'components/reset_status_modal';
import ShortcutsModal from 'components/shortcuts_modal.jsx';
import SidebarRight from 'components/sidebar_right';
import SidebarRightMenu from 'components/sidebar_right_menu';
import ImportThemeModal from 'components/user_settings/import_theme_modal.jsx';
import ModalController from 'components/modal_controller';
import TeamSidebar from 'components/team_sidebar';
import Sidebar from 'components/sidebar';
import * as Utils from 'utils/utils';
import * as UserAgent from 'utils/user_agent.jsx';
import CenterChannel from 'components/channel_layout/center_channel';
import LoadingScreen from 'components/loading_screen';
export default class ChannelController extends React.Component {
static propTypes = {
pathName: PropTypes.string.isRequired,
teamType: PropTypes.string.isRequired,
fetchingChannels: PropTypes.bool.isRequired,
};
shouldComponentUpdate(nextProps) {
return this.props.teamType !== nextProps.teamType || this.props.pathName !== nextProps.pathName || this.props.fetchingChannels !== nextProps.fetchingChannels;
}
componentDidMount() {
const platform = window.navigator.platform;
document.body.classList.add('app__body', 'channel-view');
// IE Detection
if (UserAgent.isInternetExplorer() || UserAgent.isEdge()) {
document.body.classList.add('browser--ie');
}
// OS Detection
if (platform === 'Win32' || platform === 'Win64') {
document.body.classList.add('os--windows');
} else if (platform === 'MacIntel' || platform === 'MacPPC') {
document.body.classList.add('os--mac');
}
}
componentWillUnmount() {
document.body.classList.remove('app__body', 'channel-view');
}
render() {
return (
<div
id='channel_view'
className='channel-view'
>
<AnnouncementBarController/>
<SystemNotice/>
<div className='container-fluid'>
<SidebarRight/>
<SidebarRightMenu teamType={this.props.teamType}/>
<Route component={TeamSidebar}/>
<Route component={Sidebar}/>
{!this.props.fetchingChannels && <Route component={CenterChannel}/>}
{this.props.fetchingChannels && <LoadingScreen/>}
<Pluggable pluggableName='Root'/>
<GetPostLinkModal/>
<GetPublicLinkModal/>
<ImportThemeModal/>
<EditPostModal/>
<ResetStatusModal/>
<LeavePrivateChannelModal/>
<ShortcutsModal isMac={Utils.isMac()}/>
<ModalController/>
</div>
</div>
);
}
}