diff options
Diffstat (limited to 'webapp/components/integrations')
6 files changed, 68 insertions, 31 deletions
diff --git a/webapp/components/integrations/components/installed_command.jsx b/webapp/components/integrations/components/installed_command.jsx index 658126f19..f149a21ac 100644 --- a/webapp/components/integrations/components/installed_command.jsx +++ b/webapp/components/integrations/components/installed_command.jsx @@ -2,9 +2,6 @@ // See License.txt for license information. import React from 'react'; - -import * as Utils from 'utils/utils.jsx'; - import {FormattedMessage} from 'react-intl'; export default class InstalledCommand extends React.Component { @@ -13,7 +10,8 @@ export default class InstalledCommand extends React.Component { command: React.PropTypes.object.isRequired, onRegenToken: React.PropTypes.func.isRequired, onDelete: React.PropTypes.func.isRequired, - filter: React.PropTypes.string + filter: React.PropTypes.string, + creator: React.PropTypes.object.isRequired }; } @@ -113,7 +111,7 @@ export default class InstalledCommand extends React.Component { id='installed_integrations.creation' defaultMessage='Created by {creator} on {createAt, date, full}' values={{ - creator: Utils.displayUsername(command.creator_id), + creator: this.props.creator.username, createAt: command.create_at }} /> diff --git a/webapp/components/integrations/components/installed_commands.jsx b/webapp/components/integrations/components/installed_commands.jsx index f6429c33e..1c5ef9000 100644 --- a/webapp/components/integrations/components/installed_commands.jsx +++ b/webapp/components/integrations/components/installed_commands.jsx @@ -1,16 +1,20 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import React from 'react'; +import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import InstalledCommand from './installed_command.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import IntegrationStore from 'stores/integration_store.jsx'; import TeamStore from 'stores/team_store.jsx'; +import UserStore from 'stores/user_store.jsx'; + +import {loadTeamCommands} from 'actions/integration_actions.jsx'; + +import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; -import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import React from 'react'; import {FormattedMessage} from 'react-intl'; -import InstalledCommand from './installed_command.jsx'; export default class InstalledCommands extends React.Component { static get propTypes() { @@ -23,7 +27,7 @@ export default class InstalledCommands extends React.Component { super(props); this.handleIntegrationChange = this.handleIntegrationChange.bind(this); - + this.handleUserChange = this.handleUserChange.bind(this); this.regenCommandToken = this.regenCommandToken.bind(this); this.deleteCommand = this.deleteCommand.bind(this); @@ -31,20 +35,23 @@ export default class InstalledCommands extends React.Component { this.state = { commands: IntegrationStore.getCommands(teamId), - loading: !IntegrationStore.hasReceivedCommands(teamId) + loading: !IntegrationStore.hasReceivedCommands(teamId), + users: UserStore.getProfiles() }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); + UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableCommands === 'true') { - AsyncClient.listTeamCommands(); + loadTeamCommands(); } } componentWillUnmount() { IntegrationStore.removeChangeListener(this.handleIntegrationChange); + UserStore.removeChangeListener(this.handleUserChange); } handleIntegrationChange() { @@ -56,6 +63,10 @@ export default class InstalledCommands extends React.Component { }); } + handleUserChange() { + this.setState({users: UserStore.getProfiles()}); + } + regenCommandToken(command) { AsyncClient.regenCommandToken(command.id); } @@ -72,6 +83,7 @@ export default class InstalledCommands extends React.Component { command={command} onRegenToken={this.regenCommandToken} onDelete={this.deleteCommand} + creator={this.state.users[command.creator_id] || {}} /> ); }); diff --git a/webapp/components/integrations/components/installed_incoming_webhook.jsx b/webapp/components/integrations/components/installed_incoming_webhook.jsx index 2b514d5ec..86274c3d6 100644 --- a/webapp/components/integrations/components/installed_incoming_webhook.jsx +++ b/webapp/components/integrations/components/installed_incoming_webhook.jsx @@ -13,7 +13,8 @@ export default class InstalledIncomingWebhook extends React.Component { return { incomingWebhook: React.PropTypes.object.isRequired, onDelete: React.PropTypes.func.isRequired, - filter: React.PropTypes.string + filter: React.PropTypes.string, + creator: React.PropTypes.object.isRequired }; } @@ -108,7 +109,7 @@ export default class InstalledIncomingWebhook extends React.Component { id='installed_integrations.creation' defaultMessage='Created by {creator} on {createAt, date, full}' values={{ - creator: Utils.displayUsername(incomingWebhook.user_id), + creator: this.props.creator.username, createAt: incomingWebhook.create_at }} /> diff --git a/webapp/components/integrations/components/installed_incoming_webhooks.jsx b/webapp/components/integrations/components/installed_incoming_webhooks.jsx index b14d1e3e8..243195b8b 100644 --- a/webapp/components/integrations/components/installed_incoming_webhooks.jsx +++ b/webapp/components/integrations/components/installed_incoming_webhooks.jsx @@ -1,16 +1,20 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import React from 'react'; +import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import InstalledIncomingWebhook from './installed_incoming_webhook.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; 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 * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; -import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import React from 'react'; import {FormattedMessage} from 'react-intl'; -import InstalledIncomingWebhook from './installed_incoming_webhook.jsx'; export default class InstalledIncomingWebhooks extends React.Component { static get propTypes() { @@ -23,27 +27,30 @@ export default class InstalledIncomingWebhooks extends React.Component { super(props); this.handleIntegrationChange = this.handleIntegrationChange.bind(this); - + this.handleUserChange = this.handleUserChange.bind(this); this.deleteIncomingWebhook = this.deleteIncomingWebhook.bind(this); const teamId = TeamStore.getCurrentId(); this.state = { incomingWebhooks: IntegrationStore.getIncomingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId) + loading: !IntegrationStore.hasReceivedIncomingWebhooks(teamId), + users: UserStore.getProfiles() }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); + UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableIncomingWebhooks === 'true') { - AsyncClient.listIncomingHooks(); + loadIncomingHooks(); } } componentWillUnmount() { IntegrationStore.removeChangeListener(this.handleIntegrationChange); + UserStore.removeChangeListener(this.handleUserChange); } handleIntegrationChange() { @@ -55,6 +62,12 @@ export default class InstalledIncomingWebhooks extends React.Component { }); } + handleUserChange() { + this.setState({ + users: UserStore.getProfiles() + }); + } + deleteIncomingWebhook(incomingWebhook) { AsyncClient.deleteIncomingHook(incomingWebhook.id); } @@ -66,6 +79,7 @@ export default class InstalledIncomingWebhooks extends React.Component { key={incomingWebhook.id} incomingWebhook={incomingWebhook} onDelete={this.deleteIncomingWebhook} + creator={this.state.users[incomingWebhook.user_id] || {}} /> ); }); diff --git a/webapp/components/integrations/components/installed_outgoing_webhook.jsx b/webapp/components/integrations/components/installed_outgoing_webhook.jsx index 664439843..3ff2c01a4 100644 --- a/webapp/components/integrations/components/installed_outgoing_webhook.jsx +++ b/webapp/components/integrations/components/installed_outgoing_webhook.jsx @@ -4,7 +4,6 @@ import React from 'react'; import ChannelStore from 'stores/channel_store.jsx'; -import * as Utils from 'utils/utils.jsx'; import {FormattedMessage} from 'react-intl'; @@ -14,7 +13,8 @@ export default class InstalledOutgoingWebhook extends React.Component { outgoingWebhook: React.PropTypes.object.isRequired, onRegenToken: React.PropTypes.func.isRequired, onDelete: React.PropTypes.func.isRequired, - filter: React.PropTypes.string + filter: React.PropTypes.string, + creator: React.PropTypes.object.isRequired }; } @@ -195,7 +195,7 @@ export default class InstalledOutgoingWebhook extends React.Component { id='installed_integrations.creation' defaultMessage='Created by {creator} on {createAt, date, full}' values={{ - creator: Utils.displayUsername(outgoingWebhook.creator_id), + creator: this.props.creator.username, createAt: outgoingWebhook.create_at }} /> diff --git a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx index 214e60a48..21176f8b7 100644 --- a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx +++ b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx @@ -1,16 +1,20 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import React from 'react'; +import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import InstalledOutgoingWebhook from './installed_outgoing_webhook.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; 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 * as Utils from 'utils/utils.jsx'; +import * as AsyncClient from 'utils/async_client.jsx'; -import BackstageList from 'components/backstage/components/backstage_list.jsx'; +import React from 'react'; import {FormattedMessage} from 'react-intl'; -import InstalledOutgoingWebhook from './installed_outgoing_webhook.jsx'; export default class InstalledOutgoingWebhooks extends React.Component { static get propTypes() { @@ -23,7 +27,7 @@ export default class InstalledOutgoingWebhooks extends React.Component { super(props); this.handleIntegrationChange = this.handleIntegrationChange.bind(this); - + this.handleUserChange = this.handleUserChange.bind(this); this.regenOutgoingWebhookToken = this.regenOutgoingWebhookToken.bind(this); this.deleteOutgoingWebhook = this.deleteOutgoingWebhook.bind(this); @@ -31,20 +35,23 @@ export default class InstalledOutgoingWebhooks extends React.Component { this.state = { outgoingWebhooks: IntegrationStore.getOutgoingWebhooks(teamId), - loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId) + loading: !IntegrationStore.hasReceivedOutgoingWebhooks(teamId), + users: UserStore.getProfiles() }; } componentDidMount() { IntegrationStore.addChangeListener(this.handleIntegrationChange); + UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableOutgoingWebhooks === 'true') { - AsyncClient.listOutgoingHooks(); + loadOutgoingHooks(); } } componentWillUnmount() { IntegrationStore.removeChangeListener(this.handleIntegrationChange); + UserStore.removeChangeListener(this.handleUserChange); } handleIntegrationChange() { @@ -56,6 +63,10 @@ export default class InstalledOutgoingWebhooks extends React.Component { }); } + handleUserChange() { + this.setState({users: UserStore.getProfiles()}); + } + regenOutgoingWebhookToken(outgoingWebhook) { AsyncClient.regenOutgoingHookToken(outgoingWebhook.id); } @@ -72,6 +83,7 @@ export default class InstalledOutgoingWebhooks extends React.Component { outgoingWebhook={outgoingWebhook} onRegenToken={this.regenOutgoingWebhookToken} onDelete={this.deleteOutgoingWebhook} + creator={this.state.users[outgoingWebhook.creator_id] || {}} /> ); }); |