Displayed proper token on integration creation confirmation (#3991)

Этот коммит содержится в:
Harrison Healey
2016-09-08 08:49:03 -04:00
коммит произвёл enahum
родитель 47f92441ac
Коммит faf944f47a
4 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@@ -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({

Просмотреть файл

@@ -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({

Просмотреть файл

@@ -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>

Просмотреть файл

@@ -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);
}