UserLink.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2015 - present Instructure, Inc.
  3. *
  4. * This file is part of Canvas.
  5. *
  6. * Canvas is free software: you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License as published by the Free
  8. * Software Foundation, version 3 of the License.
  9. *
  10. * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. import React from 'react'
  19. import PropTypes from 'prop-types'
  20. import I18n from 'i18n!account_course_user_search'
  21. var UserLink = React.createClass({
  22. propTypes: {
  23. id: PropTypes.string.isRequired,
  24. display_name: PropTypes.string.isRequired,
  25. avatar_image_url: PropTypes.string
  26. },
  27. render() {
  28. var { id, display_name, avatar_image_url } = this.props;
  29. var url = `/users/${id}`;
  30. return (
  31. <div className="ellipsis">
  32. {!!avatar_image_url &&
  33. <span className="ic-avatar UserLink__Avatar">
  34. <img src={avatar_image_url} alt={`User avatar for ${display_name}`} />
  35. </span>
  36. }
  37. <a href={url} className="user_link">{display_name}</a>
  38. </div>
  39. );
  40. }
  41. });
  42. export default UserLink