Skip to content

Commit

Permalink
fix: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgolovanov committed Jan 15, 2025
1 parent 7429415 commit a2e937a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { timeAgo } from '@utils/utils'
import { IconType } from '../pull-request.types'
import { getPrState } from '../utils'

type ThemeType = 'default' | 'destructive' | 'warning' | 'success' | 'emphasis' | 'muted' | null | undefined
type ThemeType = 'default' | 'destructive' | 'success' | 'emphasis' | 'muted' | null | undefined
interface PullRequestTitleProps {
data: {
title?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DropdownMenuItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuShortcut,
DropdownMenuTrigger,
Icon,
Layout,
Expand Down Expand Up @@ -202,10 +201,12 @@ const PullRequestPanel = ({
setNotBypassable(checkIfBypassAllowed)
}
}, [ruleViolationArr])

const rebasePossible = useMemo(
() => pullReqMetadata?.merge_target_sha !== pullReqMetadata?.merge_base_sha && !pullReqMetadata?.merged,
[pullReqMetadata]
)

const moreTooltip = () => {
return (
<DropdownMenu>
Expand All @@ -214,39 +215,33 @@ const PullRequestPanel = ({
<Icon name="vertical-ellipsis" size={12} />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-[180px] rounded-[10px] border border-borders-1 bg-background-2 py-2 shadow-sm">
<DropdownMenuContent className="w-[200px]" align="end">
<DropdownMenuGroup>
<DropdownMenuItem
onClick={e => {
handlePrState('draft')

e.stopPropagation()
}}
className="cursor-pointer"
>
<DropdownMenuShortcut className="ml-0"></DropdownMenuShortcut>
{'Mark as draft'}
Mark as draft
</DropdownMenuItem>
<DropdownMenuItem
onClick={e => {
handlePrState('closed')
e.stopPropagation()
}}
className="cursor-pointer"
>
<DropdownMenuShortcut className="ml-0"></DropdownMenuShortcut>
{'Close pull request'}
Close pull request
</DropdownMenuItem>
{rebasePossible && (
<DropdownMenuItem
onClick={e => {
handleRebaseBranch()
e.stopPropagation()
}}
className="cursor-pointer"
>
<DropdownMenuShortcut className="ml-0"></DropdownMenuShortcut>
{'Rebase'}
Rebase
</DropdownMenuItem>
)}
</DropdownMenuGroup>
Expand Down Expand Up @@ -305,15 +300,15 @@ const PullRequestPanel = ({
)}
<Button
variant={actions && !pullReqMetadata?.closed ? 'split' : 'default'}
size={actions && !pullReqMetadata?.closed ? 'xs_split' : 'xs'}
size={actions && !pullReqMetadata?.closed ? 'md_split' : 'md'}
theme={
mergeable && !ruleViolation && !pullReqMetadata?.is_draft && !pullReqMetadata?.closed
? 'success'
: pullReqMetadata?.is_draft || pullReqMetadata?.closed
? 'primary'
: checksInfo.status === 'pending' || checksInfo.status === 'running'
? 'warning'
: 'error'
: 'disabled'
}
disabled={!checkboxBypass && ruleViolation}
onClick={actions[0]?.action}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/views/repo/pull-request/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const getPrState = (
state?: string
): { icon: IconType; text: string; theme: string } => {
if (state === 'open' && is_draft) {
return { icon: 'pr-draft', text: 'Draft', theme: 'warning' }
return { icon: 'pr-draft', text: 'Draft', theme: 'muted' }
} else if (merged) {
return { icon: 'pr-merge', text: 'Merged', theme: 'emphasis' }
} else if (state === 'closed') {
return { icon: 'pr-closed', text: 'Closed', theme: 'muted' }
return { icon: 'pr-closed', text: 'Closed', theme: 'destructive' }
} else {
return { icon: 'pr-open', text: 'Open', theme: 'success' }
}
Expand Down

0 comments on commit a2e937a

Please sign in to comment.