Merge branch 'code-217' of _OKE5H2PQKOUfzFFDuD4FA/default/CODE/gitness (#28)

This commit is contained in:
Calvin Lee 2023-04-18 17:59:57 +00:00 committed by Harness
commit 656cf907e0
11 changed files with 50 additions and 12 deletions

View File

@ -31,9 +31,10 @@ interface PrReviewOption {
interface ReviewSplitButtonProps extends Pick<GitInfoProps, 'repoMetadata'> {
shouldHide: boolean
pullRequestMetadata?: TypesPullReq
refreshPr: () => void
}
const ReviewSplitButton = (props: ReviewSplitButtonProps) => {
const { pullRequestMetadata, repoMetadata, shouldHide } = props
const { pullRequestMetadata, repoMetadata, shouldHide, refreshPr } = props
const { getString } = useStrings()
const { showError, showSuccess } = useToaster()
@ -69,6 +70,7 @@ const ReviewSplitButton = (props: ReviewSplitButtonProps) => {
.then(() => {
// setReset(true)
showSuccess(getString('pr.reviewSubmitted'))
refreshPr()
})
.catch(exception => showError(getErrorMessage(exception)))
}, [decisionOption, mutate, showError, showSuccess, getString])

View File

@ -1,7 +1,19 @@
import React, { useCallback, useRef, useState } from 'react'
import { useResizeDetector } from 'react-resize-detector'
import { Render, Match, Truthy, Falsy, Else } from 'react-jsx-match'
import { Container, Layout, Avatar, TextInput, Text, Color, FontVariation, FlexExpander } from '@harness/uicore'
import {
Container,
Layout,
Avatar,
TextInput,
Text,
Color,
FontVariation,
FlexExpander,
Button,
ButtonVariation,
ButtonSize
} from '@harness/uicore'
import cx from 'classnames'
import ReactTimeago from 'react-timeago'
import { noop } from 'lodash-es'
@ -140,6 +152,10 @@ export const CommentBox = <T = unknown,>({
<Layout.Horizontal spacing="small" className={css.replyPlaceHolder} padding="medium">
<Avatar name={currentUserName} size="small" hoverCard={false} />
<TextInput placeholder={getString('replyHere')} onFocus={hidePlaceHolder} onClick={hidePlaceHolder} />
<Button
text={<strong>{getString('resolve')}</strong>}
variation={ButtonVariation.TERTIARY}
size={ButtonSize.SMALL}></Button>
</Layout.Horizontal>
</Container>
</Truthy>

View File

@ -48,7 +48,7 @@ export function RepositoryPageHeader({
</Fragment>
))}
</Layout.Horizontal>
<Container padding={{ top: 'xsmall', bottom: 'small' }}>
<Container padding={{ top: 'large', bottom: 'small' }}>
{typeof title === 'string' ? (
<Text tag="h1" font={{ variation: FontVariation.H4 }} tooltipProps={{ dataTooltipId }}>
{title}

View File

@ -265,6 +265,7 @@ export interface StringsMap {
requestChanges: string
required: string
resetZoom: string
resolve: string
resolved: string
reviewers: string
samplePayloadUrl: string

View File

@ -361,3 +361,4 @@ dangerDeleteRepo: Danger, are you sure you want to delete it?
repoUpdate: Repository Updated
deleteRepoText: Are you sure you want to delete the repository '{REPONAME}'?
deleteRepoTitle: Delete the repository
resolve: Resolve

View File

@ -147,6 +147,7 @@ export const PullRequestActionsBox: React.FC<PullRequestActionsBoxProps> = ({
shouldHide={(pullRequestMetadata?.state as EnumPullReqState) === 'merged'}
repoMetadata={repoMetadata}
pullRequestMetadata={pullRequestMetadata}
refreshPr={onPRStateChanged}
/>
<Container
inline

View File

@ -11,6 +11,8 @@
padding-right: var(--spacing-small);
}
.noReviewerText {
padding-left: var(--spacing-13) !important;
.semiBoldText {
font-weight: 500 !important;
line-height: 18px !important;
--typography-color: var(--grey-500) !important;
}

View File

@ -4,6 +4,6 @@ declare const styles: {
readonly reviewerPadding: string
readonly reviewerName: string
readonly reviewerAvatar: string
readonly noReviewerText: string
readonly semiBoldText: string
}
export default styles

View File

@ -71,7 +71,7 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
<Button variation={ButtonVariation.TERTIARY} size={ButtonSize.SMALL} text={'Add +'}></Button>
</Layout.Horizontal>
<Container padding={{ top: 'medium', bottom: 'large' }}>
<Text padding={{ bottom: 'medium' }} font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
<Text className={css.semiBoldText} padding={{ bottom: 'medium' }} font={{ variation: FontVariation.FORM_LABEL, size: 'small' }}>
{getString('required')}
</Text>
{reviewers && reviewers?.length !== 0 ? (
@ -120,13 +120,13 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
)
) : (
<Text
className={css.noReviewerText}
color={Color.GREY_300}
font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
{getString('noRequiredReviewers')}
</Text>
)}
<Text
className={css.semiBoldText}
padding={{ top: 'medium', bottom: 'medium' }}
font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
{getString('optional')}
@ -175,7 +175,6 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
})
) : (
<Text
className={css.noReviewerText}
color={Color.GREY_300}
font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}>
{getString('noOptionalReviewers')}

View File

@ -35,6 +35,8 @@
display: flex;
align-items: center;
height: 24px;
margin-top: var(--spacing-8);
> svg {
display: inline-block;
@ -52,6 +54,10 @@
padding: 3px 6px !important;
}
}
.tabTitle:not:first-child {
margin-left: var(--spacing-8) !important;
}
}
}

View File

@ -12,7 +12,9 @@ import {
ButtonVariation,
ButtonSize,
TextInput,
useToaster
useToaster,
Spacing,
PaddingProps
} from '@harness/uicore'
import { useGet, useMutate } from 'restful-react'
import { Render, Match, Truthy, Else } from 'react-jsx-match'
@ -167,6 +169,7 @@ export default function PullRequest() {
icon={CodeIcon.Commit}
title={getString('commits')}
count={prData?.stats?.commits || 0}
padding={{ left: 'medium' }}
/>
),
panel: (
@ -185,6 +188,7 @@ export default function PullRequest() {
icon={CodeIcon.File}
title={getString('filesChanged')}
count={prData?.stats?.files_changed || 0}
padding={{ left: 'medium' }}
/>
),
panel: (
@ -211,6 +215,7 @@ export default function PullRequest() {
icon={CodeIcon.ChecksSuccess}
title={getString('checks')}
count={0} // TODO: Count for checks when API supports it
padding={{ left: 'medium' }}
/>
),
panel: <Checks />
@ -311,13 +316,18 @@ const PullRequestTitle: React.FC<PullRequestTitleProps> = ({ repoMetadata, title
)
}
const TabTitle: React.FC<{ icon: IconName; title: string; count?: number }> = ({ icon, title, count }) => {
const TabTitle: React.FC<{ icon: IconName; title: string; count?: number; padding?: Spacing | PaddingProps }> = ({
icon,
title,
count,
padding
}) => {
// Icon inside a tab got overriden-and-looked-bad styles from UICore
// on hover. Use icon directly instead
const TabIcon: React.ElementType = HarnessIcons[icon]
return (
<Text className={css.tabTitle}>
<Text className={css.tabTitle} padding={padding}>
<TabIcon width={16} height={16} />
{title}
<Render when={count}>