diff --git a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.tsx b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.tsx index 1dd594fcff6..722fbc8a7d9 100644 --- a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.tsx +++ b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.tsx @@ -16,11 +16,11 @@ import cx from 'classnames'; import * as React from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; -import { withTheme2, stylesFactory } from '@grafana/ui'; +import { withTheme2, stylesFactory, Button } from '@grafana/ui'; import GraphTicks from './GraphTicks'; import Scrubber from './Scrubber'; -import { TUpdateViewRangeTimeFunction, UIButton, ViewRange, ViewRangeTimeUpdate, TNil } from '../..'; +import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate, TNil } from '../..'; import { autoColor } from '../../Theme'; import DraggableManager, { DraggableBounds, DraggingUpdate, EUpdateTypes } from '../../utils/DraggableManager'; @@ -344,13 +344,14 @@ export class UnthemedViewingLayer extends React.PureComponent {(viewStart !== 0 || viewEnd !== 1) && ( - Reset Selection - + )} void; resultCount: number; slimView: boolean; - textFilter: string | TNil; trace: Trace; - traceGraphView: boolean; updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void; updateViewRangeTime: TUpdateViewRangeTimeFunction; viewRange: ViewRange; searchValue: string; onSearchValueChange: (value: string) => void; - hideSearchButtons?: boolean; timeZone: TimeZone; }; export const HEADER_ITEMS = [ { key: 'timestamp', - label: 'Trace Start', + label: 'Trace Start:', renderer(trace: Trace, timeZone: TimeZone, styles: ReturnType) { // Convert date from micro to milli seconds const dateStr = dateTimeFormat(trace.startTime / 1000, { timeZone, defaultWithMS: true }); @@ -181,22 +177,22 @@ export const HEADER_ITEMS = [ }, { key: 'duration', - label: 'Duration', + label: 'Duration:', renderer: (trace: Trace) => formatDuration(trace.duration), }, { key: 'service-count', - label: 'Services', + label: 'Services:', renderer: (trace: Trace) => new Set(_values(trace.processes).map((p) => p.serviceName)).size, }, { key: 'depth', - label: 'Depth', + label: 'Depth:', renderer: (trace: Trace) => _get(_maxBy(trace.spans, 'depth'), 'depth', 0) + 1, }, { key: 'span-count', - label: 'Total Spans', + label: 'Total Spans:', renderer: (trace: Trace) => trace.spans.length, }, ]; @@ -213,15 +209,12 @@ export default function TracePageHeader(props: TracePageHeaderEmbedProps) { prevResult, resultCount, slimView, - textFilter, trace, - traceGraphView, updateNextViewRangeTime, updateViewRangeTime, viewRange, searchValue, onSearchValueChange, - hideSearchButtons, timeZone, } = props; @@ -280,11 +273,10 @@ export default function TracePageHeader(props: TracePageHeaderEmbedProps) { nextResult={nextResult} prevResult={prevResult} resultCount={resultCount} - textFilter={textFilter} - navigable={!traceGraphView} + // TODO: we can change this when we have scroll to span functionality + navigable={false} searchValue={searchValue} onSearchValueChange={onSearchValueChange} - hideSearchButtons={hideSearchButtons} /> {summaryItems && } diff --git a/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.test.js b/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.test.js index 112f2927f87..51b5eab3b57 100644 --- a/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.test.js +++ b/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.test.js @@ -25,7 +25,7 @@ const defaultProps = { nextResult: () => {}, prevResult: () => {}, resultCount: 0, - textFilter: 'something', + searchValue: 'something', }; describe('', () => { @@ -50,29 +50,27 @@ describe('', () => { }); it('renders buttons', () => { - const buttons = wrapper.find('UIButton'); + const buttons = wrapper.find('Button'); expect(buttons.length).toBe(4); buttons.forEach((button) => { - expect(button.hasClass(getStyles().TracePageSearchBarBtn)).toBe(true); - expect(button.hasClass(getStyles().TracePageSearchBarBtnDisabled)).toBe(false); expect(button.prop('disabled')).toBe(false); }); - expect(wrapper.find('UIButton[icon="up"]').prop('onClick')).toBe(defaultProps.prevResult); - expect(wrapper.find('UIButton[icon="down"]').prop('onClick')).toBe(defaultProps.nextResult); - expect(wrapper.find('UIButton[icon="close"]').prop('onClick')).toBe(defaultProps.clearSearch); + expect(wrapper.find('Button[icon="arrow-up"]').prop('onClick')).toBe(defaultProps.prevResult); + expect(wrapper.find('Button[icon="arrow-down"]').prop('onClick')).toBe(defaultProps.nextResult); + expect(wrapper.find('Button[icon="times"]').prop('onClick')).toBe(defaultProps.clearSearch); }); it('hides navigation buttons when not navigable', () => { wrapper.setProps({ navigable: false }); - const button = wrapper.find('UIButton'); + const button = wrapper.find('Button'); expect(button.length).toBe(1); - expect(button.prop('icon')).toBe('close'); + expect(button.prop('icon')).toBe('times'); }); }); describe('falsy textFilter', () => { beforeEach(() => { - wrapper.setProps({ textFilter: '' }); + wrapper.setProps({ searchValue: '' }); }); it('renders UiFindInput with correct props', () => { @@ -80,11 +78,9 @@ describe('', () => { }); it('renders buttons', () => { - const buttons = wrapper.find('UIButton'); + const buttons = wrapper.find('Button'); expect(buttons.length).toBe(4); buttons.forEach((button) => { - expect(button.hasClass(getStyles().TracePageSearchBarBtn)).toBe(true); - expect(button.hasClass(getStyles().TracePageSearchBarBtnDisabled)).toBe(true); expect(button.prop('disabled')).toBe(true); }); }); diff --git a/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.tsx b/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.tsx index 4569c8bc6e8..9e2df0446fe 100644 --- a/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.tsx +++ b/packages/jaeger-ui-components/src/TracePageHeader/TracePageSearchBar.tsx @@ -16,13 +16,11 @@ import * as React from 'react'; import cx from 'classnames'; import IoAndroidLocate from 'react-icons/lib/io/android-locate'; import { css } from '@emotion/css'; -import { useStyles2 } from '@grafana/ui'; +import { Button, useStyles2 } from '@grafana/ui'; import * as markers from './TracePageSearchBar.markers'; import UiFindInput from '../common/UiFindInput'; -import { TNil } from '../types'; -import { UIButton, UIInputGroup } from '../uiElementsContext'; import { ubFlexAuto, ubJustifyEnd } from '../uberUtilityStyles'; // eslint-disable-next-line no-duplicate-imports import { memo } from 'react'; @@ -61,7 +59,6 @@ export const getStyles = () => { }; type TracePageSearchBarProps = { - textFilter: string | TNil; prevResult: () => void; nextResult: () => void; clearSearch: () => void; @@ -70,7 +67,6 @@ type TracePageSearchBarProps = { navigable: boolean; searchValue: string; onSearchValueChange: (value: string) => void; - hideSearchButtons?: boolean; }; export default memo(function TracePageSearchBar(props: TracePageSearchBarProps) { @@ -81,16 +77,14 @@ export default memo(function TracePageSearchBar(props: TracePageSearchBarProps) nextResult, prevResult, resultCount, - textFilter, onSearchValueChange, searchValue, - hideSearchButtons, } = props; const styles = useStyles2(getStyles); - const count = textFilter ? {resultCount} : null; + const count = searchValue ? {resultCount} : null; - const btnClass = cx(styles.TracePageSearchBarBtn, { [styles.TracePageSearchBarBtnDisabled]: !textFilter }); + const btnClass = cx(styles.TracePageSearchBarBtn, { [styles.TracePageSearchBarBtnDisabled]: !searchValue }); const uiFindInputInputProps = { 'data-test': markers.IN_TRACE_SEARCH, className: cx(styles.TracePageSearchBarBar, ubFlexAuto), @@ -100,47 +94,41 @@ export default memo(function TracePageSearchBar(props: TracePageSearchBarProps) return (
- {/* style inline because compact overwrites the display */} - + - {!hideSearchButtons && ( - <> - {navigable && ( - <> - - - - - - - )} - - - )} - + <> + {navigable && ( + <> + +
); }); diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.test.js b/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.test.js index a85bcb01c2a..c3c85134c44 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.test.js +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.test.js @@ -14,12 +14,12 @@ import React from 'react'; import { shallow } from 'enzyme'; +import { Tooltip } from '@grafana/ui'; import ReferencesButton, { getStyles } from './ReferencesButton'; import transformTraceData from '../model/transform-trace-data'; import traceGenerator from '../demo/trace-generators'; import ReferenceLink from '../url/ReferenceLink'; -import { UIDropdown, UIMenuItem, UITooltip } from '../uiElementsContext'; describe(ReferencesButton, () => { const trace = transformTraceData(traceGenerator.trace({ numberOfSpans: 10 })); @@ -49,40 +49,14 @@ describe(ReferencesButton, () => { it('renders single reference', () => { const props = { ...baseProps, references: oneReference }; const wrapper = shallow(); - const dropdown = wrapper.find(UIDropdown); const refLink = wrapper.find(ReferenceLink); - const tooltip = wrapper.find(UITooltip); + const tooltip = wrapper.find(Tooltip); const styles = getStyles(); - expect(dropdown.length).toBe(0); expect(refLink.length).toBe(1); expect(refLink.prop('reference')).toBe(oneReference[0]); expect(refLink.first().props().className).toBe(styles.MultiParent); expect(tooltip.length).toBe(1); - expect(tooltip.prop('title')).toBe(props.tooltipText); - }); - - it('renders multiple references', () => { - const props = { ...baseProps, references: moreReferences }; - const wrapper = shallow(); - const dropdown = wrapper.find(UIDropdown); - expect(dropdown.length).toBe(1); - // We have some wrappers here that dynamically inject specific component so we need to traverse a bit - // here - const menuInstance = shallow( - shallow(dropdown.first().props().overlay).prop('children')({ - Menu({ children }) { - return
{children}
; - }, - }) - ); - const submenuItems = menuInstance.find(UIMenuItem); - expect(submenuItems.length).toBe(3); - submenuItems.forEach((submenuItem, i) => { - expect(submenuItem.find(ReferenceLink).prop('reference')).toBe(moreReferences[i]); - }); - expect(submenuItems.at(2).find(ReferenceLink).childAt(0).text()).toBe( - `(another trace) - ${moreReferences[2].spanID}` - ); + expect(tooltip.prop('content')).toBe(props.tooltipText); }); }); diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx b/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx index 5ac6bd1c7cc..34fc50f4750 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/ReferencesButton.tsx @@ -14,11 +14,9 @@ import React from 'react'; import { css } from '@emotion/css'; -import { stylesFactory } from '@grafana/ui'; +import { stylesFactory, Tooltip } from '@grafana/ui'; -import NewWindowIcon from '../common/NewWindowIcon'; import { TraceSpanReference } from '../types/trace'; -import { UITooltip, UIDropdown, UIMenuItem, UIMenu, TooltipPlacement } from '../uiElementsContext'; import ReferenceLink from '../url/ReferenceLink'; export const getStyles = stylesFactory(() => { @@ -51,55 +49,18 @@ type TReferencesButtonProps = { }; export default class ReferencesButton extends React.PureComponent { - referencesList = (references: TraceSpanReference[]) => { - const styles = getStyles(); - return ( - - {references.map((ref) => { - const { span, spanID } = ref; - return ( - - - {span - ? `${span.process.serviceName}:${span.operationName} - ${ref.spanID}` - : `(another trace) - ${ref.spanID}`} - {!span && } - - - ); - })} - - ); - }; - render() { const { references, children, tooltipText, focusSpan } = this.props; const styles = getStyles(); - const tooltipProps = { - arrowPointAtCenter: true, - mouseLeaveDelay: 0.5, - placement: 'bottom' as TooltipPlacement, - title: tooltipText, - overlayClassName: styles.tooltip, - }; - - if (references.length > 1) { - return ( - - - {children} - - - ); - } + // TODO: handle multiple items with some dropdown const ref = references[0]; return ( - + {children} - + ); } } diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.test.js b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.test.js index 9a39c5044c0..09146b8e459 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.test.js +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.test.js @@ -14,7 +14,7 @@ import React from 'react'; import { mount } from 'enzyme'; -import UIElementsContext, { UIPopover } from '../uiElementsContext'; +import { Popover } from '../common/Popover'; import SpanBar from './SpanBar'; @@ -74,11 +74,7 @@ describe('', () => { }; it('renders without exploding', () => { - const wrapper = mount( - '' }}> - - - ); + const wrapper = mount(); expect(wrapper).toBeDefined(); const { onMouseOver, onMouseLeave } = wrapper.find('[data-test-id="SpanBar--wrapper"]').props(); const labelElm = wrapper.find('[data-test-id="SpanBar--label"]'); @@ -91,11 +87,7 @@ describe('', () => { it('log markers count', () => { // 3 log entries, two grouped together with the same timestamp - const wrapper = mount( - '' }}> - - - ); - expect(wrapper.find(UIPopover).length).toEqual(2); + const wrapper = mount(); + expect(wrapper.find(Popover).length).toEqual(2); }); }); diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx index 13bea7c3db3..c78db4b23ae 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx @@ -22,9 +22,9 @@ import { useStyles2 } from '@grafana/ui'; import { autoColor } from '../Theme'; import { TraceSpan } from '../types/trace'; import { TNil } from '../types'; -import { UIPopover } from '../uiElementsContext'; import AccordianLogs from './SpanDetail/AccordianLogs'; import { ViewedBoundsFunctionType } from './utils'; +import { Popover } from '../common/Popover'; const getStyles = (theme: GrafanaTheme2) => { return { @@ -172,15 +172,14 @@ function SpanBar(props: TInnerProps) {
{Object.keys(logGroups).map((positionKey) => ( - } >
- + ))}
{rpc && ( diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.test.js b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.test.js index bdbfac59793..c03b0c2bf0b 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.test.js +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.test.js @@ -14,12 +14,10 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { createTheme } from '@grafana/data'; import CopyIcon from '../../common/CopyIcon'; -import KeyValuesTable, { LinkValue, getStyles } from './KeyValuesTable'; -import { UIDropdown, UIIcon } from '../../uiElementsContext'; +import KeyValuesTable, { LinkValue } from './KeyValuesTable'; import { ubInlineBlock } from '../../uberUtilityStyles'; describe('LinkValue', () => { @@ -37,12 +35,6 @@ describe('LinkValue', () => { expect(wrapper.find('a').prop('title')).toBe(title); expect(wrapper.find('a').text()).toMatch(/childrenText/); }); - - it('renders correct Icon', () => { - const styles = getStyles(createTheme()); - expect(wrapper.find(UIIcon).hasClass(styles.linkIcon)).toBe(true); - expect(wrapper.find(UIIcon).prop('type')).toBe('export'); - }); }); describe('', () => { @@ -92,38 +84,6 @@ describe('', () => { expect(anchor.closest('tr').find('td').first().text()).toBe('span.kind'); }); - it('renders multiple links correctly', () => { - wrapper.setProps({ - linksGetter: (array, i) => - array[i].key === 'span.kind' - ? [ - { url: `http://example.com/1?kind=${encodeURIComponent(array[i].value)}`, text: 'Example 1' }, - { url: `http://example.com/2?kind=${encodeURIComponent(array[i].value)}`, text: 'Example 2' }, - ] - : [], - }); - const dropdown = wrapper.find(UIDropdown); - const overlay = shallow(dropdown.prop('overlay')); - // We have some wrappers here that dynamically inject specific component so we need to traverse a bit - // here - const menu = shallow( - overlay.prop('children')({ - Menu({ children }) { - return
{children}
; - }, - }) - ); - const anchors = menu.find(LinkValue); - expect(anchors).toHaveLength(2); - const firstAnchor = anchors.first(); - expect(firstAnchor.prop('href')).toBe('http://example.com/1?kind=client'); - expect(firstAnchor.children().text()).toBe('Example 1'); - const secondAnchor = anchors.last(); - expect(secondAnchor.prop('href')).toBe('http://example.com/2?kind=client'); - expect(secondAnchor.children().text()).toBe('Example 2'); - expect(dropdown.closest('tr').find('td').first().text()).toBe('span.kind'); - }); - it('renders a with correct copyText for each data element', () => { const copyIcons = wrapper.find(CopyIcon); expect(copyIcons.length).toBe(data.length); diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx index 2fb4191dc5b..7ab37b706eb 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/KeyValuesTable.tsx @@ -16,13 +16,12 @@ import * as React from 'react'; import jsonMarkup from 'json-markup'; import { css } from '@emotion/css'; import cx from 'classnames'; -import { useStyles2 } from '@grafana/ui'; +import { Icon, useStyles2 } from '@grafana/ui'; import { GrafanaTheme2 } from '@grafana/data'; import CopyIcon from '../../common/CopyIcon'; import { TNil } from '../../types'; import { TraceKeyValuePair, TraceLink } from '../../types/trace'; -import { UIDropdown, UIIcon, UIMenu, UIMenuItem } from '../../uiElementsContext'; import { autoColor } from '../../Theme'; import { ubInlineBlock, uWidth100 } from '../../uberUtilityStyles'; @@ -89,10 +88,9 @@ function parseIfComplexJson(value: any) { } export const LinkValue = (props: { href: string; title?: string; children: React.ReactNode }) => { - const styles = useStyles2(getStyles); return ( - {props.children} + {props.children} ); }; @@ -101,17 +99,6 @@ LinkValue.defaultProps = { title: '', }; -const linkValueList = (links: TraceLink[]) => ( - - {links.map(({ text, url }, index) => ( - // `index` is necessary in the key because url can repeat - - {text} - - ))} - -); - type KeyValuesTableProps = { data: TraceKeyValuePair[]; linksGetter: ((pairs: TraceKeyValuePair[], index: number) => TraceLink[]) | TNil; @@ -131,7 +118,8 @@ export default function KeyValuesTable(props: KeyValuesTableProps) { const jsonTable =
; const links = linksGetter ? linksGetter(data, i) : null; let valueMarkup; - if (links && links.length === 1) { + if (links && links.length) { + // TODO: handle multiple items valueMarkup = (
@@ -139,16 +127,6 @@ export default function KeyValuesTable(props: KeyValuesTableProps) {
); - } else if (links && links.length > 1) { - valueMarkup = ( - - ); } else { valueMarkup = jsonTable; } diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx index 9b3add1d7a6..6555b51bc84 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanDetail/index.tsx @@ -29,7 +29,7 @@ import { SpanLinkFunc, TNil } from '../../types'; import { TraceKeyValuePair, TraceLink, TraceLog, TraceSpan } from '../../types/trace'; import AccordianReferences from './AccordianReferences'; import { autoColor } from '../../Theme'; -import { UIDivider } from '../../uiElementsContext'; +import { Divider } from '../../common/Divider'; import { uAlignIcon, ubFlex, @@ -43,21 +43,6 @@ import { const getStyles = (theme: GrafanaTheme2) => { return { - divider: css` - label: divider; - background: ${autoColor(theme, '#ddd')}; - `, - dividerVertical: css` - label: dividerVertical; - display: block; - height: 1px; - width: 100%; - margin: 24px 0; - clear: both; - vertical-align: middle; - position: relative; - top: -0.06em; - `, debugInfo: css` label: debugInfo; display: block; @@ -195,12 +180,12 @@ export default function SpanDetail(props: SpanDetailProps) {

{operationName}

- +
{link ? ( ) : null} - +
', () => { expect(wrapper.state().hasCopied).toBe(false); expect(copySpy).not.toHaveBeenCalled(); - wrapper.find(UIButton).simulate('click'); + wrapper.find(Button).simulate('click'); expect(wrapper.state().hasCopied).toBe(true); expect(copySpy).toHaveBeenCalledWith(props.copyText); }); - it('updates state when tooltip hides and state.hasCopied is true', () => { - wrapper.setState({ hasCopied: true }); - wrapper.find(UITooltip).prop('onVisibleChange')(false); - expect(wrapper.state().hasCopied).toBe(false); - - const state = wrapper.state(); - wrapper.find(UITooltip).prop('onVisibleChange')(false); - expect(wrapper.state()).toBe(state); - }); - it('persists state when tooltip opens', () => { wrapper.setState({ hasCopied: true }); - wrapper.find(UITooltip).prop('onVisibleChange')(true); expect(wrapper.state().hasCopied).toBe(true); }); }); diff --git a/packages/jaeger-ui-components/src/common/CopyIcon.tsx b/packages/jaeger-ui-components/src/common/CopyIcon.tsx index 035fb1f6a67..e4a91c7ff9e 100644 --- a/packages/jaeger-ui-components/src/common/CopyIcon.tsx +++ b/packages/jaeger-ui-components/src/common/CopyIcon.tsx @@ -16,9 +16,7 @@ import * as React from 'react'; import { css } from '@emotion/css'; import cx from 'classnames'; import copy from 'copy-to-clipboard'; -import { stylesFactory } from '@grafana/ui'; - -import { UITooltip, TooltipPlacement, UIButton } from '../uiElementsContext'; +import { Button, IconName, stylesFactory, Tooltip } from '@grafana/ui'; const getStyles = stylesFactory(() => { return { @@ -40,8 +38,7 @@ const getStyles = stylesFactory(() => { type PropsType = { className?: string; copyText: string; - icon?: string; - placement?: TooltipPlacement; + icon?: IconName; tooltipTitle: string; }; @@ -53,7 +50,6 @@ export default class CopyIcon extends React.PureComponent static defaultProps: Partial = { className: undefined, icon: 'copy', - placement: 'left', }; state = { @@ -78,20 +74,14 @@ export default class CopyIcon extends React.PureComponent render() { const styles = getStyles(); return ( - - + - ); - }, - Divider, - Input(props) { - return ; - }, - InputGroup({ children, className, style }) { - return ( - - {children} - - ); - }, -}; - -const getStyles = stylesFactory((theme: GrafanaTheme) => { - return { - Divider: css` - display: inline-block; - background: ${theme.isDark ? '#242424' : '#e8e8e8'}; - width: 1px; - height: 0.9em; - margin: 0 8px; - vertical-align: middle; - `, - }; -}); - -function Divider({ className }: { className?: string }) { - const styles = getStyles(useTheme()); - return
; -} diff --git a/public/app/features/explore/TraceView/useSearch.ts b/public/app/features/explore/TraceView/useSearch.ts index b49315459fb..2d0084edaac 100644 --- a/public/app/features/explore/TraceView/useSearch.ts +++ b/public/app/features/explore/TraceView/useSearch.ts @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { filterSpans, TraceSpan } from '@jaegertracing/jaeger-ui-components'; /** @@ -7,9 +7,13 @@ import { filterSpans, TraceSpan } from '@jaegertracing/jaeger-ui-components'; */ export function useSearch(spans?: TraceSpan[]) { const [search, setSearch] = useState(''); - const spanFindMatches: Set | undefined | null = useMemo(() => { + const spanFindMatches: Set | undefined = useMemo(() => { return search && spans ? filterSpans(search, spans) : undefined; }, [search, spans]); - return { search, setSearch, spanFindMatches }; + const clearSearch = useCallback(() => { + setSearch(''); + }, [setSearch]); + + return { search, setSearch, spanFindMatches, clearSearch }; }