diff options
author | George Goldberg <george@gberg.me> | 2017-08-08 13:45:17 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-08-08 08:45:17 -0400 |
commit | 5132c62d15d6a590ba44085c8c93d5dbe9200dc6 (patch) | |
tree | 442a9fa4987a530a1b22f5660a832408c9575294 /webapp | |
parent | 82407bd44aeac52c526b57c7c3ef5c8579760849 (diff) | |
download | chat-5132c62d15d6a590ba44085c8c93d5dbe9200dc6.tar.gz chat-5132c62d15d6a590ba44085c8c93d5dbe9200dc6.tar.bz2 chat-5132c62d15d6a590ba44085c8c93d5dbe9200dc6.zip |
PLT-7309: Fix webook management when permitted for non-admins. (#7132)
Diffstat (limited to 'webapp')
3 files changed, 32 insertions, 4 deletions
diff --git a/webapp/actions/integration_actions.jsx b/webapp/actions/integration_actions.jsx index c9bba9202..cc20b3ab8 100644 --- a/webapp/actions/integration_actions.jsx +++ b/webapp/actions/integration_actions.jsx @@ -33,6 +33,20 @@ export function loadIncomingHooks(complete) { ); } +export function loadIncomingHooksForTeam(teamId, complete) { + IntegrationActions.getIncomingHooks(teamId, 0, 10000)(dispatch, getState).then( + (data) => { + if (data) { + loadProfilesForIncomingHooks(data); + } + + if (complete) { + complete(data); + } + } + ); +} + function loadProfilesForIncomingHooks(hooks) { const profilesToLoad = {}; for (let i = 0; i < hooks.length; i++) { @@ -64,6 +78,20 @@ export function loadOutgoingHooks(complete) { ); } +export function loadOutgoingHooksForTeam(teamId, complete) { + IntegrationActions.getOutgoingHooks('', teamId, 0, 10000)(dispatch, getState).then( + (data) => { + if (data) { + loadProfilesForOutgoingHooks(data); + } + + if (complete) { + complete(data); + } + } + ); +} + function loadProfilesForOutgoingHooks(hooks) { const profilesToLoad = {}; for (let i = 0; i < hooks.length; i++) { diff --git a/webapp/components/integrations/components/installed_incoming_webhooks.jsx b/webapp/components/integrations/components/installed_incoming_webhooks.jsx index 2b46dbd40..06fa217dc 100644 --- a/webapp/components/integrations/components/installed_incoming_webhooks.jsx +++ b/webapp/components/integrations/components/installed_incoming_webhooks.jsx @@ -9,7 +9,7 @@ import IntegrationStore from 'stores/integration_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; -import {loadIncomingHooks, deleteIncomingHook} from 'actions/integration_actions.jsx'; +import {loadIncomingHooksForTeam, deleteIncomingHook} from 'actions/integration_actions.jsx'; import * as Utils from 'utils/utils.jsx'; @@ -48,7 +48,7 @@ export default class InstalledIncomingWebhooks extends React.Component { UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableIncomingWebhooks === 'true') { - loadIncomingHooks(() => this.setState({loading: false})); + loadIncomingHooksForTeam(TeamStore.getCurrentId(), () => this.setState({loading: false})); } } diff --git a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx index 4f39b0f05..9b8baf3f4 100644 --- a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx +++ b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx @@ -9,7 +9,7 @@ import IntegrationStore from 'stores/integration_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; -import {loadOutgoingHooks, regenOutgoingHookToken, deleteOutgoingHook} from 'actions/integration_actions.jsx'; +import {loadOutgoingHooksForTeam, regenOutgoingHookToken, deleteOutgoingHook} from 'actions/integration_actions.jsx'; import * as Utils from 'utils/utils.jsx'; @@ -49,7 +49,7 @@ export default class InstalledOutgoingWebhooks extends React.Component { UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableOutgoingWebhooks === 'true') { - loadOutgoingHooks(() => this.setState({loading: false})); + loadOutgoingHooksForTeam(TeamStore.getCurrentId(), () => this.setState({loading: false})); } } |