feat: datatrails: include metric prefix filter (#81316)

* feat: datatrails: include metric prefix filter

* fix: remove current metric from related metrics list

* fix: Cascader issues

- handle empty items list when generating searchable options
- correct state management to ensure cascade shows cascade
  path of selection from search

* fix: remove custom value creation
This commit is contained in:
Darren Janeczek
2024-01-31 09:33:27 -05:00
committed by GitHub
parent c8f47e0c54
commit 7319a75110
4 changed files with 238 additions and 35 deletions

View File

@@ -93,7 +93,7 @@ export class Cascader extends PureComponent<CascaderProps, CascaderState> {
for (const option of options) {
const cpy = [...optionPath];
cpy.push(option);
if (!option.items) {
if (!option.items || option.items.length === 0) {
selectOptions.push({
singleLabel: cpy[cpy.length - 1].label,
label: cpy.map((o) => o.label).join(this.props.separator || DEFAULT_SEPARATOR),
@@ -135,23 +135,27 @@ export class Cascader extends PureComponent<CascaderProps, CascaderState> {
: this.props.displayAllSelectedLevels
? selectedOptions.map((option) => option.label).join(this.props.separator || DEFAULT_SEPARATOR)
: selectedOptions[selectedOptions.length - 1].label;
this.setState({
rcValue: value,
const state: CascaderState = {
rcValue: { value, label: activeLabel },
focusCascade: true,
activeLabel,
});
isSearching: false,
};
this.setState(state);
this.props.onSelect(selectedOptions[selectedOptions.length - 1].value);
};
//For select
onSelect = (obj: SelectableValue<string[]>) => {
const valueArray = obj.value || [];
this.setState({
activeLabel: this.props.displayAllSelectedLevels ? obj.label : obj.singleLabel || '',
rcValue: valueArray,
const activeLabel = this.props.displayAllSelectedLevels ? obj.label : obj.singleLabel || '';
const state: CascaderState = {
activeLabel: activeLabel,
rcValue: { value: valueArray, label: activeLabel },
isSearching: false,
});
focusCascade: false,
};
this.setState(state);
this.props.onSelect(valueArray[valueArray.length - 1]);
};