mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: bug ongoing backup deletion
This commit is contained in:
@@ -12,7 +12,7 @@ import {useMutation, useQueryClient} from "@tanstack/react-query";
|
||||
import {toast} from "sonner";
|
||||
import {MemberWithUser} from "@/db/schema/03_organization";
|
||||
import {deleteBackupAction} from "@/components/wrappers/dashboard/database/backup/actions/backup-actions.action";
|
||||
import { ButtonWithConfirm } from "@/components/wrappers/common/button/button-with-confirm";
|
||||
import {ButtonWithConfirm} from "@/components/wrappers/common/button/button-with-confirm";
|
||||
|
||||
|
||||
type DatabaseBackupListProps = {
|
||||
@@ -69,19 +69,12 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
||||
mutationFn: async (backups: Backup[]) => {
|
||||
const results = await Promise.all(
|
||||
backups.map(async (backup) => {
|
||||
if (backup.deletedAt == null) {
|
||||
if (backup.deletedAt == null || backup.status == "ongoing") {
|
||||
|
||||
const backupDeleted = await deleteBackupAction({
|
||||
databaseId: backup.databaseId,
|
||||
backupId: backup.id,
|
||||
})
|
||||
// const backupDeleted = await deleteBackupAction({
|
||||
// backupId: backup.id,
|
||||
// databaseId: backup.databaseId,
|
||||
// status: backup.status,
|
||||
// file: backup.file ?? "",
|
||||
// projectSlug: props.database?.project?.slug!
|
||||
// });
|
||||
return {
|
||||
success: backupDeleted?.data?.success,
|
||||
message: backupDeleted?.data?.success
|
||||
@@ -136,15 +129,9 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
||||
>Actions</ButtonWithLoading>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
<ButtonWithConfirm
|
||||
<ButtonWithConfirm
|
||||
onConfirm={() => {
|
||||
const backupsToDelete = rows.map(row => row
|
||||
).filter(backup => backup.deletedAt == null)
|
||||
if (backupsToDelete.length === 0) {
|
||||
toast.error("No available backup selected for deletion.");
|
||||
return;
|
||||
}
|
||||
mutationDeleteBackups.mutate(backupsToDelete);
|
||||
mutationDeleteBackups.mutate(rows);
|
||||
setIsActionsOpen(false);
|
||||
}}
|
||||
onCancel={() => setIsActionsOpen(false)}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {cn} from "@/lib/utils";
|
||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
|
||||
import {MemberWithUser} from "@/db/schema/03_organization";
|
||||
import {formatLocalizedDate} from "@/utils/date-formatting";
|
||||
import {formatBytes, isImportedFilename} from "@/utils/text";
|
||||
import {formatBytes} from "@/utils/text";
|
||||
import {DatabaseActionsCell} from "@/components/wrappers/dashboard/database/backup/actions/backup-actions-cell";
|
||||
import { Badge as BadgeC } from "@/components/ui/badge";
|
||||
|
||||
@@ -22,7 +22,17 @@ export function backupColumns(
|
||||
{
|
||||
id: "availability",
|
||||
cell: ({row}) => {
|
||||
const colorStatus = row.original.deletedAt != null ? "bg-red-400 border-red-600" : "bg-green-400 border-green-600";
|
||||
const statusColors: Record<string, string> = {
|
||||
waiting: "bg-gray-400 border-gray-600",
|
||||
ongoing: "bg-orange-400 border-orange-600",
|
||||
success: "bg-green-400 border-green-600",
|
||||
};
|
||||
|
||||
const colorStatus =
|
||||
row.original.deletedAt != null
|
||||
? "bg-red-400 border-red-600"
|
||||
: statusColors[row.original.status] ?? "bg-gray-400 border-gray-600";
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
|
||||
@@ -70,6 +70,8 @@ export const deleteBackupCronAction = action
|
||||
.update(drizzleDb.schemas.backup)
|
||||
.set(withUpdatedAt({
|
||||
deletedAt: new Date(),
|
||||
status: backup.status == "ongoing" ? "failed" : backup.status
|
||||
|
||||
}))
|
||||
.where(and(eq(drizzleDb.schemas.backup.id, parsedInput.backupId), eq(drizzleDb.schemas.backup.databaseId, parsedInput.databaseId)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user