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
/
announcement_bar_controller.jsx
68 lines (62 loc) · 2.4 KB
/
announcement_bar_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
// 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 ConfigurationAnnouncementBar from './configuration_bar';
import VersionBar from './version_bar';
import TextDismissableBar from './text_dismissable_bar.jsx';
import AnnouncementBar from './default_announcement_bar';
export default class AnnouncementBarController extends React.PureComponent {
static propTypes = {
license: PropTypes.object,
config: PropTypes.object,
user: PropTypes.shape({
email: PropTypes.string.isRequired,
email_verified: PropTypes.bool,
}),
canViewSystemErrors: PropTypes.bool.isRequired,
latestError: PropTypes.object,
totalUsers: PropTypes.number,
actions: PropTypes.shape({
dismissError: PropTypes.func.isRequired,
}).isRequired,
}
render() {
let adminConfiguredAnnouncementBar = null;
if (this.props.config.EnableBanner === 'true' && this.props.config.BannerText.trim()) {
adminConfiguredAnnouncementBar = (
<TextDismissableBar
color={this.props.config.BannerColor}
textColor={this.props.config.BannerTextColor}
allowDismissal={this.props.config.AllowBannerDismissal === 'true'}
text={this.props.config.BannerText}
/>
);
}
let errorBar = null;
if (this.props.latestError) {
errorBar = (
<AnnouncementBar
type={this.props.latestError.error.type}
message={this.props.latestError.error.message}
showCloseButton={true}
handleClose={this.props.actions.dismissError}
/>
);
}
return (
<React.Fragment>
{adminConfiguredAnnouncementBar}
{errorBar}
<VersionBar/>
<ConfigurationAnnouncementBar
config={this.props.config}
license={this.props.license}
canViewSystemErrors={this.props.canViewSystemErrors}
totalUsers={this.props.totalUsers}
user={this.props.user}
/>
</React.Fragment>
);
}
}