Skip to content

Commit

Permalink
Allow custom values in the filters bar (#288)
Browse files Browse the repository at this point in the history
* Fix spell check

* Allow custom values
  • Loading branch information
adrapereira authored Jan 13, 2025
1 parent 8bcceef commit d986053
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"queryless",
"unroute",
"gdev",
"lokiexplore"
"lokiexplore",
"viewports"
]
}
16 changes: 9 additions & 7 deletions src/components/Explore/filters/FilterRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ export function FilterRenderer({ filter, model, isWip }: Props) {
const [keyQuery, setKeyQuery] = useState<string>('');
const [valueQuery, setValueQuery] = useState<string>('');

const key = filter.key !== '' ? state?.keys?.find((key) => key.value === filter.key) ?? toOption(filter.key) : null;
const key = filter.key !== '' ? (state?.keys?.find((key) => key.value === filter.key) ?? toOption(filter.key)) : null;
const value = filter.value !== '' ? toOption(filter.value) : null;
const exploration = getTraceExplorationScene(model);
const { value: metric } = exploration.getMetricVariable().useState();

const operators = useMemo(() => {
const operators = model._getOperators();
return operators;
return model._getOperators();
}, [model]);

useEffect(() => {
Expand Down Expand Up @@ -114,6 +113,7 @@ export function FilterRenderer({ filter, model, isWip }: Props) {
}}
onCloseMenu={() => setValueQuery('')}
virtualized
allowCustomValue
/>
);

Expand Down Expand Up @@ -145,15 +145,17 @@ export function FilterRenderer({ filter, model, isWip }: Props) {
);
}

export const formatKeys = (keys: Array<SelectableValue<string>>, filters: AdHocVariableFilter[], metric: VariableValue) => {
export const formatKeys = (
keys: Array<SelectableValue<string>>,
filters: AdHocVariableFilter[],
metric: VariableValue
) => {
// Ensure we always have the same order of keys
const resourceAttributes = keys.filter((k) => k.value?.includes(RESOURCE_ATTR));
const spanAttributes = keys.filter((k) => k.value?.includes(SPAN_ATTR));
const intrinsicAttributes = keys.filter((k) => {
let checks =
!k.value?.includes(RESOURCE_ATTR) &&
!k.value?.includes(SPAN_ATTR) &&
ignoredAttributes.indexOf(k.value!) === -1;
!k.value?.includes(RESOURCE_ATTR) && !k.value?.includes(SPAN_ATTR) && ignoredAttributes.indexOf(k.value!) === -1;

// if filters (primary signal) has kind key selected, then don't add kind to intrinsicAttributes
// as you would overwrite it in the query if it's selected in the drop down
Expand Down

0 comments on commit d986053

Please sign in to comment.