Merge branch 'develop' into travis/encryption-warning
This commit is contained in:
commit
879fa22416
31 changed files with 486 additions and 296 deletions
|
@ -19,7 +19,6 @@ import Promise from 'bluebird';
|
|||
import sdk from '../../../index';
|
||||
import { _t } from '../../../languageHandler';
|
||||
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||
import UserSettingsStore from '../../../UserSettingsStore';
|
||||
import SettingsStore, {SettingLevel} from '../../../settings/SettingsStore';
|
||||
import Modal from '../../../Modal';
|
||||
import {
|
||||
|
@ -132,14 +131,41 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* Returns the email pusher (pusher of type 'email') for a given
|
||||
* email address. Email pushers all have the same app ID, so since
|
||||
* pushers are unique over (app ID, pushkey), there will be at most
|
||||
* one such pusher.
|
||||
*/
|
||||
getEmailPusher: function(pushers, address) {
|
||||
if (pushers === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
for (let i = 0; i < pushers.length; ++i) {
|
||||
if (pushers[i].kind === 'email' && pushers[i].pushkey === address) {
|
||||
return pushers[i];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
onEnableEmailNotificationsChange: function(address, checked) {
|
||||
let emailPusherPromise;
|
||||
if (checked) {
|
||||
const data = {};
|
||||
data['brand'] = SdkConfig.get().brand || 'Riot';
|
||||
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
||||
emailPusherPromise = MatrixClientPeg.get().setPusher({
|
||||
kind: 'email',
|
||||
app_id: 'm.email',
|
||||
pushkey: address,
|
||||
app_display_name: 'Email Notifications',
|
||||
device_display_name: address,
|
||||
lang: navigator.language,
|
||||
data: data,
|
||||
append: true, // We always append for email pushers since we don't want to stop other accounts notifying to the same email address
|
||||
});
|
||||
} else {
|
||||
const emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
||||
const emailPusher = this.getEmailPusher(this.state.pushers, address);
|
||||
emailPusher.kind = null;
|
||||
emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher);
|
||||
}
|
||||
|
@ -697,7 +723,7 @@ module.exports = React.createClass({
|
|||
emailNotificationsRow: function(address, label) {
|
||||
return <LabelledToggleSwitch value={this.hasEmailPusher(this.state.pushers, address)}
|
||||
onChange={this.onEnableEmailNotificationsChange.bind(this, address)}
|
||||
label={label} />;
|
||||
label={label} key={`emailNotif_${label}`} />;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -729,17 +755,15 @@ module.exports = React.createClass({
|
|||
}
|
||||
|
||||
const emailThreepids = this.state.threepids.filter((tp) => tp.medium === "email");
|
||||
let emailNotificationsRow;
|
||||
let emailNotificationsRows;
|
||||
if (emailThreepids.length === 0) {
|
||||
emailNotificationsRow = <div>
|
||||
emailNotificationsRows = <div>
|
||||
{ _t('Add an email address to configure email notifications') }
|
||||
</div>;
|
||||
} else {
|
||||
// This only supports the first email address in your profile for now
|
||||
emailNotificationsRow = this.emailNotificationsRow(
|
||||
emailThreepids[0].address,
|
||||
`${_t('Enable email notifications')} (${emailThreepids[0].address})`,
|
||||
);
|
||||
emailNotificationsRows = emailThreepids.map((threePid) => this.emailNotificationsRow(
|
||||
threePid.address, `${_t('Enable email notifications')} (${threePid.address})`,
|
||||
));
|
||||
}
|
||||
|
||||
// Build external push rules
|
||||
|
@ -823,7 +847,7 @@ module.exports = React.createClass({
|
|||
onChange={this.onEnableAudioNotificationsChange}
|
||||
label={_t('Enable audible notifications in web client')} />
|
||||
|
||||
{ emailNotificationsRow }
|
||||
{ emailNotificationsRows }
|
||||
|
||||
<div className="mx_UserNotifSettings_pushRulesTableWrapper">
|
||||
<table className="mx_UserNotifSettings_pushRulesTable">
|
||||
|
|
|
@ -20,13 +20,22 @@ import MatrixClientPeg from "../../../MatrixClientPeg";
|
|||
import Field from "../elements/Field";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import classNames from 'classnames';
|
||||
import {User} from "matrix-js-sdk";
|
||||
|
||||
export default class ProfileSettings extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const client = MatrixClientPeg.get();
|
||||
const user = client.getUser(client.getUserId());
|
||||
let user = client.getUser(client.getUserId());
|
||||
if (!user) {
|
||||
// XXX: We shouldn't have to do this.
|
||||
// There seems to be a condition where the User object won't exist until a room
|
||||
// exists on the account. To work around this, we'll just create a temporary User
|
||||
// and use that.
|
||||
console.warn("User object not found - creating one for ProfileSettings");
|
||||
user = new User(client.getUserId());
|
||||
}
|
||||
let avatarUrl = user.avatarUrl;
|
||||
if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false);
|
||||
this.state = {
|
||||
|
@ -72,7 +81,6 @@ export default class ProfileSettings extends React.Component {
|
|||
newState.avatarFile = null;
|
||||
}
|
||||
|
||||
newState.enableProfileSave = true;
|
||||
this.setState(newState);
|
||||
};
|
||||
|
||||
|
|
|
@ -24,14 +24,14 @@ import Modal from "../../../../../Modal";
|
|||
|
||||
const plEventsToLabels = {
|
||||
// These will be translated for us later.
|
||||
"m.room.avatar": _td("To change the room's avatar, you must be a"),
|
||||
"m.room.name": _td("To change the room's name, you must be a"),
|
||||
"m.room.canonical_alias": _td("To change the room's main address, you must be a"),
|
||||
"m.room.history_visibility": _td("To change the room's history visibility, you must be a"),
|
||||
"m.room.power_levels": _td("To change the permissions in the room, you must be a"),
|
||||
"m.room.topic": _td("To change the topic, you must be a"),
|
||||
"m.room.avatar": _td("Change room avatar"),
|
||||
"m.room.name": _td("Change room name"),
|
||||
"m.room.canonical_alias": _td("Change main address for the room"),
|
||||
"m.room.history_visibility": _td("Change history visibility"),
|
||||
"m.room.power_levels": _td("Change permissions"),
|
||||
"m.room.topic": _td("Change topic"),
|
||||
|
||||
"im.vector.modular.widgets": _td("To modify widgets in the room, you must be a"),
|
||||
"im.vector.modular.widgets": _td("Modify widgets"),
|
||||
};
|
||||
|
||||
const plEventsToShow = {
|
||||
|
@ -158,35 +158,35 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
|
||||
const powerLevelDescriptors = {
|
||||
"users_default": {
|
||||
desc: _t('The default role for new room members is'),
|
||||
desc: _t('Default role'),
|
||||
defaultValue: 0,
|
||||
},
|
||||
"events_default": {
|
||||
desc: _t('To send messages, you must be a'),
|
||||
desc: _t('Send messages'),
|
||||
defaultValue: 0,
|
||||
},
|
||||
"invite": {
|
||||
desc: _t('To invite users into the room, you must be a'),
|
||||
desc: _t('Invite users'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
"state_default": {
|
||||
desc: _t('To configure the room, you must be a'),
|
||||
desc: _t('Change settings'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
"kick": {
|
||||
desc: _t('To kick users, you must be a'),
|
||||
desc: _t('Kick users'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
"ban": {
|
||||
desc: _t('To ban users, you must be a'),
|
||||
desc: _t('Ban users'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
"redact": {
|
||||
desc: _t('To remove other users\' messages, you must be a'),
|
||||
desc: _t('Remove messages'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
"notifications.room": {
|
||||
desc: _t('To notify everyone in the room, you must be a'),
|
||||
desc: _t('Notify everyone'),
|
||||
defaultValue: 50,
|
||||
},
|
||||
};
|
||||
|
@ -217,20 +217,15 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
const mutedUsers = [];
|
||||
|
||||
Object.keys(userLevels).forEach(function(user) {
|
||||
const canChange = userLevels[user] < currentUserLevel && canChangeLevels;
|
||||
if (userLevels[user] > defaultUserLevel) { // privileged
|
||||
privilegedUsers.push(<li key={user}>
|
||||
{ _t("%(user)s is a %(userRole)s", {
|
||||
user: user,
|
||||
userRole: <PowerSelector value={userLevels[user]} disabled={true} />,
|
||||
}) }
|
||||
</li>);
|
||||
privilegedUsers.push(
|
||||
<PowerSelector value={userLevels[user]} disabled={!canChange} label={user} key={user} />,
|
||||
);
|
||||
} else if (userLevels[user] < defaultUserLevel) { // muted
|
||||
mutedUsers.push(<li key={user}>
|
||||
{ _t("%(user)s is a %(userRole)s", {
|
||||
user: user,
|
||||
userRole: <PowerSelector value={userLevels[user]} disabled={true} />,
|
||||
}) }
|
||||
</li>);
|
||||
mutedUsers.push(
|
||||
<PowerSelector value={userLevels[user]} disabled={!canChange} label={user} key={user} />,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -247,18 +242,14 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
privilegedUsersSection =
|
||||
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
||||
<div className='mx_SettingsTab_subheading'>{ _t('Privileged Users') }</div>
|
||||
<ul>
|
||||
{privilegedUsers}
|
||||
</ul>
|
||||
{privilegedUsers}
|
||||
</div>;
|
||||
}
|
||||
if (mutedUsers.length) {
|
||||
mutedUsersSection =
|
||||
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
||||
<div className='mx_SettingsTab_subheading'>{ _t('Muted Users') }</div>
|
||||
<ul>
|
||||
{mutedUsers}
|
||||
</ul>
|
||||
{mutedUsers}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
@ -300,11 +291,10 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
|
||||
const value = parseIntWithDefault(currentObj, descriptor.defaultValue);
|
||||
return <div key={index} className="">
|
||||
<span>{descriptor.desc} </span>
|
||||
<PowerSelector
|
||||
label={descriptor.desc}
|
||||
value={value}
|
||||
usersDefault={defaultUserLevel}
|
||||
controlled={false}
|
||||
disabled={!canChangeLevels || currentUserLevel < value}
|
||||
powerLevelKey={key} // Will be sent as the second parameter to `onChange`
|
||||
onChange={this._onPowerLevelsChanged}
|
||||
|
@ -317,18 +307,14 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
if (label) {
|
||||
label = _t(label);
|
||||
} else {
|
||||
label = _t(
|
||||
"To send events of type <eventType/>, you must be a", {},
|
||||
{ 'eventType': <code>{ eventType }</code> },
|
||||
);
|
||||
label = _t("Send %(eventType)s events", {eventType});
|
||||
}
|
||||
return (
|
||||
<div className="" key={eventType}>
|
||||
<span>{label} </span>
|
||||
<PowerSelector
|
||||
label={label}
|
||||
value={eventsLevels[eventType]}
|
||||
usersDefault={defaultUserLevel}
|
||||
controlled={false}
|
||||
disabled={!canChangeLevels || currentUserLevel < eventsLevels[eventType]}
|
||||
powerLevelKey={"event_levels_" + eventType}
|
||||
onChange={this._onPowerLevelsChanged}
|
||||
|
@ -345,6 +331,7 @@ export default class RolesRoomSettingsTab extends React.Component {
|
|||
{bannedUsersSection}
|
||||
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
|
||||
<span className='mx_SettingsTab_subheading'>{_t("Permissions")}</span>
|
||||
<p>{_t('Select the roles required to change various parts of the room')}</p>
|
||||
{powerSelectors}
|
||||
{eventPowerSelectors}
|
||||
</div>
|
||||
|
|
|
@ -76,14 +76,23 @@ export default class VoiceUserSettingsTab extends React.Component {
|
|||
|
||||
_setAudioOutput = (e) => {
|
||||
CallMediaHandler.setAudioOutput(e.target.value);
|
||||
this.setState({
|
||||
activeAudioOutput: e.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
_setAudioInput = (e) => {
|
||||
CallMediaHandler.setAudioInput(e.target.value);
|
||||
this.setState({
|
||||
activeAudioInput: e.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
_setVideoInput = (e) => {
|
||||
CallMediaHandler.setVideoInput(e.target.value);
|
||||
this.setState({
|
||||
activeVideoInput: e.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
_changeWebRtcMethod = (p2p) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue