From d3506c9d69e25f67109ffaae4ebc32e79a61244d Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 13 Jul 2017 01:35:49 +0900 Subject: fix JS error on SpinnerButton and refactor edit incoming/outgoing webhook (#6917) --- .../components/edit_incoming_webhook.jsx | 10 ++++------ .../components/edit_outgoing_webhook.jsx | 23 +++++++++------------- 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'webapp/components/integrations') diff --git a/webapp/components/integrations/components/edit_incoming_webhook.jsx b/webapp/components/integrations/components/edit_incoming_webhook.jsx index 5a6309212..00cb50cbd 100644 --- a/webapp/components/integrations/components/edit_incoming_webhook.jsx +++ b/webapp/components/integrations/components/edit_incoming_webhook.jsx @@ -31,13 +31,11 @@ export default class EditIncomingWebhook extends AbstractIncomingWebhook { handleIntegrationChange() { const teamId = TeamStore.getCurrentId(); - this.setState({ - hooks: IntegrationStore.getIncomingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId) - }); + const hooks = IntegrationStore.getIncomingWebhooks(teamId); + const loading = !IntegrationStore.hasReceivedIncomingWebhooks(teamId); - if (!this.state.loading) { - this.originalIncomingHook = this.state.hooks.filter((hook) => hook.id === this.props.location.query.id)[0]; + if (!loading) { + this.originalIncomingHook = hooks.filter((hook) => hook.id === this.props.location.query.id)[0]; this.setState({ displayName: this.originalIncomingHook.display_name, diff --git a/webapp/components/integrations/components/edit_outgoing_webhook.jsx b/webapp/components/integrations/components/edit_outgoing_webhook.jsx index 2b6776b28..2f56d1eae 100644 --- a/webapp/components/integrations/components/edit_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/edit_outgoing_webhook.jsx @@ -43,21 +43,11 @@ export default class EditOutgoingWebhook extends AbstractOutgoingWebhook { handleIntegrationChange() { const teamId = TeamStore.getCurrentId(); - this.setState({ - hooks: IntegrationStore.getOutgoingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId) - }); + const hooks = IntegrationStore.getOutgoingWebhooks(teamId); + const loading = !IntegrationStore.hasReceivedOutgoingWebhooks(teamId); - if (!this.state.loading) { - this.originalOutgoingHook = this.state.hooks.filter((hook) => hook.id === this.props.location.query.id)[0]; - - this.setState({ - displayName: this.originalOutgoingHook.display_name, - description: this.originalOutgoingHook.description, - channelId: this.originalOutgoingHook.channel_id, - contentType: this.originalOutgoingHook.content_type, - triggerWhen: this.originalOutgoingHook.trigger_when - }); + if (!loading) { + this.originalOutgoingHook = hooks.filter((hook) => hook.id === this.props.location.query.id)[0]; var triggerWords = ''; if (this.originalOutgoingHook.trigger_words) { @@ -76,6 +66,11 @@ export default class EditOutgoingWebhook extends AbstractOutgoingWebhook { } this.setState({ + displayName: this.originalOutgoingHook.display_name, + description: this.originalOutgoingHook.description, + channelId: this.originalOutgoingHook.channel_id, + contentType: this.originalOutgoingHook.content_type, + triggerWhen: this.originalOutgoingHook.trigger_when, triggerWords, callbackUrls }); -- cgit v1.2.3-1-g7c22