FilePreviewInfoPanel.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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!file_preview'
  21. import FriendlyDatetime from 'jsx/shared/FriendlyDatetime'
  22. import friendlyBytes from 'compiled/util/friendlyBytes'
  23. import customPropTypes from 'compiled/react_files/modules/customPropTypes'
  24. import getFileStatus from 'compiled/react_files/utils/getFileStatus'
  25. import mimeClass from 'compiled/util/mimeClass'
  26. var FilePreviewInfoPanel = React.createClass({
  27. displayName: 'FilePreviewInfoPanel',
  28. propTypes: {
  29. displayedItem: customPropTypes.filesystemObject.isRequired,
  30. usageRightsRequiredForContext: PropTypes.bool
  31. },
  32. render () {
  33. return (
  34. <div className='ef-file-preview-information-container'>
  35. <table className='ef-file-preview-infotable'>
  36. <tbody>
  37. <tr>
  38. <th scope='row'>{I18n.t('Name')}</th>
  39. <td ref='displayName'>{this.props.displayedItem.displayName()}</td>
  40. </tr>
  41. <tr>
  42. <th scope='row'>{I18n.t('Status')}</th>
  43. <td ref='status'>{getFileStatus(this.props.displayedItem)}</td>
  44. </tr>
  45. <tr>
  46. <th scope='row'>{I18n.t('Kind')}</th>
  47. <td ref='contentType'>{mimeClass.displayName(this.props.displayedItem.get('content-type'))}</td>
  48. </tr>
  49. <tr>
  50. <th scope='row'>{I18n.t('Size')}</th>
  51. <td ref='size'>{friendlyBytes(this.props.displayedItem.get('size'))}</td>
  52. </tr>
  53. <tr>
  54. <th scope='row'>{I18n.t('Date Modified')}</th>
  55. <td id='dateModified' ref='dateModified'><FriendlyDatetime dateTime={this.props.displayedItem.get('updated_at')} /></td>
  56. </tr>
  57. {this.props.displayedItem.get('user') && (
  58. <tr>
  59. <th scope='row'>{I18n.t('Last Modified By')}</th>
  60. <td ref='modifedBy'>
  61. <a href={this.props.displayedItem.get('user').html_url}>{this.props.displayedItem.get('user').display_name}</a>
  62. </td>
  63. </tr>
  64. )}
  65. <tr>
  66. <th scope='row'>{I18n.t('Date Created')}</th>
  67. <td id= 'dateCreated'><FriendlyDatetime dateTime={this.props.displayedItem.get('created_at')} /></td>
  68. </tr>
  69. {this.props.usageRightsRequiredForContext && (
  70. <tr className='FilePreviewInfoPanel__usageRights'>
  71. <th scope='row'>{I18n.t('Usage Rights')}</th>
  72. <td>
  73. {this.props.displayedItem && this.props.displayedItem.get('usage_rights') && this.props.displayedItem.get('usage_rights').license_name && (
  74. <div ref='licenseName'>{this.props.displayedItem.get('usage_rights').license_name}</div>
  75. )}
  76. {this.props.displayedItem && this.props.displayedItem.get('usage_rights') && this.props.displayedItem.get('usage_rights').legal_copyright && (
  77. <div ref='legalCopyright'>{this.props.displayedItem.get('usage_rights').legal_copyright}</div>
  78. )}
  79. </td>
  80. </tr>
  81. )}
  82. </tbody>
  83. </table>
  84. </div>
  85. );
  86. }
  87. });
  88. export default FilePreviewInfoPanel