Skip to content

Commit

Permalink
Add second copy icon for value only (#1505)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #1503 

## Short description of the changes
- Adds a second Copy icon that copies value only
- Change Copy JSON icon to `snippets`, to be visually different
- Reduce fade-out time for tooltip

Original Copy JSON was added in #292 / #312.

---------

Signed-off-by: Yuri Shkuro <ysh@meta.com>
  • Loading branch information
yurishkuro committed Jun 17, 2023
1 parent 4834ea7 commit beca0a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,16 @@ describe('<KeyValuesTable>', () => {

it('renders a <CopyIcon /> with correct copyText for each data element', () => {
const copyIcons = wrapper.find(CopyIcon);
expect(copyIcons.length).toBe(data.length);
expect(copyIcons.length).toBe(2 * data.length); // Copy and Copy JSON buttons
copyIcons.forEach((copyIcon, i) => {
expect(copyIcon.prop('copyText')).toBe(JSON.stringify(data[i], null, 2));
expect(copyIcon.prop('tooltipTitle')).toBe('Copy JSON');
const datum = data[Math.floor(i / 2)];
if (i % 2 === 0) {
expect(copyIcon.prop('copyText')).toBe(datum.value);
expect(copyIcon.prop('tooltipTitle')).toBe('Copy value');
} else {
expect(copyIcon.prop('copyText')).toBe(JSON.stringify(datum, null, 2));
expect(copyIcon.prop('tooltipTitle')).toBe('Copy JSON');
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ export default function KeyValuesTable(props: KeyValuesTableProps) {
<td className="KeyValueTable--copyColumn">
<CopyIcon
className="KeyValueTable--copyIcon"
copyText={row.value}
tooltipTitle="Copy value"
/>
<CopyIcon
className="KeyValueTable--copyIcon"
icon="snippets"
copyText={JSON.stringify(row, null, 2)}
tooltipTitle="Copy JSON"
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/components/common/CopyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class CopyIcon extends React.PureComponent<PropsType, StateType>
return (
<Tooltip
arrowPointAtCenter
mouseLeaveDelay={0.5}
mouseLeaveDelay={0.1}
onVisibleChange={this.handleTooltipVisibilityChange}
placement={this.props.placement}
title={this.state.hasCopied ? 'Copied' : this.props.tooltipTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`<CopyIcon /> renders as expected 1`] = `
arrowPointAtCenter={true}
autoAdjustOverflow={true}
mouseEnterDelay={0.1}
mouseLeaveDelay={0.5}
mouseLeaveDelay={0.1}
onVisibleChange={[Function]}
placement="left"
title="tooltipTitleValue"
Expand Down

0 comments on commit beca0a8

Please sign in to comment.