blob: 41ab8a073a829467c4afb3408b45783d5388faeb (
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
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import AbstractOutgoingWebhook from 'components/integrations/components/abstract_outgoing_webhook.jsx';
import React from 'react';
import {browserHistory} from 'react-router/es6';
import PropTypes from 'prop-types';
const HEADER = {id: 'integrations.add', defaultMessage: 'Add'};
const FOOTER = {id: 'add_outgoing_webhook.save', defaultMessage: 'Save'};
export default class AddOutgoingWebhook extends React.PureComponent {
static propTypes = {
/**
* The current team
*/
team: PropTypes.object.isRequired,
/**
* The request state for createOutgoingHook action. Contains status and error
*/
createOutgoingHookRequest: PropTypes.object.isRequired,
actions: PropTypes.shape({
/**
* The function to call to add a new outgoing webhook
*/
createOutgoingHook: PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
this.state = {
serverError: ''
};
}
addOutgoingHook = async (hook) => {
this.setState({serverError: ''});
const data = await this.props.actions.createOutgoingHook(hook);
if (data) {
browserHistory.push(`/${this.props.team.name}/integrations/confirm?type=outgoing_webhooks&id=${data.id}`);
return;
}
if (this.props.createOutgoingHookRequest.error) {
this.setState({serverError: this.props.createOutgoingHookRequest.error.message});
}
}
render() {
return (
<AbstractOutgoingWebhook
team={this.props.team}
header={HEADER}
footer={FOOTER}
renderExtra={''}
action={this.addOutgoingHook}
serverError={this.state.serverError}
/>
);
}
}
|