mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Move integrations over to redux and v4 (#6679)
This commit is contained in:
committed by
Christopher Speller
parent
1594cf8af1
commit
ef9326bcbb
@@ -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';
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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`);
|
||||
|
||||
@@ -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`);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user