diff --git a/public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx b/public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx new file mode 100644 index 00000000000..8be7be68cd4 --- /dev/null +++ b/public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx @@ -0,0 +1,59 @@ +import { css } from '@emotion/css'; +import React from 'react'; + +import { GrafanaTheme2, IconName } from '@grafana/data'; +import { Button, useStyles2 } from '@grafana/ui'; + +export const getStyles = (theme: GrafanaTheme2) => { + return { + ActionButton: css` + label: ActionButton; + overflow: hidden; + position: relative; + width: 110px; + justify-content: center; + &:after { + content: ''; + background: ${theme.colors.primary.main}; + display: block; + position: absolute; + right: 0; + width: 100%; + height: 100%; + opacity: 0; + transition: all 0.8s; + } + &:active:after { + margin: 0; + opacity: 0.3; + transition: 0s; + } + `, + }; +}; + +export type ActionButtonProps = { + onClick: () => void; + ariaLabel: string; + label: string; + icon: IconName; +}; + +export default function ActionButton(props: ActionButtonProps) { + const { onClick, ariaLabel, label, icon } = props; + const styles = useStyles2(getStyles); + + return ( + + ); +} diff --git a/public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx b/public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx new file mode 100644 index 00000000000..7475fec0f99 --- /dev/null +++ b/public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx @@ -0,0 +1,51 @@ +import { css } from '@emotion/css'; +import React, { useState } from 'react'; + +import { useStyles2 } from '@grafana/ui'; + +import ActionButton from './ActionButton'; + +export const getStyles = () => { + return { + TracePageActions: css` + label: TracePageActions; + display: flex; + gap: 4px; + `, + }; +}; + +export type TracePageActionsProps = { + traceId: string; +}; + +export default function TracePageActions(props: TracePageActionsProps) { + const { traceId } = props; + const styles = useStyles2(getStyles); + const [copyTraceIdClicked, setCopyTraceIdClicked] = useState(false); + + const copyTraceId = () => { + navigator.clipboard.writeText(traceId); + setCopyTraceIdClicked(true); + setTimeout(() => { + setCopyTraceIdClicked(false); + }, 5000); + }; + + return ( +