Bug 1609140 - Perfherder tooltip fix (#5822)

Add CSS change to allow cursor selection of text on the graph tooltip and
add the Clipboard component to make copying easier
This commit is contained in:
Sarah Clements 2020-01-16 10:59:09 -08:00 коммит произвёл GitHub
Родитель e9f907d52b
Коммит 7d94199b2e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 22 добавлений и 5 удалений

Просмотреть файл

@ -87,6 +87,12 @@ h1 {
}
.graph-tooltip.locked {
pointer-events: auto;
-webkit-touch-callout: text;
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.graph-tooltip .body {
display: block;

Просмотреть файл

@ -14,6 +14,7 @@ import { getJobsUrl, createQueryParams, getApiUrl } from '../../helpers/url';
import { create } from '../../helpers/http';
import RepositoryModel from '../../models/repository';
import { displayNumber, getStatus } from '../helpers';
import Clipboard from '../../shared/Clipboard';
const GraphTooltip = ({
testData,
@ -213,7 +214,12 @@ const GraphTooltip = ({
>
compare
</a>
)
){' '}
<Clipboard
text={dataPointDetails.revision}
description="Revision"
outline
/>
</span>
)}
{dataPointDetails.alertSummary && (

Просмотреть файл

@ -2,8 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faClipboard } from '@fortawesome/free-regular-svg-icons';
import { Button } from 'reactstrap';
const Clipboard = ({ description, text }) => {
const Clipboard = ({ description, text, outline }) => {
if (!text) {
return null;
}
@ -11,24 +12,28 @@ const Clipboard = ({ description, text }) => {
const copyToClipboard = () => navigator.clipboard.writeText(text);
return (
<button
<Button
type="button"
title={`Copy ${description}`}
onClick={copyToClipboard}
className="px-1 mx-1"
className="py-0 px-1"
color="light"
outline={outline}
>
<FontAwesomeIcon icon={faClipboard} />
</button>
</Button>
);
};
Clipboard.propTypes = {
description: PropTypes.string.isRequired,
text: PropTypes.string,
outline: PropTypes.bool,
};
Clipboard.defaultProps = {
text: null,
outline: false,
};
export { Clipboard as default };