From d9f724f959e86e417e274f50b249b39acaf81a79 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 12 May 2016 11:30:53 -0400 Subject: PLT-2927/PLT-2924 Fixing issues with integration lists (#2974) * Changed IntegrationStore to store integrations by team * Fixed regenerating a command's token not causing the UI to update * Re-added IntegrationStore.hasReceived methods --- webapp/components/backstage/installed_commands.jsx | 15 ++++++++++----- .../components/backstage/installed_incoming_webhooks.jsx | 15 ++++++++++----- .../components/backstage/installed_outgoing_webhooks.jsx | 15 ++++++++++----- 3 files changed, 30 insertions(+), 15 deletions(-) (limited to 'webapp/components/backstage') diff --git a/webapp/components/backstage/installed_commands.jsx b/webapp/components/backstage/installed_commands.jsx index 71373e077..df1f56687 100644 --- a/webapp/components/backstage/installed_commands.jsx +++ b/webapp/components/backstage/installed_commands.jsx @@ -5,6 +5,7 @@ import React from 'react'; import * as AsyncClient from 'utils/async_client.jsx'; import IntegrationStore from 'stores/integration_store.jsx'; +import TeamStore from 'stores/team_store.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; @@ -20,16 +21,18 @@ export default class InstalledCommands extends React.Component { this.regenCommandToken = this.regenCommandToken.bind(this); this.deleteCommand = this.deleteCommand.bind(this); + const teamId = TeamStore.getCurrentId(); + this.state = { - commands: IntegrationStore.getCommands(), - loading: !IntegrationStore.hasReceivedCommands() + commands: IntegrationStore.getCommands(teamId), + loading: !IntegrationStore.hasReceivedCommands(teamId) }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); - if (window.mm_config.EnableCommands === 'true' && this.state.loading) { + if (window.mm_config.EnableCommands === 'true') { AsyncClient.listTeamCommands(); } } @@ -39,9 +42,11 @@ export default class InstalledCommands extends React.Component { } handleIntegrationChange() { + const teamId = TeamStore.getCurrentId(); + this.setState({ - commands: IntegrationStore.getCommands(), - loading: !IntegrationStore.hasReceivedCommands() + commands: IntegrationStore.getCommands(teamId), + loading: !IntegrationStore.hasReceivedCommands(teamId) }); } diff --git a/webapp/components/backstage/installed_incoming_webhooks.jsx b/webapp/components/backstage/installed_incoming_webhooks.jsx index 389f65919..0a38a6ab5 100644 --- a/webapp/components/backstage/installed_incoming_webhooks.jsx +++ b/webapp/components/backstage/installed_incoming_webhooks.jsx @@ -5,6 +5,7 @@ import React from 'react'; import * as AsyncClient from 'utils/async_client.jsx'; import IntegrationStore from 'stores/integration_store.jsx'; +import TeamStore from 'stores/team_store.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; @@ -19,16 +20,18 @@ export default class InstalledIncomingWebhooks extends React.Component { this.deleteIncomingWebhook = this.deleteIncomingWebhook.bind(this); + const teamId = TeamStore.getCurrentId(); + this.state = { - incomingWebhooks: IntegrationStore.getIncomingWebhooks(), - loading: !IntegrationStore.hasReceivedIncomingWebhooks() + incomingWebhooks: IntegrationStore.getIncomingWebhooks(teamId), + loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId) }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); - if (window.mm_config.EnableIncomingWebhooks === 'true' && this.state.loading) { + if (window.mm_config.EnableIncomingWebhooks === 'true') { AsyncClient.listIncomingHooks(); } } @@ -38,9 +41,11 @@ export default class InstalledIncomingWebhooks extends React.Component { } handleIntegrationChange() { + const teamId = TeamStore.getCurrentId(); + this.setState({ - incomingWebhooks: IntegrationStore.getIncomingWebhooks(), - loading: !IntegrationStore.hasReceivedIncomingWebhooks() + incomingWebhooks: IntegrationStore.getIncomingWebhooks(teamId), + loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId) }); } diff --git a/webapp/components/backstage/installed_outgoing_webhooks.jsx b/webapp/components/backstage/installed_outgoing_webhooks.jsx index e0817fda8..b79bc3530 100644 --- a/webapp/components/backstage/installed_outgoing_webhooks.jsx +++ b/webapp/components/backstage/installed_outgoing_webhooks.jsx @@ -5,6 +5,7 @@ import React from 'react'; import * as AsyncClient from 'utils/async_client.jsx'; import IntegrationStore from 'stores/integration_store.jsx'; +import TeamStore from 'stores/team_store.jsx'; import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; @@ -20,16 +21,18 @@ export default class InstalledOutgoingWebhooks extends React.Component { this.regenOutgoingWebhookToken = this.regenOutgoingWebhookToken.bind(this); this.deleteOutgoingWebhook = this.deleteOutgoingWebhook.bind(this); + const teamId = TeamStore.getCurrentId(); + this.state = { - outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(), - loading: !IntegrationStore.hasReceivedOutgoingWebhooks() + outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(teamId), + loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId) }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); - if (window.mm_config.EnableOutgoingWebhooks === 'true' && this.state.loading) { + if (window.mm_config.EnableOutgoingWebhooks === 'true') { AsyncClient.listOutgoingHooks(); } } @@ -39,9 +42,11 @@ export default class InstalledOutgoingWebhooks extends React.Component { } handleIntegrationChange() { + const teamId = TeamStore.getCurrentId(); + this.setState({ - outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(), - loading: !IntegrationStore.hasReceivedOutgoingWebhooks() + outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(teamId), + loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId) }); } -- cgit v1.2.3-1-g7c22