99import _truncate from "lodash/truncate" ;
1010import PropTypes from "prop-types" ;
1111import { Component } from "react" ;
12+ import { connect } from "react-redux" ;
1213import { OverridableContext } from "react-overridable" ;
1314import {
1415 Button ,
@@ -21,6 +22,7 @@ import {
2122 Menu ,
2223} from "semantic-ui-react" ;
2324import { OSSearchApi } from "../../lib/api/contrib/opensearch" ;
25+ import { updateQueryFilters } from "../../lib/state/actions" ;
2426import {
2527 BucketAggregation ,
2628 RangeFacet ,
@@ -79,9 +81,8 @@ const customAggValueCmp = (
7981
8082class Tags extends Component {
8183 onClick = ( event , value ) => {
82- window . history . push ( {
83- search : `${ window . location . search } &f=tags_agg:${ value } ` ,
84- } ) ;
84+ const { updateQueryFilters } = this . props ;
85+ updateQueryFilters ( [ "tags_agg" , value ] ) ;
8586 event . preventDefault ( ) ;
8687 } ;
8788
@@ -102,8 +103,13 @@ class Tags extends Component {
102103
103104Tags . propTypes = {
104105 tags : PropTypes . array . isRequired ,
106+ updateQueryFilters : PropTypes . func . isRequired ,
105107} ;
106108
109+ const TagsComponent = connect ( null , ( dispatch ) => ( {
110+ updateQueryFilters : ( filter ) => dispatch ( updateQueryFilters ( filter ) ) ,
111+ } ) ) ( Tags ) ;
112+
107113const OpenSearchResultsListItem = ( { result, index } ) => {
108114 return (
109115 < Item key = { index } href = "#" >
@@ -119,7 +125,7 @@ const OpenSearchResultsListItem = ({ result, index }) => {
119125 { _truncate ( result . about , { length : 200 } ) }
120126 </ Item . Description >
121127 < Item . Extra >
122- < Tags tags = { result . tags } />
128+ < TagsComponent tags = { result . tags } />
123129 </ Item . Extra >
124130 </ Item . Content >
125131 </ Item >
@@ -128,7 +134,7 @@ const OpenSearchResultsListItem = ({ result, index }) => {
128134
129135OpenSearchResultsListItem . propTypes = {
130136 result : PropTypes . object . isRequired ,
131- index : PropTypes . string . isRequired ,
137+ index : PropTypes . number ,
132138} ;
133139
134140const OpenSearchResultsGridItem = ( { result, index } ) => {
@@ -144,15 +150,15 @@ const OpenSearchResultsGridItem = ({ result, index }) => {
144150 </ Card . Description >
145151 </ Card . Content >
146152 < Card . Content extra >
147- < Tags tags = { result . tags } />
153+ < TagsComponent tags = { result . tags } />
148154 </ Card . Content >
149155 </ Card >
150156 ) ;
151157} ;
152158
153159OpenSearchResultsGridItem . propTypes = {
154160 result : PropTypes . object . isRequired ,
155- index : PropTypes . string . isRequired ,
161+ index : PropTypes . number ,
156162} ;
157163
158164const overriddenComponents = {
0 commit comments