Copy annoation text to clipboard
This commit is contained in:
parent
a6f0a89169
commit
3a9fb3f7d2
|
|
@ -25,6 +25,7 @@ import './testCaseView.css';
|
||||||
import { TestResultView } from './testResultView';
|
import { TestResultView } from './testResultView';
|
||||||
import { hashStringToInt } from './labelUtils';
|
import { hashStringToInt } from './labelUtils';
|
||||||
import { msToString } from './uiUtils';
|
import { msToString } from './uiUtils';
|
||||||
|
import { CopyToClipboard } from './copyToClipboard';
|
||||||
|
|
||||||
export const TestCaseView: React.FC<{
|
export const TestCaseView: React.FC<{
|
||||||
projectNames: string[],
|
projectNames: string[],
|
||||||
|
|
@ -68,15 +69,19 @@ function renderAnnotationDescription(description: string) {
|
||||||
try {
|
try {
|
||||||
if (['http:', 'https:'].includes(new URL(description).protocol))
|
if (['http:', 'https:'].includes(new URL(description).protocol))
|
||||||
return <a href={description} target='_blank' rel='noopener noreferrer'>{description}</a>;
|
return <a href={description} target='_blank' rel='noopener noreferrer'>{description}</a>;
|
||||||
} catch {}
|
} catch { }
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestCaseAnnotationView({ annotation: { type, description } }: { annotation: TestCaseAnnotation }) {
|
function TestCaseAnnotationView({ annotation: { type, description } }: { annotation: TestCaseAnnotation }) {
|
||||||
|
const [hover, setHover] = React.useState(false);
|
||||||
|
const onHover = () => setHover(true);
|
||||||
|
const onLeave = () => setHover(false);
|
||||||
return (
|
return (
|
||||||
<div className='test-case-annotation'>
|
<div className='test-case-annotation' onMouseEnter={onHover} onMouseLeave={onLeave}>
|
||||||
<span style={{ fontWeight: 'bold' }}>{type}</span>
|
<span style={{ fontWeight: 'bold', display: 'inline-block', marginBlock: '3px' }}>{type}</span>
|
||||||
{description && <span>: {renderAnnotationDescription(description)}</span>}
|
{description && <span>: {renderAnnotationDescription(description)}</span>}
|
||||||
|
<span style={{ paddingLeft: '3px' }}>{hover && description && <CopyToClipboard value={description} />}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue