Skip to content

Commit

Permalink
Fixed type error for pull request check section
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-harness committed Jan 24, 2025
1 parent 253349d commit 31cb3c5
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ const PullRequestPanel = ({
{(!!resolvedCommentArr || requiresCommentApproval) && !pullReqMetadata?.merged && (
<PullRequestCommentSection commentsInfo={commentsInfo} />
)}
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/* @ts-ignore */}
<PullRequestCheckSection checkData={checkData} checksInfo={checksInfo} spaceId={spaceId} repoId={repoId} />

{!pullReqMetadata?.merged && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,44 @@ const PullRequestCheckSection = ({ checkData, checksInfo, spaceId, repoId }: Pul
}
}

return (
!isEmpty(checkData) && (
<AccordionItem value="item-3">
<AccordionTrigger className="text-left">
<StackedList.Field
title={<LineTitle text={checksInfo.header} icon={getStatusIcon(checksInfo.status)} />}
description={<LineDescription text={checksInfo.content} />}
/>
<Text className="pr-2" size={1}>
Show more
</Text>
</AccordionTrigger>
<AccordionContent className={cn('flex flex-col pl-6', { 'pb-0': checkData.length === 1 })}>
{checkData.map(check => {
const time = timeDistance(check?.check?.created, check?.check?.updated)
return !isEmpty(checkData) ? (
<AccordionItem value="item-3">
<AccordionTrigger className="text-left">
<StackedList.Field
title={<LineTitle text={checksInfo.header} icon={getStatusIcon(checksInfo.status)} />}
description={<LineDescription text={checksInfo.content} />}
/>
<Text className="pr-2" size={1}>
Show more
</Text>
</AccordionTrigger>
<AccordionContent className={cn('flex flex-col pl-6', { 'pb-0': checkData.length === 1 })}>
{checkData.map(check => {
const time = timeDistance(check?.check?.created, check?.check?.updated)

return (
<div key={check.check?.id} className={cn('flex items-center justify-between gap-2 border-t py-2.5')}>
<div className="flex items-center gap-2">
{getStatusIcon(check?.check?.status as EnumCheckStatus)}
<Text size={1} color="primary" truncate className="max-w-[300px] overflow-hidden">
{check?.check?.identifier}
</Text>
<Text size={1} color="tertiaryBackground">
{check?.check?.status === ExecutionState.SUCCESS
? `Succeeded in ${time}`
: check?.check?.status === ExecutionState.FAILURE
? `Failed in ${time}`
: check?.check?.status === ExecutionState.RUNNING
? 'Running...'
: check?.check?.status === ExecutionState.PENDING
? 'Pending...'
: `Errored in ${time}`}
</Text>
</div>
<div className="grid grid-cols-[84px_auto] items-center">
<div className="col-span-1">
{/* TODO: figure out how to do link in this? */}
{/* <Link
return (
<div key={check.check?.id} className={cn('flex items-center justify-between gap-2 border-t py-2.5')}>
<div className="flex items-center gap-2">
{getStatusIcon(check?.check?.status as EnumCheckStatus)}
<Text size={1} color="primary" truncate className="max-w-[300px] overflow-hidden">
{check?.check?.identifier}
</Text>
<Text size={1} color="tertiaryBackground">
{check?.check?.status === ExecutionState.SUCCESS
? `Succeeded in ${time}`
: check?.check?.status === ExecutionState.FAILURE
? `Failed in ${time}`
: check?.check?.status === ExecutionState.RUNNING
? 'Running...'
: check?.check?.status === ExecutionState.PENDING
? 'Pending...'
: `Errored in ${time}`}
</Text>
</div>
<div className="grid grid-cols-[84px_auto] items-center">
<div className="col-span-1">
{/* TODO: figure out how to do link in this? */}
{/* <Link
className="text-blue-500 mx-2"
to={
routes.toCODEPullRequest({
Expand All @@ -93,85 +92,84 @@ const PullRequestCheckSection = ({ checkData, checksInfo, spaceId, repoId }: Pul
}) + `?uid=${check?.check?.identifier}`
}
></Link> */}
{check?.check?.status !== ExecutionState.PENDING && (
<Link
to={`/${spaceId}/repos/${repoId}/pipelines/${check?.check?.identifier}/executions/${(check?.check?.payload?.data as ExecutionPayloadType).execution_number}`}
replace
>
<Text size={1} color="tertiaryBackground">
Details
</Text>
</Link>
)}
</div>
<div className="col-span-1 flex justify-end">
{check?.check?.status === ExecutionState.PENDING ? (
<Badge variant="outline" size="sm">
<Text size={1} color="tertiaryBackground">
Required
</Text>
</Badge>
) : (
<div className="min-w-[70px]"></div>
)}
</div>
{check?.check?.status !== ExecutionState.PENDING && (
<Link
to={`/${spaceId}/repos/${repoId}/pipelines/${check?.check?.identifier}/executions/${(check?.check?.payload?.data as ExecutionPayloadType).execution_number}`}
replace
>
<Text size={1} color="tertiaryBackground">
Details
</Text>
</Link>
)}
</div>
<div className="col-span-1 flex justify-end">
{check?.check?.status === ExecutionState.PENDING ? (
<Badge variant="outline" size="sm">
<Text size={1} color="tertiaryBackground">
Required
</Text>
</Badge>
) : (
<div className="min-w-[70px]"></div>
)}
</div>
</div>
)
// return (
// <div key={check_idx} className="flex justify-between py-2 border-t">
// <div className="flex items-center">
// {getStatusIcon(check?.check?.status as EnumCheckStatus)}
</div>
)
// return (
// <div key={check_idx} className="flex justify-between py-2 border-t">
// <div className="flex items-center">
// {getStatusIcon(check?.check?.status as EnumCheckStatus)}

// <div className="truncate min-w-[200px] max-w-[200px] pl-3 pt-0.5"> {check?.check?.identifier}</div>
// <div className="truncate max-w-[200px] pl-3 pt-0.5">
// {check?.check?.status === ExecutionState.SUCCESS
// ? `Succeeded in ${time}`
// : check?.check?.status === ExecutionState.FAILURE
// ? `Failed in ${time}`
// : check?.check?.status === ExecutionState.RUNNING
// ? 'Running...'
// : check?.check?.status === ExecutionState.PENDING
// ? 'Pending...'
// : `Errored in ${time}`}
// </div>
// </div>
// <div className="grid grid-cols-[84px_auto] items-center">
// <div className="col-span-1">
// {/* TODO: figure out how to do link in this? */}
// {/* <Link
// className="text-blue-500 mx-2"
// to={
// routes.toCODEPullRequest({
// repoPath: repoMetadata.path as string,
// pullRequestId: String(pullReqMetadata.number),
// pullRequestSection: PullRequestSection.CHECKS
// }) + `?uid=${check?.check?.identifier}`
// }
// ></Link> */}
// {check?.check?.status !== ExecutionState.PENDING && (
// <Text weight="medium" size={1}>
// Details
// </Text>
// )}
// </div>
// <div className="col-span-1 flex justify-end">
// {check.required ? (
// <div className="border rounded-full bg-transparent">
// <Text className="text-xs text-tertiary-background px-2 py-1.5">required</Text>
// </div>
// ) : (
// <div className="min-w-[70px]"></div>
// )}
// </div>
// </div>
// </div>
// )
})}
</AccordionContent>
</AccordionItem>
)
)
// <div className="truncate min-w-[200px] max-w-[200px] pl-3 pt-0.5"> {check?.check?.identifier}</div>
// <div className="truncate max-w-[200px] pl-3 pt-0.5">
// {check?.check?.status === ExecutionState.SUCCESS
// ? `Succeeded in ${time}`
// : check?.check?.status === ExecutionState.FAILURE
// ? `Failed in ${time}`
// : check?.check?.status === ExecutionState.RUNNING
// ? 'Running...'
// : check?.check?.status === ExecutionState.PENDING
// ? 'Pending...'
// : `Errored in ${time}`}
// </div>
// </div>
// <div className="grid grid-cols-[84px_auto] items-center">
// <div className="col-span-1">
// {/* TODO: figure out how to do link in this? */}
// {/* <Link
// className="text-blue-500 mx-2"
// to={
// routes.toCODEPullRequest({
// repoPath: repoMetadata.path as string,
// pullRequestId: String(pullReqMetadata.number),
// pullRequestSection: PullRequestSection.CHECKS
// }) + `?uid=${check?.check?.identifier}`
// }
// ></Link> */}
// {check?.check?.status !== ExecutionState.PENDING && (
// <Text weight="medium" size={1}>
// Details
// </Text>
// )}
// </div>
// <div className="col-span-1 flex justify-end">
// {check.required ? (
// <div className="border rounded-full bg-transparent">
// <Text className="text-xs text-tertiary-background px-2 py-1.5">required</Text>
// </div>
// ) : (
// <div className="min-w-[70px]"></div>
// )}
// </div>
// </div>
// </div>
// )
})}
</AccordionContent>
</AccordionItem>
) : null
}

export default PullRequestCheckSection

0 comments on commit 31cb3c5

Please sign in to comment.