diff --git a/app/components/channel_drawer/channel_drawer.js b/app/components/channel_drawer/channel_drawer.js index 2b892427a..416d3fb30 100644 --- a/app/components/channel_drawer/channel_drawer.js +++ b/app/components/channel_drawer/channel_drawer.js @@ -22,6 +22,7 @@ const DRAWER_INITIAL_OFFSET = 40; export default class ChannelDrawer extends PureComponent { static propTypes = { actions: PropTypes.shape({ + getTeams: PropTypes.func.isRequired, handleSelectChannel: PropTypes.func.isRequired, viewChannel: PropTypes.func.isRequired, markChannelAsRead: PropTypes.func.isRequired, @@ -50,6 +51,10 @@ export default class ChannelDrawer extends PureComponent { swiperIndex = 1; + componentWillMount() { + this.props.actions.getTeams(); + } + componentDidMount() { EventEmitter.on('open_channel_drawer', this.openChannelDrawer); EventEmitter.on('close_channel_drawer', this.closeChannelDrawer); diff --git a/app/components/channel_drawer/index.js b/app/components/channel_drawer/index.js index 60089457d..4a574183f 100644 --- a/app/components/channel_drawer/index.js +++ b/app/components/channel_drawer/index.js @@ -4,13 +4,13 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {handleSelectChannel, setChannelLoading} from 'app/actions/views/channel'; - +import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels'; +import {getTeams} from 'mattermost-redux/actions/teams'; import {getChannelsWithUnreadSection, getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; -import {getTheme} from 'app/selectors/preferences'; import {getCurrentTeam, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams'; -import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels'; +import {handleSelectChannel, setChannelLoading} from 'app/actions/views/channel'; +import {getTheme} from 'app/selectors/preferences'; import ChannelDrawer from './channel_drawer.js'; @@ -29,6 +29,7 @@ function mapStateToProps(state, ownProps) { function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ + getTeams, handleSelectChannel, viewChannel, markChannelAsRead, diff --git a/app/components/channel_drawer_teams/channel_drawer_teams.js b/app/components/channel_drawer_teams/channel_drawer_teams.js index dbc94fa84..825ada152 100644 --- a/app/components/channel_drawer_teams/channel_drawer_teams.js +++ b/app/components/channel_drawer_teams/channel_drawer_teams.js @@ -24,7 +24,6 @@ import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; class ChannelDrawerTeams extends PureComponent { static propTypes = { actions: PropTypes.shape({ - getTeams: PropTypes.func.isRequired, handleTeamChange: PropTypes.func.isRequired, markChannelAsRead: PropTypes.func.isRequired }).isRequired, @@ -50,10 +49,6 @@ class ChannelDrawerTeams extends PureComponent { }); } - componentWillMount() { - this.props.actions.getTeams(); - } - selectTeam = (team) => { const {actions, closeChannelDrawer, currentChannelId, currentTeamId} = this.props; if (team.id === currentTeamId) { diff --git a/app/components/channel_drawer_teams/index.js b/app/components/channel_drawer_teams/index.js index 2a93f156a..7290775b9 100644 --- a/app/components/channel_drawer_teams/index.js +++ b/app/components/channel_drawer_teams/index.js @@ -5,7 +5,6 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; import {markChannelAsRead} from 'mattermost-redux/actions/channels'; -import {getTeams} from 'mattermost-redux/actions/teams'; import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general'; import {getCurrentTeamId, getJoinableTeams, getMyTeams} from 'mattermost-redux/selectors/entities/teams'; @@ -43,7 +42,6 @@ function mapStateToProps(state, ownProps) { function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ - getTeams, handleTeamChange, markChannelAsRead }, dispatch) diff --git a/app/screens/settings/index.js b/app/screens/settings/index.js index 00b384110..42012db94 100644 --- a/app/screens/settings/index.js +++ b/app/screens/settings/index.js @@ -6,8 +6,11 @@ import {connect} from 'react-redux'; import {clearErrors} from 'mattermost-redux/actions/errors'; import {logout} from 'mattermost-redux/actions/users'; +import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general'; +import {getJoinableTeams} from 'mattermost-redux/selectors/entities/teams'; import {getTheme} from 'app/selectors/preferences'; +import {removeProtocol} from 'app/utils/url'; import Settings from './settings'; @@ -20,7 +23,9 @@ function mapStateToProps(state, ownProps) { theme: getTheme(state), errors: state.errors, currentUserId: state.entities.users.currentUserId, - currentTeamId: state.entities.teams.currentTeamId + currentTeamId: state.entities.teams.currentTeamId, + currentUrl: removeProtocol(getCurrentUrl(state)), + joinableTeams: getJoinableTeams(state) }; } diff --git a/app/screens/settings/settings.js b/app/screens/settings/settings.js index fc302719f..3434dcc71 100644 --- a/app/screens/settings/settings.js +++ b/app/screens/settings/settings.js @@ -27,8 +27,10 @@ class Settings extends PureComponent { config: PropTypes.object.isRequired, currentTeamId: PropTypes.string.isRequired, currentUserId: PropTypes.string.isRequired, + currentUrl: PropTypes.string.isRequired, errors: PropTypes.array.isRequired, intl: intlShape.isRequired, + joinableTeams: PropTypes.object.isRequired, navigator: PropTypes.object, theme: PropTypes.object }; @@ -88,6 +90,28 @@ class Settings extends PureComponent { }); }; + goToSelectTeam = () => { + const {currentUrl, intl, navigator, theme} = this.props; + + navigator.push({ + screen: 'SelectTeam', + title: intl.formatMessage({id: 'mobile.routes.selectTeam', defaultMessage: 'Select Team'}), + animationType: 'slide-up', + animated: true, + backButtonTitle: '', + navigatorStyle: { + navBarTextColor: theme.sidebarHeaderTextColor, + navBarBackgroundColor: theme.sidebarHeaderBg, + navBarButtonColor: theme.sidebarHeaderTextColor, + screenBackgroundColor: theme.centerChannelBg + }, + passProps: { + currentUrl, + theme + } + }); + }; + handlePress = (action) => { preventDoubleTap(action, this); }; @@ -122,8 +146,9 @@ class Settings extends PureComponent { }; render() { - const {config, theme} = this.props; + const {config, joinableTeams, theme} = this.props; const style = getStyleSheet(theme); + const showTeams = Object.keys(joinableTeams).length > 0; return ( @@ -137,6 +162,17 @@ class Settings extends PureComponent { separator={true} theme={theme} /> + {showTeams && + preventDoubleTap(this.goToSelectTeam, this)} + separator={true} + theme={theme} + /> + } {config.HelpLink &&