Show join teams option in the team sidebar when there are other joinable teams (#2293)

This commit is contained in:
Elias Nahum
2018-10-31 14:07:59 -03:00
parent c71389c98c
commit dd318c2a10
2 changed files with 19 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general';
import {getCurrentTeamId, getMySortedTeamIds} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentTeamId, getMySortedTeamIds, getJoinableTeamIds} from 'mattermost-redux/selectors/entities/teams';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {handleTeamChange} from 'app/actions/views/select_team';
@@ -20,6 +20,7 @@ function mapStateToProps(state) {
return {
currentTeamId: getCurrentTeamId(state),
currentUrl: removeProtocol(getCurrentUrl(state)),
hasOtherJoinableTeams: getJoinableTeamIds(state).length > 0,
teamIds: getMySortedTeamIds(state, locale),
theme: getTheme(state),
};

View File

@@ -36,6 +36,7 @@ export default class TeamsList extends PureComponent {
closeChannelDrawer: PropTypes.func.isRequired,
currentTeamId: PropTypes.string.isRequired,
currentUrl: PropTypes.string.isRequired,
hasOtherJoinableTeams: PropTypes.bool,
navigator: PropTypes.object.isRequired,
teamIds: PropTypes.array.isRequired,
theme: PropTypes.object.isRequired,
@@ -109,22 +110,25 @@ export default class TeamsList extends PureComponent {
};
render() {
const {teamIds, theme} = this.props;
const {hasOtherJoinableTeams, teamIds, theme} = this.props;
const styles = getStyleSheet(theme);
const moreAction = (
<TouchableHighlight
style={styles.moreActionContainer}
onPress={this.goToSelectTeam}
underlayColor={changeOpacity(theme.sidebarHeaderBg, 0.5)}
>
<Text
style={styles.moreAction}
let moreAction;
if (hasOtherJoinableTeams) {
moreAction = (
<TouchableHighlight
style={styles.moreActionContainer}
onPress={this.goToSelectTeam}
underlayColor={changeOpacity(theme.sidebarHeaderBg, 0.5)}
>
{'+'}
</Text>
</TouchableHighlight>
);
<Text
style={styles.moreAction}
>
{'+'}
</Text>
</TouchableHighlight>
);
}
return (
<View style={styles.container}>