From ef9326bcbb461b4f3265f75a9f738e67e58b88d1 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 19 Jun 2017 13:55:47 -0400 Subject: Move integrations over to redux and v4 (#6679) --- .../components/abstract_incoming_webhook.jsx | 3 +-- .../components/abstract_outgoing_webhook.jsx | 6 ++++-- .../integrations/components/add_command.jsx | 8 ++++---- .../integrations/components/add_incoming_webhook.jsx | 4 ++-- .../integrations/components/add_outgoing_webhook.jsx | 4 ++-- .../integrations/components/commands_container.jsx | 5 ++--- .../integrations/components/edit_command.jsx | 8 +++----- .../integrations/components/edit_incoming_webhook.jsx | 6 ++---- .../integrations/components/edit_outgoing_webhook.jsx | 6 ++---- .../integrations/components/installed_commands.jsx | 6 +++--- .../components/installed_incoming_webhooks.jsx | 10 ++++------ .../integrations/components/installed_oauth_app.jsx | 6 ++---- .../integrations/components/installed_oauth_apps.jsx | 19 ++++++------------- .../components/installed_outgoing_webhooks.jsx | 12 +++++------- 14 files changed, 42 insertions(+), 61 deletions(-) (limited to 'webapp/components') diff --git a/webapp/components/integrations/components/abstract_incoming_webhook.jsx b/webapp/components/integrations/components/abstract_incoming_webhook.jsx index 9c73ae6d6..a75c29fac 100644 --- a/webapp/components/integrations/components/abstract_incoming_webhook.jsx +++ b/webapp/components/integrations/components/abstract_incoming_webhook.jsx @@ -1,9 +1,8 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; import BackstageHeader from 'components/backstage/components/backstage_header.jsx'; import ChannelSelect from 'components/channel_select.jsx'; diff --git a/webapp/components/integrations/components/abstract_outgoing_webhook.jsx b/webapp/components/integrations/components/abstract_outgoing_webhook.jsx index 9f3902e2c..912ad3bdf 100644 --- a/webapp/components/integrations/components/abstract_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/abstract_outgoing_webhook.jsx @@ -1,9 +1,10 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; + +import TeamStore from 'stores/team_store.jsx'; import {localizeMessage} from 'utils/utils.jsx'; @@ -131,6 +132,7 @@ export default class AbstractOutgoingWebhook extends React.Component { } const hook = { + team_id: TeamStore.getCurrentId(), channel_id: this.state.channelId, trigger_words: triggerWords, trigger_when: parseInt(this.state.triggerWhen, 10), diff --git a/webapp/components/integrations/components/add_command.jsx b/webapp/components/integrations/components/add_command.jsx index 204b45ca4..dcf059a1d 100644 --- a/webapp/components/integrations/components/add_command.jsx +++ b/webapp/components/integrations/components/add_command.jsx @@ -1,13 +1,13 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; -import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; +import {addCommand} from 'actions/integration_actions.jsx'; + import BackstageHeader from 'components/backstage/components/backstage_header.jsx'; import {FormattedMessage} from 'react-intl'; import FormError from 'components/form_error.jsx'; @@ -165,7 +165,7 @@ export default class AddCommand extends React.Component { return; } - AsyncClient.addCommand( + addCommand( command, (data) => { browserHistory.push('/' + this.props.team.name + '/integrations/commands/confirm?type=commands&id=' + data.id); diff --git a/webapp/components/integrations/components/add_incoming_webhook.jsx b/webapp/components/integrations/components/add_incoming_webhook.jsx index c3ddf5798..eecfb8558 100644 --- a/webapp/components/integrations/components/add_incoming_webhook.jsx +++ b/webapp/components/integrations/components/add_incoming_webhook.jsx @@ -1,14 +1,14 @@ // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import * as AsyncClient from 'utils/async_client.jsx'; +import {addIncomingHook} from 'actions/integration_actions.jsx'; import {browserHistory} from 'react-router/es6'; import AbstractIncomingWebhook from './abstract_incoming_webhook.jsx'; export default class AddIncomingWebhook extends AbstractIncomingWebhook { performAction(hook) { - AsyncClient.addIncomingHook( + addIncomingHook( hook, (data) => { browserHistory.push(`/${this.props.team.name}/integrations/confirm?type=incoming_webhooks&id=${data.id}`); diff --git a/webapp/components/integrations/components/add_outgoing_webhook.jsx b/webapp/components/integrations/components/add_outgoing_webhook.jsx index 22fba7c7d..d7f338587 100644 --- a/webapp/components/integrations/components/add_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/add_outgoing_webhook.jsx @@ -1,14 +1,14 @@ // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import * as AsyncClient from 'utils/async_client.jsx'; +import {addOutgoingHook} from 'actions/integration_actions.jsx'; import {browserHistory} from 'react-router/es6'; import AbstractOutgoingWebhook from './abstract_outgoing_webhook.jsx'; export default class AddOutgoingWebhook extends AbstractOutgoingWebhook { performAction(hook) { - AsyncClient.addOutgoingHook( + addOutgoingHook( hook, (data) => { browserHistory.push(`/${this.props.team.name}/integrations/confirm?type=outgoing_webhooks&id=${data.id}`); diff --git a/webapp/components/integrations/components/commands_container.jsx b/webapp/components/integrations/components/commands_container.jsx index a831bc8f2..338d95fa0 100644 --- a/webapp/components/integrations/components/commands_container.jsx +++ b/webapp/components/integrations/components/commands_container.jsx @@ -40,7 +40,7 @@ export default class CommandsContainer extends React.Component { UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableCommands === 'true') { - loadTeamCommands(); + loadTeamCommands((() => this.setState({loading: false}))); } } @@ -53,8 +53,7 @@ export default class CommandsContainer extends React.Component { const teamId = this.props.team.id; this.setState({ - commands: IntegrationStore.getCommands(teamId), - loading: !IntegrationStore.hasReceivedCommands(teamId) + commands: IntegrationStore.getCommands(teamId) }); } diff --git a/webapp/components/integrations/components/edit_command.jsx b/webapp/components/integrations/components/edit_command.jsx index ae1040463..68b50c01c 100644 --- a/webapp/components/integrations/components/edit_command.jsx +++ b/webapp/components/integrations/components/edit_command.jsx @@ -1,16 +1,14 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; -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 {loadTeamCommands} from 'actions/integration_actions.jsx'; +import {loadTeamCommands, editCommand} from 'actions/integration_actions.jsx'; import BackstageHeader from 'components/backstage/components/backstage_header.jsx'; import {FormattedMessage} from 'react-intl'; import FormError from 'components/form_error.jsx'; @@ -98,7 +96,7 @@ export default class EditCommand extends React.Component { } submitCommand() { - AsyncClient.editCommand( + editCommand( this.newCmd, browserHistory.push('/' + this.props.team.name + '/integrations/commands'), (err) => { diff --git a/webapp/components/integrations/components/edit_incoming_webhook.jsx b/webapp/components/integrations/components/edit_incoming_webhook.jsx index 2c3a69c0d..5a6309212 100644 --- a/webapp/components/integrations/components/edit_incoming_webhook.jsx +++ b/webapp/components/integrations/components/edit_incoming_webhook.jsx @@ -1,11 +1,9 @@ // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import * as AsyncClient from 'utils/async_client.jsx'; - import {browserHistory} from 'react-router/es6'; import IntegrationStore from 'stores/integration_store.jsx'; -import {loadIncomingHooks} from 'actions/integration_actions.jsx'; +import {updateIncomingHook, loadIncomingHooks} from 'actions/integration_actions.jsx'; import AbstractIncomingWebhook from './abstract_incoming_webhook.jsx'; import TeamStore from 'stores/team_store.jsx'; @@ -54,7 +52,7 @@ export default class EditIncomingWebhook extends AbstractIncomingWebhook { hook.id = this.originalIncomingHook.id; } - AsyncClient.updateIncomingHook( + updateIncomingHook( hook, () => { browserHistory.push(`/${this.props.team.name}/integrations/incoming_webhooks`); diff --git a/webapp/components/integrations/components/edit_outgoing_webhook.jsx b/webapp/components/integrations/components/edit_outgoing_webhook.jsx index 785023d14..2b6776b28 100644 --- a/webapp/components/integrations/components/edit_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/edit_outgoing_webhook.jsx @@ -3,11 +3,9 @@ import React from 'react'; -import * as AsyncClient from 'utils/async_client.jsx'; - import {browserHistory} from 'react-router/es6'; import IntegrationStore from 'stores/integration_store.jsx'; -import {loadOutgoingHooks} from 'actions/integration_actions.jsx'; +import {loadOutgoingHooks, updateOutgoingHook} from 'actions/integration_actions.jsx'; import AbstractOutgoingWebhook from './abstract_outgoing_webhook.jsx'; import ConfirmModal from 'components/confirm_modal.jsx'; @@ -131,7 +129,7 @@ export default class EditOutgoingWebhook extends AbstractOutgoingWebhook { } submitCommand() { - AsyncClient.updateOutgoingHook( + updateOutgoingHook( this.newHook, () => { browserHistory.push(`/${this.props.team.name}/integrations/outgoing_webhooks`); diff --git a/webapp/components/integrations/components/installed_commands.jsx b/webapp/components/integrations/components/installed_commands.jsx index 9d7b16c88..731b62cd6 100644 --- a/webapp/components/integrations/components/installed_commands.jsx +++ b/webapp/components/integrations/components/installed_commands.jsx @@ -4,7 +4,7 @@ import BackstageList from 'components/backstage/components/backstage_list.jsx'; import InstalledCommand from './installed_command.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; +import {regenCommandToken, deleteCommand} from 'actions/integration_actions.jsx'; import * as Utils from 'utils/utils.jsx'; import PropTypes from 'prop-types'; @@ -32,11 +32,11 @@ export default class InstalledCommands extends React.Component { } regenCommandToken(command) { - AsyncClient.regenCommandToken(command.id); + regenCommandToken(command.id); } deleteCommand(command) { - AsyncClient.deleteCommand(command.id); + deleteCommand(command.id); } commandCompare(a, b) { diff --git a/webapp/components/integrations/components/installed_incoming_webhooks.jsx b/webapp/components/integrations/components/installed_incoming_webhooks.jsx index 5667979e1..80f887d1b 100644 --- a/webapp/components/integrations/components/installed_incoming_webhooks.jsx +++ b/webapp/components/integrations/components/installed_incoming_webhooks.jsx @@ -9,9 +9,8 @@ import IntegrationStore from 'stores/integration_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; -import {loadIncomingHooks} from 'actions/integration_actions.jsx'; +import {loadIncomingHooks, deleteIncomingHook} from 'actions/integration_actions.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; import PropTypes from 'prop-types'; @@ -49,7 +48,7 @@ export default class InstalledIncomingWebhooks extends React.Component { UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableIncomingWebhooks === 'true') { - loadIncomingHooks(); + loadIncomingHooks(() => this.setState({loading: false})); } } @@ -62,8 +61,7 @@ export default class InstalledIncomingWebhooks extends React.Component { const teamId = TeamStore.getCurrentId(); this.setState({ - incomingWebhooks: IntegrationStore.getIncomingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId) + incomingWebhooks: IntegrationStore.getIncomingWebhooks(teamId) }); } @@ -74,7 +72,7 @@ export default class InstalledIncomingWebhooks extends React.Component { } deleteIncomingWebhook(incomingWebhook) { - AsyncClient.deleteIncomingHook(incomingWebhook.id); + deleteIncomingHook(incomingWebhook.id); } incomingWebhookCompare(a, b) { diff --git a/webapp/components/integrations/components/installed_oauth_app.jsx b/webapp/components/integrations/components/installed_oauth_app.jsx index 100d82043..a59bf8e47 100644 --- a/webapp/components/integrations/components/installed_oauth_app.jsx +++ b/webapp/components/integrations/components/installed_oauth_app.jsx @@ -1,9 +1,8 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; import FormError from 'components/form_error.jsx'; @@ -55,8 +54,7 @@ export default class InstalledOAuthApp extends React.Component { regenerateOAuthAppSecret( this.props.oauthApp.id, - (data) => { - this.props.oauthApp.client_secret = data.client_secret; + () => { this.handleShowClientSecret(e); }, (err) => { diff --git a/webapp/components/integrations/components/installed_oauth_apps.jsx b/webapp/components/integrations/components/installed_oauth_apps.jsx index 33494c464..36d9c8dfa 100644 --- a/webapp/components/integrations/components/installed_oauth_apps.jsx +++ b/webapp/components/integrations/components/installed_oauth_apps.jsx @@ -1,9 +1,8 @@ -import PropTypes from 'prop-types'; - // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; import UserStore from 'stores/user_store.jsx'; import IntegrationStore from 'stores/integration_store.jsx'; @@ -28,11 +27,9 @@ export default class InstalledOAuthApps extends React.Component { this.deleteOAuthApp = this.deleteOAuthApp.bind(this); - const userId = UserStore.getCurrentId(); - this.state = { - oauthApps: IntegrationStore.getOAuthApps(userId), - loading: !IntegrationStore.hasReceivedOAuthApps(userId) + oauthApps: IntegrationStore.getOAuthApps(), + loading: !IntegrationStore.hasReceivedOAuthApps() }; } @@ -40,7 +37,7 @@ export default class InstalledOAuthApps extends React.Component { IntegrationStore.addChangeListener(this.handleIntegrationChange); if (window.mm_config.EnableOAuthServiceProvider === 'true') { - OAuthActions.listOAuthApps(UserStore.getCurrentId()); + OAuthActions.listOAuthApps(() => this.setState({loading: false})); } } @@ -49,17 +46,13 @@ export default class InstalledOAuthApps extends React.Component { } handleIntegrationChange() { - const userId = UserStore.getCurrentId(); - this.setState({ - oauthApps: IntegrationStore.getOAuthApps(userId), - loading: !IntegrationStore.hasReceivedOAuthApps(userId) + oauthApps: IntegrationStore.getOAuthApps() }); } deleteOAuthApp(app) { - const userId = UserStore.getCurrentId(); - OAuthActions.deleteOAuthApp(app.id, userId); + OAuthActions.deleteOAuthApp(app.id); } oauthAppCompare(a, b) { diff --git a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx index 0750b5157..2a0f1c59f 100644 --- a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx +++ b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx @@ -9,10 +9,9 @@ import IntegrationStore from 'stores/integration_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; -import {loadOutgoingHooks} from 'actions/integration_actions.jsx'; +import {loadOutgoingHooks, regenOutgoingHookToken, deleteOutgoingHook} from 'actions/integration_actions.jsx'; import * as Utils from 'utils/utils.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import PropTypes from 'prop-types'; @@ -50,7 +49,7 @@ export default class InstalledOutgoingWebhooks extends React.Component { UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableOutgoingWebhooks === 'true') { - loadOutgoingHooks(); + loadOutgoingHooks(() => this.setState({loading: false})); } } @@ -63,8 +62,7 @@ export default class InstalledOutgoingWebhooks extends React.Component { const teamId = TeamStore.getCurrentId(); this.setState({ - outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId) + outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(teamId) }); } @@ -73,11 +71,11 @@ export default class InstalledOutgoingWebhooks extends React.Component { } regenOutgoingWebhookToken(outgoingWebhook) { - AsyncClient.regenOutgoingHookToken(outgoingWebhook.id); + regenOutgoingHookToken(outgoingWebhook.id); } deleteOutgoingWebhook(outgoingWebhook) { - AsyncClient.deleteOutgoingHook(outgoingWebhook.id); + deleteOutgoingHook(outgoingWebhook.id); } outgoingWebhookCompare(a, b) { -- cgit v1.2.3-1-g7c22