mirror of
https://github.com/MeshEnvy/mesh-forge.git
synced 2026-07-06 09:52:12 +02:00
refactor: improve build management by implementing profileBuilds for better tracking, enhancing build retrieval logic, and synchronizing profile updates with target changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQuery } from 'convex/react'
|
||||
import { CheckCircle, Loader2, RotateCw, Trash2, XCircle } from 'lucide-react'
|
||||
import { CheckCircle, Loader2, Trash2, XCircle } from 'lucide-react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { toast } from 'sonner'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -14,7 +14,6 @@ interface BuildsPanelProps {
|
||||
export default function BuildsPanel({ profileId }: BuildsPanelProps) {
|
||||
const builds = useQuery(api.builds.listByProfile, { profileId })
|
||||
const deleteBuild = useMutation(api.builds.deleteBuild)
|
||||
const retryBuild = useMutation(api.builds.retryBuild)
|
||||
|
||||
const getStatusIcon = (status: string) => {
|
||||
if (status === 'success') {
|
||||
@@ -40,7 +39,7 @@ export default function BuildsPanel({ profileId }: BuildsPanelProps) {
|
||||
|
||||
const handleDelete = async (buildId: Id<'builds'>) => {
|
||||
try {
|
||||
await deleteBuild({ buildId })
|
||||
await deleteBuild({ buildId, profileId })
|
||||
toast.success('Build deleted', {
|
||||
description: 'Build record has been removed.',
|
||||
})
|
||||
@@ -51,19 +50,6 @@ export default function BuildsPanel({ profileId }: BuildsPanelProps) {
|
||||
}
|
||||
}
|
||||
|
||||
const handleRetry = async (buildId: Id<'builds'>) => {
|
||||
try {
|
||||
await retryBuild({ buildId })
|
||||
toast.success('Build retrying', {
|
||||
description: 'Build has been queued again.',
|
||||
})
|
||||
} catch (error) {
|
||||
toast.error('Retry failed', {
|
||||
description: String(error),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!builds || builds.length === 0) {
|
||||
return (
|
||||
<div className="text-slate-500 text-sm py-4">
|
||||
@@ -101,20 +87,6 @@ export default function BuildsPanel({ profileId }: BuildsPanelProps) {
|
||||
</Link>
|
||||
|
||||
<div className="flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
{build.status === 'failure' && (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-slate-400 hover:text-white"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleRetry(build._id)
|
||||
}}
|
||||
title="Retry Build"
|
||||
>
|
||||
<RotateCw className="w-4 h-4" />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
|
||||
Reference in New Issue
Block a user