forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel_header_mobile.tsx
123 lines (107 loc) · 4.02 KB
/
channel_header_mobile.tsx
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import classNames from 'classnames';
import React from 'react';
import {FormattedMessage} from 'react-intl';
import {Channel} from 'mattermost-redux/types/channels';
import {UserProfile} from 'mattermost-redux/types/users';
import {MobileChannelHeaderDropdown} from 'components/channel_header_dropdown';
import MobileChannelHeaderPlug from 'plugins/mobile_channel_header_plug';
import CollapseLhsButton from './collapse_lhs_button';
import CollapseRhsButton from './collapse_rhs_button';
import ChannelInfoButton from './channel_info_button';
import ShowSearchButton from './show_search_button';
import UnmuteChannelButton from './unmute_channel_button';
type Props = {
channel?: Channel;
/**
* Relative url for the team, used to redirect if a link in the channel header is clicked
*/
currentRelativeTeamUrl?: string;
inGlobalThreads?: boolean;
isMobileView: boolean;
isMuted?: boolean;
isReadOnly?: boolean;
isRHSOpen?: boolean;
user: UserProfile;
actions: {
closeLhs: () => void;
closeRhs: () => void;
closeRhsMenu: () => void;
};
}
export default class ChannelHeaderMobile extends React.PureComponent<Props> {
componentDidMount() {
document.querySelector('.inner-wrap')?.addEventListener('click', this.hideSidebars);
}
componentWillUnmount() {
document.querySelector('.inner-wrap')?.removeEventListener('click', this.hideSidebars);
}
hideSidebars = (e: Event) => {
if (this.props.isMobileView) {
this.props.actions.closeRhs();
const target = e.target as HTMLElement | undefined;
if (target && target.className !== 'navbar-toggle' && target.className !== 'icon-bar') {
this.props.actions.closeLhs();
this.props.actions.closeRhsMenu();
}
}
}
render() {
const {user, channel, isMuted, isReadOnly, isRHSOpen, currentRelativeTeamUrl, inGlobalThreads} = this.props;
let heading;
if (inGlobalThreads) {
heading = (
<FormattedMessage
id='globalThreads.heading'
defaultMessage='Followed threads'
/>
);
} else if (channel) {
heading = (
<>
<MobileChannelHeaderDropdown/>
{isMuted && (
<UnmuteChannelButton
user={user}
channel={channel}
/>
)}
</>
);
}
return (
<nav
id='navbar'
className='navbar navbar-default navbar-fixed-top'
role='navigation'
>
<div className='container-fluid theme'>
<div className='navbar-header'>
<CollapseLhsButton/>
<div className={classNames('navbar-brand', {GlobalThreads___title: inGlobalThreads})}>
{heading}
</div>
<div className='spacer'/>
{channel && (
<ChannelInfoButton
channel={channel}
isReadOnly={isReadOnly}
isRHSOpen={isRHSOpen}
currentRelativeTeamUrl={currentRelativeTeamUrl}
/>
)}
<ShowSearchButton/>
{channel && (
<MobileChannelHeaderPlug
channel={channel}
isDropdown={false}
/>
)}
<CollapseRhsButton/>
</div>
</div>
</nav>
);
}
}