Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 24ac1d1

Browse files
committed
Merge branch 'develop' into travis/integs/widgets
2 parents d2c7a5a + 831da69 commit 24ac1d1

File tree

11 files changed

+81
-128
lines changed

11 files changed

+81
-128
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"karma-summary-reporter": "^1.5.1",
149149
"karma-webpack": "^4.0.0-beta.0",
150150
"matrix-mock-request": "^1.2.3",
151-
"matrix-react-test-utils": "^0.1.1",
151+
"matrix-react-test-utils": "^0.2.2",
152152
"mocha": "^5.0.5",
153153
"react-addons-test-utils": "^15.4.0",
154154
"require-json": "0.0.1",

res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ limitations under the License.
2323
margin-top: 0;
2424
}
2525

26-
.mx_GeneralUserSettingsTab_accountSection > .mx_EmailAddresses,
27-
.mx_GeneralUserSettingsTab_accountSection > .mx_PhoneNumbers,
26+
.mx_GeneralUserSettingsTab_accountSection .mx_EmailAddresses,
27+
.mx_GeneralUserSettingsTab_accountSection .mx_PhoneNumbers,
2828
.mx_GeneralUserSettingsTab_languageInput {
2929
margin-right: 100px; // Align with the other fields on the page
3030
}

src/components/views/auth/ModularServerConfig.js

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ limitations under the License.
1515
*/
1616

1717
import React from 'react';
18-
import PropTypes from 'prop-types';
1918
import sdk from '../../../index';
2019
import { _t } from '../../../languageHandler';
2120
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
2221
import SdkConfig from "../../../SdkConfig";
2322
import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils";
2423
import * as ServerType from '../../views/auth/ServerTypeSelector';
24+
import ServerConfig from "./ServerConfig";
2525

2626
const MODULAR_URL = 'https://modular.im/?utm_source=riot-web&utm_medium=web&utm_campaign=riot-web-authentication';
2727

@@ -33,49 +33,8 @@ const MODULAR_URL = 'https://modular.im/?utm_source=riot-web&utm_medium=web&utm_
3333
* This is a variant of ServerConfig with only the HS field and different body
3434
* text that is specific to the Modular case.
3535
*/
36-
export default class ModularServerConfig extends React.PureComponent {
37-
static propTypes = {
38-
onServerConfigChange: PropTypes.func,
39-
40-
// The current configuration that the user is expecting to change.
41-
serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
42-
43-
delayTimeMs: PropTypes.number, // time to wait before invoking onChanged
44-
45-
// Called after the component calls onServerConfigChange
46-
onAfterSubmit: PropTypes.func,
47-
48-
// Optional text for the submit button. If falsey, no button will be shown.
49-
submitText: PropTypes.string,
50-
51-
// Optional class for the submit button. Only applies if the submit button
52-
// is to be rendered.
53-
submitClass: PropTypes.string,
54-
};
55-
56-
static defaultProps = {
57-
onServerConfigChange: function() {},
58-
customHsUrl: "",
59-
delayTimeMs: 0,
60-
};
61-
62-
constructor(props) {
63-
super(props);
64-
65-
this.state = {
66-
busy: false,
67-
errorText: "",
68-
hsUrl: props.serverConfig.hsUrl,
69-
isUrl: props.serverConfig.isUrl,
70-
};
71-
}
72-
73-
componentWillReceiveProps(newProps) {
74-
if (newProps.serverConfig.hsUrl === this.state.hsUrl &&
75-
newProps.serverConfig.isUrl === this.state.isUrl) return;
76-
77-
this.validateAndApplyServer(newProps.serverConfig.hsUrl, newProps.serverConfig.isUrl);
78-
}
36+
export default class ModularServerConfig extends ServerConfig {
37+
static propTypes = ServerConfig.propTypes;
7938

8039
async validateAndApplyServer(hsUrl, isUrl) {
8140
// Always try and use the defaults first
@@ -120,35 +79,6 @@ export default class ModularServerConfig extends React.PureComponent {
12079
return this.validateAndApplyServer(this.state.hsUrl, ServerType.TYPES.PREMIUM.identityServerUrl);
12180
}
12281

123-
onHomeserverBlur = (ev) => {
124-
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
125-
this.validateServer();
126-
});
127-
};
128-
129-
onHomeserverChange = (ev) => {
130-
const hsUrl = ev.target.value;
131-
this.setState({ hsUrl });
132-
};
133-
134-
onSubmit = async (ev) => {
135-
ev.preventDefault();
136-
ev.stopPropagation();
137-
const result = await this.validateServer();
138-
if (!result) return; // Do not continue.
139-
140-
if (this.props.onAfterSubmit) {
141-
this.props.onAfterSubmit();
142-
}
143-
};
144-
145-
_waitThenInvoke(existingTimeoutId, fn) {
146-
if (existingTimeoutId) {
147-
clearTimeout(existingTimeoutId);
148-
}
149-
return setTimeout(fn.bind(this), this.props.delayTimeMs);
150-
}
151-
15282
render() {
15383
const Field = sdk.getComponent('elements.Field');
15484
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');

src/components/views/auth/RegistrationForm.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Copyright 2015, 2016 OpenMarket Ltd
33
Copyright 2017 Vector Creations Ltd
44
Copyright 2018, 2019 New Vector Ltd
5+
Copyright 2019 Michael Telatynski <[email protected]>
56
67
Licensed under the Apache License, Version 2.0 (the "License");
78
you may not use this file except in compliance with the License.
@@ -69,10 +70,10 @@ module.exports = React.createClass({
6970
fieldValid: {},
7071
// The ISO2 country code selected in the phone number entry
7172
phoneCountry: this.props.defaultPhoneCountry,
72-
username: "",
73-
email: "",
74-
phoneNumber: "",
75-
password: "",
73+
username: this.props.defaultUsername || "",
74+
email: this.props.defaultEmail || "",
75+
phoneNumber: this.props.defaultPhoneNumber || "",
76+
password: this.props.defaultPassword || "",
7677
passwordConfirm: "",
7778
passwordComplexity: null,
7879
passwordSafe: false,
@@ -90,7 +91,7 @@ module.exports = React.createClass({
9091
}
9192

9293
const self = this;
93-
if (this.state.email == '') {
94+
if (this.state.email === '') {
9495
const haveIs = Boolean(this.props.serverConfig.isUrl);
9596

9697
let desc;
@@ -455,7 +456,6 @@ module.exports = React.createClass({
455456
ref={field => this[FIELD_EMAIL] = field}
456457
type="text"
457458
label={emailPlaceholder}
458-
defaultValue={this.props.defaultEmail}
459459
value={this.state.email}
460460
onChange={this.onEmailChange}
461461
onValidate={this.onEmailValidate}
@@ -469,7 +469,6 @@ module.exports = React.createClass({
469469
ref={field => this[FIELD_PASSWORD] = field}
470470
type="password"
471471
label={_t("Password")}
472-
defaultValue={this.props.defaultPassword}
473472
value={this.state.password}
474473
onChange={this.onPasswordChange}
475474
onValidate={this.onPasswordValidate}
@@ -483,7 +482,6 @@ module.exports = React.createClass({
483482
ref={field => this[FIELD_PASSWORD_CONFIRM] = field}
484483
type="password"
485484
label={_t("Confirm")}
486-
defaultValue={this.props.defaultPassword}
487485
value={this.state.passwordConfirm}
488486
onChange={this.onPasswordConfirmChange}
489487
onValidate={this.onPasswordConfirmValidate}
@@ -512,7 +510,6 @@ module.exports = React.createClass({
512510
ref={field => this[FIELD_PHONE_NUMBER] = field}
513511
type="text"
514512
label={phoneLabel}
515-
defaultValue={this.props.defaultPhoneNumber}
516513
value={this.state.phoneNumber}
517514
prefix={phoneCountry}
518515
onChange={this.onPhoneNumberChange}
@@ -528,7 +525,6 @@ module.exports = React.createClass({
528525
type="text"
529526
autoFocus={true}
530527
label={_t("Username")}
531-
defaultValue={this.props.defaultUsername}
532528
value={this.state.username}
533529
onChange={this.onUsernameChange}
534530
onValidate={this.onUsernameValidate}

src/components/views/avatars/BaseAvatar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright 2015, 2016 OpenMarket Ltd
33
Copyright 2018 New Vector Ltd
4+
Copyright 2019 Michael Telatynski <[email protected]>
45
56
Licensed under the Apache License, Version 2.0 (the "License");
67
you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import React from 'react';
1920
import PropTypes from 'prop-types';
2021
import { MatrixClient } from 'matrix-js-sdk';
2122
import AvatarLogic from '../../../Avatar';
22-
import sdk from '../../../index';
2323
import SettingsStore from "../../../settings/SettingsStore";
2424
import AccessibleButton from '../elements/AccessibleButton';
2525

@@ -121,6 +121,10 @@ module.exports = React.createClass({
121121
);
122122
urls.push(defaultImageUrl); // lowest priority
123123
}
124+
125+
// deduplicate URLs
126+
urls = Array.from(new Set(urls));
127+
124128
return {
125129
imageUrls: urls,
126130
defaultImageUrl: defaultImageUrl,

src/components/views/messages/RoomAvatarEvent.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2017 Vector Creations Ltd
3+
Copyright 2019 Michael Telatynski <[email protected]>
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@ limitations under the License.
1718
import React from 'react';
1819
import PropTypes from 'prop-types';
1920
import MatrixClientPeg from '../../../MatrixClientPeg';
20-
import { ContentRepo } from 'matrix-js-sdk';
2121
import { _t } from '../../../languageHandler';
2222
import sdk from '../../../index';
2323
import Modal from '../../../Modal';
@@ -31,42 +31,44 @@ module.exports = React.createClass({
3131
mxEvent: PropTypes.object.isRequired,
3232
},
3333

34-
onAvatarClick: function(name) {
35-
const httpUrl = MatrixClientPeg.get().mxcUrlToHttp(this.props.mxEvent.getContent().url);
34+
onAvatarClick: function() {
35+
const cli = MatrixClientPeg.get();
36+
const ev = this.props.mxEvent;
37+
const httpUrl = cli.mxcUrlToHttp(ev.getContent().url);
38+
39+
const room = cli.getRoom(this.props.mxEvent.getRoomId());
40+
const text = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', {
41+
senderDisplayName: ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(),
42+
roomName: room ? room.name : '',
43+
});
44+
3645
const ImageView = sdk.getComponent("elements.ImageView");
3746
const params = {
3847
src: httpUrl,
39-
name: name,
48+
name: text,
4049
};
4150
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox");
4251
},
4352

4453
render: function() {
4554
const ev = this.props.mxEvent;
4655
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
47-
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
48-
49-
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
50-
const name = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', {
51-
senderDisplayName: senderDisplayName,
52-
roomName: room ? room.name : '',
53-
});
56+
const RoomAvatar = sdk.getComponent("avatars.RoomAvatar");
5457

5558
if (!ev.getContent().url || ev.getContent().url.trim().length === 0) {
5659
return (
5760
<div className="mx_TextualEvent">
58-
{ _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName: senderDisplayName}) }
61+
{ _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName}) }
5962
</div>
6063
);
6164
}
6265

63-
const url = ContentRepo.getHttpUriForMxc(
64-
MatrixClientPeg.get().getHomeserverUrl(),
65-
ev.getContent().url,
66-
Math.ceil(14 * window.devicePixelRatio),
67-
Math.ceil(14 * window.devicePixelRatio),
68-
'crop',
69-
);
66+
const room = MatrixClientPeg.get().getRoom(ev.getRoomId());
67+
// Provide all arguments to RoomAvatar via oobData because the avatar is historic
68+
const oobData = {
69+
avatarUrl: ev.getContent().url,
70+
name: room ? room.name : "",
71+
};
7072

7173
return (
7274
<div className="mx_RoomAvatarEvent">
@@ -75,8 +77,8 @@ module.exports = React.createClass({
7577
{
7678
'img': () =>
7779
<AccessibleButton key="avatar" className="mx_RoomAvatarEvent_avatar"
78-
onClick={this.onAvatarClick.bind(this, name)}>
79-
<BaseAvatar width={14} height={14} url={url} name={name} />
80+
onClick={this.onAvatarClick}>
81+
<RoomAvatar width={14} height={14} oobData={oobData} />
8082
</AccessibleButton>,
8183
})
8284
}

src/components/views/settings/tabs/user/GeneralUserSettingsTab.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright 2019 New Vector Ltd
33
Copyright 2019 The Matrix.org Foundation C.I.C.
4+
Copyright 2019 Michael Telatynski <[email protected]>
45
56
Licensed under the Apache License, Version 2.0 (the "License");
67
you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import LanguageDropdown from "../../../elements/LanguageDropdown";
2627
import AccessibleButton from "../../../elements/AccessibleButton";
2728
import DeactivateAccountDialog from "../../../dialogs/DeactivateAccountDialog";
2829
import PropTypes from "prop-types";
30+
import {THEMES} from "../../../../../themes";
2931
const PlatformPeg = require("../../../../../PlatformPeg");
3032
const MatrixClientPeg = require("../../../../../MatrixClientPeg");
3133
const sdk = require('../../../../..');
@@ -160,8 +162,9 @@ export default class GeneralUserSettingsTab extends React.Component {
160162
<span className="mx_SettingsTab_subheading">{_t("Theme")}</span>
161163
<Field id="theme" label={_t("Theme")} element="select"
162164
value={this.state.theme} onChange={this._onThemeChange}>
163-
<option value="light">{_t("Light theme")}</option>
164-
<option value="dark">{_t("Dark theme")}</option>
165+
{Object.entries(THEMES).map(([theme, text]) => {
166+
return <option key={theme} value={theme}>{_t(text)}</option>;
167+
})}
165168
</Field>
166169
<SettingsFlag name="useCompactLayout" level={SettingLevel.ACCOUNT} />
167170
</div>

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@
251251
"%(widgetName)s widget modified by %(senderName)s": "%(widgetName)s widget modified by %(senderName)s",
252252
"%(widgetName)s widget added by %(senderName)s": "%(widgetName)s widget added by %(senderName)s",
253253
"%(widgetName)s widget removed by %(senderName)s": "%(widgetName)s widget removed by %(senderName)s",
254+
"Light theme": "Light theme",
255+
"Dark theme": "Dark theme",
254256
"%(displayName)s is typing …": "%(displayName)s is typing …",
255257
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
256258
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
@@ -548,8 +550,6 @@
548550
"Set a new account password...": "Set a new account password...",
549551
"Language and region": "Language and region",
550552
"Theme": "Theme",
551-
"Light theme": "Light theme",
552-
"Dark theme": "Dark theme",
553553
"Account management": "Account management",
554554
"Deactivating your account is a permanent action - be careful!": "Deactivating your account is a permanent action - be careful!",
555555
"Deactivate Account": "Deactivate Account",

src/settings/controllers/ThemeController.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2019 New Vector Ltd
3+
Copyright 2019 Michael Telatynski <[email protected]>
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -15,17 +16,13 @@ limitations under the License.
1516
*/
1617

1718
import SettingController from "./SettingController";
18-
19-
const SUPPORTED_THEMES = [
20-
"light",
21-
"dark",
22-
];
19+
import {DEFAULT_THEME, THEMES} from "../../themes";
2320

2421
export default class ThemeController extends SettingController {
2522
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
2623
// Override in case some no longer supported theme is stored here
27-
if (!SUPPORTED_THEMES.includes(calculatedValue)) {
28-
return "light";
24+
if (!THEMES[calculatedValue]) {
25+
return DEFAULT_THEME;
2926
}
3027

3128
return null; // no override

0 commit comments

Comments
 (0)