Commit 8e7709d9 authored by Christopher Speller's avatar Christopher Speller Committed by GitHub

Updating react-router to version 4. (#620)

parent 6cd85a31
{
"presets": [
"es2015",
["es2015", { "modules": false }],
"react",
"stage-0"
],
"plugins": [
"transform-es2015-modules-commonjs",
"dynamic-import-node"
]
}
......@@ -60,7 +60,7 @@
"func-call-spacing": [2, "never"],
"func-name-matching": 0,
"func-names": 2,
"func-style": [2, "declaration"],
"func-style": [2, "declaration", { "allowArrowFunctions": true }],
"generator-star-spacing": [2, {"before": false, "after": true}],
"global-require": 2,
"guard-for-in": 2,
......@@ -207,7 +207,7 @@
"quote-props": [2, "as-needed"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"react/display-name": [2, { "ignoreTranspilerName": false }],
"react/display-name": [0, { "ignoreTranspilerName": false }],
"react/forbid-component-props": 0,
"react/forbid-elements": [2, { "forbid": ["embed"] }],
"react/jsx-boolean-value": [2, "always"],
......@@ -251,7 +251,7 @@
"react/no-unused-prop-types": [1, {"skipShapeProps": true}],
"react/prefer-es6-class": 2,
"react/prefer-stateless-function": 0,
"react/prop-types": 2,
"react/prop-types": [2, { "ignore": ["match", "location", "history", "component"] }],
"react/require-default-props": 0,
"react/require-optimization": 1,
"react/require-render-return": 2,
......
......@@ -121,11 +121,11 @@ export function getOAuthAppInfo(clientId, success, error) {
}
export function allowOAuth2(params, success, error) {
const responseType = params.response_type;
const clientId = params.client_id;
const redirectUri = params.redirect_uri;
const state = params.state;
const scope = params.scope;
const responseType = params.get('response_type');
const clientId = params.get('client_id');
const redirectUri = params.get('redirect_uri');
const state = params.get('state');
const scope = params.get('scope');
Client4.authorizeOAuthApp(responseType, clientId, redirectUri, state, scope).then(
(data) => {
......
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {browserHistory} from 'react-router';
import * as ChannelActions from 'mattermost-redux/actions/channels';
import {deletePreferences, savePreferences} from 'mattermost-redux/actions/preferences';
import {Client4} from 'mattermost-redux/client';
import {getMyChannelMemberships, getChannel} from 'mattermost-redux/selectors/entities/channels';
import {browserHistory} from 'utils/browser_history';
import {actionOnGlobalItemsWithPrefix} from 'actions/storage';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import * as PostActions from 'actions/post_actions.jsx';
......@@ -19,7 +17,6 @@ import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as ChannelUtils from 'utils/channel_utils.jsx';
import {Constants, Preferences, StoragePrefixes} from 'utils/constants.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
......
......@@ -7,7 +7,6 @@ import {getProfilesByIds} from 'mattermost-redux/actions/users';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import store from 'stores/redux_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {ActionTypes} from 'utils/constants.jsx';
const dispatch = store.dispatch;
......
......@@ -2,16 +2,13 @@
// See License.txt for license information.
import {batchActions} from 'redux-batched-actions';
import request from 'superagent';
import {FileTypes} from 'mattermost-redux/action_types';
import {getLogErrorAction} from 'mattermost-redux/actions/errors';
import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers';
import {Client4} from 'mattermost-redux/client';
import store from 'stores/redux_store.jsx';
import * as Utils from 'utils/utils.jsx';
export function uploadFile(file, name, channelId, clientId, successCallback, errorCallback) {
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {browserHistory} from 'react-router';
import {createDirectChannel, getChannelAndMyMember, getChannelStats, getMyChannelMember, joinChannel, viewChannel} from 'mattermost-redux/actions/channels';
import {getPostThread} from 'mattermost-redux/actions/posts';
import {removeUserFromTeam} from 'mattermost-redux/actions/teams';
import {Client4} from 'mattermost-redux/client';
import {browserHistory} from 'utils/browser_history';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import {handleNewPost} from 'actions/post_actions.jsx';
import {stopPeriodicStatusUpdates} from 'actions/status_actions.jsx';
......@@ -21,14 +20,12 @@ import ErrorStore from 'stores/error_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import WebSocketClient from 'client/web_websocket_client.jsx';
import {ActionTypes, Constants, ErrorPageTypes, PostTypes} from 'utils/constants.jsx';
import EventTypes from 'utils/event_types.jsx';
import {sortTeamsByDisplayName} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';
import en from 'i18n/en.json';
import * as I18n from 'i18n/i18n.jsx';
......@@ -104,8 +101,7 @@ export async function doFocusPost(channelId, postId, data) {
dispatch({
type: ActionTypes.RECEIVED_FOCUSED_POST,
data: postId,
channelId
data: postId
});
const member = getState().entities.channels.myMembers[channelId];
......@@ -121,7 +117,7 @@ export function emitCloseRightHandSide() {
dispatch(closeRightHandSide());
}
export async function emitPostFocusEvent(postId, onSuccess) {
export async function emitPostFocusEvent(postId) {
loadChannelsForCurrentUser();
const {data} = await getPostThread(postId)(dispatch, getState);
......@@ -134,11 +130,7 @@ export async function emitPostFocusEvent(postId, onSuccess) {
loadNewGMIfNeeded(channel.id);
}
doFocusPost(channelId, postId, data).then(() => {
if (onSuccess) {
onSuccess();
}
});
await doFocusPost(channelId, postId, data);
} else {
browserHistory.push('/error?type=' + ErrorPageTypes.PERMALINK_NOT_FOUND);
}
......@@ -460,7 +452,7 @@ export function clientLogout(redirectTo = '/') {
stopPeriodicStatusUpdates();
WebsocketActions.close();
document.cookie = 'MMUSERID=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
window.location.href = redirectTo;
browserHistory.push(redirectTo);
}
export function toggleSideBarRightMenuAction() {
......@@ -507,7 +499,7 @@ export async function redirectUserToDefaultTeam() {
const channelId = BrowserStore.getGlobalItem(teamId);
const channel = ChannelStore.getChannelById(channelId);
if (channel) {
redirect(teams[teamId].name, channel);
redirect(teams[teamId].name, channel.name);
} else if (channelId) {
const {data} = await getChannelAndMyMember(channelId)(dispatch, getState);
if (data) {
......
......@@ -2,7 +2,6 @@
// See License.txt for license information.
import request from 'superagent';
import * as IntegrationActions from 'mattermost-redux/actions/integrations';
import {getProfilesByIds} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
......@@ -11,7 +10,6 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {ActionTypes} from 'utils/constants.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
......
......@@ -4,7 +4,6 @@
import ChannelStore from 'stores/channel_store.jsx';
import NotificationStore from 'stores/notification_store.jsx';
import UserStore from 'stores/user_store.jsx';
import Constants, {NotificationLevels, UserStatuses} from 'utils/constants.jsx';
import {isSystemMessage} from 'utils/post_utils.jsx';
import {isMacApp, isMobileApp, isWindowsApp} from 'utils/user_agent.jsx';
......
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {browserHistory} from 'react-router';
import {batchActions} from 'redux-batched-actions';
import {PostTypes} from 'mattermost-redux/action_types';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
import * as PostActions from 'mattermost-redux/actions/posts';
import * as Selectors from 'mattermost-redux/selectors/entities/posts';
import {browserHistory} from 'utils/browser_history';
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import * as RhsActions from 'actions/views/rhs';
......@@ -17,9 +16,7 @@ import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import {getSelectedPostId} from 'selectors/rhs';
import {ActionTypes, Constants} from 'utils/constants.jsx';
import {EMOJI_PATTERN} from 'utils/emoticons.jsx';
import * as UserAgent from 'utils/user_agent';
......
......@@ -8,7 +8,6 @@ import PostStore from 'stores/post_store.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';
const dispatch = store.dispatch;
......
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {browserHistory} from 'react-router';
import {TeamTypes} from 'mattermost-redux/action_types';
import {viewChannel, getChannelStats} from 'mattermost-redux/actions/channels';
import * as TeamActions from 'mattermost-redux/actions/teams';
import {getUser} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import {browserHistory} from 'utils/browser_history';
import ChannelStore from 'stores/channel_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
......@@ -29,7 +28,6 @@ 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/${Constants.DEFAULT_CHANNEL}`);
onSuccess(rteam);
} else if (err && onError) {
onError({id: err.server_error_id, ...err});
......
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {browserHistory} from 'react-router';
import {getChannelAndMyMember} from 'mattermost-redux/actions/channels';
import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general';
import {deletePreferences, savePreferences as savePreferencesRedux} from 'mattermost-redux/actions/preferences';
......@@ -13,6 +11,7 @@ import {Preferences as PreferencesRedux} from 'mattermost-redux/constants';
import {getBool} from 'mattermost-redux/selectors/entities/preferences';
import * as Selectors from 'mattermost-redux/selectors/entities/users';
import {browserHistory} from 'utils/browser_history';
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
import {clientLogout, loadCurrentLocale} from 'actions/global_actions.jsx';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
......@@ -21,7 +20,6 @@ import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';
......
......@@ -2,12 +2,10 @@
// See License.txt for license information.
import {createSelector} from 'reselect';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {makeGetMessageInHistoryItem, makeGetCommentCountForPost, getPost} from 'mattermost-redux/selectors/entities/posts';
import {getCustomEmojisByName} from 'mattermost-redux/selectors/entities/emojis';
import {
addReaction,
removeReaction,
......@@ -15,7 +13,6 @@ import {
moveHistoryIndexBack,
moveHistoryIndexForward
} from 'mattermost-redux/actions/posts';
import {Posts} from 'mattermost-redux/constants';
import * as PostActions from 'actions/post_actions.jsx';
......@@ -23,9 +20,7 @@ import * as GlobalActions from 'actions/global_actions.jsx';
import * as ChannelActions from 'actions/channel_actions.jsx';
import {setGlobalItem, actionOnGlobalItemsWithPrefix} from 'actions/storage';
import {EmojiMap} from 'stores/emoji_store.jsx';
import {makeGetCommentDraft} from 'selectors/rhs';
import * as Utils from 'utils/utils.jsx';
import {Constants, StoragePrefixes} from 'utils/constants.jsx';
......
......@@ -4,7 +4,6 @@
import * as PostActions from 'mattermost-redux/actions/posts';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {ActionTypes} from 'utils/constants.jsx';
export function editPost(post) {
......
......@@ -2,22 +2,17 @@
// See License.txt for license information.
import {batchActions} from 'redux-batched-actions';
import {SearchTypes} from 'mattermost-redux/action_types';
import {searchPosts} from 'mattermost-redux/actions/search';
import * as PostActions from 'mattermost-redux/actions/posts';
import {Client4} from 'mattermost-redux/client';
import {getCurrentUserId, getCurrentUserMentionKeys} from 'mattermost-redux/selectors/entities/users';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import {getSearchTerms, getRhsState} from 'selectors/rhs';
import {ActionTypes, RHSStates} from 'utils/constants';
import * as Utils from 'utils/utils';
......
......@@ -4,7 +4,6 @@
import {Client4} from 'mattermost-redux/client';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {WebrtcActionTypes} from 'utils/constants.jsx';
export function initWebrtc(userId, isCalling) {
......
......@@ -2,10 +2,7 @@
// See License.txt for license information.
import $ from 'jquery';
import {browserHistory} from 'react-router';
import {batchActions} from 'redux-batched-actions';
import {ChannelTypes, EmojiTypes, PostTypes, TeamTypes, UserTypes} from 'mattermost-redux/action_types';
import {getChannelAndMyMember, getChannelStats, viewChannel} from 'mattermost-redux/actions/channels';
import {setServerVersion} from 'mattermost-redux/actions/general';
......@@ -15,6 +12,7 @@ import {getMe} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {browserHistory} from 'utils/browser_history';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {handleNewPost} from 'actions/post_actions.jsx';
......@@ -28,10 +26,8 @@ import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import WebSocketClient from 'client/web_websocket_client.jsx';
import {loadPlugin, loadPluginsIfNecessary, removePlugin} from 'plugins';
import {ActionTypes, Constants, ErrorBarTypes, Preferences, SocketEvents, UserStatuses} from 'utils/constants.jsx';
import {getSiteURL} from 'utils/url.jsx';
......
......@@ -2,7 +2,6 @@
// See License.txt for license information.
import {connect} from 'react-redux';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
import AboutBuildModal from './about_build_modal.jsx';
......
......@@ -2,16 +2,13 @@
// See License.txt for license information.
import $ from 'jquery';
import PropTypes from 'prop-types';
import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import AuditTable from 'components/audit_table.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
......
......@@ -3,7 +3,6 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getUserAudits} from 'mattermost-redux/actions/users';
import AccessHistoryModal from './access_history_modal.jsx';
......
......@@ -2,18 +2,14 @@
// See License.txt for license information.
import $ from 'jquery';
import PropTypes from 'prop-types';
import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedDate, FormattedMessage, FormattedTime} from 'react-intl';
import {General} from 'mattermost-redux/constants';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
export default class ActivityLogModal extends React.Component {
......
......@@ -3,7 +3,6 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getSessions, revokeSession} from 'mattermost-redux/actions/users';
import ActivityLogModal from './activity_log_modal.jsx';
......
......@@ -5,7 +5,6 @@ import PropTypes from 'prop-types';
import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
import {Client4} from 'mattermost-redux/client';
import {searchProfilesNotInCurrentTeam} from 'mattermost-redux/selectors/entities/users';
......@@ -14,10 +13,8 @@ import {searchUsersNotInTeam} from 'actions/user_actions.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import Constants from 'utils/constants.jsx';
import {displayEntireNameForUser, localizeMessage} from 'utils/utils.jsx';
import MultiSelect from 'components/multiselect/multiselect.jsx';
import ProfilePicture from 'components/profile_picture.jsx';
......