diff --git a/packages/ui/src/components/avatar.tsx b/packages/ui/src/components/avatar.tsx index 2563ed882b..8fc2e38395 100644 --- a/packages/ui/src/components/avatar.tsx +++ b/packages/ui/src/components/avatar.tsx @@ -37,7 +37,7 @@ export interface AvatarProps extends ComponentPropsWithoutRef<'span'> { } const Avatar = forwardRef( - ({ name, src, size = 'md', rounded = false, className, ...props }, ref) => { + ({ name, src, size = 'sm', rounded = false, className, ...props }, ref) => { const initials = getInitials(name || '') return ( diff --git a/packages/ui/src/components/branch-tag.tsx b/packages/ui/src/components/branch-tag.tsx index d31d69e472..96d72f5bad 100644 --- a/packages/ui/src/components/branch-tag.tsx +++ b/packages/ui/src/components/branch-tag.tsx @@ -1,4 +1,4 @@ -import { CopyTag, Link } from '@/components' +import { CopyTag, Link, Tag } from '@/components' import type { TagProps } from './tag' @@ -7,6 +7,7 @@ interface BranchTagProps { spaceId?: string repoId?: string hideBranchIcon?: boolean + hideCopyButton?: boolean theme?: TagProps['theme'] variant?: TagProps['variant'] size?: TagProps['size'] @@ -17,13 +18,16 @@ const BranchTag: React.FC = ({ spaceId, repoId, hideBranchIcon, + hideCopyButton, theme = 'gray', variant = 'secondary', size = 'md' }) => { + const TagComponent = hideCopyButton ? Tag : CopyTag + return ( - ( - ({ actions, iconName = 'more-vert', sideOffset = 2, alignOffset = 0, className, buttonVariant = 'ghost' }, ref) => { + ( + { theme, actions, iconName = 'more-vert', sideOffset = 2, alignOffset = 0, className, buttonVariant = 'ghost' }, + ref + ) => { const { Link } = useRouterContext() if (!actions.length) return <> @@ -38,6 +42,7 @@ export const MoreActionsTooltip = forwardRef - {showDeleteBranchButton ? ( - - ) : showRestoreBranchButton ? ( - - ) : null} - - - {headerMsg && ( -
- {headerMsg} -
- )} - - ) - } - return ( -
- - {isDraft - ? 'This pull request is still a work in progress' + + {isDraft + ? 'This pull request is still a work in progress' + : isMerged + ? 'This pull request is merged' : isClosed ? 'This pull request is closed' : unchecked @@ -223,8 +152,7 @@ const HeaderTitle = ({ ...props }: HeaderProps) => { : isFastForwardNotPossible ? 'Cannot merge pull request' : `Pull request can be merged`} - -
+ ) } @@ -254,7 +182,7 @@ const getButtonState = ({ checksNotAllowingMerge = true } }) - if (checksNotAllowingMerge) { + if (checksNotAllowingMerge || isMergeable === false) { return { disabled: canBypass ? !checkboxBypass : true, theme: 'danger', @@ -384,7 +312,6 @@ const PullRequestPanel = ({ onMergeMethodSelect, ...routingProps }: PullRequestPanelProps) => { - const { Link } = useRouterContext() const [notBypassable, setNotBypassable] = useState(false) const [mergeButtonValue, setMergeButtonValue] = useState(() => { const firstEnabledAction = actions.find(action => !action.disabled) @@ -564,17 +491,12 @@ const PullRequestPanel = ({ const prState = getPrState() const headerRowBgClass = cn({ 'bg-cn-green-surface': prState === PrState.Success, - 'bg-cn-2': prState === PrState.Draft, + 'bg-cn-1': prState === PrState.Draft, 'bg-cn-red-surface': prState === PrState.Error, - 'bg-cn-gray-surface': prState === PrState.Closed, + 'bg-cn-brand-surface': prState === PrState.Closed, 'bg-cn-purple-surface': prState === PrState.Merged }) - const headerTitleColorClass = cn({ - 'text-cn-success': prState === PrState.Success, - 'text-cn-danger': prState === PrState.Error - }) - const shouldShowConfirmation = actions && !pullReqMetadata?.closed && (showActionBtn || isMerging || mergeInitiated) const shouldShowSplitButton = @@ -586,34 +508,40 @@ const PullRequestPanel = ({ !mergeInitiated const shouldShowMoreActions = !shouldShowConfirmation && isOpen + const areRulesBypassed = pullReqMetadata?.merge_violations_bypassed + const mergeMethod = getMergeMethodDisplay(pullReqMetadata?.merge_method as MergeStrategy) return ( <> - + - - + } /> @@ -621,21 +549,12 @@ const PullRequestPanel = ({ <> - {!!commitSuggestionsBatchCount && ( - - - - )} - + {!notBypassable && isMergeable && !isDraft && prPanelData.ruleViolation && ( )} + {shouldShowMoreActions && ( + handlePrState('draft'), + iconName: 'page-edit' as const + } + ] + : []), + { + title: 'Close pull request', + onClick: () => handlePrState('closed'), + iconName: 'git-pull-request-closed' + }, + ...(isRebasable + ? [ + { + title: 'Rebase', + onClick: () => handleRebaseBranch(), + iconName: 'git-rebase' as const + } + ] + : []) + ]} + /> + )} + + {!!commitSuggestionsBatchCount && ( + + + + )} + + {/* When in merge input mode or merging, show Cancel/Confirm buttons */} + {shouldShowConfirmation && ( + + + + + )} + + {actions?.length === 1 && ( + + )} + {/*Only show SplitButton if we're not in any merge-related state*/} {shouldShowSplitButton && ( )} - - {/* When in merge input mode or merging, show Cancel/Confirm buttons */} - {shouldShowConfirmation && ( - - - - - )} - - {actions?.length === 1 && ( - - )} - - {shouldShowMoreActions && ( - handlePrState('draft'), - iconName: 'page-edit' as const - } - ] - : []), - { - title: 'Close pull request', - onClick: () => handlePrState('closed'), - iconName: 'git-pull-request-closed' - }, - ...(isRebasable - ? [ - { - title: 'Rebase', - onClick: () => handleRebaseBranch(), - iconName: 'git-rebase' as const - } - ] - : []) - ]} - /> - )} } /> {showMergeInputs && ( - - - ) => setMergeTitle(e.target.value)} - optional - placeholder="Enter commit message (optional)" - /> -