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
48 lines (42 loc) · 2.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
// 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 * as Actions from 'mattermost-redux/actions/integrations';
import {getOutgoingHooks} from 'mattermost-redux/selectors/entities/integrations';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getAllChannels} from 'mattermost-redux/selectors/entities/channels';
import {getUsers} from 'mattermost-redux/selectors/entities/users';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {loadOutgoingHooksAndProfilesForTeam} from 'actions/integration_actions';
import InstalledOutgoingWebhook from './installed_outgoing_webhooks.jsx';
function mapStateToProps(state) {
const config = getConfig(state);
const teamId = getCurrentTeamId(state);
const canManageOthersWebhooks = haveITeamPermission(state, {team: teamId, permission: Permissions.MANAGE_OTHERS_WEBHOOKS});
const outgoingHooks = getOutgoingHooks(state);
const outgoingWebhooks = Object.keys(outgoingHooks).
map((key) => outgoingHooks[key]).
filter((outgoingWebhook) => outgoingWebhook.team_id === teamId);
const enableOutgoingWebhooks = config.EnableOutgoingWebhooks === 'true';
return {
outgoingWebhooks,
channels: getAllChannels(state),
users: getUsers(state),
teamId,
canManageOthersWebhooks,
enableOutgoingWebhooks,
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
loadOutgoingHooksAndProfilesForTeam,
removeOutgoingHook: Actions.removeOutgoingHook,
regenOutgoingHookToken: Actions.regenOutgoingHookToken,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(InstalledOutgoingWebhook);