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;
|
cursor: pointer;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
border-radius: 4px;
|
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 {
|
.copy-icon:not(:disabled):hover {
|
||||||
background-color: var(--color-border-default);
|
background-color: var(--color-border-default);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ import './copyToClipboard.css';
|
||||||
|
|
||||||
export const CopyToClipboard: React.FunctionComponent<{
|
export const CopyToClipboard: React.FunctionComponent<{
|
||||||
value: string,
|
value: string,
|
||||||
}> = ({ value }) => {
|
variant: 'small' | 'large'
|
||||||
|
}> = ({ value, variant }) => {
|
||||||
type IconType = 'copy' | 'check' | 'cross';
|
type IconType = 'copy' | 'check' | 'cross';
|
||||||
const [icon, setIcon] = React.useState<IconType>('copy');
|
const [icon, setIcon] = React.useState<IconType>('copy');
|
||||||
const handleCopy = React.useCallback(() => {
|
const handleCopy = React.useCallback(() => {
|
||||||
|
|
@ -34,5 +35,5 @@ export const CopyToClipboard: React.FunctionComponent<{
|
||||||
});
|
});
|
||||||
}, [value]);
|
}, [value]);
|
||||||
const iconElement = icon === 'check' ? icons.check() : icon === 'cross' ? icons.cross() : icons.copy();
|
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>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,10 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
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 { linkifyText } from '@web/renderUtils';
|
||||||
import { hashStringToInt, msToString } from './utils';
|
import { hashStringToInt, msToString } from './utils';
|
||||||
import { clsx } from '@web/uiUtils';
|
import { clsx } from '@web/uiUtils';
|
||||||
|
import { CopyToClipboard } from './copyToClipboard';
|
||||||
|
|
||||||
export const TestCaseView: React.FC<{
|
export const TestCaseView: React.FC<{
|
||||||
projectNames: string[],
|
projectNames: string[],
|
||||||
|
|
@ -74,6 +75,9 @@ function TestCaseAnnotationView({ annotation: { type, description } }: { annotat
|
||||||
<div className='test-case-annotation'>
|
<div className='test-case-annotation'>
|
||||||
<span style={{ fontWeight: 'bold' }}>{type}</span>
|
<span style={{ fontWeight: 'bold' }}>{type}</span>
|
||||||
{description && <span>: {linkifyText(description)}</span>}
|
{description && <span>: {linkifyText(description)}</span>}
|
||||||
|
{description && <span className='copy-button-container'>
|
||||||
|
<CopyToClipboard value={description} variant='small'/>
|
||||||
|
</span>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue