forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel_controller.jsx
98 lines (85 loc) · 3.97 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
92
93
94
95
96
97
98
// 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 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';
import ModalController from 'components/modal_controller';
import LegacyTeamSidebar from 'components/legacy_team_sidebar';
import LegacySidebar from 'components/legacy_sidebar';
import Sidebar from 'components/sidebar';
import * as Utils from 'utils/utils';
import * as UserAgent from 'utils/user_agent';
import CenterChannel from 'components/channel_layout/center_channel';
import LoadingScreen from 'components/loading_screen';
import FaviconTitleHandler from 'components/favicon_title_handler';
import ProductNoticesModal from 'components/product_notices_modal';
export default class ChannelController extends React.Component {
static propTypes = {
pathName: PropTypes.string.isRequired,
teamType: PropTypes.string.isRequired,
fetchingChannels: PropTypes.bool.isRequired,
useLegacyLHS: PropTypes.bool.isRequired,
};
shouldComponentUpdate(nextProps) {
return this.props.teamType !== nextProps.teamType || this.props.pathName !== nextProps.pathName || this.props.fetchingChannels !== nextProps.fetchingChannels || this.props.useLegacyLHS !== nextProps.useLegacyLHS;
}
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() {
const PreferredTeamSidebar = LegacyTeamSidebar; // TODO: Replace with switch when we rewrite team sidebar
const PreferredSidebar = this.props.useLegacyLHS ? LegacySidebar : Sidebar;
return (
<div
id='channel_view'
className='channel-view'
>
<AnnouncementBarController/>
<SystemNotice/>
<FaviconTitleHandler/>
<ProductNoticesModal/>
<div className='container-fluid'>
<SidebarRight/>
<SidebarRightMenu teamType={this.props.teamType}/>
<Route component={PreferredTeamSidebar}/>
<Route component={PreferredSidebar}/>
{!this.props.fetchingChannels && <Route component={CenterChannel}/>}
{this.props.fetchingChannels && <LoadingScreen/>}
<Pluggable pluggableName='Root'/>
<GetPublicLinkModal/>
<ImportThemeModal/>
<EditPostModal/>
<ResetStatusModal/>
<LeavePrivateChannelModal/>
<ShortcutsModal isMac={Utils.isMac()}/>
<ModalController/>
</div>
</div>
);
}
}