Skip to content

Commit cb13a80

Browse files
authored
Support copy in git new issue page (#940)
resolves: #939 Signed-off-by: Lan Xia <[email protected]>
1 parent 4f17b9c commit cb13a80

File tree

3 files changed

+48
-20
lines changed

3 files changed

+48
-20
lines changed

test-result-summary-client/package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-result-summary-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"qs": "^6.11.1",
2020
"react": "^18.2.0",
2121
"react-app-rewired": "^2.2.1",
22+
"react-copy-to-clipboard": "^5.1.0",
2223
"react-day-picker": "^7.4.10",
2324
"react-dom": "^18.2.0",
2425
"react-grid-layout": "^0.16.6",

test-result-summary-client/src/Build/GitNewIssue.jsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import React, { useEffect, useState } from 'react';
22
import { useLocation } from 'react-router-dom';
33
import { params } from '../utils/query';
4-
import { Button, Tooltip, Card } from 'antd';
4+
import { Button, Tooltip, Card, Space } from 'antd';
55
import TestBreadcrumb from './TestBreadcrumb';
6-
import { GithubOutlined } from '@ant-design/icons';
6+
import { GithubOutlined, CopyOutlined } from '@ant-design/icons';
77
import { getParams } from '../utils/query';
88
import { fetchData } from '../utils/Utils';
9-
import renderDuration from './Duration';
10-
import { getGitDiffLinks } from '../utils/Utils';
9+
import { CopyToClipboard } from 'react-copy-to-clipboard';
1110

1211
import './table.css';
1312

14-
import moment from 'moment';
15-
const DAY_FORMAT = 'MMM DD YYYY, hh:mm a';
16-
1713
const GitNewissue = () => {
1814
const [state, setState] = useState({
1915
body: '',
@@ -24,7 +20,6 @@ const GitNewissue = () => {
2420
useEffect(() => {
2521
async function updateData() {
2622
const { testId, buildId } = getParams(location.search);
27-
const originUrl = window.location.origin;
2823
// fetch build data
2924
const buildDataRes = fetchData(`/api/getData?_id=${buildId}`);
3025
// fetch test data
@@ -115,18 +110,28 @@ const GitNewissue = () => {
115110
bordered={true}
116111
style={{ width: '100%' }}
117112
extra={
118-
<Tooltip title={`Create new issue at ${issueUrl}`}>
119-
<a
120-
href={`${issueUrl}issues/new${urlParams}`}
121-
target="_blank"
122-
rel="noopener noreferrer"
123-
>
124-
<Button size="large">
125-
<GithubOutlined />
126-
Create New Git Issue
127-
</Button>
128-
</a>
129-
</Tooltip>
113+
<div>
114+
<Space>
115+
<Tooltip title={`Create new issue at ${issueUrl}`}>
116+
<a
117+
href={`${issueUrl}issues/new${urlParams}`}
118+
target="_blank"
119+
rel="noopener noreferrer"
120+
>
121+
<Button size="large">
122+
<GithubOutlined />
123+
Create New Git Issue
124+
</Button>
125+
</a>
126+
</Tooltip>
127+
<CopyToClipboard text={body}>
128+
<Button size="large">
129+
<CopyOutlined />
130+
Copy
131+
</Button>
132+
</CopyToClipboard>
133+
</Space>
134+
</div>
130135
}
131136
>
132137
<pre className="card-body">{body}</pre>

0 commit comments

Comments
 (0)