@@ -2,7 +2,6 @@ import React from "react";
22import { connect } from "react-redux" ;
33
44import ContextLineTemplate from "../templates/ContextLine" ;
5- import HoverPopover from "../templates/HoverPopover" ;
65import Author from "../templates/contextfeatures/Author" ;
76import DocumentTypes from "../templates/contextfeatures/DocumentTypes" ;
87import NumArticles from "../templates/contextfeatures/NumArticles" ;
@@ -15,10 +14,9 @@ import ProjectRuntime from "../templates/contextfeatures/ProjectRuntime";
1514import LegacySearchLang from "../templates/contextfeatures/LegacySearchLang" ;
1615import SearchLang from "../templates/contextfeatures/SearchLang" ;
1716import Timestamp from "../templates/contextfeatures/Timestamp" ;
18- import MetadataQuality from "../templates/contextfeatures/MetadataQuality" ;
1917import Modifier from "../templates/contextfeatures/Modifier" ;
20- import { trackMatomoEvent } from "../utils/useMatomo" ;
2118import MoreInfoLink from "../templates/contextfeatures/MoreInfoLink" ;
19+ import MetadataQuality from "../templates/contextfeatures/MetadataQuality" ;
2220
2321const defined = ( param ) => param !== undefined && param !== null ;
2422
@@ -29,7 +27,8 @@ const defined = (param) => param !== undefined && param !== null;
2927 */
3028class ContextLine extends React . Component {
3129 render ( ) {
32- const { params, localization, hidden } = this . props ;
30+ const { params, localization, hidden, service } = this . props ;
31+ const { popoverContainer } = this . props ;
3332
3433 if ( hidden ) {
3534 return null ;
@@ -49,7 +48,7 @@ class ContextLine extends React.Component {
4948 openAccessArticlesCount = { params . openAccessCount }
5049 articlesCountLabel = { localization . articles_label }
5150 >
52- < Modifier popoverContainer = { this . props . popoverContainer } />
51+ < Modifier popoverContainer = { popoverContainer } />
5352 </ NumArticles >
5453 { defined ( params . dataSource ) && (
5554 < DataSource
@@ -58,7 +57,10 @@ class ContextLine extends React.Component {
5857 />
5958 ) }
6059 { defined ( params . timespan ) && < Timespan > { params . timespan } </ Timespan > }
61- { this . renderDocTypes ( ) }
60+ < DocumentTypes
61+ documentTypes = { params . documentTypes }
62+ popoverContainer = { popoverContainer }
63+ />
6264 { defined ( params . paperCount ) && (
6365 < PaperCount
6466 value = { params . paperCount }
@@ -84,92 +86,18 @@ class ContextLine extends React.Component {
8486 label = { localization . timestamp_label }
8587 />
8688 ) }
87- { this . renderMetadataQuality ( ) }
89+ < MetadataQuality
90+ quality = { params . metadataQuality }
91+ service = { service }
92+ popoverContainer = { popoverContainer }
93+ />
8894 { defined ( params . searchLanguage ) && (
8995 < SearchLang > { params . searchLanguage } </ SearchLang >
9096 ) }
9197 < MoreInfoLink />
9298 </ ContextLineTemplate >
9399 ) ;
94100 }
95-
96- // TODO refactor this function to a standalone template
97- renderDocTypes ( ) {
98- const {
99- params : { documentTypes } ,
100- localization,
101- popoverContainer,
102- } = this . props ;
103-
104- if ( ! documentTypes || documentTypes . length === 0 ) {
105- return null ;
106- }
107-
108- const text = documentTypes . join ( ", " ) ;
109-
110- const trackMouseOver = ( ) =>
111- trackMatomoEvent ( "Title & Context line" , "Hover document types" , "Context line" ) ;
112-
113- return (
114- < >
115- < span
116- id = "document_types"
117- className = "context_item"
118- onMouseOver = { trackMouseOver }
119- >
120- < HoverPopover
121- id = "doctypes-popover"
122- size = "wide"
123- container = { popoverContainer }
124- content = {
125- < >
126- { localization . documenttypes_tooltip }
127- < br />
128- < br />
129- { text }
130- </ >
131- }
132- >
133- < DocumentTypes label = { localization . documenttypes_label } />
134- </ HoverPopover >
135- </ span > { " " }
136- </ >
137- ) ;
138- }
139-
140- // TODO refactor this function to a standalone template
141- renderMetadataQuality ( ) {
142- const {
143- params : { metadataQuality } ,
144- localization,
145- popoverContainer,
146- service,
147- } = this . props ;
148-
149- if (
150- ! metadataQuality ||
151- ( metadataQuality !== "low" && metadataQuality !== "high" )
152- ) {
153- return null ;
154- }
155-
156- return (
157- < span className = "context_item" id = "metadata_quality" >
158- < HoverPopover
159- id = "metadata-quality-popover"
160- container = { popoverContainer }
161- content = {
162- localization [ metadataQuality + "_metadata_quality_desc_" + service ]
163- }
164- >
165- < MetadataQuality
166- quality = { metadataQuality }
167- label = { localization [ [ metadataQuality + "_metadata_quality" ] ] }
168- />
169- </ HoverPopover >
170- </ span >
171- ) ;
172- }
173101}
174102
175103const mapStateToProps = ( state ) => ( {
0 commit comments