Commit b6e1b36a authored by Sudheer's avatar Sudheer Committed by Joram Wilander

Change town-square strings to use constant (#558)

* Change town-square strings to use constant

* Fix rebase conflicts
parent f3bde7c2
......@@ -103,7 +103,7 @@ export function executeCommand(message, args, success, error) {
if (ChannelUtils.isFavoriteChannel(channel)) {
unmarkFavorite(channel.id);
}
browserHistory.push(`${TeamStore.getCurrentTeamRelativeUrl()}/channels/town-square`);
browserHistory.push(`${TeamStore.getCurrentTeamRelativeUrl()}/channels/${Constants.DEFAULT_CHANNEL}`);
return;
}
break;
......@@ -378,7 +378,7 @@ export async function leaveChannel(channelId, success) {
unmarkFavorite(channelId);
}
const townsquare = ChannelStore.getByName('town-square');
const townsquare = ChannelStore.getByName(Constants.DEFAULT_CHANNEL);
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name);
if (success) {
......
......@@ -492,10 +492,10 @@ export async function redirectUserToDefaultTeam() {
if (data) {
redirect(teams[teamId].name, data.channel.name);
} else {
redirect(teams[teamId].name, 'town-square');
redirect(teams[teamId].name, Constants.DEFAULT_CHANNEL);
}
} else {
redirect(teams[teamId].name, 'town-square');
redirect(teams[teamId].name, Constants.DEFAULT_CHANNEL);
}
} else {
browserHistory.push('/select_team');
......
......@@ -12,6 +12,7 @@ import {Client4} from 'mattermost-redux/client';
import ChannelStore from 'stores/channel_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import {Constants} from 'utils/constants.jsx';
const dispatch = store.dispatch;
const getState = store.getState;
......@@ -28,7 +29,7 @@ export async function checkIfTeamExists(teamName, onSuccess, onError) {
export async function createTeam(team, onSuccess, onError) {
const {data: rteam, error: err} = await TeamActions.createTeam(team)(dispatch, getState);
if (rteam && onSuccess) {
browserHistory.push('/' + rteam.name + '/channels/town-square');
browserHistory.push('/' + rteam.name + `/channels/${Constants.DEFAULT_CHANNEL}`);
onSuccess(rteam);
} else if (err && onError) {
onError({id: err.server_error_id, ...err});
......@@ -38,7 +39,7 @@ export async function createTeam(team, onSuccess, onError) {
export async function updateTeam(team, onSuccess, onError) {
const {data: rteam, error: err} = await TeamActions.updateTeam(team)(dispatch, getState);
if (rteam && onSuccess) {
browserHistory.push('/' + rteam.name + '/channels/town-square');
browserHistory.push('/' + rteam.name + `/channels/${Constants.DEFAULT_CHANNEL}`);
onSuccess(rteam);
} else if (err && onError) {
onError({id: err.server_error_id, ...err});
......
......@@ -391,7 +391,7 @@ function handleUserRemovedEvent(msg) {
GlobalActions.emitCloseRightHandSide();
const townsquare = ChannelStore.getByName('town-square');
const townsquare = ChannelStore.getByName(Constants.DEFAULT_CHANNEL);
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name);
dispatch({
......
......@@ -14,6 +14,7 @@ import TeamStore from 'stores/team_store.jsx';
import {sortTeamsByDisplayName} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';
import {Constants} from 'utils/constants.jsx';
import AboutBuildModal from 'components/about_build_modal';
import BlockableLink from 'components/admin_console/blockable_link';
......@@ -111,7 +112,7 @@ export default class AdminNavbarDropdown extends React.Component {
<li key={'team_' + team.name}>
<BlockableLink
id={'swithTo' + Utils.createSafeId(team.name)}
to={'/' + team.name + '/channels/town-square'}
to={'/' + team.name + `/channels/${Constants.DEFAULT_CHANNEL}`}
>
<FormattedMessage
id='navbar_dropdown.switchTo'
......
......@@ -12,7 +12,7 @@ import {updateActive, revokeAllSessions} from 'actions/user_actions.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import Constants from 'utils/constants.jsx';
import {Constants} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import {clientLogout} from 'actions/global_actions.jsx';
......@@ -122,7 +122,7 @@ export default class SystemUsersDropdown extends React.Component {
const teamUrl = TeamStore.getCurrentTeamUrl();
if (teamUrl) {
// the channel is added to the URL cause endless loading not being fully fixed
window.location.href = teamUrl + '/channels/town-square';
window.location.href = teamUrl + `/channels/${Constants.DEFAULT_CHANNEL}`;
} else {
window.location.href = '/';
}
......
......@@ -6,6 +6,8 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
import {Link} from 'react-router';
import {Constants} from 'utils/constants.jsx';
export default class BackstageNavbar extends React.Component {
static get propTypes() {
return {
......@@ -22,7 +24,7 @@ export default class BackstageNavbar extends React.Component {
<div className='backstage-navbar'>
<Link
className='backstage-navbar__back'
to={`/${this.props.team.name}/channels/town-square`}
to={`/${this.props.team.name}/channels/${Constants.DEFAULT_CHANNEL}`}
>
<i className='fa fa-angle-left'/>
<span>
......
......@@ -67,7 +67,7 @@ export default class LoginController extends React.Component {
const experimentalPrimaryTeam = global.mm_config.ExperimentalPrimaryTeam;
const primaryTeam = TeamStore.getByName(experimentalPrimaryTeam);
if (UserStore.getCurrentUser() && primaryTeam) {
browserHistory.push(`/${primaryTeam.name}/channels/town-square`);
browserHistory.push(`/${primaryTeam.name}/channels/${Constants.DEFAULT_CHANNEL}`);
} else if (UserStore.getCurrentUser()) {
GlobalActions.redirectUserToDefaultTeam();
}
......@@ -228,7 +228,7 @@ export default class LoginController extends React.Component {
} else if (team) {
browserHistory.push(`/${team.name}`);
} else if (primaryTeam) {
browserHistory.push(`/${primaryTeam.name}/channels/town-square`);
browserHistory.push(`/${primaryTeam.name}/channels/${Constants.DEFAULT_CHANNEL}`);
} else {
GlobalActions.redirectUserToDefaultTeam();
}
......
......@@ -711,7 +711,7 @@ export default class Navbar extends React.Component {
return (
<div className='navbar-brand'>
<Link
to={TeamStore.getCurrentTeamUrl() + '/channels/town-square'}
to={TeamStore.getCurrentTeamUrl() + `/channels/${Constants.DEFAULT_CHANNEL}`}
className='heading'
>
{channelTitle}
......
......@@ -12,6 +12,7 @@ import BrowserStore from 'stores/browser_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {Constants} from 'utils/constants.jsx';
export default class RemovedFromChannelModal extends React.Component {
constructor(props) {
......@@ -33,7 +34,7 @@ export default class RemovedFromChannelModal extends React.Component {
BrowserStore.removeItem('channel-removed-state');
}
var townSquare = ChannelStore.getByName('town-square');
var townSquare = ChannelStore.getByName(Constants.DEFAULT_CHANNEL);
setTimeout(
() => {
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townSquare.name);
......
......@@ -98,7 +98,7 @@ export default class Root extends React.Component {
if (UserStore.getNoAccounts()) {
browserHistory.push('/signup_user_complete');
} else if (UserStore.getCurrentUser() && primaryTeam) {
browserHistory.push(`/${primaryTeam.name}/channels/town-square`);
browserHistory.push(`/${primaryTeam.name}/channels/${Constants.DEFAULT_CHANNEL}`);
} else if (UserStore.getCurrentUser()) {
GlobalActions.redirectUserToDefaultTeam();
} else {
......
......@@ -11,6 +11,7 @@ import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import TeamInfoIcon from 'components/svg/team_info_icon';
import * as Utils from 'utils/utils.jsx';
import {Constants} from 'utils/constants.jsx';
export default class SelectTeamItem extends React.PureComponent {
static propTypes = {
......@@ -22,7 +23,7 @@ export default class SelectTeamItem extends React.PureComponent {
handleTeamClick = () => {
addUserToTeamFromInvite('', '', this.props.team.invite_id,
() => {
browserHistory.push(`/${this.props.team.name}/channels/town-square`);
browserHistory.push(`/${this.props.team.name}/channels/${Constants.DEFAULT_CHANNEL}`);
}
);
this.props.onTeamClick(this.props.team);
......
......@@ -148,7 +148,7 @@ export default class Sidebar extends React.PureComponent {
this.channelIdIsDisplayedForProps(prevProps, this.props.currentChannel.id)
) {
this.closedDirectChannel = true;
browserHistory.push('/' + this.props.currentTeam.name + '/channels/town-square');
browserHistory.push(`/${this.props.currentTeam.name}/channels/${Constants.DEFAULT_CHANNEL}`);
return;
}
......
......@@ -169,7 +169,7 @@ export default class SidebarChannel extends React.PureComponent {
}
if (this.props.active) {
browserHistory.push('/' + this.props.currentTeamName + '/channels/town-square');
browserHistory.push(`/${this.props.currentTeamName}/channels/${Constants.DEFAULT_CHANNEL}`);
}
}
......
......@@ -463,7 +463,7 @@ export default class SidebarRightMenu extends React.Component {
<div className='team__header theme'>
<Link
className='team__name'
to='/channels/town-square'
to={`/channels/${Constants.DEFAULT_CHANNEL}`}
>
{teamDisplayName}
</Link>
......
......@@ -20,6 +20,7 @@ import AnnouncementBar from 'components/announcement_bar';
import BackButton from 'components/common/back_button.jsx';
import FormError from 'components/form_error.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
import {Constants} from 'utils/constants.jsx';
export default class SignupController extends React.Component {
constructor(props) {
......@@ -76,7 +77,7 @@ export default class SignupController extends React.Component {
(team) => {
loadMe().then(
() => {
browserHistory.push('/' + team.name + '/channels/town-square');
browserHistory.push('/' + team.name + `/channels/${Constants.DEFAULT_CHANNEL}`);
}
);
},
......
......@@ -55,7 +55,7 @@ export default class TutorialIntroScreens extends React.Component {
return;
}
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
browserHistory.push(TeamStore.getCurrentTeamUrl() + `/channels/${Constants.DEFAULT_CHANNEL}`);
const step = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 0);
......@@ -86,7 +86,7 @@ export default class TutorialIntroScreens extends React.Component {
'999'
);
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
browserHistory.push(TeamStore.getCurrentTeamUrl() + `/channels/${Constants.DEFAULT_CHANNEL}`);
}
createScreen() {
switch (this.state.currentScreen) {
......
......@@ -62,7 +62,7 @@ function doChannelChange(state, replace, callback) {
GlobalActions.emitChannelClickEvent(channel);
} else if (result.error) {
if (state.params.team) {
replace('/' + state.params.team + '/channels/town-square');
replace('/' + state.params.team + `/channels/${Constants.DEFAULT_CHANNEL}`);
} else {
replace('/');
}
......@@ -141,7 +141,7 @@ function selectLastChannel(nextState, replace, callback) {
const channelId = BrowserStore.getGlobalItem(team.id);
const channel = ChannelStore.getChannelById(channelId);
let channelName = 'town-square';
let channelName = Constants.DEFAULT_CHANNEL;
if (channel) {
channelName = channel.name;
}
......
......@@ -146,9 +146,9 @@ export function notifyMe(title, body, channel, teamId, duration, silent) {
} else if (channel) {
browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/' + channel.name);
} else if (teamId) {
browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/town-square');
browserHistory.push(TeamStore.getTeamUrl(teamId) + `/channels/${Constants.DEFAULT_CHANNEL}`);
} else {
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
browserHistory.push(TeamStore.getCurrentTeamUrl() + `/channels/${Constants.DEFAULT_CHANNEL}`);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment