2017-09-26 13:49:13 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 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 React from 'react';
|
|
|
|
import {MatrixClient} from 'matrix-js-sdk';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import sdk from '../../../index';
|
|
|
|
import dis from '../../../dispatcher';
|
|
|
|
import { GroupRoomType } from '../../../groups';
|
|
|
|
|
|
|
|
const GroupRoomTile = React.createClass({
|
|
|
|
displayName: 'GroupRoomTile',
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
groupId: PropTypes.string.isRequired,
|
|
|
|
groupRoom: GroupRoomType.isRequired,
|
|
|
|
},
|
|
|
|
|
|
|
|
onClick: function(e) {
|
|
|
|
dis.dispatch({
|
2017-11-01 17:13:00 +00:00
|
|
|
action: 'view_group_room',
|
|
|
|
groupId: this.props.groupId,
|
2017-11-02 13:25:55 +00:00
|
|
|
groupRoomId: this.props.groupRoom.roomId,
|
2017-10-03 10:16:22 +00:00
|
|
|
});
|
2017-09-29 16:59:24 +00:00
|
|
|
},
|
|
|
|
|
2017-09-26 13:49:13 +00:00
|
|
|
render: function() {
|
|
|
|
const BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
|
|
|
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
|
|
|
const avatarUrl = this.context.matrixClient.mxcUrlToHttp(
|
|
|
|
this.props.groupRoom.avatarUrl,
|
|
|
|
36, 36, 'crop',
|
|
|
|
);
|
|
|
|
|
|
|
|
const av = (
|
2017-11-01 17:13:00 +00:00
|
|
|
<BaseAvatar name={this.props.groupRoom.displayname}
|
2017-09-26 13:49:13 +00:00
|
|
|
width={36} height={36}
|
|
|
|
url={avatarUrl}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AccessibleButton className="mx_GroupRoomTile" onClick={this.onClick}>
|
|
|
|
<div className="mx_GroupRoomTile_avatar">
|
2017-09-28 10:21:06 +00:00
|
|
|
{ av }
|
2017-09-26 13:49:13 +00:00
|
|
|
</div>
|
|
|
|
<div className="mx_GroupRoomTile_name">
|
2017-11-01 17:13:00 +00:00
|
|
|
{ this.props.groupRoom.displayname }
|
2017-09-26 13:49:13 +00:00
|
|
|
</div>
|
|
|
|
</AccessibleButton>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
GroupRoomTile.contextTypes = {
|
2017-12-26 01:03:18 +00:00
|
|
|
matrixClient: PropTypes.instanceOf(MatrixClient).isRequired,
|
2017-09-26 13:49:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default GroupRoomTile;
|