Fix team switch (#4851)
* Fix team switch * Fix channel switching by using BrowserStore * Fixes plt-5076 and plt-5068 * Updating styles for Teams sidebar (#4875)
Этот коммит содержится в:
@@ -53,6 +53,8 @@ export function emitChannelClickEvent(channel) {
|
|||||||
trackPage();
|
trackPage();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
BrowserStore.setGlobalItem(chan.team_id, chan.id);
|
||||||
|
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.CLICK_CHANNEL,
|
type: ActionTypes.CLICK_CHANNEL,
|
||||||
name: chan.name,
|
name: chan.name,
|
||||||
@@ -542,7 +544,11 @@ export function emitBrowserFocus(focus) {
|
|||||||
export function redirectUserToDefaultTeam() {
|
export function redirectUserToDefaultTeam() {
|
||||||
const teams = TeamStore.getAll();
|
const teams = TeamStore.getAll();
|
||||||
const teamMembers = TeamStore.getMyTeamMembers();
|
const teamMembers = TeamStore.getMyTeamMembers();
|
||||||
let teamId = PreferenceStore.get('last', 'team');
|
let teamId = BrowserStore.getGlobalItem('team');
|
||||||
|
|
||||||
|
function redirect(teamName, channelName) {
|
||||||
|
browserHistory.push(`/${teamName}/channels/${channelName}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (!teams[teamId] && teamMembers.length > 0) {
|
if (!teams[teamId] && teamMembers.length > 0) {
|
||||||
let myTeams = [];
|
let myTeams = [];
|
||||||
@@ -560,12 +566,24 @@ export function redirectUserToDefaultTeam() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (teams[teamId]) {
|
if (teams[teamId]) {
|
||||||
const channelId = PreferenceStore.get(teamId, 'channel');
|
const channelId = BrowserStore.getGlobalItem(teamId);
|
||||||
let channel = ChannelStore.getChannelById(channelId);
|
const channel = ChannelStore.getChannelById(channelId);
|
||||||
if (!channel) {
|
if (channel) {
|
||||||
channel = 'town-square';
|
redirect(teams[teamId].name, channel);
|
||||||
|
} else if (channelId) {
|
||||||
|
Client.setTeamId(teamId);
|
||||||
|
Client.getChannel(
|
||||||
|
channelId,
|
||||||
|
(data) => {
|
||||||
|
redirect(teams[teamId].name, data.channel.name);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
redirect(teams[teamId].name, 'town-square');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
redirect(teams[teamId].name, 'town-square');
|
||||||
}
|
}
|
||||||
browserHistory.push(`/${teams[teamId].name}/channels/${channel}`);
|
|
||||||
} else {
|
} else {
|
||||||
browserHistory.push('/select_team');
|
browserHistory.push('/select_team');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import $ from 'jquery';
|
|||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
import PostStore from 'stores/post_store.jsx';
|
import PostStore from 'stores/post_store.jsx';
|
||||||
import PreferenceStore from 'stores/preference_store.jsx';
|
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
import BrowserStore from 'stores/browser_store.jsx';
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
import ErrorStore from 'stores/error_store.jsx';
|
import ErrorStore from 'stores/error_store.jsx';
|
||||||
@@ -224,11 +223,7 @@ function handleLeaveTeamEvent(msg) {
|
|||||||
if (TeamStore.getCurrentId() === msg.data.team_id) {
|
if (TeamStore.getCurrentId() === msg.data.team_id) {
|
||||||
TeamStore.setCurrentId('');
|
TeamStore.setCurrentId('');
|
||||||
Client.setTeamId('');
|
Client.setTeamId('');
|
||||||
PreferenceStore.deletePreference({
|
BrowserStore.removeGlobalItem(msg.data.team_id);
|
||||||
category: 'last',
|
|
||||||
name: 'team',
|
|
||||||
value: msg.data.team_id
|
|
||||||
});
|
|
||||||
GlobalActions.redirectUserToDefaultTeam();
|
GlobalActions.redirectUserToDefaultTeam();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ErrorBar from 'components/error_bar.jsx';
|
|||||||
import FormError from 'components/form_error.jsx';
|
import FormError from 'components/form_error.jsx';
|
||||||
|
|
||||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||||
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
|
||||||
import Client from 'client/web_client.jsx';
|
import Client from 'client/web_client.jsx';
|
||||||
@@ -52,7 +53,7 @@ export default class LoginController extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
document.title = global.window.mm_config.SiteName;
|
document.title = global.window.mm_config.SiteName;
|
||||||
|
BrowserStore.removeGlobalItem('team');
|
||||||
if (UserStore.getCurrentUser()) {
|
if (UserStore.getCurrentUser()) {
|
||||||
GlobalActions.redirectUserToDefaultTeam();
|
GlobalActions.redirectUserToDefaultTeam();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default class SignupController extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
AsyncClient.checkVersion();
|
AsyncClient.checkVersion();
|
||||||
|
BrowserStore.removeGlobalItem('team');
|
||||||
if (this.props.location.query) {
|
if (this.props.location.query) {
|
||||||
const hash = this.props.location.query.h;
|
const hash = this.props.location.query.h;
|
||||||
const data = this.props.location.query.d;
|
const data = this.props.location.query.d;
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import React from 'react';
|
|||||||
import {Link} from 'react-router/es6';
|
import {Link} from 'react-router/es6';
|
||||||
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
|
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
|
||||||
|
|
||||||
|
import {isMobile} from 'utils/utils.jsx';
|
||||||
|
import {isMobileApp} from 'utils/user_agent.jsx';
|
||||||
|
|
||||||
export default class TeamButton extends React.Component {
|
export default class TeamButton extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -20,6 +23,7 @@ export default class TeamButton extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
let teamClass = this.props.active ? 'active' : '';
|
let teamClass = this.props.active ? 'active' : '';
|
||||||
|
const btnClass = this.props.btnClass;
|
||||||
const disabled = this.props.disabled ? 'team-disabled' : '';
|
const disabled = this.props.disabled ? 'team-disabled' : '';
|
||||||
const handleClick = (this.props.active || this.props.disabled) ? this.handleDisabled : null;
|
const handleClick = (this.props.active || this.props.disabled) ? this.handleDisabled : null;
|
||||||
let badge;
|
let badge;
|
||||||
@@ -34,6 +38,44 @@ export default class TeamButton extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let btn;
|
||||||
|
let content = this.props.content;
|
||||||
|
if (!content) {
|
||||||
|
content = (
|
||||||
|
<div className='team-btn__initials'>
|
||||||
|
{this.props.displayName.substring(0, 2)}
|
||||||
|
<div className='team-btn__content'>
|
||||||
|
{this.props.displayName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isMobile() && !isMobileApp()) {
|
||||||
|
btn = (
|
||||||
|
<OverlayTrigger
|
||||||
|
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||||
|
placement={this.props.placement}
|
||||||
|
overlay={
|
||||||
|
<Tooltip id={`tooltip-${this.props.url}`}>
|
||||||
|
{this.props.displayName}
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={'team-btn ' + btnClass}>
|
||||||
|
{badge}
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
</OverlayTrigger>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
btn = (
|
||||||
|
<div className={'team-btn ' + btnClass}>
|
||||||
|
{badge}
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`team-container ${teamClass}`}
|
className={`team-container ${teamClass}`}
|
||||||
@@ -43,20 +85,7 @@ export default class TeamButton extends React.Component {
|
|||||||
to={this.props.url}
|
to={this.props.url}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
<OverlayTrigger
|
{btn}
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
|
||||||
placement={this.props.placement}
|
|
||||||
overlay={
|
|
||||||
<Tooltip id={`tooltip-${this.props.url}`}>
|
|
||||||
{this.props.tip}
|
|
||||||
</Tooltip>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className='team-btn'>
|
|
||||||
{badge}
|
|
||||||
{this.props.contents}
|
|
||||||
</div>
|
|
||||||
</OverlayTrigger>
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -64,6 +93,7 @@ export default class TeamButton extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TeamButton.defaultProps = {
|
TeamButton.defaultProps = {
|
||||||
|
btnClass: '',
|
||||||
tip: '',
|
tip: '',
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
active: false,
|
active: false,
|
||||||
@@ -73,9 +103,11 @@ TeamButton.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TeamButton.propTypes = {
|
TeamButton.propTypes = {
|
||||||
|
btnClass: React.PropTypes.string,
|
||||||
url: React.PropTypes.string.isRequired,
|
url: React.PropTypes.string.isRequired,
|
||||||
contents: React.PropTypes.node.isRequired,
|
displayName: React.PropTypes.string,
|
||||||
tip: React.PropTypes.node,
|
content: React.PropTypes.node,
|
||||||
|
tip: React.PropTypes.node.isRequired,
|
||||||
active: React.PropTypes.bool,
|
active: React.PropTypes.bool,
|
||||||
disabled: React.PropTypes.bool,
|
disabled: React.PropTypes.bool,
|
||||||
unread: React.PropTypes.bool,
|
unread: React.PropTypes.bool,
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export default class TeamSidebar extends React.Component {
|
|||||||
url={`/${team.name}`}
|
url={`/${team.name}`}
|
||||||
tip={team.display_name}
|
tip={team.display_name}
|
||||||
active={team.id === this.state.currentTeamId}
|
active={team.id === this.state.currentTeamId}
|
||||||
contents={team.display_name.substring(0, 1).toUpperCase()}
|
displayName={team.display_name}
|
||||||
unread={team.unread}
|
unread={team.unread}
|
||||||
mentions={team.mentions}
|
mentions={team.mentions}
|
||||||
/>
|
/>
|
||||||
@@ -131,6 +131,7 @@ export default class TeamSidebar extends React.Component {
|
|||||||
if (moreTeams) {
|
if (moreTeams) {
|
||||||
teams.push(
|
teams.push(
|
||||||
<TeamButton
|
<TeamButton
|
||||||
|
btnClass='team-btn__add'
|
||||||
key='more_teams'
|
key='more_teams'
|
||||||
url='/select_team'
|
url='/select_team'
|
||||||
tip={
|
tip={
|
||||||
@@ -139,12 +140,13 @@ export default class TeamSidebar extends React.Component {
|
|||||||
defaultMessage='Other teams you can join.'
|
defaultMessage='Other teams you can join.'
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
contents={<i className='fa fa-plus'/>}
|
content={<i className='fa fa-plus'/>}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (global.window.mm_config.EnableTeamCreation === 'true' || isSystemAdmin) {
|
} else if (global.window.mm_config.EnableTeamCreation === 'true' || isSystemAdmin) {
|
||||||
teams.push(
|
teams.push(
|
||||||
<TeamButton
|
<TeamButton
|
||||||
|
btnClass='team-btn__add'
|
||||||
key='more_teams'
|
key='more_teams'
|
||||||
url='/create_team'
|
url='/create_team'
|
||||||
tip={
|
tip={
|
||||||
@@ -153,7 +155,7 @@ export default class TeamSidebar extends React.Component {
|
|||||||
defaultMessage='Create a New Team'
|
defaultMessage='Create a New Team'
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
contents={<i className='fa fa-plus'/>}
|
content={<i className='fa fa-plus'/>}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const ActionTypes = Constants.ActionTypes;
|
|||||||
import * as AsyncClient from 'utils/async_client.jsx';
|
import * as AsyncClient from 'utils/async_client.jsx';
|
||||||
import Client from 'client/web_client.jsx';
|
import Client from 'client/web_client.jsx';
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
import PreferenceStore from 'stores/preference_store.jsx';
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
|
|
||||||
import emojiRoute from 'routes/route_emoji.jsx';
|
import emojiRoute from 'routes/route_emoji.jsx';
|
||||||
import integrationsRoute from 'routes/route_integrations.jsx';
|
import integrationsRoute from 'routes/route_integrations.jsx';
|
||||||
@@ -70,14 +70,18 @@ function preNeedsTeam(nextState, replace, callback) {
|
|||||||
browserHistory.push('/');
|
browserHistory.push('/');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nextState.location.pathname.indexOf('/channels/') > -1) {
|
|
||||||
GlobalActions.emitCloseRightHandSide();
|
|
||||||
|
|
||||||
TeamStore.saveMyTeam(team);
|
TeamStore.saveMyTeam(team);
|
||||||
|
BrowserStore.setGlobalItem('team', team.id);
|
||||||
TeamStore.emitChange();
|
TeamStore.emitChange();
|
||||||
|
GlobalActions.emitCloseRightHandSide();
|
||||||
|
|
||||||
|
if (nextState.location.pathname.indexOf('/channels/') > -1 ||
|
||||||
|
nextState.location.pathname.indexOf('/pl/') > -1) {
|
||||||
loadProfilesAndTeamMembersForDMSidebar();
|
loadProfilesAndTeamMembersForDMSidebar();
|
||||||
AsyncClient.getMyTeamsUnread();
|
AsyncClient.getMyTeamsUnread();
|
||||||
AsyncClient.getMyChannelMembers();
|
AsyncClient.getMyChannelMembers();
|
||||||
|
}
|
||||||
|
|
||||||
const d1 = $.Deferred(); //eslint-disable-line new-cap
|
const d1 = $.Deferred(); //eslint-disable-line new-cap
|
||||||
|
|
||||||
@@ -101,14 +105,11 @@ function preNeedsTeam(nextState, replace, callback) {
|
|||||||
$.when(d1).done(() => {
|
$.when(d1).done(() => {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLastChannel(nextState, replace, callback) {
|
function selectLastChannel(nextState, replace, callback) {
|
||||||
const team = TeamStore.getByName(nextState.params.team);
|
const team = TeamStore.getByName(nextState.params.team);
|
||||||
const channelId = PreferenceStore.get(team.id, 'channel');
|
const channelId = BrowserStore.getGlobalItem(team.id);
|
||||||
const channel = ChannelStore.getChannelById(channelId);
|
const channel = ChannelStore.getChannelById(channelId);
|
||||||
|
|
||||||
let channelName = 'town-square';
|
let channelName = 'town-square';
|
||||||
|
|||||||
@@ -23,13 +23,29 @@
|
|||||||
.team-btn {
|
.team-btn {
|
||||||
@include border-radius(2px);
|
@include border-radius(2px);
|
||||||
background-color: alpha-color($black, .3);
|
background-color: alpha-color($black, .3);
|
||||||
|
border: 1px solid transparent;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
|
font-size: 12px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
height: 35px;
|
padding: 4px 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: top;
|
||||||
width: 35px;
|
width: 40px;
|
||||||
|
|
||||||
|
.team-btn__initials {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.team-btn__content {
|
||||||
|
bottom: 4px;
|
||||||
|
font-size: 8.5px;
|
||||||
|
font-weight: normal;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 31px;
|
||||||
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
@@ -37,12 +53,17 @@
|
|||||||
right: -6px;
|
right: -6px;
|
||||||
top: -3px;
|
top: -3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.team-btn__add {
|
||||||
|
height: 39px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
.team-btn {
|
.team-btn {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 1px solid $white;
|
border-color: $white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user