/* 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. */ 'use strict'; var React = require('react'); var classNames = require('classnames'); var sdk = require("../../../index"); var Invite = require("../../../Invite"); var MatrixClientPeg = require("../../../MatrixClientPeg"); var Avatar = require('../../../Avatar'); // React PropType definition for an object describing // an address that can be invited to a room (which // could be a third party identifier or a matrix ID) // along with some additional information about the // address / target. export const InviteAddressType = React.PropTypes.shape({ addressType: React.PropTypes.oneOf([ 'mx', 'email' ]).isRequired, address: React.PropTypes.string.isRequired, displayName: React.PropTypes.string, avatarMxc: React.PropTypes.string, // true if the address is known to be a valid address (eg. is a real // user we've seen) or false otherwise (eg. is just an address the // user has entered) isKnown: React.PropTypes.bool, }); export default React.createClass({ displayName: 'AddressTile', propTypes: { address: InviteAddressType.isRequired, canDismiss: React.PropTypes.bool, onDismissed: React.PropTypes.func, justified: React.PropTypes.bool, }, getDefaultProps: function() { return { canDismiss: false, onDismissed: function() {}, // NOP justified: false, }; }, render: function() { const address = this.props.address; const name = address.displayName || address.address; let imgUrl; if (address.avatarMxc) { imgUrl = MatrixClientPeg.get().mxcUrlToHttp( address.avatarMxc, 25, 25, 'crop' ); } if (address.addressType === "mx") { if (!imgUrl) imgUrl = 'img/icon-mx-user.svg'; } else if (address.addressType === 'email') { if (!imgUrl) imgUrl = 'img/icon-email-user.svg'; } else { if (!imgUrl) imgUrl = "img/avatar-error.svg"; } // Removing networks for now as they're not really supported /* var network; if (this.props.networkUrl !== "") { network = (