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:
@@ -69,19 +69,12 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
|||||||
mutationFn: async (backups: Backup[]) => {
|
mutationFn: async (backups: Backup[]) => {
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
backups.map(async (backup) => {
|
backups.map(async (backup) => {
|
||||||
if (backup.deletedAt == null) {
|
if (backup.deletedAt == null || backup.status == "ongoing") {
|
||||||
|
|
||||||
const backupDeleted = await deleteBackupAction({
|
const backupDeleted = await deleteBackupAction({
|
||||||
databaseId: backup.databaseId,
|
databaseId: backup.databaseId,
|
||||||
backupId: backup.id,
|
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 {
|
return {
|
||||||
success: backupDeleted?.data?.success,
|
success: backupDeleted?.data?.success,
|
||||||
message: backupDeleted?.data?.success
|
message: backupDeleted?.data?.success
|
||||||
@@ -138,13 +131,7 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
|||||||
<DropdownMenuContent align="start">
|
<DropdownMenuContent align="start">
|
||||||
<ButtonWithConfirm
|
<ButtonWithConfirm
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
const backupsToDelete = rows.map(row => row
|
mutationDeleteBackups.mutate(rows);
|
||||||
).filter(backup => backup.deletedAt == null)
|
|
||||||
if (backupsToDelete.length === 0) {
|
|
||||||
toast.error("No available backup selected for deletion.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mutationDeleteBackups.mutate(backupsToDelete);
|
|
||||||
setIsActionsOpen(false);
|
setIsActionsOpen(false);
|
||||||
}}
|
}}
|
||||||
onCancel={() => setIsActionsOpen(false)}
|
onCancel={() => setIsActionsOpen(false)}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {cn} from "@/lib/utils";
|
|||||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
|
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
|
||||||
import {MemberWithUser} from "@/db/schema/03_organization";
|
import {MemberWithUser} from "@/db/schema/03_organization";
|
||||||
import {formatLocalizedDate} from "@/utils/date-formatting";
|
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 {DatabaseActionsCell} from "@/components/wrappers/dashboard/database/backup/actions/backup-actions-cell";
|
||||||
import { Badge as BadgeC } from "@/components/ui/badge";
|
import { Badge as BadgeC } from "@/components/ui/badge";
|
||||||
|
|
||||||
@@ -22,7 +22,17 @@ export function backupColumns(
|
|||||||
{
|
{
|
||||||
id: "availability",
|
id: "availability",
|
||||||
cell: ({row}) => {
|
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 (
|
return (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ export const deleteBackupCronAction = action
|
|||||||
.update(drizzleDb.schemas.backup)
|
.update(drizzleDb.schemas.backup)
|
||||||
.set(withUpdatedAt({
|
.set(withUpdatedAt({
|
||||||
deletedAt: new Date(),
|
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)))
|
.where(and(eq(drizzleDb.schemas.backup.id, parsedInput.backupId), eq(drizzleDb.schemas.backup.databaseId, parsedInput.databaseId)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user