mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
16 lines
491 B
TypeScript
16 lines
491 B
TypeScript
|
import { useState } from 'react';
|
||
|
import { Span, filterSpans } from '@jaegertracing/jaeger-ui-components';
|
||
|
|
||
|
/**
|
||
|
* Controls the state of search input that highlights spans if they match the search string.
|
||
|
* @param spans
|
||
|
*/
|
||
|
export function useSearch(spans?: Span[]) {
|
||
|
const [search, setSearch] = useState('');
|
||
|
let spanFindMatches: Set<string> | undefined;
|
||
|
if (search && spans) {
|
||
|
spanFindMatches = filterSpans(search, spans);
|
||
|
}
|
||
|
return { search, setSearch, spanFindMatches };
|
||
|
}
|