elements={elements}
filterSelected={props.filterSelected}
footerNode={footerNode}
+ legend={translate('project_activity.graphs.custom.select_metric')}
onSearch={props.onSearch}
onSelect={(item: string) => elements.includes(item) && props.onSelect(item)}
onUnselect={props.onUnselect}
- placeholder={translate('search.search_for_tags')}
+ placeholder={translate('search.search_for_metrics')}
renderLabel={props.renderLabel}
selectedElements={props.selectedElements}
/>
elements={Array []}
filterSelected={[MockFunction]}
footerNode=""
+ legend="project_activity.graphs.custom.select_metric"
listSize={0}
onSearch={[MockFunction]}
onSelect={[Function]}
onUnselect={[MockFunction]}
- placeholder="search.search_for_tags"
+ placeholder="search.search_for_metrics"
renderLabel={[Function]}
selectedElements={Array []}
validateSearchInput={[Function]}
project_activity.graphs.custom.add_metric_info
</Alert>
}
+ legend="project_activity.graphs.custom.select_metric"
listSize={0}
onSearch={[MockFunction]}
onSelect={[Function]}
onUnselect={[MockFunction]}
- placeholder="search.search_for_tags"
+ placeholder="search.search_for_metrics"
renderLabel={[Function]}
selectedElements={
Array [
project_activity.graphs.custom.type_x_message.metric.type.filter1, metric.type.filter2
</Alert>
}
+ legend="project_activity.graphs.custom.select_metric"
listSize={0}
onSearch={[MockFunction]}
onSelect={[Function]}
onUnselect={[MockFunction]}
- placeholder="search.search_for_tags"
+ placeholder="search.search_for_metrics"
renderLabel={[Function]}
selectedElements={Array []}
validateSearchInput={[Function]}
export interface MultiSelectProps {
allowNewElements?: boolean;
allowSelection?: boolean;
+ legend: string;
elements: string[];
// eslint-disable-next-line react/no-unused-prop-types
filterSelected?: (query: string, selectedElements: string[]) => string[];
};
render() {
- const { allowSelection = true, allowNewElements = true, footerNode = '' } = this.props;
+ const { legend, allowSelection = true, allowNewElements = true, footerNode = '' } = this.props;
const { renderLabel } = this.props as PropsWithDefault;
const { query, activeIdx, selectedElements, unselectedElements } = this.state;
const activeElement = this.getAllElements(this.props, this.state)[activeIdx];
value={query}
/>
</div>
- <ul className={listClasses}>
- {selectedElements.length > 0 &&
- selectedElements.map(element => (
+ <fieldset aria-label={legend}>
+ <ul className={listClasses}>
+ {selectedElements.length > 0 &&
+ selectedElements.map(element => (
+ <MultiSelectOption
+ active={activeElement === element}
+ element={element}
+ key={element}
+ onHover={this.handleElementHover}
+ onSelectChange={this.handleSelectChange}
+ renderLabel={renderLabel}
+ selected={true}
+ />
+ ))}
+ {unselectedElements.length > 0 &&
+ unselectedElements.map(element => (
+ <MultiSelectOption
+ active={activeElement === element}
+ disabled={!allowSelection}
+ element={element}
+ key={element}
+ onHover={this.handleElementHover}
+ onSelectChange={this.handleSelectChange}
+ renderLabel={renderLabel}
+ />
+ ))}
+ {showNewElement && (
<MultiSelectOption
- active={activeElement === element}
- element={element}
- key={element}
+ active={activeElement === query}
+ custom={true}
+ element={query}
+ key={query}
onHover={this.handleElementHover}
onSelectChange={this.handleSelectChange}
renderLabel={renderLabel}
- selected={true}
/>
- ))}
- {unselectedElements.length > 0 &&
- unselectedElements.map(element => (
- <MultiSelectOption
- active={activeElement === element}
- disabled={!allowSelection}
- element={element}
- key={element}
- onHover={this.handleElementHover}
- onSelectChange={this.handleSelectChange}
- renderLabel={renderLabel}
- />
- ))}
- {showNewElement && (
- <MultiSelectOption
- active={activeElement === query}
- custom={true}
- element={query}
- key={query}
- onHover={this.handleElementHover}
- onSelectChange={this.handleSelectChange}
- renderLabel={renderLabel}
- />
- )}
- {!showNewElement && selectedElements.length < 1 && unselectedElements.length < 1 && (
- <li className="spacer-left">{translateWithParameters('no_results_for_x', query)}</li>
- )}
- </ul>
+ )}
+ {!showNewElement && selectedElements.length < 1 && unselectedElements.length < 1 && (
+ <li className="spacer-left">{translateWithParameters('no_results_for_x', query)}</li>
+ )}
+ </ul>
+ </fieldset>
{footerNode}
</div>
);
*/
const container = document.createElement('div');
document.body.appendChild(container);
- const multiselect = mount(<MultiSelect {...props} />, { attachTo: container });
+ const multiselect = mount(<MultiSelect legend="multi select" {...props} />, {
+ attachTo: container
+ });
expect(multiselect.find('input').getDOMNode()).toBe(document.activeElement);
<MultiSelect
selectedElements={['bar']}
elements={[]}
+ legend="multi select"
onSearch={() => Promise.resolve()}
onSelect={jest.fn()}
onUnselect={jest.fn()}
value=""
/>
</div>
- <ul
- className="menu menu-vertically-limited spacer-top with-top-separator"
+ <fieldset
+ aria-label="multi select"
>
- <MultiSelectOption
- active={true}
- element="bar"
- key="bar"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- selected={true}
- />
- </ul>
+ <ul
+ className="menu menu-vertically-limited spacer-top with-top-separator"
+ >
+ <MultiSelectOption
+ active={true}
+ element="bar"
+ key="bar"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ selected={true}
+ />
+ </ul>
+ </fieldset>
</div>
`;
value=""
/>
</div>
- <ul
- className="menu menu-vertically-limited spacer-top with-top-separator"
+ <fieldset
+ aria-label="multi select"
>
- <MultiSelectOption
- active={true}
- element="bar"
- key="bar"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- selected={true}
- />
- <MultiSelectOption
- active={false}
- disabled={false}
- element="foo"
- key="foo"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- <MultiSelectOption
- active={false}
- disabled={false}
- element="baz"
- key="baz"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- </ul>
+ <ul
+ className="menu menu-vertically-limited spacer-top with-top-separator"
+ >
+ <MultiSelectOption
+ active={true}
+ element="bar"
+ key="bar"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ selected={true}
+ />
+ <MultiSelectOption
+ active={false}
+ disabled={false}
+ element="foo"
+ key="foo"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ <MultiSelectOption
+ active={false}
+ disabled={false}
+ element="baz"
+ key="baz"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ </ul>
+ </fieldset>
</div>
`;
value=""
/>
</div>
- <ul
- className="menu menu-vertically-limited spacer-top with-top-separator"
+ <fieldset
+ aria-label="multi select"
>
- <MultiSelectOption
- active={false}
- element="bar"
- key="bar"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- selected={true}
- />
- <MultiSelectOption
- active={false}
- disabled={false}
- element="foo"
- key="foo"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- <MultiSelectOption
- active={true}
- disabled={false}
- element="baz"
- key="baz"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- </ul>
+ <ul
+ className="menu menu-vertically-limited spacer-top with-top-separator"
+ >
+ <MultiSelectOption
+ active={false}
+ element="bar"
+ key="bar"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ selected={true}
+ />
+ <MultiSelectOption
+ active={false}
+ disabled={false}
+ element="foo"
+ key="foo"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ <MultiSelectOption
+ active={true}
+ disabled={false}
+ element="baz"
+ key="baz"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ </ul>
+ </fieldset>
</div>
`;
value="test"
/>
</div>
- <ul
- className="menu menu-vertically-limited spacer-top with-top-separator"
+ <fieldset
+ aria-label="multi select"
>
- <MultiSelectOption
- active={false}
- element="bar"
- key="bar"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- selected={true}
- />
- <MultiSelectOption
- active={false}
- disabled={false}
- element="foo"
- key="foo"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- <MultiSelectOption
- active={true}
- disabled={false}
- element="baz"
- key="baz"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- <MultiSelectOption
- active={false}
- custom={true}
- element="test"
- key="test"
- onHover={[Function]}
- onSelectChange={[Function]}
- renderLabel={[Function]}
- />
- </ul>
+ <ul
+ className="menu menu-vertically-limited spacer-top with-top-separator"
+ >
+ <MultiSelectOption
+ active={false}
+ element="bar"
+ key="bar"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ selected={true}
+ />
+ <MultiSelectOption
+ active={false}
+ disabled={false}
+ element="foo"
+ key="foo"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ <MultiSelectOption
+ active={true}
+ disabled={false}
+ element="baz"
+ key="baz"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ <MultiSelectOption
+ active={false}
+ custom={true}
+ element="test"
+ key="test"
+ onHover={[Function]}
+ onSelectChange={[Function]}
+ renderLabel={[Function]}
+ />
+ </ul>
+ </fieldset>
</div>
`;
<MultiSelect
elements={props.tags}
listSize={props.listSize}
+ legend={translate('select_tags')}
onSearch={props.onSearch}
onSelect={props.onSelect}
onUnselect={props.onUnselect}
]
}
filterSelected={[Function]}
+ legend="select_tags"
listSize={10}
onSearch={[Function]}
onSelect={[Function]}
<MultiSelect
elements={Array []}
filterSelected={[Function]}
+ legend="select_tags"
listSize={10}
onSearch={[Function]}
onSelect={[Function]}
see_x=See {0}
select_verb=Select
selected=Selected
+select_tags=Add or remove tags
set=Set
set_up=Set Up
severity=Severity
project_activity.graphs.custom=Custom
project_activity.graphs.custom.add=Add metric
project_activity.graphs.custom.add_metric=Add a metric
+project_activity.graphs.custom.select_metric=Select metric to display
project_activity.graphs.custom.add_metric_info=Only 3 metrics of the same type can be displayed on one graph. You can have a maximum of two graphs.
project_activity.graphs.custom.no_history=There isn't enough data to generate an activity graph, please select more metrics.
project_activity.graphs.custom.metric_no_history=This metric has no historical data to display.