2017-01-21 08:13:36 +03:00
|
|
|
/*
|
|
|
|
Copyright 2015, 2016 OpenMarket 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.
|
|
|
|
*/
|
|
|
|
|
2017-01-25 21:25:40 +03:00
|
|
|
import React from 'react';
|
|
|
|
import sdk from '../../../index';
|
2017-01-26 02:17:57 +03:00
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
2017-01-21 08:13:36 +03:00
|
|
|
|
2017-01-25 21:25:40 +03:00
|
|
|
function UserUnknownDeviceList(props) {
|
|
|
|
const {userDevices} = props;
|
|
|
|
|
|
|
|
const deviceListEntries = Object.keys(userDevices).map((deviceId) =>
|
|
|
|
<li key={ deviceId }>
|
|
|
|
{ deviceId } ( { userDevices[deviceId].getDisplayName() } )
|
|
|
|
</li>,
|
|
|
|
);
|
|
|
|
|
|
|
|
return <ul>{deviceListEntries}</ul>;
|
|
|
|
}
|
|
|
|
|
|
|
|
UserUnknownDeviceList.propTypes = {
|
|
|
|
// map from deviceid -> deviceinfo
|
|
|
|
userDevices: React.PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function UnknownDeviceList(props) {
|
|
|
|
const {devices} = props;
|
|
|
|
|
|
|
|
const userListEntries = Object.keys(devices).map((userId) =>
|
|
|
|
<li key={ userId }>
|
|
|
|
<p>{ userId }:</p>
|
|
|
|
<UserUnknownDeviceList userDevices={devices[userId]} />
|
|
|
|
</li>,
|
|
|
|
);
|
|
|
|
|
|
|
|
return <ul>{userListEntries}</ul>;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnknownDeviceList.propTypes = {
|
|
|
|
// map from userid -> deviceid -> deviceinfo
|
|
|
|
devices: React.PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default React.createClass({
|
2017-01-21 08:13:36 +03:00
|
|
|
displayName: 'UnknownEventDialog',
|
|
|
|
|
|
|
|
propTypes: {
|
2017-01-25 21:25:40 +03:00
|
|
|
// map from userid -> deviceid -> deviceinfo
|
2017-01-21 08:13:36 +03:00
|
|
|
devices: React.PropTypes.object.isRequired,
|
|
|
|
onFinished: React.PropTypes.func.isRequired,
|
|
|
|
},
|
|
|
|
|
2017-01-26 01:52:48 +03:00
|
|
|
componentDidMount: function() {
|
|
|
|
// Given we've now shown the user the unknown device, it is no longer
|
|
|
|
// unknown to them. Therefore mark it as 'known'.
|
2017-01-26 02:17:57 +03:00
|
|
|
Object.keys(this.props.devices).forEach((userId) => {
|
|
|
|
Object.keys(this.props.devices[userId]).map((deviceId) => {
|
2017-01-26 01:52:48 +03:00
|
|
|
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true);
|
2017-01-26 02:17:57 +03:00
|
|
|
});
|
2017-01-26 01:52:48 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-01-21 08:13:36 +03:00
|
|
|
render: function() {
|
2017-01-25 21:25:40 +03:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
2017-01-21 08:13:36 +03:00
|
|
|
return (
|
2017-01-25 21:25:40 +03:00
|
|
|
<BaseDialog className='mx_UnknownDeviceDialog'
|
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
title='Room contains unknown devices'
|
|
|
|
>
|
2017-01-21 08:13:36 +03:00
|
|
|
<div className="mx_Dialog_content">
|
2017-01-25 21:25:40 +03:00
|
|
|
<h4>This room contains unknown devices which have not been
|
|
|
|
verified.</h4>
|
|
|
|
|
2017-01-21 08:13:36 +03:00
|
|
|
<h4>We strongly recommend you verify them before continuing.</h4>
|
2017-01-25 21:25:40 +03:00
|
|
|
<p>Unknown devices:</p>
|
|
|
|
<UnknownDeviceList devices={this.props.devices} />
|
2017-01-21 08:13:36 +03:00
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
2017-01-25 21:25:40 +03:00
|
|
|
<button className="mx_Dialog_primary" autoFocus={ true }
|
|
|
|
onClick={ this.props.onFinished } >
|
2017-01-21 08:13:36 +03:00
|
|
|
OK
|
|
|
|
</button>
|
|
|
|
</div>
|
2017-01-25 21:25:40 +03:00
|
|
|
</BaseDialog>
|
2017-01-21 08:13:36 +03:00
|
|
|
);
|
2017-01-25 21:25:40 +03:00
|
|
|
},
|
2017-01-21 08:13:36 +03:00
|
|
|
});
|