mirror of
https://github.com/harness/drone.git
synced 2025-05-16 00:50:00 +08:00
feat: [code-517]: fix branch copy icon (#184)
This commit is contained in:
parent
0b6403c902
commit
99b3ac1c79
@ -13,7 +13,7 @@ interface CodeCommentStatusSelectProps extends Pick<GitInfoProps, 'repoMetadata'
|
|||||||
commentItems: CommentItem<TypesPullReqActivity>[]
|
commentItems: CommentItem<TypesPullReqActivity>[]
|
||||||
onCommentUpdate: () => void
|
onCommentUpdate: () => void
|
||||||
|
|
||||||
refetchActivities: () => void
|
refetchActivities?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CodeCommentStatusSelect: React.FC<CodeCommentStatusSelectProps> = ({
|
export const CodeCommentStatusSelect: React.FC<CodeCommentStatusSelectProps> = ({
|
||||||
@ -77,7 +77,9 @@ export const CodeCommentStatusSelect: React.FC<CodeCommentStatusSelectProps> = (
|
|||||||
commentItems[0].payload.resolved = Date.now()
|
commentItems[0].payload.resolved = Date.now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refetchActivities()
|
if (refetchActivities) {
|
||||||
|
refetchActivities()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(_exception => {
|
.catch(_exception => {
|
||||||
showError(getErrorMessage(_exception), 0, getString('pr.failedToUpdateCommentStatus'))
|
showError(getErrorMessage(_exception), 0, getString('pr.failedToUpdateCommentStatus'))
|
||||||
|
@ -7,3 +7,32 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 2px 6px !important;
|
padding: 2px 6px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.copyContainer {
|
||||||
|
background-color: var(--primary-1) !important;
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
border-radius: 4px !important;
|
||||||
|
--button-height: unset !important;
|
||||||
|
--text-color: unset !important;
|
||||||
|
padding: unset !important ;
|
||||||
|
--padding-right: 2px !important;
|
||||||
|
padding-left: 4px !important;
|
||||||
|
min-width: unset !important;
|
||||||
|
padding-bottom: 1px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.linkText {
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
background-color: var(--primary-1) !important;
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
border-radius: 4px;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 2px 6px !important;
|
||||||
|
width: fit-content !important;
|
||||||
|
padding-bottom: 3px !important;
|
||||||
|
}
|
||||||
|
@ -2,5 +2,7 @@
|
|||||||
// this is an auto-generated file
|
// this is an auto-generated file
|
||||||
declare const styles: {
|
declare const styles: {
|
||||||
readonly link: string
|
readonly link: string
|
||||||
|
readonly copyContainer: string
|
||||||
|
readonly linkText: string
|
||||||
}
|
}
|
||||||
export default styles
|
export default styles
|
||||||
|
@ -1,9 +1,34 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
import { Color, Layout } from '@harness/uicore'
|
||||||
|
import { CopyButton } from 'components/CopyButton/CopyButton'
|
||||||
|
import { useStrings } from 'framework/strings'
|
||||||
|
import { CodeIcon } from 'utils/GitUtils'
|
||||||
import css from './GitRefLink.module.scss'
|
import css from './GitRefLink.module.scss'
|
||||||
|
|
||||||
export const GitRefLink: React.FC<{ text: string; url: string }> = ({ text, url }) => (
|
export const GitRefLink: React.FC<{ text: string; url: string; showCopy: boolean }> = ({
|
||||||
<Link to={url} className={css.link}>
|
text,
|
||||||
{text}
|
url,
|
||||||
</Link>
|
showCopy = true
|
||||||
)
|
}) => {
|
||||||
|
const { getString } = useStrings()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout.Horizontal className={css.link} inline>
|
||||||
|
<Link className={css.linkText} to={url}>
|
||||||
|
{text}
|
||||||
|
</Link>
|
||||||
|
{showCopy ? (
|
||||||
|
<CopyButton
|
||||||
|
className={css.copyContainer}
|
||||||
|
content={text}
|
||||||
|
tooltip={getString('copyBranch')}
|
||||||
|
icon={CodeIcon.Copy}
|
||||||
|
color={Color.PRIMARY_7}
|
||||||
|
iconProps={{ size: 14, color: Color.PRIMARY_7 }}
|
||||||
|
background={Color.PRIMARY_1}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</Layout.Horizontal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { noop } from 'lodash-es'
|
// import { noop } from 'lodash-es'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
@ -12,8 +12,8 @@ import {
|
|||||||
IconName,
|
IconName,
|
||||||
useToaster
|
useToaster
|
||||||
} from '@harness/uicore'
|
} from '@harness/uicore'
|
||||||
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
|
||||||
import { useMutate } from 'restful-react'
|
import { useMutate } from 'restful-react'
|
||||||
|
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import type { TypesPullReq, TypesRepository } from 'services/code'
|
import type { TypesPullReq, TypesRepository } from 'services/code'
|
||||||
import { getErrorMessage } from 'utils/Utils'
|
import { getErrorMessage } from 'utils/Utils'
|
||||||
|
@ -18,3 +18,30 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.copyContainer {
|
||||||
|
background-color: var(--primary-1) !important;
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
border-radius: 4px !important;
|
||||||
|
--button-height: unset !important;
|
||||||
|
--text-color: unset !important;
|
||||||
|
padding: unset !important ;
|
||||||
|
--padding-right: 2px !important;
|
||||||
|
padding-left: 8px !important;
|
||||||
|
min-width: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.linkText {
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
background-color: var(--primary-1) !important;
|
||||||
|
color: var(--primary-7) !important;
|
||||||
|
border-radius: 4px;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 2px 6px !important;
|
||||||
|
width: fit-content !important;
|
||||||
|
}
|
||||||
|
@ -5,5 +5,8 @@ declare const styles: {
|
|||||||
readonly metaline: string
|
readonly metaline: string
|
||||||
readonly time: string
|
readonly time: string
|
||||||
readonly layout: string
|
readonly layout: string
|
||||||
|
readonly copyContainer: string
|
||||||
|
readonly linkText: string
|
||||||
|
readonly link: string
|
||||||
}
|
}
|
||||||
export default styles
|
export default styles
|
||||||
|
@ -2,14 +2,13 @@ import React from 'react'
|
|||||||
import { Container, Text, Layout, StringSubstitute } from '@harness/uicore'
|
import { Container, Text, Layout, StringSubstitute } from '@harness/uicore'
|
||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
import ReactTimeago from 'react-timeago'
|
import ReactTimeago from 'react-timeago'
|
||||||
import { CodeIcon, type GitInfoProps } from 'utils/GitUtils'
|
import type { GitInfoProps } from 'utils/GitUtils'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import type { TypesPullReq } from 'services/code'
|
import type { TypesPullReq } from 'services/code'
|
||||||
import { PullRequestStateLabel } from 'components/PullRequestStateLabel/PullRequestStateLabel'
|
import { PullRequestStateLabel } from 'components/PullRequestStateLabel/PullRequestStateLabel'
|
||||||
import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator'
|
import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator'
|
||||||
import { GitRefLink } from 'components/GitRefLink/GitRefLink'
|
import { GitRefLink } from 'components/GitRefLink/GitRefLink'
|
||||||
import { CopyButton } from 'components/CopyButton/CopyButton'
|
|
||||||
import css from './PullRequestMetaLine.module.scss'
|
import css from './PullRequestMetaLine.module.scss'
|
||||||
|
|
||||||
export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 'repoMetadata'>> = ({
|
export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 'repoMetadata'>> = ({
|
||||||
@ -32,12 +31,14 @@ export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 're
|
|||||||
<GitRefLink
|
<GitRefLink
|
||||||
text={target_branch as string}
|
text={target_branch as string}
|
||||||
url={routes.toCODERepository({ repoPath: repoMetadata.path as string, gitRef: target_branch })}
|
url={routes.toCODERepository({ repoPath: repoMetadata.path as string, gitRef: target_branch })}
|
||||||
|
showCopy
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
source: (
|
source: (
|
||||||
<GitRefLink
|
<GitRefLink
|
||||||
text={source_branch as string}
|
text={source_branch as string}
|
||||||
url={routes.toCODERepository({ repoPath: repoMetadata.path as string, gitRef: source_branch })}
|
url={routes.toCODERepository({ repoPath: repoMetadata.path as string, gitRef: source_branch })}
|
||||||
|
showCopy
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -48,15 +49,6 @@ export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 're
|
|||||||
<PullRequestStateLabel data={{ is_draft, state }} />
|
<PullRequestStateLabel data={{ is_draft, state }} />
|
||||||
<Text className={css.metaline}>
|
<Text className={css.metaline}>
|
||||||
<StringSubstitute str={getString('pr.metaLine')} vars={vars} />
|
<StringSubstitute str={getString('pr.metaLine')} vars={vars} />
|
||||||
{source_branch ? (
|
|
||||||
<CopyButton
|
|
||||||
content={source_branch}
|
|
||||||
tooltip={getString('copyBranch')}
|
|
||||||
icon={CodeIcon.Copy}
|
|
||||||
iconProps={{ size: 14 }}
|
|
||||||
padding={{ bottom: 'xsmall' }}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<PipeSeparator height={9} />
|
<PipeSeparator height={9} />
|
||||||
|
@ -145,6 +145,7 @@ export default function PullRequests() {
|
|||||||
repoPath: repoMetadata?.path as string,
|
repoPath: repoMetadata?.path as string,
|
||||||
gitRef: row.original.target_branch
|
gitRef: row.original.target_branch
|
||||||
})}
|
})}
|
||||||
|
showCopy={false}
|
||||||
/>
|
/>
|
||||||
<Text color={Color.GREY_500}>←</Text>
|
<Text color={Color.GREY_500}>←</Text>
|
||||||
<GitRefLink
|
<GitRefLink
|
||||||
@ -153,6 +154,7 @@ export default function PullRequests() {
|
|||||||
repoPath: repoMetadata?.path as string,
|
repoPath: repoMetadata?.path as string,
|
||||||
gitRef: row.original.source_branch
|
gitRef: row.original.source_branch
|
||||||
})}
|
})}
|
||||||
|
showCopy={false}
|
||||||
/>
|
/>
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useMemo, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { Container, Layout, FlexExpander, DropDown, ButtonVariation } from '@harness/uicore'
|
import { Container, Layout, FlexExpander, ButtonVariation } from '@harness/uicore'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import { GitBranchType, CodeIcon, GitInfoProps } from 'utils/GitUtils'
|
import { GitBranchType, CodeIcon, GitInfoProps } from 'utils/GitUtils'
|
||||||
import { SearchInputWithSpinner } from 'components/SearchInputWithSpinner/SearchInputWithSpinner'
|
import { SearchInputWithSpinner } from 'components/SearchInputWithSpinner/SearchInputWithSpinner'
|
||||||
|
@ -104,7 +104,7 @@ export default function RepositoryCommits() {
|
|||||||
null}
|
null}
|
||||||
{(repoMetadata && (!commitRef || pageBrowser.page) && !!commits?.commits?.length && (
|
{(repoMetadata && (!commitRef || pageBrowser.page) && !!commits?.commits?.length && (
|
||||||
<Container padding="xlarge" className={css.resourceContent}>
|
<Container padding="xlarge" className={css.resourceContent}>
|
||||||
<Container className={css.contentHeader}>
|
<Container className={css.contentHeader} padding={{ bottom: 'xlarge' }}>
|
||||||
<Layout.Horizontal spacing="medium">
|
<Layout.Horizontal spacing="medium">
|
||||||
<BranchTagSelect
|
<BranchTagSelect
|
||||||
repoMetadata={repoMetadata}
|
repoMetadata={repoMetadata}
|
||||||
|
Loading…
Reference in New Issue
Block a user