feat(reporter): add copy button for annotations
Adds a copy-to-clipboard button for each annotation
This commit is contained in:
parent
571f25a7d3
commit
caa6986577
|
|
@ -26,9 +26,23 @@
|
|||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.copy-icon svg {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.copy-icon.small {
|
||||
color: var(--color-fg-muted);
|
||||
}
|
||||
|
||||
.copy-icon.small svg {
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
.copy-icon:not(:disabled):hover {
|
||||
background-color: var(--color-border-default);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import './copyToClipboard.css';
|
|||
|
||||
export const CopyToClipboard: React.FunctionComponent<{
|
||||
value: string,
|
||||
}> = ({ value }) => {
|
||||
variant: 'small' | 'large'
|
||||
}> = ({ value, variant }) => {
|
||||
type IconType = 'copy' | 'check' | 'cross';
|
||||
const [icon, setIcon] = React.useState<IconType>('copy');
|
||||
const handleCopy = React.useCallback(() => {
|
||||
|
|
@ -34,5 +35,5 @@ export const CopyToClipboard: React.FunctionComponent<{
|
|||
});
|
||||
}, [value]);
|
||||
const iconElement = icon === 'check' ? icons.check() : icon === 'cross' ? icons.cross() : icons.copy();
|
||||
return <button className='copy-icon' onClick={handleCopy}>{iconElement}</button>;
|
||||
return <button className={`copy-icon ${variant}`} onClick={handleCopy}>{iconElement}</button>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,3 +74,9 @@
|
|||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.copy-button-container {
|
||||
display: inline-flex;
|
||||
margin-left: 8px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import { TestResultView } from './testResultView';
|
|||
import { linkifyText } from '@web/renderUtils';
|
||||
import { hashStringToInt, msToString } from './utils';
|
||||
import { clsx } from '@web/uiUtils';
|
||||
import { CopyToClipboard } from './copyToClipboard';
|
||||
|
||||
export const TestCaseView: React.FC<{
|
||||
projectNames: string[],
|
||||
|
|
@ -74,6 +75,9 @@ function TestCaseAnnotationView({ annotation: { type, description } }: { annotat
|
|||
<div className='test-case-annotation'>
|
||||
<span style={{ fontWeight: 'bold' }}>{type}</span>
|
||||
{description && <span>: {linkifyText(description)}</span>}
|
||||
{description && <span className='copy-button-container'>
|
||||
<CopyToClipboard value={description} variant='small'/>
|
||||
</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue