forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
center_channel.jsx
76 lines (70 loc) · 2.7 KB
/
center_channel.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
// 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, Switch, Redirect} from 'react-router-dom';
import classNames from 'classnames';
import PermalinkView from 'components/permalink_view';
import Navbar from 'components/navbar';
import ChannelIdentifierRouter from 'components/channel_layout/channel_identifier_router';
export default class CenterChannel extends React.PureComponent {
static propTypes = {
match: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
lastChannelPath: PropTypes.string.isRequired,
lhsOpen: PropTypes.bool.isRequired,
rhsOpen: PropTypes.bool.isRequired,
rhsMenuOpen: PropTypes.bool.isRequired,
webRtcOpen: PropTypes.bool.isRequired,
};
constructor(props) {
super(props);
this.state = {
returnTo: '',
};
}
componentWillReceiveProps(nextProps) {
if (this.props.location.pathname !== nextProps.location.pathname && nextProps.location.pathname.includes('/pl/')) {
this.setState({returnTo: this.props.location.pathname});
}
}
render() {
const {lastChannelPath} = this.props;
const url = this.props.match.url;
return (
<div
key='inner-wrap'
className={classNames('inner-wrap', 'channel__wrap', {
'webrtc--show': this.props.webRtcOpen,
'move--right': this.props.lhsOpen,
'move--left': this.props.rhsOpen || this.props.webRtcOpen,
'move--left-small': this.props.rhsMenuOpen,
})}
>
<div className='row header'>
<div id='navbar'>
<Navbar/>
</div>
</div>
<div className='row main'>
<Switch>
<Route
path={`${url}/pl/:postid`}
render={(props) => (
<PermalinkView
{...props}
returnTo={this.state.returnTo}
/>
)}
/>
<Route
path={'/:team/:path(channels|messages)/:identifier'}
component={ChannelIdentifierRouter}
/>
<Redirect to={lastChannelPath}/>
</Switch>
</div>
</div>
);
}
}