blob: 795fb0e95a71e21fd35b16a8aeeb9fb1e339f772 (
plain)
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
|
import PropTypes from 'prop-types';
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import BackstageSidebar from './components/backstage_sidebar.jsx';
import BackstageNavbar from './components/backstage_navbar.jsx';
import AnnouncementBar from 'components/announcement_bar';
export default class BackstageController extends React.Component {
static get propTypes() {
return {
user: PropTypes.object,
children: PropTypes.node.isRequired
};
}
constructor(props) {
super(props);
this.onTeamChange = this.onTeamChange.bind(this);
const team = TeamStore.getCurrent();
this.state = {
team,
isAdmin: UserStore.isSystemAdminForCurrentUser(this.props.user) ||
TeamStore.isTeamAdminForCurrentTeam(team)
};
}
componentDidMount() {
TeamStore.addChangeListener(this.onTeamChange);
}
componentWillUnmount() {
TeamStore.removeChangeListener(this.onTeamChange);
}
onTeamChange() {
const team = TeamStore.getCurrent();
this.state = {
team,
isAdmin: UserStore.isSystemAdminForCurrentUser(this.props.user) ||
TeamStore.isTeamAdminForCurrentTeam(team)
};
}
render() {
return (
<div className='backstage'>
<AnnouncementBar/>
<BackstageNavbar team={this.state.team}/>
<div className='backstage-body'>
<BackstageSidebar
team={this.state.team}
user={this.props.user}
/>
{
React.Children.map(this.props.children, (child) => {
if (!child) {
return child;
}
return React.cloneElement(child, {
team: this.state.team,
user: this.props.user,
isAdmin: this.state.isAdmin
});
})
}
</div>
</div>
);
}
}
|