diff options
Diffstat (limited to 'webapp/components/integrations/components/installed_commands.jsx')
-rw-r--r-- | webapp/components/integrations/components/installed_commands.jsx | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/webapp/components/integrations/components/installed_commands.jsx b/webapp/components/integrations/components/installed_commands.jsx index 1c5ef9000..da4d871fa 100644 --- a/webapp/components/integrations/components/installed_commands.jsx +++ b/webapp/components/integrations/components/installed_commands.jsx @@ -4,12 +4,6 @@ import BackstageList from 'components/backstage/components/backstage_list.jsx'; import InstalledCommand from './installed_command.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'; @@ -19,52 +13,18 @@ import {FormattedMessage} from 'react-intl'; export default class InstalledCommands extends React.Component { static get propTypes() { return { - team: React.propTypes.object.isRequired + team: React.propTypes.object.isRequired, + users: React.propTypes.object.isRequired, + commands: React.propTypes.array.isRequired, + loading: React.propTypes.bool.isRequired }; } constructor(props) { 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); - - const teamId = TeamStore.getCurrentId(); - - this.state = { - commands: IntegrationStore.getCommands(teamId), - loading: !IntegrationStore.hasReceivedCommands(teamId), - users: UserStore.getProfiles() - }; - } - - componentDidMount() { - IntegrationStore.addChangeListener(this.handleIntegrationChange); - UserStore.addChangeListener(this.handleUserChange); - - if (window.mm_config.EnableCommands === 'true') { - loadTeamCommands(); - } - } - - componentWillUnmount() { - IntegrationStore.removeChangeListener(this.handleIntegrationChange); - UserStore.removeChangeListener(this.handleUserChange); - } - - handleIntegrationChange() { - const teamId = TeamStore.getCurrentId(); - - this.setState({ - commands: IntegrationStore.getCommands(teamId), - loading: !IntegrationStore.hasReceivedCommands(teamId) - }); - } - - handleUserChange() { - this.setState({users: UserStore.getProfiles()}); } regenCommandToken(command) { @@ -76,14 +36,14 @@ export default class InstalledCommands extends React.Component { } render() { - const commands = this.state.commands.map((command) => { + const commands = this.props.commands.map((command) => { return ( <InstalledCommand key={command.id} command={command} onRegenToken={this.regenCommandToken} onDelete={this.deleteCommand} - creator={this.state.users[command.creator_id] || {}} + creator={this.props.users[command.creator_id] || {}} /> ); }); @@ -130,7 +90,7 @@ export default class InstalledCommands extends React.Component { /> } searchPlaceholder={Utils.localizeMessage('installed_commands.search', 'Search Slash Commands')} - loading={this.state.loading} + loading={this.props.loading} > {commands} </BackstageList> |