mirror of
https://github.com/harness/drone.git
synced 2025-05-12 23:20:10 +08:00
Update: [code-1803] copy button on comment header (#1235)
This commit is contained in:
parent
175f26e9fe
commit
3f047635a0
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { Button, ButtonVariation, Container, Layout, Text, Utils } from '@harnessio/uicore'
|
import { ButtonSize, Container, Layout, Text } from '@harnessio/uicore'
|
||||||
import { Diff2HtmlUI } from 'diff2html/lib-esm/ui/js/diff2html-ui'
|
import { Diff2HtmlUI } from 'diff2html/lib-esm/ui/js/diff2html-ui'
|
||||||
import * as Diff2Html from 'diff2html'
|
import * as Diff2Html from 'diff2html'
|
||||||
import { get } from 'lodash-es'
|
import { get } from 'lodash-es'
|
||||||
@ -24,8 +24,9 @@ import type { TypesPullReqActivity } from 'services/code'
|
|||||||
import type { CommentItem } from 'components/CommentBox/CommentBox'
|
import type { CommentItem } from 'components/CommentBox/CommentBox'
|
||||||
import { DIFF2HTML_CONFIG, ViewStyle } from 'components/DiffViewer/DiffViewerUtils'
|
import { DIFF2HTML_CONFIG, ViewStyle } from 'components/DiffViewer/DiffViewerUtils'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
import type { GitInfoProps } from 'utils/GitUtils'
|
import { CodeIcon, type GitInfoProps } from 'utils/GitUtils'
|
||||||
import { PullRequestSection } from 'utils/Utils'
|
import { PullRequestSection } from 'utils/Utils'
|
||||||
|
import { CopyButton } from 'components/CopyButton/CopyButton'
|
||||||
import { isCodeComment } from '../PullRequestUtils'
|
import { isCodeComment } from '../PullRequestUtils'
|
||||||
import css from './Conversation.module.scss'
|
import css from './Conversation.module.scss'
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ export const CodeCommentHeader: React.FC<CodeCommentHeaderProps> = ({
|
|||||||
<Container className={css.snapshot}>
|
<Container className={css.snapshot}>
|
||||||
<Layout.Vertical>
|
<Layout.Vertical>
|
||||||
<Container className={css.title}>
|
<Container className={css.title}>
|
||||||
<Layout.Horizontal flex={{ alignItems: 'center' }}>
|
<Layout.Horizontal flex={{ alignItems: 'center', justifyContent: 'flex-start' }}>
|
||||||
<Text
|
<Text
|
||||||
inline
|
inline
|
||||||
className={css.fname}
|
className={css.fname}
|
||||||
@ -88,17 +89,13 @@ export const CodeCommentHeader: React.FC<CodeCommentHeaderProps> = ({
|
|||||||
{commentItems[0].payload?.code_comment?.path}
|
{commentItems[0].payload?.code_comment?.path}
|
||||||
</Link>
|
</Link>
|
||||||
</Text>
|
</Text>
|
||||||
<Button
|
{commentItems[0].payload?.code_comment?.path && (
|
||||||
variation={ButtonVariation.ICON}
|
<CopyButton
|
||||||
icon="code-copy"
|
content={commentItems[0].payload?.code_comment?.path}
|
||||||
className={css.copyButton}
|
icon={CodeIcon.Copy}
|
||||||
iconProps={{ size: 14 }}
|
size={ButtonSize.MEDIUM}
|
||||||
onClick={() => {
|
|
||||||
if (commentItems[0].payload?.code_comment?.path) {
|
|
||||||
Utils.copy(commentItems[0].payload?.code_comment?.path)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
</Container>
|
</Container>
|
||||||
<Container className={css.snapshotContent} id={id} />
|
<Container className={css.snapshotContent} id={id} />
|
||||||
|
Loading…
Reference in New Issue
Block a user