Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const showNoFacetValuesWarning = facetValues.length === 0
&& !this.props.data.viewState.values.loading;
const showTooManyFacetValuesWarning = this.props.config.facetValuesThreshold > 0
&& facetValues.length > this.props.config.facetValuesThreshold;
if (this.props.data.viewState.values.error) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'An error has occurred! Probably, there are too many facet values for the selected relation. Please, try to refine your search.')
);
} else if (showNoFacetValuesWarning) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'Values not found...')
);
} else {
return D.div(
{className: 'facet__relation__values'},
showTooManyFacetValuesWarning ? D.em(
{className: 'facet__relation__warning'},
`Only first ${this.props.config.facetValuesThreshold} facet values are shown! Please refine your search `
) : null,
createElement(ClearableInput, {
type: 'text',
className: 'facet__relation__values__filter',
placeholder: `Search ${nlp.noun(rangeLabel).pluralize()}...`,
value: filterString,
onClear: () => this.setState({filterString: undefined}),
onChange: (event) => {
const value = (event.target as any).value;
private renderFacetValues(facetValues: Array, kind: 'resource' | 'literal') {
const rangeLabel = this.props.relation.hasRange.label;
const filterString = this.state.filterString ? this.state.filterString : '';
const showNoFacetValuesWarning = facetValues.length === 0
&& !this.props.data.viewState.values.loading;
const showTooManyFacetValuesWarning = this.props.config.facetValuesThreshold > 0
&& facetValues.length > this.props.config.facetValuesThreshold;
if (this.props.data.viewState.values.error) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'An error has occurred! Probably, there are too many facet values for the selected relation. Please, try to refine your search.')
);
} else if (showNoFacetValuesWarning) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'Values not found...')
);
} else {
return D.div(
{className: 'facet__relation__values'},
showTooManyFacetValuesWarning ? D.em(
{className: 'facet__relation__warning'},
`Only first ${this.props.config.facetValuesThreshold} facet values are shown! Please refine your search `
) : null,
createElement(ClearableInput, {
type: 'text',
className: 'facet__relation__values__filter',
private renderLoadingIndicator = () => {
const loading = this.props.data.relations.some(rel => _.isUndefined(rel.available));
return loading ? [
D.div({}, D.em({}, 'Searching for relations ...')),
D.div({}, createElement(Spinner)),
] : [];
}
&& facetValues.length > this.props.config.facetValuesThreshold;
if (this.props.data.viewState.values.error) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'An error has occurred! Probably, there are too many facet values for the selected relation. Please, try to refine your search.')
);
} else if (showNoFacetValuesWarning) {
return D.div(
{className: 'facet__relation__values'},
D.em({}, 'Values not found...')
);
} else {
return D.div(
{className: 'facet__relation__values'},
showTooManyFacetValuesWarning ? D.em(
{className: 'facet__relation__warning'},
`Only first ${this.props.config.facetValuesThreshold} facet values are shown! Please refine your search `
) : null,
createElement(ClearableInput, {
type: 'text',
className: 'facet__relation__values__filter',
placeholder: `Search ${nlp.noun(rangeLabel).pluralize()}...`,
value: filterString,
onClear: () => this.setState({filterString: undefined}),
onChange: (event) => {
const value = (event.target as any).value;
this.setState({filterString: value});
},
}),
Infinite(
{