Unverified Commit 19069b5e authored by Christopher Speller's avatar Christopher Speller Committed by GitHub

Upgrading webapp dependencies except webpack. (#1223)

* Easy dependancies upgrade.

* Redux upgrade to 4

* React codemod to change to UNSAFE

* Upgrade eslint.

* Being more specific with disabled lines.

* Fixing tests.

* Downgrading image-webpack-loader because latest is broken.
parent 624dd405
This diff is collapsed.
......@@ -91,10 +91,9 @@ export function loadStatusesForProfilesMap(users) {
const statusesToLoad = [];
for (const userId in users) {
if (!users.hasOwnProperty(userId)) {
return;
if ({}.hasOwnProperty.call(users, userId)) {
statusesToLoad.push(userId);
}
statusesToLoad.push(userId);
}
loadStatusesByIds(statusesToLoad);
......
......@@ -53,7 +53,7 @@ export default class AddUsersToTeam extends React.Component {
});
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.searchTerm !== nextProps.searchTerm) {
clearTimeout(this.searchTimeoutId);
......
......@@ -111,7 +111,7 @@ export default class AdminConsole extends React.Component {
}).isRequired,
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.props.actions.getConfig();
this.props.actions.getEnvironmentConfig();
reloadIfServerVersionChanged();
......
......@@ -63,18 +63,18 @@ export default class AdminSidebarCategory extends React.Component {
render={() => (
<ul className={'sections ' + this.props.sectionClass}>
{
React.Children.map(this.props.children, (child) => {
if (child === null) {
return null;
}
React.Children.map(this.props.children, (child) => {
if (child === null) {
return null;
}
return React.cloneElement(child, {
parentLink: link,
});
})
}
return React.cloneElement(child, {
parentLink: link,
});
})
}
</ul>
)}
)}
/>
);
}
......
......@@ -39,7 +39,7 @@ export default class BrandImageSetting extends React.PureComponent {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
fetch(Client4.getBrandImageUrl(this.state.brandImageTimestamp)).then(
(resp) => {
if (resp.status === HTTP_STATUS_OK) {
......
......@@ -33,7 +33,7 @@ export default class ClusterTableContainer extends React.Component {
);
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.load();
// reload the cluster status every 15 seconds
......
......@@ -34,7 +34,7 @@ export class WebhookSettings extends AdminSettings {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.props.actions.loadRolesIfNeeded(['team_user', 'system_user']);
if (this.props.roles.system_user &&
this.props.roles.team_user) {
......@@ -42,7 +42,7 @@ export class WebhookSettings extends AdminSettings {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (!this.state.loaded &&
nextProps.roles.system_user &&
nextProps.roles.team_user) {
......
......@@ -9,7 +9,7 @@ export default class CustomPluginSettings extends SchemaAdminSettings {
this.isPlugin = true;
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
const id = this.props.schema ? this.props.schema.id : '';
const nextId = nextProps.schema ? nextProps.schema.id : '';
......
......@@ -66,7 +66,7 @@ class JobTable extends React.PureComponent {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.interval = setInterval(this.reload, 15000);
}
......
......@@ -60,7 +60,7 @@ export default class ManageRolesModal extends React.PureComponent {
this.state = getStateFromProps(props);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
const user = this.props.user || {};
const nextUser = nextProps.user || {};
if (user.id !== nextUser.id) {
......
......@@ -39,7 +39,7 @@ export default class ManageTeamsModal extends React.Component {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
const userId = this.props.user ? this.props.user.id : '';
const nextUserId = nextProps.user ? nextProps.user.id : '';
......
......@@ -48,7 +48,7 @@ export default class ManageTokensModal extends React.PureComponent {
this.state = {error: null};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
const userId = this.props.user ? this.props.user.id : null;
const nextUserId = nextProps.user ? nextProps.user.id : null;
if (nextUserId && nextUserId !== userId) {
......
......@@ -49,7 +49,7 @@ export default class MultiSelectSetting extends React.Component {
}
}
componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line camelcase
if (newProps.selected.length > 0 && newProps.mustBePresent && newProps.selected.join(',').indexOf(newProps.mustBePresent) === -1) {
this.setState({error: this.props.notPresent});
} else {
......
......@@ -70,7 +70,7 @@ export class PolicySettings extends AdminSettings {
this.setState({...this.roleBasedPolicies, loaded: true});
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.props.actions.loadRolesIfNeeded(['channel_user', 'team_user', 'channel_admin', 'team_admin', 'system_admin']);
if (this.props.roles.system_user &&
this.props.roles.system_admin &&
......@@ -82,7 +82,7 @@ export class PolicySettings extends AdminSettings {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (!this.state.loaded &&
nextProps.roles.system_user &&
nextProps.roles.system_admin &&
......
......@@ -82,7 +82,7 @@ export default class SamlSettings extends AdminSettings {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
AdminActions.samlCertificateStatus(
(data) => {
const files = {};
......
......@@ -41,7 +41,7 @@ export default class SchemaAdminSettings extends AdminSettings {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.schema !== this.props.schema) {
this.setState(this.getStateFromConfig(nextProps.config, nextProps.schema));
}
......
......@@ -42,7 +42,7 @@ export default class Logs extends React.Component {
);
}
componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) { // eslint-disable-line camelcase
if (this.state.page !== nextState.page) {
this.props.actions.getLogs(nextState.page, nextState.perPage).then(
() => this.setState({loadingLogs: false})
......
......@@ -64,7 +64,7 @@ export default class SystemUsersList extends React.Component {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.teamId !== this.props.teamId) {
this.setState({page: 0});
}
......
......@@ -110,7 +110,7 @@ export default class SystemUsers extends React.Component {
this.props.actions.getTeams(0, 1000).then(reloadIfServerVersionChanged);
}
componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) { // eslint-disable-line camelcase
const nextTeamId = nextState.teamId;
if (this.state.teamId !== nextTeamId) {
......
......@@ -42,14 +42,14 @@ export class UsersAndTeamsSettings extends AdminSettings {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.props.actions.loadRolesIfNeeded(['system_user']);
if (this.props.roles.system_user) {
this.loadPoliciesIntoState(this.props);
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (!this.state.loaded && nextProps.roles.system_user) {
this.loadPoliciesIntoState(nextProps);
}
......
......@@ -44,7 +44,7 @@ export default class LineChart extends React.PureComponent {
this.initChart();
}
componentWillUpdate(nextProps) {
UNSAFE_componentWillUpdate(nextProps) { // eslint-disable-line camelcase
const willHaveData = nextProps.data && nextProps.data.labels.length > 0;
const hasChart = Boolean(this.chart);
......
......@@ -77,7 +77,7 @@ export default class TeamAnalytics extends React.Component {
this.props.actions.getTeams(0, 1000);
}
componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) { // eslint-disable-line camelcase
if (nextState.team && nextState.team !== this.state.team) {
this.getData(nextState.team.id);
}
......
......@@ -59,7 +59,7 @@ export default class AnnouncementBar extends React.PureComponent {
this.state = this.getState(props);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.enableBanner !== this.props.enableBanner ||
nextProps.bannerText !== this.props.bannerText ||
nextProps.bannerColor !== this.props.bannerColor ||
......
......@@ -21,11 +21,11 @@ export class AsyncComponent extends React.Component {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.load(this.props);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.doLoad !== this.props.doLoad) {
this.load(nextProps);
}
......@@ -43,8 +43,10 @@ export class AsyncComponent extends React.Component {
}
export function makeAsyncComponent(loadComponent) {
return (props) => (<AsyncComponent
doLoad={loadComponent}
{...props}
/>);
return (props) => (
<AsyncComponent
doLoad={loadComponent}
{...props}
/>
);
}
......@@ -36,7 +36,7 @@ export default class AtMention extends React.PureComponent {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.mentionName !== this.props.mentionName || nextProps.usersByUsername !== this.props.usersByUsername) {
this.setState({
user: this.getUserFromMentionName(nextProps),
......
......@@ -38,7 +38,7 @@ export default class AudioVideoPreview extends React.PureComponent {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.handleFileInfoChanged(this.props.fileInfo);
}
......@@ -48,7 +48,7 @@ export default class AudioVideoPreview extends React.PureComponent {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.fileUrl !== nextProps.fileUrl) {
this.handleFileInfoChanged(nextProps.fileInfo);
}
......
......@@ -26,7 +26,7 @@ export default class Authorize extends React.Component {
this.state = {};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
const clientId = (new URLSearchParams(this.props.location.search)).get('client_id');
if (!(/^[a-z0-9]+$/.test(clientId))) {
return;
......
......@@ -51,18 +51,18 @@ export default class BackstageCategory extends React.Component {
render={() => (
<ul className='sections'>
{
React.Children.map(children, (child) => {
if (!child) {
return child;
}
React.Children.map(children, (child) => {
if (!child) {
return child;
}
return React.cloneElement(child, {
parentLink: link,
});
})
}
return React.cloneElement(child, {
parentLink: link,
});
})
}
</ul>
)}
)}
/>
</li>
);
......
......@@ -10,7 +10,6 @@ import Constants from 'utils/constants';
import {getShortenedURL, cleanUpUrlable} from 'utils/url';
export default class ChangeURLModal extends React.PureComponent {
static propTypes = {
/**
......@@ -76,7 +75,7 @@ export default class ChangeURLModal extends React.PureComponent {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
// This check prevents the url being deleted when we re-render
// because of user status check
if (!this.state.userEdit) {
......@@ -106,29 +105,29 @@ export default class ChangeURLModal extends React.PureComponent {
if (url.length < 2) {
error.push(
this.formattedError('error1', 'change_url.longer', 'URL must be two or more characters.')
this.formattedError('error1', 'change_url.longer', 'URL must be two or more characters.')
);
}
if (url.charAt(0) === '-' || url.charAt(0) === '_') {
error.push(
this.formattedError('error2', 'change_url.startWithLetter', 'URL must start with a letter or number.')
this.formattedError('error2', 'change_url.startWithLetter', 'URL must start with a letter or number.')
);
}
if (url.length > 1 && (url.charAt(url.length - 1) === '-' || url.charAt(url.length - 1) === '_')) {
error.push(
this.formattedError('error3', 'change_url.endWithLetter', 'URL must end with a letter or number.')
this.formattedError('error3', 'change_url.endWithLetter', 'URL must end with a letter or number.')
);
}
if (url.indexOf('__') > -1) {
error.push(
this.formattedError('error4', 'change_url.noUnderscore', 'URL can not contain two underscores in a row.')
this.formattedError('error4', 'change_url.noUnderscore', 'URL can not contain two underscores in a row.')
);
}
// In case of error we don't detect
if (error.length === 0) {
error.push(
this.formattedError('errorlast', 'change_url.invalidUrl', 'Invalid URL')
this.formattedError('errorlast', 'change_url.invalidUrl', 'Invalid URL')
);
}
return error;
......
......@@ -116,7 +116,7 @@ export default class ChannelHeader extends React.Component {
window.removeEventListener('resize', this.handleResize);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.channel.id !== nextProps.channel.id) {
this.props.actions.getCustomEmojisInText(nextProps.channel.header);
}
......
......@@ -28,7 +28,7 @@ export default class CenterChannel extends React.PureComponent {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.location.pathname !== nextProps.location.pathname && nextProps.location.pathname.includes('/pl/')) {
this.setState({returnTo: this.props.location.pathname});
}
......
......@@ -223,7 +223,7 @@ export default class ChannelIdentifierRouter extends React.PureComponent {
onChannelByIdentifierEnter(props);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.match.params.identifier !== nextProps.match.params.identifier) {
onChannelByIdentifierEnter(nextProps);
}
......
......@@ -18,7 +18,7 @@ describe('components/ChannelMembersModal', () => {
},
canManageChannelMembers: true,
onModalDismissed: () => {}, // eslint-disable-line no-empty-function
showInviteModal: () => {}, // eslint-disable-line no-empty-function
showInviteModal: () => {}, // eslint-disable-line no-empty-function
};
test('renders the channel display name', () => {
......
......@@ -38,7 +38,7 @@ export default class ChannelNotificationsModal extends React.Component {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (!Utils.areObjectsEqual(this.props.channelMember.notify_props, nextProps.channelMember.notify_props)) {
this.setState({
desktopNotifyLevel: nextProps.channelMember.notify_props.desktop,
......
......@@ -67,7 +67,7 @@ export default class ChannelView extends React.PureComponent {
$('body').removeClass('app__body');
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.match.url !== nextProps.match.url) {
this.createDeferredPostView();
}
......
......@@ -39,7 +39,7 @@ export default class ClaimController extends React.Component {
siteName={this.props.siteName}
passwordConfig={this.props.passwordConfig}
/>
)}
)}
/>
<Route
path={`${this.props.match.url}/email_to_oauth`}
......@@ -50,7 +50,7 @@ export default class ClaimController extends React.Component {
email={email}
siteName={this.props.siteName}
/>
)}
)}
/>
<Route
path={`${this.props.match.url}/ldap_to_email`}
......@@ -61,7 +61,7 @@ export default class ClaimController extends React.Component {
email={email}
passwordConfig={this.props.passwordConfig}
/>
)}
)}
/>
<Route
path={`${this.props.match.url}/email_to_ldap`}
......@@ -72,7 +72,7 @@ export default class ClaimController extends React.Component {
siteName={this.props.siteName}
ldapLoginFieldName={this.props.ldapLoginFieldName}
/>
)}
)}
/>
</Switch>
</div>
......
......@@ -31,7 +31,7 @@ export default class CodePreview extends React.Component {
this.updateStateFromProps(this.props);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.fileUrl !== nextProps.fileUrl) {
this.updateStateFromProps(nextProps);
}
......
......@@ -93,7 +93,7 @@ export default class ConfirmModal extends React.Component {
document.removeEventListener('keypress', this.handleKeypress);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (this.props.show && !nextProps.show) {
document.removeEventListener('keypress', this.handleKeypress);
} else if (!this.props.show && nextProps.show) {
......
......@@ -162,7 +162,7 @@ export default class CreateComment extends React.PureComponent {
this.lastBlurAt = 0;
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.props.clearCommentDraftUploads();
this.props.onResetHistoryIndex();
this.setState({draft: {...this.props.draft, uploadsInProgress: []}});
......@@ -176,7 +176,7 @@ export default class CreateComment extends React.PureComponent {
this.props.resetCreatePostRequest();
}
componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line camelcase
if (newProps.createPostErrorId === 'api.post.create_post.root_id.app_error' && newProps.createPostErrorId !== this.props.createPostErrorId) {
this.showPostDeletedModal();
}
......
......@@ -211,7 +211,7 @@ export default class CreatePost extends React.Component {
this.lastBlurAt = 0;
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
const enableSendButton = this.handleEnableSendButton(this.state.message, this.props.draft.fileInfos);
this.props.actions.clearDraftUploads(StoragePrefixes.DRAFT, (key, value) => {
if (value) {
......@@ -231,7 +231,7 @@ export default class CreatePost extends React.Component {
document.addEventListener('keydown', this.showShortcuts);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line camelcase
if (nextProps.currentChannel.id !== this.props.currentChannel.id) {
const draft = nextProps.draft;
......
......@@ -100,7 +100,7 @@ export default class CreateTeam extends React.PureComponent {
updateParent={this.updateParent}
{...props}
/>
)}
)}
/>
<Route
path={`${this.props.match.url}/team_url`}
......@@ -110,7 +110,7 @@ export default class CreateTeam extends React.PureComponent {
updateParent={this.updateParent}
{...props}
/>
)}
)}
/>
<Redirect to={`${match.url}/display_name`}/>
</Switch>
......
......@@ -44,7 +44,7 @@ export default class DoVerifyEmail extends React.PureComponent {
};
}
componentWillMount() {
UNSAFE_componentWillMount() { // eslint-disable-line camelcase
this.verifyEmail();
}
......
......@@ -85,7 +85,7 @@ export default class DotMenu extends Component {
$('#' + this.props.idPrefix + '_dropdown' + this.props.post.id).on('hidden.bs.dropdown', () => this.props.handleDropdownOpened(false));