@@ -2,40 +2,51 @@ import React from 'react';
22import PropTypes from 'prop-types' ;
33
44import Icon from '../../../common/icon/icon' ;
5+
56import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper' ;
67
7- const SearchNoResults = ( { searchText } ) => {
8+ import { createCssClassNames } from '@ibexa-admin-ui/src/bundle/ui-dev/src/modules/common/helpers/css.class.names' ;
9+
10+ const SearchNoResults = ( { searchText, noResultsHints : noResultsHintsCustom , extraClasses } ) => {
811 const Translator = getTranslator ( ) ;
9- const noResultsLabel = Translator . trans (
10- /*@Desc ("No results found for %query%")*/ 'search.no_results' ,
11- { query : searchText } ,
12- 'ibexa_universal_discovery_widget' ,
13- ) ;
14- const noResultsHints = [
15- Translator . trans (
16- /*@Desc ("Check the spelling of keywords.")*/ 'search.no_results.hint.check_spelling' ,
17- { } ,
18- 'ibexa_universal_discovery_widget' ,
19- ) ,
20- Translator . trans (
21- /*@Desc ("Try more general keywords.")*/ 'search.no_results.hint.more_general' ,
22- { } ,
23- 'ibexa_universal_discovery_widget' ,
24- ) ,
25- Translator . trans (
26- /*@Desc ("Try different keywords.")*/ 'search.no_results.hint.different_kewords' ,
27- { } ,
28- 'ibexa_universal_discovery_widget' ,
29- ) ,
30- Translator . trans (
31- /*@Desc ("Try fewer keywords. Reducing keywords results in more matches.")*/ 'search.no_results.hint.fewer_keywords' ,
32- { } ,
33- 'ibexa_universal_discovery_widget' ,
34- ) ,
35- ] ;
12+ const className = createCssClassNames ( {
13+ 'c-search-no-results' : true ,
14+ [ extraClasses ] : true ,
15+ } ) ;
16+ const noResultsLabel = searchText
17+ ? Translator . trans (
18+ /*@Desc ("No results found for %query%")*/ 'search.no_results' ,
19+ { query : searchText } ,
20+ 'ibexa_universal_discovery_widget' ,
21+ )
22+ : Translator . trans ( /*@Desc ("No results found")*/ 'search.no_results_without_query' , { } , 'ibexa_universal_discovery_widget' ) ;
23+ const noResultsHints = noResultsHintsCustom
24+ ? noResultsHintsCustom
25+ : [
26+ Translator . trans (
27+ /*@Desc ("Check the spelling of keywords.")*/ 'search.no_results.hint.check_spelling' ,
28+ { } ,
29+ 'ibexa_universal_discovery_widget' ,
30+ ) ,
31+ Translator . trans (
32+ /*@Desc ("Try more general keywords.")*/ 'search.no_results.hint.more_general' ,
33+ { } ,
34+ 'ibexa_universal_discovery_widget' ,
35+ ) ,
36+ Translator . trans (
37+ /*@Desc ("Try different keywords.")*/ 'search.no_results.hint.different_kewords' ,
38+ { } ,
39+ 'ibexa_universal_discovery_widget' ,
40+ ) ,
41+ Translator . trans (
42+ /*@Desc ("Try fewer keywords. Reducing keywords results in more matches.")*/ 'search.no_results.hint.fewer_keywords' ,
43+ { } ,
44+ 'ibexa_universal_discovery_widget' ,
45+ ) ,
46+ ] ;
3647
3748 return (
38- < div className = "c-search-no-results" >
49+ < div className = { className } >
3950 < img src = "/bundles/ibexaadminui/img/no-results.svg" />
4051 < h2 className = "c-search-no-results__no-results-title" > { noResultsLabel } </ h2 >
4152 < div className = "c-search-no-results__no-results-subtitle" >
@@ -56,7 +67,15 @@ const SearchNoResults = ({ searchText }) => {
5667} ;
5768
5869SearchNoResults . propTypes = {
59- searchText : PropTypes . string . isRequired ,
70+ extraClasses : PropTypes . string ,
71+ searchText : PropTypes . string ,
72+ noResultsHints : PropTypes . arrayOf ( PropTypes . string ) ,
73+ } ;
74+
75+ SearchNoResults . defaultProps = {
76+ extraClasses : '' ,
77+ searchText : null ,
78+ noResultsHints : null ,
6079} ;
6180
6281export default SearchNoResults ;
0 commit comments