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
/
index.js
84 lines (72 loc) · 3.01 KB
/
index.js
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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {Preferences} from 'mattermost-redux/constants/index';
import {
getCurrentChannel,
getSortedUnreadChannelIds,
getOrderedChannelIds,
getUnreads,
} from 'mattermost-redux/selectors/entities/channels';
import Permissions from 'mattermost-redux/constants/permissions';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getBool as getBoolPreference, getSidebarPreferences} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import {switchToChannelById} from 'actions/views/channel';
import {openModal} from 'actions/views/modals';
import {close} from 'actions/views/lhs';
import {getIsLhsOpen} from 'selectors/lhs';
import Sidebar from './sidebar.jsx';
function mapStateToProps(state) {
const config = getConfig(state);
const currentChannel = getCurrentChannel(state);
const currentTeammate = currentChannel && currentChannel.teammate_id && getCurrentChannel(state, currentChannel.teammate_id);
const currentTeam = getCurrentTeam(state);
const canCreatePublicChannel = haveITeamPermission(state, {team: currentTeam.id, permission: Permissions.CREATE_PUBLIC_CHANNEL});
const canCreatePrivateChannel = haveITeamPermission(state, {team: currentTeam.id, permission: Permissions.CREATE_PRIVATE_CHANNEL});
const sidebarPrefs = getSidebarPreferences(state);
const lastUnreadChannel = state.views.channel.keepChannelIdAsUnread;
const unreadChannelIds = getSortedUnreadChannelIds(state, lastUnreadChannel);
const orderedChannelIds = getOrderedChannelIds(
state,
lastUnreadChannel,
sidebarPrefs.grouping,
sidebarPrefs.sorting,
sidebarPrefs.unreads_at_top === 'true',
sidebarPrefs.favorite_at_top === 'true',
);
const channelSwitcherOption = getBoolPreference(
state,
Preferences.CATEGORY_SIDEBAR_SETTINGS,
'channel_switcher_section',
'true'
);
return {
config,
unreadChannelIds,
orderedChannelIds,
channelSwitcherOption,
currentChannel,
currentTeammate,
currentTeam,
currentUser: getCurrentUser(state),
canCreatePublicChannel,
canCreatePrivateChannel,
isOpen: getIsLhsOpen(state),
unreads: getUnreads(state),
viewArchivedChannels: (getConfig(state).ExperimentalViewArchivedChannels === 'true')
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
close,
switchToChannelById,
openModal,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);