import classNames from 'classnames';
import { orderBy, sortBy, without } from 'lodash';
import * as React from 'react';
-import Tooltip from '../../../components/controls/Tooltip';
import FacetBox from '../../../components/facet/FacetBox';
import FacetHeader from '../../../components/facet/FacetHeader';
import FacetItem from '../../../components/facet/FacetItem';
className={classNames({ 'search-navigator-facet-box-forbidden': disabled })}
property={this.props.property}>
<FacetHeader
- name={
- <Tooltip overlay={disabled ? this.props.disabledHelper : undefined}>
- <span>{translate('coding_rules.facet', this.props.property)}</span>
- </Tooltip>
- }
+ name={translate('coding_rules.facet', this.props.property)}
+ disabled={disabled}
+ disabledHelper={this.props.disabledHelper}
onClear={this.handleClear}
onClick={disabled ? undefined : this.handleHeaderClick}
open={this.props.open && !disabled}
import OpenCloseIcon from '../../components/icons/OpenCloseIcon';
import DeferredSpinner from '../../components/ui/DeferredSpinner';
import { translate, translateWithParameters } from '../../helpers/l10n';
+import Tooltip from '../controls/Tooltip';
interface Props {
children?: React.ReactNode;
fetching?: boolean;
helper?: string;
- name: React.ReactNode;
+ disabled?: boolean;
+ disabledHelper?: string;
+ name: string;
onClear?: () => void;
onClick?: () => void;
open: boolean;
}
render() {
- const showClearButton =
- this.props.values != null && this.props.values.length > 0 && this.props.onClear != null;
-
+ const { disabled, values, disabledHelper, name, open, children, fetching } = this.props;
+ const showClearButton = values != null && values.length > 0 && this.props.onClear != null;
+ const header = disabled ? (
+ <Tooltip overlay={disabledHelper}>
+ <span>{name}</span>
+ </Tooltip>
+ ) : (
+ name
+ );
return (
<div className="search-navigator-facet-header-wrapper display-flex-center">
{this.props.onClick ? (
className="button-link"
type="button"
onClick={this.handleClick}
- aria-expanded={this.props.open}
+ aria-expanded={open}
tabIndex={0}>
- <OpenCloseIcon className="little-spacer-right" open={this.props.open} />
- {this.props.name}
+ <OpenCloseIcon className="little-spacer-right" open={open} />
+ {header}
</button>
{this.renderHelper()}
</span>
) : (
<span className="search-navigator-facet-header display-flex-center">
- {this.props.name}
+ {header}
{this.renderHelper()}
</span>
)}
- {this.props.children}
+ {children}
<span className="search-navigator-facet-header-value spacer-left spacer-right ">
{this.renderValueIndicator()}
</span>
- {this.props.fetching && (
+ {fetching && (
<span className="little-spacer-right">
<DeferredSpinner />
</span>
{showClearButton && (
<Button
className="search-navigator-facet-header-button button-small button-red"
+ aria-label={translateWithParameters('clear_x_filter', name)}
onClick={this.props.onClear}>
{translate('clear')}
</Button>
import * as React from 'react';
import ListFooter from '../../components/controls/ListFooter';
import SearchBox from '../../components/controls/SearchBox';
-import Tooltip from '../../components/controls/Tooltip';
import { Alert } from '../../components/ui/Alert';
import { translate } from '../../helpers/l10n';
import { formatMeasure } from '../../helpers/measures';
property={this.props.property}>
<FacetHeader
fetching={this.props.fetching}
- name={
- <Tooltip overlay={disabled ? this.props.disabledHelper : undefined}>
- <span>{this.props.facetHeader}</span>
- </Tooltip>
- }
+ name={this.props.facetHeader}
+ disabled={disabled}
+ disabledHelper={this.props.disabledHelper}
onClear={this.handleClear}
onClick={disabled ? undefined : this.handleHeaderClick}
open={this.props.open && !disabled}
it('should correctly render a header with value data', () => {
renderFacet(undefined, { values: ['value 1'] });
expect(screen.getByText('value 1')).toBeInTheDocument();
- screen.getByRole('button', { name: 'clear' }).click();
+ screen.getByRole('button', { name: 'clear_x_filter.foo' }).click();
expect(screen.queryByText('value 1')).not.toBeInTheDocument();
});
property="foo"
>
<FacetHeader
+ disabled={true}
+ disabledHelper="Disabled helper description"
fetching={false}
- name={
- <Tooltip
- overlay="Disabled helper description"
- >
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
open={false}
values={Array []}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
>
<FacetHeader
fetching={false}
- name={
- <Tooltip>
- <span>
- facet header
- </span>
- </Tooltip>
- }
+ name="facet header"
onClear={[Function]}
onClick={[Function]}
open={true}
bulk_change=Bulk Change
bulleted_point=Bulleted point
clear=Clear
+clear_x_filter=Clear {0} Filters
clear_all_filters=Clear All Filters
coding_rules=Rules
copy_to_clipboard=Click to copy to clipboard