diff --git a/src/components/wrappers/dashboard/database/backup/actions/backup-actions-cell.tsx b/src/components/wrappers/dashboard/database/backup/actions/backup-actions-cell.tsx index 6e6a9cae..7a01aeb9 100644 --- a/src/components/wrappers/dashboard/database/backup/actions/backup-actions-cell.tsx +++ b/src/components/wrappers/dashboard/database/backup/actions/backup-actions-cell.tsx @@ -21,14 +21,14 @@ interface DatabaseActionsCellProps { backup: BackupWith; activeMember: MemberWithUser; isAlreadyRestore: boolean; + isBackupOnly: boolean; } -export function DatabaseActionsCell({backup, activeMember, isAlreadyRestore}: DatabaseActionsCellProps) { +export function DatabaseActionsCell({backup, activeMember, isAlreadyRestore, isBackupOnly}: DatabaseActionsCellProps) { const {openModal} = useBackupModal(); if (backup.deletedAt || activeMember.role === "member") return null; - return (
@@ -40,18 +40,19 @@ export function DatabaseActionsCell({backup, activeMember, isAlreadyRestore}: Da Actions - {backup.status == "success" ? ( <> - - openModal("restore", backup)} - > - Restore - - + {!isBackupOnly && ( + + openModal("restore", backup)} + > + Restore + + + )} openModal("download", backup)} > diff --git a/src/components/wrappers/dashboard/database/channels-policy/policy-form.tsx b/src/components/wrappers/dashboard/database/channels-policy/policy-form.tsx index a3a856d5..f5247c0c 100644 --- a/src/components/wrappers/dashboard/database/channels-policy/policy-form.tsx +++ b/src/components/wrappers/dashboard/database/channels-policy/policy-form.tsx @@ -22,6 +22,7 @@ import { } from "@/components/wrappers/dashboard/admin/channels/helpers/common"; import {StorageChannel} from "@/db/schema/12_storage-channel"; import { + EVENT_KIND_BACKUP_ONLY_OPTIONS, EVENT_KIND_OPTIONS, PoliciesSchema, PoliciesType, @@ -31,6 +32,7 @@ import { createAlertPoliciesAction, createStoragePoliciesAction, deleteAlertPoliciesAction, deleteStoragePoliciesAction, updateAlertPoliciesAction, updateStoragePoliciesAction } from "@/components/wrappers/dashboard/database/channels-policy/policy.action"; +import {backupOnly} from "@/components/wrappers/dashboard/projects/database/database-tabs"; type ChannelPoliciesFormProps = { onSuccess?: () => void; @@ -53,6 +55,9 @@ export const ChannelPoliciesForm = ({ const isMobile = useIsMobile(); const channelText = getChannelTextBasedOnKind(kind); + const isBackupOnly = backupOnly.some((type) => database.dbms === type) + + const organizationChannels = channels.map(c => c.id); const filterByChannel = ( @@ -300,7 +305,7 @@ export const ChannelPoliciesForm = ({
{ const router = useRouter(); const searchParams = useSearchParams(); @@ -26,6 +28,7 @@ export const DatabaseTabs = (props: DatabaseTabsProps) => { useEffect(() => { const newTab = searchParams.get("tab") ?? "backup"; + // eslint-disable-next-line react-hooks/set-state-in-effect setTab(newTab); }, [searchParams]); @@ -33,13 +36,13 @@ export const DatabaseTabs = (props: DatabaseTabsProps) => { router.push(`?tab=${value}`); }; + + const isBackupOnly = backupOnly.some((type) => props.database.dbms === type) + + return ( - - - Backup - Restoration - - + <> + {isBackupOnly ? { backups={props.backups} activeMember={props.activeMember} /> - - - - - + : + + + Backup + Restoration + + + + + + + + + } + + + ); }; diff --git a/src/features/dashboard/backup/columns.tsx b/src/features/dashboard/backup/columns.tsx index 0995e5cb..ca6547b1 100644 --- a/src/features/dashboard/backup/columns.tsx +++ b/src/features/dashboard/backup/columns.tsx @@ -11,6 +11,7 @@ import {formatLocalizedDate} from "@/utils/date-formatting"; 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"; +import {backupOnly} from "@/components/wrappers/dashboard/projects/database/database-tabs"; export function backupColumns( isAlreadyRestore: boolean, @@ -18,6 +19,10 @@ export function backupColumns( database: DatabaseWith, activeMember: MemberWithUser ): ColumnDef[] { + + const isBackupOnly = backupOnly.some((type) => database.dbms === type) + + return [ { id: "availability", @@ -90,137 +95,7 @@ export function backupColumns( }, { id: "actions", - cell: ({row}) => , + cell: ({row}) => , }, - // { - // id: "actions", - // cell: ({row, table}) => { - // const status = row.getValue("status"); - // const rowData: Backup = row.original; - // const fileName = rowData.file; - // - // const router = useRouter(); - // - // const mutationRestore = useMutation({ - // mutationFn: async () => { - // const restoration = await createRestorationAction({ - // backupId: rowData.id, - // databaseId: rowData.databaseId, - // }); - // // @ts-ignore - // if (restoration.data.success) { - // // @ts-ignore - // toast.success(restoration.data.actionSuccess?.message || "Restoration created successfully!"); - // router.refresh(); - // } else { - // // @ts-ignore - // toast.error(restoration.serverError || "Failed to create restoration."); - // } - // }, - // }); - // - // const mutationDeleteBackup = useMutation({ - // mutationFn: async () => { - // const deletion = await deleteBackupAction({ - // backupId: rowData.id, - // databaseId: rowData.databaseId, - // status: rowData.status, - // file: rowData.file ?? "", - // projectSlug: database.project?.slug! - // }); - // // @ts-ignore - // if (deletion.data.success) { - // // @ts-ignore - // toast.success(deletion.data.actionSuccess.message); - // router.refresh(); - // } else { - // // @ts-ignore - // toast.error(deletion.data.actionError.message); - // } - // }, - // }); - // - // const handleRestore = async () => { - // await mutationRestore.mutateAsync(); - // }; - // - // const handleDelete = async () => { - // await mutationDeleteBackup.mutateAsync(); - // }; - // - // const handleDownload = async (fileName: string) => { - // - // let url: string = ""; - // let data: SafeActionResult, object> | undefined - // - // if (settings.storage == "local") { - // data = await getFileUrlPresignedLocal({fileName: fileName!}) - // } else if (settings.storage == "s3") { - // data = await getFileUrlPreSignedS3Action(`backups/${database.project?.slug}/${fileName}`); - // } - // if (data?.data?.success) { - // url = data.data.value ?? ""; - // } else { - // // @ts-ignore - // const errorMessage = data?.data?.actionError?.message || "Failed to get file!"; - // toast.error(errorMessage); - // } - // - // window.open(url, "_self"); - // }; - // - // return ( - // <> - // {(rowData.deletedAt == null && activeMember.role != "member") && ( - // - // - // - // - // - // Actions - // {status == "success" ? ( - // <> - // - // { - // await handleRestore(); - // }} - // > - // Restore - // - // - // { - // await handleDownload(fileName ?? ""); - // }} - // > - // Download - // - // - // ) : null} - // - // { - // await handleDelete(); - // }} - // > - // Delete - // - // - // - // )} - // - // - // ); - // }, - // }, ]; } \ No newline at end of file