Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 58x 58x 58x 58x 58x 58x 58x 58x 58x 58x 58x 65x 65x 65x 65x 65x 65x 65x 43x 108x 108x 65x 22x 43x 58x 64x | /*
* Copyright 2021 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
import React from 'react'
import { IPopoverProps, PopoverInteractionKind } from '@blueprintjs/core'
import { Icon, Layout, Popover, Text } from '@wings-software/uicore'
import type { IconProps } from '@wings-software/uicore/dist/icons/Icon'
import { Color } from '@harness/design-system'
import { getRepoDetailsByIndentifier } from '@common/utils/gitSyncUtils'
import type { EntityGitDetails } from 'services/pipeline-ng'
import { useStrings } from 'framework/strings'
import { useGitSyncStore } from 'framework/GitRepoStore/GitSyncStoreContext'
import { getEntityUrl, getRepoEntityObject } from '@gitsync/common/gitSyncUtils'
import type { GitSyncEntityDTO } from 'services/cd-ng'
import GitPopoverInfo, { GitPopoverInfoProps } from './GitPopoverInfo'
export interface GitPopoverProps {
data: EntityGitDetails
iconProps?: Omit<IconProps, 'name'>
popoverProps?: IPopoverProps
customUI?: JSX.Element
}
const breakWord = 'break-word'
export function RenderGitPopover(props: GitPopoverProps): React.ReactElement | null {
const { getString } = useStrings()
const { data, iconProps, popoverProps, customUI } = props
const { gitSyncRepos, loadingRepos } = useGitSyncStore()
const repo = getRepoDetailsByIndentifier(data?.repoIdentifier, gitSyncRepos)
const repoEntity: GitSyncEntityDTO = getRepoEntityObject(repo, data)
const popoverContent: GitPopoverInfoProps[] = [
{
heading: getString('repository'),
content: (!loadingRepos && getRepoDetailsByIndentifier(data?.repoIdentifier, gitSyncRepos)?.name) || '',
iconName: 'repository'
},
{
heading: getString('common.git.filePath'),
content: getEntityUrl(repoEntity),
iconName: 'repository',
contentTextProps: {
style: { wordWrap: breakWord, maxWidth: '200px' },
lineClamp: 1
}
},
{
heading: getString('pipelineSteps.deploy.inputSet.branch'),
content: data.branch || '',
iconName: 'git-new-branch'
}
]
const gitPopover = React.useCallback(() => {
return (
<Popover interactionKind={PopoverInteractionKind.HOVER} {...popoverProps}>
<Icon
name={'service-github'}
color={Color.GREY_700}
{...iconProps}
size={iconProps?.size || 16}
data-testid={'git-popover'}
/>
<Layout.Vertical padding={{ top: 'large', bottom: 'large', left: 'xlarge', right: 'xlarge' }}>
<Text font={{ size: 'small', weight: 'bold' }} color={Color.BLACK}>
{getString('pipeline.gitDetails').toUpperCase()}
</Text>
{customUI ?? (
<>
{popoverContent.map((item: GitPopoverInfoProps) => {
const key = `${item.content}-${item.heading}`
return <GitPopoverInfo key={key} {...item} />
})}
</>
)}
</Layout.Vertical>
</Popover>
)
}, [gitSyncRepos, data, loadingRepos, iconProps, popoverProps])
if (!data.repoIdentifier) {
return null
}
return <>{gitPopover()}</>
}
export default function GitPopover(props: GitPopoverProps): React.ReactElement | null {
return <RenderGitPopover {...props} />
}
|