diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index e5eb9d70c8..c6f25c2480 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -12,8 +12,6 @@ src/components/structures/HomePage.js src/components/structures/LeftPanel.js src/components/structures/LoggedInView.js src/components/structures/login/ForgotPassword.js -src/components/structures/login/Login.js -src/components/structures/login/Registration.js src/components/structures/LoginBox.js src/components/structures/MessagePanel.js src/components/structures/NotificationPanel.js @@ -25,12 +23,11 @@ src/components/structures/ScrollPanel.js src/components/structures/SearchBox.js src/components/structures/TimelinePanel.js src/components/structures/UploadBar.js +src/components/structures/UserSettings.js src/components/structures/ViewSource.js src/components/views/avatars/BaseAvatar.js -src/components/views/avatars/GroupAvatar.js src/components/views/avatars/MemberAvatar.js src/components/views/create_room/RoomAlias.js -src/components/views/dialogs/BugReportDialog.js src/components/views/dialogs/ChangelogDialog.js src/components/views/dialogs/ChatCreateOrReuseDialog.js src/components/views/dialogs/DeactivateAccountDialog.js @@ -46,6 +43,7 @@ src/components/views/elements/InlineSpinner.js src/components/views/elements/MemberEventListSummary.js src/components/views/elements/Spinner.js src/components/views/elements/TintableSvg.js +src/components/views/elements/UserInfo.js src/components/views/elements/UserSelector.js src/components/views/globals/MatrixToolbar.js src/components/views/globals/NewVersionBar.js @@ -64,7 +62,6 @@ src/components/views/room_settings/UrlPreviewSettings.js src/components/views/rooms/Autocomplete.js src/components/views/rooms/AuxPanel.js src/components/views/rooms/EntityTile.js -src/components/views/rooms/EventTile.js src/components/views/rooms/LinkPreviewWidget.js src/components/views/rooms/MemberDeviceInfo.js src/components/views/rooms/MemberInfo.js @@ -72,12 +69,11 @@ src/components/views/rooms/MemberList.js src/components/views/rooms/MemberTile.js src/components/views/rooms/MessageComposer.js src/components/views/rooms/MessageComposerInput.js +src/components/views/rooms/PinnedEventTile.js src/components/views/rooms/RoomDropTarget.js src/components/views/rooms/RoomList.js src/components/views/rooms/RoomPreviewBar.js src/components/views/rooms/RoomSettings.js -src/components/views/rooms/RoomTile.js -src/components/views/rooms/RoomTooltip.js src/components/views/rooms/SearchableEntityList.js src/components/views/rooms/SearchBar.js src/components/views/rooms/SearchResultTile.js @@ -91,6 +87,7 @@ src/components/views/settings/DevicesPanel.js src/components/views/settings/IntegrationsManager.js src/components/views/settings/Notifications.js src/ContentMessages.js +src/GroupAddressPicker.js src/HtmlUtils.js src/ImageUtils.js src/languageHandler.js @@ -134,6 +131,7 @@ test/components/structures/TimelinePanel-test.js test/components/views/dialogs/InteractiveAuthDialog-test.js test/components/views/login/RegistrationForm-test.js test/components/views/rooms/MessageComposerInput-test.js +test/components/views/rooms/RoomSettings-test.js test/mock-clock.js test/notifications/ContentRules-test.js test/notifications/PushRuleVectorState-test.js diff --git a/src/components/structures/login/ForgotPassword.js b/src/components/structures/login/ForgotPassword.js index ca50b9db6e..7e0cd5da8e 100644 --- a/src/components/structures/login/ForgotPassword.js +++ b/src/components/structures/login/ForgotPassword.js @@ -1,6 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd -Copyright 2017 New Vector Ltd +Copyright 2017, 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -'use strict'; - import React from 'react'; import PropTypes from 'prop-types'; import { _t } from '../../../languageHandler'; @@ -45,6 +43,8 @@ module.exports = React.createClass({ enteredHomeserverUrl: this.props.customHsUrl || this.props.defaultHsUrl, enteredIdentityServerUrl: this.props.customIsUrl || this.props.defaultIsUrl, progress: null, + password: null, + password2: null, }; }, @@ -103,7 +103,7 @@ module.exports = React.createClass({ , button: _t('Continue'), extraButtons: [ - , @@ -169,7 +169,8 @@ module.exports = React.createClass({ } else if (this.state.progress === "sent_email") { resetPasswordJsx = (
- { _t("An email has been sent to %(emailAddress)s. Once you've followed the link it contains, click below.", { emailAddress: this.state.email }) } + { _t("An email has been sent to %(emailAddress)s. Once you've followed the link it contains, " + + "click below.", { emailAddress: this.state.email }) }
@@ -179,14 +180,15 @@ module.exports = React.createClass({ resetPasswordJsx = (

{ _t('Your password has been reset') }.

-

{ _t('You have been logged out of all devices and will no longer receive push notifications. To re-enable notifications, sign in again on each device') }.

+

{ _t('You have been logged out of all devices and will no longer receive push notifications. ' + + 'To re-enable notifications, sign in again on each device') }.

); } else { let serverConfigSection; - if (!SdkConfig.get().disable_custom_urls) { + if (!SdkConfig.get()['disable_custom_urls']) { serverConfigSection = (
@@ -233,6 +237,7 @@ module.exports = React.createClass({ { _t('Create an account') } +
diff --git a/src/components/structures/login/LanguageSelector.js b/src/components/structures/login/LanguageSelector.js new file mode 100644 index 0000000000..965d8334d9 --- /dev/null +++ b/src/components/structures/login/LanguageSelector.js @@ -0,0 +1,38 @@ +/* +Copyright 2018 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import SdkConfig from "../../../SdkConfig"; +import {getCurrentLanguage} from "../../../languageHandler"; +import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore"; +import PlatformPeg from "../../../PlatformPeg"; +import sdk from '../../../index'; +import React from 'react'; + +function onChange(newLang) { + if (getCurrentLanguage() !== newLang) { + SettingsStore.setValue("language", null, SettingLevel.DEVICE, newLang); + PlatformPeg.get().reload(); + } +} + +export default function LanguageSelector() { + if (SdkConfig.get()['disable_login_language_selector']) return
; + + const LanguageDropdown = sdk.getComponent('views.elements.LanguageDropdown'); + return
+ +
; +} diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js index 1332f52f97..bc04434bb2 100644 --- a/src/components/structures/login/Login.js +++ b/src/components/structures/login/Login.js @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,15 +21,13 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; import { _t } from '../../../languageHandler'; -import * as languageHandler from '../../../languageHandler'; import sdk from '../../../index'; import Login from '../../../Login'; -import PlatformPeg from '../../../PlatformPeg'; import SdkConfig from '../../../SdkConfig'; -import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore"; +import SettingsStore from "../../../settings/SettingsStore"; // For validating phone numbers without country codes -const PHONE_NUMBER_REGEX = /^[0-9\(\)\-\s]*$/; +const PHONE_NUMBER_REGEX = /^[0-9()\-\s]*$/; /** * A wire component which glues together login UI components and Login logic @@ -113,10 +112,10 @@ module.exports = React.createClass({ // Some error strings only apply for logging in const usingEmail = username.indexOf("@") > 0; - if (error.httpStatus == 400 && usingEmail) { + if (error.httpStatus === 400 && usingEmail) { errorText = _t('This Home Server does not support login using email address.'); } else if (error.httpStatus === 401 || error.httpStatus === 403) { - if (SdkConfig.get().disable_custom_urls) { + if (SdkConfig.get()['disable_custom_urls']) { errorText = (
{ _t('Incorrect username and/or password.') }
@@ -143,7 +142,7 @@ module.exports = React.createClass({ // but the login API gives a 403 https://matrix.org/jira/browse/SYN-744 // mentions this (although the bug is for UI auth which is not this) // We treat both as an incorrect password - loginIncorrect: error.httpStatus === 401 || error.httpStatus == 403, + loginIncorrect: error.httpStatus === 401 || error.httpStatus === 403, }); }).finally(() => { if (this._unmounted) { @@ -231,7 +230,7 @@ module.exports = React.createClass({ hsUrl = hsUrl || this.state.enteredHomeserverUrl; isUrl = isUrl || this.state.enteredIdentityServerUrl; - const fallbackHsUrl = hsUrl == this.props.defaultHsUrl ? this.props.fallbackHsUrl : null; + const fallbackHsUrl = hsUrl === this.props.defaultHsUrl ? this.props.fallbackHsUrl : null; const loginLogic = new Login(hsUrl, isUrl, fallbackHsUrl, { defaultDeviceDisplayName: this.props.defaultDeviceDisplayName, @@ -310,19 +309,27 @@ module.exports = React.createClass({ !this.state.enteredHomeserverUrl.startsWith("http")) ) { errorText = - { - _t("Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. " + - "Either use HTTPS or enable unsafe scripts.", - {}, - { 'a': (sub) => { return { sub }; } }, + { _t("Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. " + + "Either use HTTPS or enable unsafe scripts.", {}, + { + 'a': (sub) => { + return + { sub } + ; + }, + }, ) } ; } else { errorText = - { - _t("Can't connect to homeserver - please check your connectivity, ensure your homeserver's SSL certificate is trusted, and that a browser extension is not blocking requests.", - {}, - { 'a': (sub) => { return { sub }; } }, + { _t("Can't connect to homeserver - please check your connectivity, ensure your " + + "homeserver's SSL certificate is trusted, and that a browser extension " + + "is not blocking requests.", {}, + { + 'a': (sub) => { + return { sub }; + }, + }, ) } ; } @@ -370,23 +377,6 @@ module.exports = React.createClass({ ); }, - _onLanguageChange: function(newLang) { - if (languageHandler.getCurrentLanguage() !== newLang) { - SettingsStore.setValue("language", null, SettingLevel.DEVICE, newLang); - PlatformPeg.get().reload(); - } - }, - - _renderLanguageSetting: function() { - const LanguageDropdown = sdk.getComponent('views.elements.LanguageDropdown'); - return
- -
; - }, - render: function() { const Loader = sdk.getComponent("elements.Spinner"); const LoginPage = sdk.getComponent("login.LoginPage"); @@ -403,21 +393,10 @@ module.exports = React.createClass({ ; } - let returnToAppJsx; - /* - // with the advent of ILAG I don't think we need this any more - if (this.props.onCancelClick) { - returnToAppJsx = - - { _t('Return to app') } - ; - } - */ - let serverConfig; let header; - if (!SdkConfig.get().disable_custom_urls) { + if (!SdkConfig.get()['disable_custom_urls']) { serverConfig =
@@ -460,8 +441,7 @@ module.exports = React.createClass({ { _t('Create an account') } { loginAsGuestJsx } - { returnToAppJsx } - { !SdkConfig.get().disable_login_language_selector ? this._renderLanguageSetting() : '' } +
diff --git a/src/components/structures/login/Registration.js b/src/components/structures/login/Registration.js index 62a3ee4f68..462063406f 100644 --- a/src/components/structures/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,7 +23,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import sdk from '../../../index'; -import ServerConfig from '../../views/login/ServerConfig'; import MatrixClientPeg from '../../../MatrixClientPeg'; import RegistrationForm from '../../views/login/RegistrationForm'; import RtsClient from '../../../RtsClient'; @@ -62,6 +62,12 @@ module.exports = React.createClass({ onLoginClick: PropTypes.func.isRequired, onCancelClick: PropTypes.func, onServerConfigChange: PropTypes.func.isRequired, + + rtsClient: PropTypes.shape({ + getTeamsConfig: PropTypes.func.isRequired, + trackReferral: PropTypes.func.isRequired, + getTeam: PropTypes.func.isRequired, + }), }, getInitialState: function() { @@ -133,7 +139,7 @@ module.exports = React.createClass({ newState.isUrl = config.isUrl; } this.props.onServerConfigChange(config); - this.setState(newState, function() { + this.setState(newState, () => { this._replaceClient(); }); }, @@ -159,11 +165,11 @@ module.exports = React.createClass({ let msg = response.message || response.toString(); // can we give a better error message? if (response.required_stages && response.required_stages.indexOf('m.login.msisdn') > -1) { - let msisdn_available = false; + let msisdnAvailable = false; for (const flow of response.available_flows) { - msisdn_available |= flow.stages.indexOf('m.login.msisdn') > -1; + msisdnAvailable |= flow.stages.indexOf('m.login.msisdn') > -1; } - if (!msisdn_available) { + if (!msisdnAvailable) { msg = _t('This server does not support authentication with a phone number.'); } } @@ -242,7 +248,7 @@ module.exports = React.createClass({ return matrixClient.getPushers().then((resp)=>{ const pushers = resp.pushers; for (let i = 0; i < pushers.length; ++i) { - if (pushers[i].kind == 'email') { + if (pushers[i].kind === 'email') { const emailPusher = pushers[i]; emailPusher.data = { brand: this.props.brand }; matrixClient.setPusher(emailPusher).done(() => { @@ -267,7 +273,7 @@ module.exports = React.createClass({ errMsg = _t('Passwords don\'t match.'); break; case "RegistrationForm.ERR_PASSWORD_LENGTH": - errMsg = _t('Password too short (min %(MIN_PASSWORD_LENGTH)s).', {MIN_PASSWORD_LENGTH: MIN_PASSWORD_LENGTH}); + errMsg = _t('Password too short (min %(MIN_PASSWORD_LENGTH)s).', {MIN_PASSWORD_LENGTH}); break; case "RegistrationForm.ERR_EMAIL_INVALID": errMsg = _t('This doesn\'t look like a valid email address.'); @@ -353,7 +359,7 @@ module.exports = React.createClass({ registerBody = ; } else { let serverConfigSection; - if (!SdkConfig.get().disable_custom_urls) { + if (!SdkConfig.get()['disable_custom_urls']) { serverConfigSection = ( - { _t('Return to app') } - - ); - } - */ - let header; let errorText; // FIXME: remove hardcoded Status team tweaks at some point @@ -418,6 +412,8 @@ module.exports = React.createClass({ ); } + const LanguageSelector = sdk.getComponent('structures.login.LanguageSelector'); + return (
@@ -431,7 +427,7 @@ module.exports = React.createClass({ { registerBody } { signIn } { errorText } - { returnToAppJsx } +