diff --git a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/ShareSpanButton.tsx b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/ShareSpanButton.tsx new file mode 100644 index 00000000000..23b76bb4b97 --- /dev/null +++ b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/ShareSpanButton.tsx @@ -0,0 +1,37 @@ +import { LinkModel } from '@grafana/data'; +import { Trans } from '@grafana/i18n'; +import { Button } from '@grafana/ui'; + +type Props = { + focusSpanLink: LinkModel; +}; + +export function ShareSpanButton(props: Props) { + const { focusSpanLink } = props; + return ( + + {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} + { + // click handling logic copied from react router: + // https://github.com/remix-run/react-router/blob/997b4d67e506d39ac6571cb369d6d2d6b3dda557/packages/react-router-dom/index.tsx#L392-L394s + if ( + focusSpanLink.onClick && + e.button === 0 && // Ignore everything but left clicks + (!e.currentTarget.target || e.currentTarget.target === '_self') && // Let browser handle "target=_blank" etc. + !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) // Ignore clicks with modifier keys + ) { + e.preventDefault(); + focusSpanLink.onClick(e); + } + }} + > + + Share + + + + ); +} diff --git a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.test.tsx b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.test.tsx index 330b043ac82..dd1a23c12e8 100644 --- a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.test.tsx +++ b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.test.tsx @@ -250,7 +250,7 @@ describe('', () => { it('renders deep link URL', () => { render(); - expect(screen.getByText('test-spanID')).toBeInTheDocument(); + expect(screen.getByTestId('share-span-button')).toBeInTheDocument(); }); it('renders the flame graph', async () => { diff --git a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.tsx b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.tsx index b9735b03720..67a6043f397 100644 --- a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.tsx +++ b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/index.tsx @@ -14,7 +14,6 @@ import { css } from '@emotion/css'; import { SpanStatusCode } from '@opentelemetry/api'; -import cx from 'classnames'; import { useCallback, useMemo } from 'react'; import { @@ -34,7 +33,7 @@ import { Trans, t } from '@grafana/i18n'; import { TraceToProfilesOptions } from '@grafana/o11y-ds-frontend'; import { usePluginLinks } from '@grafana/runtime'; import { TimeZone } from '@grafana/schema'; -import { Icon, TextArea, useStyles2 } from '@grafana/ui'; +import { TextArea, useStyles2 } from '@grafana/ui'; import { pyroscopeProfileIdTagKey } from '../../../createSpanLink'; import { autoColor } from '../../Theme'; @@ -49,6 +48,7 @@ import AccordianLogs from './AccordianLogs'; import AccordianReferences from './AccordianReferences'; import AccordianText from './AccordianText'; import DetailState from './DetailState'; +import { ShareSpanButton } from './ShareSpanButton'; import { getSpanDetailLinkButtons } from './SpanDetailLinkButtons'; import SpanFlameGraph from './SpanFlameGraph'; @@ -101,43 +101,22 @@ const getStyles = (theme: GrafanaTheme2) => { }), listWrapper: css({ overflow: 'hidden', + flexGrow: 1, + display: 'flex', + justifyContent: 'flex-end', }), list: css({ - textAlign: 'right', + textAlign: 'left', }), operationName: css({ margin: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', - flexBasis: '50%', + maxWidth: '50%', flexGrow: 0, flexShrink: 0, }), - debugInfo: css({ - label: 'debugInfo', - display: 'block', - letterSpacing: '0.25px', - margin: '0.5em 0 -0.75em', - textAlign: 'right', - }), - debugLabel: css({ - label: 'debugLabel', - '&::before': { - color: autoColor(theme, '#bbb'), - content: 'attr(data-label)', - }, - }), - debugValue: css({ - label: 'debugValue', - backgroundColor: 'inherit', - border: 'none', - color: autoColor(theme, '#888'), - cursor: 'pointer', - '&:hover': { - color: autoColor(theme, '#333'), - }, - }), AccordianWarnings: css({ label: 'AccordianWarnings', background: autoColor(theme, '#fafafa'), @@ -164,9 +143,6 @@ const getStyles = (theme: GrafanaTheme2) => { wordBreak: 'break-all', whiteSpace: 'pre', }), - LinkIcon: css({ - fontSize: '1.5em', - }), linkList: css({ display: 'flex', flexWrap: 'wrap', @@ -355,12 +331,13 @@ export default function SpanDetail(props: SpanDetailProps) { return ( - + {operationName} - + + {linksComponent} @@ -455,29 +432,6 @@ export default function SpanDetail(props: SpanDetailProps) { traceName={traceName} /> )} - - {/* TODO: fix keyboard a11y */} - {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} - { - // click handling logic copied from react router: - // https://github.com/remix-run/react-router/blob/997b4d67e506d39ac6571cb369d6d2d6b3dda557/packages/react-router-dom/index.tsx#L392-L394s - if ( - focusSpanLink.onClick && - e.button === 0 && // Ignore everything but left clicks - (!e.currentTarget.target || e.currentTarget.target === '_self') && // Let browser handle "target=_blank" etc. - !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) // Ignore clicks with modifier keys - ) { - e.preventDefault(); - focusSpanLink.onClick(e); - } - }} - > - - - {spanID} - ); diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index ddd03eccbf7..8a70d10f52d 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -7160,6 +7160,7 @@ "start-time": "Start Time:" } }, + "share-span": "Share", "warnings": "Warnings" }, "span-filters": {