Files
b05457666f Add review requested at (#36877)
* allow creating branching without git

* update branching modals

* add account connections

* edit branch

* copy

* update copy

* enable branch modal changes

* add gitless branching flag

* update account connections

* merge page

* merge experiment

* update merge

* update pull requests empty state

* use diff query

* branch diffing

* diff query

* Clean up

* refinements to gitless branching

* branching merge and status

* link

* branch function diffing

* update styling

* refactor

* remove hook

* error handling

* move

* remove enable branching modal

* re-add github linker

* abstract away enable and disable

* toggle fixes

* update logic to lean on connection status

* update form logic

* sheet layout

* gitless flag

* style and workflow updates

* fix side panel size

* fix duplicate onerror

* copy changes

* refetch

* merge mutation copy

* remove import

* add cost

* allow connection details on create

* initial queries

* push button

* merge cleanup

* Fix TS issues

* Fix TS issues

* Couple of clean ups

* Revert hardcode in useFlag

* Fix TS

* layout issues and github check

* refactor

* refactor to use new field

* cleanup

* style

* failed merge

* error positioning

* refactoring merge

* workflow refactor

* hook move

* clarification with github integration

* replace branch dropdown button

* update repo picker

* updates

* remove modal

* fix small nits

* change defaults

* clean up

* disable if not gitless and no connection

* clean up

* always show workflow run id

* optimistic

* fix branch query

* fix issues

* fetch edge diff

* confirm merge

* update edge functions key

* add review requested at

* gitless check

* request review

* use requestReview

* use new review boolean

* unnecessary comment

* ready for review route

* hide removed functions for now

* type fix

* codegen

* Fix the types.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
Co-authored-by: Alaister Young <a@alaisteryoung.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-07-09 20:45:28 +10:00

102 lines
2.9 KiB
TypeScript

import dayjs from 'dayjs'
import { MoreVertical, X } from 'lucide-react'
import { useRouter } from 'next/router'
import { useParams } from 'common'
import { useBranchUpdateMutation } from 'data/branches/branch-update-mutation'
import type { Branch } from 'data/branches/branches-query'
import { branchKeys } from 'data/branches/keys'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from 'ui'
import { toast } from 'sonner'
import { useQueryClient } from '@tanstack/react-query'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
interface ReviewRowProps {
branch: Branch
}
export const ReviewRow = ({ branch }: ReviewRowProps) => {
const router = useRouter()
const project = useSelectedProject()
const { ref: projectRef } = useParams()
const queryClient = useQueryClient()
const { mutate: updateBranch, isLoading: isUpdating } = useBranchUpdateMutation({
onSuccess: () => {
toast.success('Branch marked as not ready for review')
queryClient.invalidateQueries({
queryKey: branchKeys.list(project?.parent_project_ref || projectRef),
})
},
onError: (error) => {
toast.error(`Failed to update branch: ${error.message}`)
},
})
const handleRowClick = () => {
router.push(`/project/${branch.project_ref}/merge`)
}
const handleNotReadyForReview = (e?: Event) => {
e?.preventDefault()
e?.stopPropagation()
if (!projectRef) return
updateBranch({
id: branch.id,
projectRef,
requestReview: false,
})
}
const formattedReviewDate = branch.review_requested_at
? dayjs(branch.review_requested_at).format('MMM DD, YYYY HH:mm')
: ''
return (
<div
className="w-full flex items-center justify-between px-6 py-3 hover:bg-surface-100 cursor-pointer transition-colors"
onClick={handleRowClick}
>
<div className="flex items-center gap-x-4">
<div className="flex gap-4">
<h4 className="text-sm text-foreground" title={branch.name}>
{branch.name}
</h4>
<p className="text-foreground-light">{formattedReviewDate}</p>
</div>
</div>
<div className="flex items-center gap-x-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="text"
icon={<MoreVertical />}
className="px-1"
onClick={(e) => e.stopPropagation()}
/>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56" side="bottom" align="end">
<DropdownMenuItem
className="gap-x-2"
disabled={isUpdating}
onClick={(e) => e.stopPropagation()}
onSelect={handleNotReadyForReview}
>
<X size={14} />
Not ready for review
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
)
}