summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-09-08 08:49:03 -0400
committerenahum <nahumhbl@gmail.com>2016-09-08 09:49:03 -0300
commitfaf944f47a9bc84365a7ddd949fc7e7b1ac2c057 (patch)
tree9a2a5700e8744e01e2b50907cf291dfd60489714
parent47f92441aced1e2dd6e85fc18f27330d88e07593 (diff)
downloadchat-faf944f47a9bc84365a7ddd949fc7e7b1ac2c057.tar.gz
chat-faf944f47a9bc84365a7ddd949fc7e7b1ac2c057.tar.bz2
chat-faf944f47a9bc84365a7ddd949fc7e7b1ac2c057.zip
Displayed proper token on integration creation confirmation (#3991)
-rw-r--r--webapp/components/integrations/components/add_command.jsx2
-rw-r--r--webapp/components/integrations/components/add_outgoing_webhook.jsx2
-rw-r--r--webapp/components/integrations/components/confirm_integration.jsx22
-rw-r--r--webapp/stores/integration_store.jsx8
4 files changed, 16 insertions, 18 deletions
diff --git a/webapp/components/integrations/components/add_command.jsx b/webapp/components/integrations/components/add_command.jsx
index d71fb7c3f..e01358aa7 100644
--- a/webapp/components/integrations/components/add_command.jsx
+++ b/webapp/components/integrations/components/add_command.jsx
@@ -166,7 +166,7 @@ export default class AddCommand extends React.Component {
AsyncClient.addCommand(
command,
(data) => {
- browserHistory.push('/' + this.props.team.name + '/integrations/confirm?type=commands&id=' + data.token);
+ browserHistory.push('/' + this.props.team.name + '/integrations/confirm?type=commands&id=' + data.id);
},
(err) => {
this.setState({
diff --git a/webapp/components/integrations/components/add_outgoing_webhook.jsx b/webapp/components/integrations/components/add_outgoing_webhook.jsx
index bf0d327ef..c3d9b0933 100644
--- a/webapp/components/integrations/components/add_outgoing_webhook.jsx
+++ b/webapp/components/integrations/components/add_outgoing_webhook.jsx
@@ -120,7 +120,7 @@ export default class AddOutgoingWebhook extends React.Component {
AsyncClient.addOutgoingHook(
hook,
(data) => {
- browserHistory.push('/' + this.props.team.name + '/integrations/confirm?type=outgoing_webhooks&id=' + data.token);
+ browserHistory.push('/' + this.props.team.name + '/integrations/confirm?type=outgoing_webhooks&id=' + data.id);
},
(err) => {
this.setState({
diff --git a/webapp/components/integrations/components/confirm_integration.jsx b/webapp/components/integrations/components/confirm_integration.jsx
index bb26a9a8a..b9274f2e4 100644
--- a/webapp/components/integrations/components/confirm_integration.jsx
+++ b/webapp/components/integrations/components/confirm_integration.jsx
@@ -5,8 +5,7 @@ import React from 'react';
import BackstageHeader from 'components/backstage/components/backstage_header.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
-import {browserHistory, Link} from 'react-router/es6';
-import SpinnerButton from 'components/spinner_button.jsx';
+import {Link} from 'react-router/es6';
import UserStore from 'stores/user_store.jsx';
import IntegrationStore from 'stores/integration_store.jsx';
@@ -24,8 +23,6 @@ export default class ConfirmIntegration extends React.Component {
constructor(props) {
super(props);
- this.handleDone = this.handleDone.bind(this);
-
this.handleIntegrationChange = this.handleIntegrationChange.bind(this);
const userId = UserStore.getCurrentId();
@@ -55,13 +52,6 @@ export default class ConfirmIntegration extends React.Component {
});
}
- handleDone() {
- browserHistory.push('/' + this.props.team.name + '/integrations/' + this.state.type);
- this.setState({
- id: ''
- });
- }
-
render() {
let headerText = null;
let helpText = null;
@@ -87,7 +77,7 @@ export default class ConfirmIntegration extends React.Component {
id='add_command.token'
defaultMessage='<b>Token</b>: {token}'
values={{
- token: this.state.id
+ token: IntegrationStore.getCommand(this.props.team.id, this.state.id).token
}}
/>
</p>
@@ -139,7 +129,7 @@ export default class ConfirmIntegration extends React.Component {
id='add_outgoing_webhook.token'
defaultMessage='<b>Token</b>: {token}'
values={{
- token: this.state.id
+ token: IntegrationStore.getOutgoingWebhook(this.props.team.id, this.state.id).token
}}
/>
</p>
@@ -233,16 +223,16 @@ export default class ConfirmIntegration extends React.Component {
{helpText}
{tokenText}
<div className='backstage-form__footer'>
- <SpinnerButton
+ <Link
className='btn btn-primary'
type='submit'
- onClick={this.handleDone}
+ to={'/' + this.props.team.name + '/integrations/' + this.state.type}
>
<FormattedMessage
id='integrations.done'
defaultMessage='Done'
/>
- </SpinnerButton>
+ </Link>
</div>
</div>
</div>
diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx
index a23b9d206..33680452b 100644
--- a/webapp/stores/integration_store.jsx
+++ b/webapp/stores/integration_store.jsx
@@ -73,6 +73,10 @@ class IntegrationStore extends EventEmitter {
return this.outgoingWebhooks.get(teamId) || [];
}
+ getOutgoingWebhook(teamId, id) {
+ return this.getOutgoingWebhooks(teamId).filter((outgoingWebhook) => outgoingWebhook.id === id)[0];
+ }
+
setOutgoingWebhooks(teamId, outgoingWebhooks) {
this.outgoingWebhooks.set(teamId, outgoingWebhooks);
}
@@ -116,6 +120,10 @@ class IntegrationStore extends EventEmitter {
return this.commands.get(teamId) || [];
}
+ getCommand(teamId, id) {
+ return this.getCommands(teamId).filter((command) => command.id === id)[0];
+ }
+
setCommands(teamId, commands) {
this.commands.set(teamId, commands);
}