Skip to content

Commit 4b89a8c

Browse files
add pr status header design review
1 parent b0e32d9 commit 4b89a8c

File tree

12 files changed

+269
-250
lines changed

12 files changed

+269
-250
lines changed

apps/gitness/src/pages-v2/pull-request/hooks/usePRChecksDecision.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,45 @@ export function usePRChecksDecision({
4747
status: string
4848
}>({ title: '', content: '', color: '', status: '' })
4949

50+
const checks = [
51+
{
52+
bypassable: true,
53+
required: false,
54+
check: {
55+
created: 0,
56+
ended: 0,
57+
id: 1,
58+
identifier: 'some',
59+
link: '',
60+
metadata: {},
61+
payload: {
62+
data: {},
63+
kind: 'pipeline',
64+
version: '1.0.0'
65+
},
66+
reported_by: '',
67+
started: 0,
68+
status: 'success',
69+
summary: 'some text',
70+
updated: 0
71+
}
72+
}
73+
]
74+
5075
const status = useMemo(() => {
5176
let _status: ExecutionState | undefined
5277
const _count = { ...DEFAULT_COUNTS }
53-
const total = data?.checks?.length
78+
const total = checks?.length
5479
// @ts-expect-error remove "@ts-expect-error" once CodeServiceClient Response for useChecksPullReqQuery is fixed
55-
const { message: summaryMessage } = generateStatusSummary(data?.checks)
80+
const { message: summaryMessage } = generateStatusSummary(checks)
5681
setSummaryText(summaryMessage)
5782
// @ts-expect-error remove "@ts-expect-error" once CodeServiceClient Response for useChecksPullReqQuery is fixed
58-
const checkInfoData = determineStatusMessage(data?.checks)
83+
const checkInfoData = determineStatusMessage(checks)
5984
if (checkInfoData) {
6085
setCheckInfo(checkInfoData)
6186
}
6287
if (total) {
63-
for (const check of (data as Data).checks) {
88+
for (const check of checks) {
6489
switch (check.check.status) {
6590
case ExecutionState.ERROR:
6691
case ExecutionState.FAILURE:
@@ -140,7 +165,7 @@ export function usePRChecksDecision({
140165
}
141166

142167
return _status
143-
}, [data])
168+
}, [])
144169

145170
// *******
146171
// NOTE: TODO: refactor this to make it more clear and readable
@@ -169,7 +194,7 @@ export function usePRChecksDecision({
169194
overallStatus: status,
170195
count,
171196
error,
172-
data,
197+
data: { ...data, checks },
173198
color,
174199
background,
175200
message,

apps/gitness/src/pages-v2/pull-request/pull-request-conversation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default function PullRequestConversationPage() {
190190
pullReqCommits: state.pullReqCommits,
191191
repoMetadata: state.repoMetadata
192192
}))
193+
console.log('🚀 ~ PullRequestConversationPage ~ pullReqChecksDecision:', pullReqChecksDecision)
193194

194195
const { currentUser: currentUserData } = useAppContext()
195196

packages/ui/src/components/avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const avatarVariants = cva('cn-avatar', {
2222
}
2323
},
2424
defaultVariants: {
25-
size: 'sm',
25+
size: 'md',
2626
rounded: false
2727
}
2828
})

packages/ui/src/components/branch-tag.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface BranchTagProps {
77
spaceId?: string
88
repoId?: string
99
hideBranchIcon?: boolean
10+
hideCopyButton?: boolean
1011
theme?: TagProps['theme']
1112
variant?: TagProps['variant']
1213
size?: TagProps['size']
@@ -17,6 +18,7 @@ const BranchTag: React.FC<BranchTagProps> = ({
1718
spaceId,
1819
repoId,
1920
hideBranchIcon,
21+
hideCopyButton,
2022
theme = 'gray',
2123
variant = 'secondary',
2224
size = 'md'
@@ -29,6 +31,7 @@ const BranchTag: React.FC<BranchTagProps> = ({
2931
size={size}
3032
icon={hideBranchIcon ? undefined : 'git-branch'}
3133
value={branchName || ''}
34+
hideCopyButton={hideCopyButton}
3235
/>
3336
</Link>
3437
)

packages/ui/src/components/copy-tag.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import { Tag, TagProps } from './tag'
77
type CopyTagProps = TagProps & {
88
actionIcon?: never
99
onActionClick?: never
10+
hideCopyButton?: boolean
1011
}
1112

12-
export function CopyTag(props: CopyTagProps) {
13+
export function CopyTag({ hideCopyButton, ...props }: CopyTagProps) {
1314
const { value } = props
1415

1516
const [copied, setCopied] = useState(false)
@@ -32,5 +33,7 @@ export function CopyTag(props: CopyTagProps) {
3233
})
3334
}, [value])
3435

35-
return <Tag {...props} actionIcon={copied ? 'check' : 'copy'} onActionClick={handleCopy} />
36+
return (
37+
<Tag {...props} actionIcon={!hideCopyButton ? (copied ? 'check' : 'copy') : undefined} onActionClick={handleCopy} />
38+
)
3639
}

packages/ui/src/components/more-actions-tooltip.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FC } from 'react'
22

33
import { useRouterContext } from '@/context'
4-
import { Button, ButtonVariants } from '@components/button'
4+
import { Button, ButtonProps, ButtonVariants } from '@components/button'
55
import { DropdownMenu } from '@components/dropdown-menu'
66
import { IconV2, type IconPropsV2 } from '@components/icon-v2'
77
import { cn } from '@utils/cn'
@@ -17,6 +17,7 @@ export interface ActionData {
1717
}
1818

1919
export interface MoreActionsTooltipProps {
20+
theme?: ButtonProps['theme']
2021
actions: ActionData[]
2122
isInTable?: boolean
2223
iconName?: IconPropsV2['name']
@@ -30,6 +31,7 @@ export interface MoreActionsTooltipProps {
3031
* A component for displaying a button that, when clicked, shows a tooltip with a list of actions.
3132
*/
3233
export const MoreActionsTooltip: FC<MoreActionsTooltipProps> = ({
34+
theme,
3335
actions,
3436
iconName = 'more-vert',
3537
sideOffset = 2,
@@ -44,6 +46,7 @@ export const MoreActionsTooltip: FC<MoreActionsTooltipProps> = ({
4446
<DropdownMenu.Root>
4547
<DropdownMenu.Trigger asChild>
4648
<Button
49+
theme={theme}
4750
className={cn('text-icons-1 hover:text-icons-2 data-[state=open]:text-icons-2')}
4851
variant={buttonVariant}
4952
iconOnly

packages/ui/src/views/repo/pull-request/components/pull-request-side-bar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const PullRequestSideBar: FC<PullRequestSideBarProps> = ({
7474
}) => {
7575
return (
7676
<Layout.Vertical gap="md">
77-
<Layout.Vertical gap="md">
77+
<Layout.Vertical gap="2xs">
7878
<ReviewersHeader
7979
currentUserId={currentUserId}
8080
usersList={usersList}
@@ -95,7 +95,7 @@ export const PullRequestSideBar: FC<PullRequestSideBarProps> = ({
9595
/>
9696
</Layout.Vertical>
9797
{!isCreatingPr ? (
98-
<Layout.Vertical gap="md">
98+
<Layout.Vertical gap="2xs">
9999
<LabelsHeader
100100
labelsList={labelsList}
101101
labelsValues={labelsValues}

packages/ui/src/views/repo/pull-request/components/reviewers/pull-request-reviewers-header.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { useMemo, useRef } from 'react'
22

3-
import { Button, DropdownMenu, IconV2, SearchInput, Text, useSearchableDropdownKeyboardNavigation } from '@/components'
3+
import {
4+
Button,
5+
DropdownMenu,
6+
IconV2,
7+
Layout,
8+
SearchInput,
9+
Text,
10+
useSearchableDropdownKeyboardNavigation
11+
} from '@/components'
412
import { useTranslation } from '@/context'
513
import { PrincipalType } from '@/types'
614
import { PRReviewer } from '@/views'
@@ -46,7 +54,7 @@ const ReviewersHeader = ({
4654
const handleCloseValuesView = useRef(debounce(() => handleSearchQuery(''), 300)).current
4755

4856
return (
49-
<div className="mb-0.5 flex items-center justify-between">
57+
<Layout.Flex align="center" justify="between">
5058
<Text as="h5" variant="body-strong" color="foreground-1">
5159
{t('views:pullRequests.reviewers', 'Reviewers')}
5260
</Text>
@@ -94,7 +102,7 @@ const ReviewersHeader = ({
94102
})}
95103
</DropdownMenu.Content>
96104
</DropdownMenu.Root>
97-
</div>
105+
</Layout.Flex>
98106
)
99107
}
100108

packages/ui/src/views/repo/pull-request/components/reviewers/pull-request-reviewers-list.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Alert } from '@components/alert'
2+
import { Layout } from '@components/layout'
23
import { Text } from '@components/text'
34

45
import { EnumPullReqReviewDecision, PullReqReviewDecision } from '../../pull-request.types'
@@ -28,13 +29,14 @@ const ReviewersList: React.FC<ReviewersListProps> = ({
2829
addReviewerError,
2930
removeReviewerError
3031
}) => (
31-
<div className="flex flex-col gap-3">
32-
{addReviewerError || removeReviewerError ? (
33-
<Alert.Root theme="danger">
34-
<Alert.Title>Failed to add reviewer</Alert.Title>
35-
<Alert.Description>{addReviewerError ?? removeReviewerError}</Alert.Description>
36-
</Alert.Root>
37-
) : null}
32+
<Layout.Vertical gapY="md">
33+
{addReviewerError ||
34+
(removeReviewerError && (
35+
<Alert.Root theme="danger">
36+
<Alert.Title>Failed to add reviewer</Alert.Title>
37+
<Alert.Description>{addReviewerError ?? removeReviewerError}</Alert.Description>
38+
</Alert.Root>
39+
))}
3840

3941
{reviewers.length ? (
4042
reviewers.map(({ reviewer, review_decision, sha }) => (
@@ -52,7 +54,7 @@ const ReviewersList: React.FC<ReviewersListProps> = ({
5254
No reviewers
5355
</Text>
5456
)}
55-
</div>
57+
</Layout.Vertical>
5658
)
5759

5860
export { ReviewersList }

0 commit comments

Comments
 (0)