equal
deleted
inserted
replaced
|
1 import _ from 'lodash'; |
|
2 |
|
3 import React, { Component } from 'react'; |
|
4 import { FormattedRelative } from 'react-intl'; |
|
5 import PropTypes from 'prop-types'; |
|
6 |
|
7 import Tag from './Tag'; |
|
8 |
|
9 export default class AnnotationsDocumentsTableRow extends Component { |
|
10 tags() { |
|
11 const { document, topics, metacategories } = this.props; |
|
12 |
|
13 const tags = _.chain(document.annotations) |
|
14 .map('tags') |
|
15 .flatten() |
|
16 .uniq() |
|
17 .value(); |
|
18 |
|
19 return tags.map(t => <span className="mr-1 mb-1" key={`${document.uri}_${t}`}><Tag tag={t} categories={topics} metacategories={metacategories} /></span>); |
|
20 } |
|
21 |
|
22 render() { |
|
23 const { document, viaBaseUrl } = this.props; |
|
24 |
|
25 const { |
|
26 uri, |
|
27 name, |
|
28 updated, |
|
29 usersNb, |
|
30 annotationsNb, |
|
31 } = document; |
|
32 |
|
33 return ( |
|
34 <tr> |
|
35 <td className="text-muted small"><FormattedRelative value={updated} /></td> |
|
36 <td> |
|
37 <p><a href={uri}>{ name }</a></p> |
|
38 <p>{ this.tags() }</p> |
|
39 </td> |
|
40 <td>{ usersNb }</td> |
|
41 <td>{ annotationsNb }</td> |
|
42 <td> |
|
43 <a href={viaBaseUrl + uri} target="_blank" rel="noopener noreferrer">#</a> |
|
44 </td> |
|
45 </tr> |
|
46 ); |
|
47 } |
|
48 } |
|
49 |
|
50 AnnotationsDocumentsTableRow.propTypes = { |
|
51 document: PropTypes.object.isRequired, |
|
52 metacategories: PropTypes.arrayOf(PropTypes.object).isRequired, |
|
53 topics: PropTypes.arrayOf(PropTypes.string).isRequired, |
|
54 viaBaseUrl: PropTypes.string.isRequired, |
|
55 }; |