From 6c4c706313eb765eb00c639f381646be74f27b69 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 25 Apr 2017 11:46:02 -0400 Subject: Start moving webapp to Redux (#6140) * Start moving webapp to Redux * Fix localforage import * Updates per feedback * Feedback udpates and a few fixes * Minor updates * Fix statuses, config not loading properly, getMe sanitizing too much * Fix preferences * Fix user autocomplete * Fix sessions and audits * Fix error handling for all redux actions * Use new directory structure for components and containers * Refresh immediately on logout instead of after timeout * Add fetch polyfill --- webapp/components/channel_invite_modal.jsx | 197 ----------------------------- 1 file changed, 197 deletions(-) delete mode 100644 webapp/components/channel_invite_modal.jsx (limited to 'webapp/components/channel_invite_modal.jsx') diff --git a/webapp/components/channel_invite_modal.jsx b/webapp/components/channel_invite_modal.jsx deleted file mode 100644 index d41948a2b..000000000 --- a/webapp/components/channel_invite_modal.jsx +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import ChannelInviteButton from './channel_invite_button.jsx'; -import SearchableUserList from 'components/searchable_user_list/searchable_user_list_container.jsx'; -import LoadingScreen from './loading_screen.jsx'; - -import ChannelStore from 'stores/channel_store.jsx'; -import UserStore from 'stores/user_store.jsx'; -import TeamStore from 'stores/team_store.jsx'; - -import {searchUsers} from 'actions/user_actions.jsx'; - -import * as AsyncClient from 'utils/async_client.jsx'; -import * as UserAgent from 'utils/user_agent.jsx'; -import Constants from 'utils/constants.jsx'; - -import React from 'react'; -import {Modal} from 'react-bootstrap'; -import {FormattedMessage} from 'react-intl'; - -const USERS_PER_PAGE = 50; - -export default class ChannelInviteModal extends React.Component { - constructor(props) { - super(props); - - this.onChange = this.onChange.bind(this); - this.onStatusChange = this.onStatusChange.bind(this); - this.onHide = this.onHide.bind(this); - this.handleInviteError = this.handleInviteError.bind(this); - this.nextPage = this.nextPage.bind(this); - this.search = this.search.bind(this); - - this.term = ''; - this.searchTimeoutId = 0; - - const channelStats = ChannelStore.getStats(props.channel.id); - const teamStats = TeamStore.getCurrentStats(); - - this.state = { - users: null, - total: teamStats.active_member_count - channelStats.member_count, - show: true, - search: false, - statusChange: false - }; - } - - componentDidMount() { - TeamStore.addStatsChangeListener(this.onChange); - ChannelStore.addStatsChangeListener(this.onChange); - UserStore.addNotInChannelChangeListener(this.onChange); - UserStore.addStatusesChangeListener(this.onStatusChange); - - AsyncClient.getProfilesNotInChannel(this.props.channel.id, 0); - AsyncClient.getTeamStats(TeamStore.getCurrentId()); - } - - componentWillUnmount() { - TeamStore.removeStatsChangeListener(this.onChange); - ChannelStore.removeStatsChangeListener(this.onChange); - UserStore.removeNotInChannelChangeListener(this.onChange); - UserStore.removeStatusesChangeListener(this.onStatusChange); - } - - onChange(force) { - if (this.state.search && !force) { - this.search(this.term); - return; - } - - const channelStats = ChannelStore.getStats(this.props.channel.id); - const teamStats = TeamStore.getCurrentStats(); - - this.setState({ - users: UserStore.getProfileListNotInChannel(this.props.channel.id, true), - total: teamStats.active_member_count - channelStats.member_count - }); - } - - onStatusChange() { - // Initiate a render to pick up on new statuses - this.setState({ - statusChange: !this.state.statusChange - }); - } - - onHide() { - this.setState({show: false}); - } - - handleInviteError(err) { - if (err) { - this.setState({ - inviteError: err.message - }); - } else { - this.setState({ - inviteError: null - }); - } - } - - nextPage(page) { - AsyncClient.getProfilesNotInChannel(this.props.channel.id, (page + 1) * USERS_PER_PAGE, USERS_PER_PAGE); - } - - search(term) { - clearTimeout(this.searchTimeoutId); - - this.term = term; - - if (term === '') { - this.onChange(true); - this.setState({search: false}); - this.searchTimeoutId = ''; - return; - } - - const searchTimeoutId = setTimeout( - () => { - searchUsers( - term, - TeamStore.getCurrentId(), - {not_in_channel_id: this.props.channel.id}, - (users) => { - if (searchTimeoutId !== this.searchTimeoutId) { - return; - } - - this.setState({search: true, users}); - } - ); - }, - Constants.SEARCH_TIMEOUT_MILLISECONDS - ); - - this.searchTimeoutId = searchTimeoutId; - } - - render() { - let inviteError = null; - if (this.state.inviteError) { - inviteError = (); - } - - let content; - if (this.state.loading) { - content = (); - } else { - content = ( - - ); - } - - return ( - - - - - {this.props.channel.display_name} - - - - {inviteError} - {content} - - - ); - } -} - -ChannelInviteModal.propTypes = { - onHide: React.PropTypes.func.isRequired, - channel: React.PropTypes.object.isRequired -}; -- cgit v1.2.3-1-g7c22