mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
changing restauration to restoration.
This commit is contained in:
@@ -2,11 +2,11 @@ import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs";
|
||||
import {DataTableWithPagination} from "@/components/wrappers/table/data-table-with-pagination";
|
||||
import {backupColumns} from "@/features/backup/columns";
|
||||
import {restoreColumns} from "@/features/restore/columns";
|
||||
import {Backup, Restauration} from "@prisma/client";
|
||||
import {Backup, Restoration} from "@prisma/client";
|
||||
|
||||
export type DatabaseTabsProps = {
|
||||
backups: Backup[]
|
||||
restaurations: Restauration[]
|
||||
restorations: Restoration[]
|
||||
isAlreadyRestore: boolean
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export const DatabaseTabs = (props: DatabaseTabsProps) => {
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent className="h-full justify-between" value="restore">
|
||||
<DataTableWithPagination columns={restoreColumns} data={props.restaurations}/>
|
||||
<DataTableWithPagination columns={restoreColumns} data={props.restorations}/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)
|
||||
|
||||
@@ -36,8 +36,6 @@ export const DatabaseForm = (props: DatabaseFormProps) => {
|
||||
defaultValues: {...defaultValues},
|
||||
});
|
||||
|
||||
console.log("aaaaaaaaaa", form.getValues())
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const mutation = useMutation({
|
||||
|
||||
@@ -15,7 +15,7 @@ import {ReloadIcon} from "@radix-ui/react-icons";
|
||||
import {Backup} from "@prisma/client";
|
||||
import {getFileUrlPresignedLocal} from "@/features/upload/private/upload.action";
|
||||
import {useMutation} from "@tanstack/react-query";
|
||||
import {createRestaurationAction} from "@/features/restore/restore.action";
|
||||
import {createRestorationAction} from "@/features/restore/restore.action";
|
||||
import {toast} from "sonner";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {TooltipCustom} from "@/components/wrappers/TooltipCustom/TooltipCustom";
|
||||
@@ -50,7 +50,7 @@ export const backupColumns: ColumnDef<Backup>[] = [
|
||||
const {extendedProps} = table.options.meta;
|
||||
|
||||
|
||||
// const isRestauring = !!rowData.restaurations.find(restauration => restauration.status === "waiting");
|
||||
// const isRestoring = !!rowData.restorations.find(restoration => restoration.status === "waiting");
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -62,15 +62,15 @@ export const backupColumns: ColumnDef<Backup>[] = [
|
||||
|
||||
const mutationRestore = useMutation({
|
||||
mutationFn: async () => {
|
||||
const restauration = await createRestaurationAction({
|
||||
const restoration = await createRestorationAction({
|
||||
backupId: rowData.id,
|
||||
databaseId: rowData.databaseId
|
||||
})
|
||||
if (restauration.data.success) {
|
||||
toast.success(restauration.data.actionSuccess?.message || "Restauration created successfully!");
|
||||
if (restoration.data.success) {
|
||||
toast.success(restoration.data.actionSuccess?.message || "Restoration created successfully!");
|
||||
router.refresh()
|
||||
} else {
|
||||
toast.error(restauration.serverError || "Failed to create restauration.");
|
||||
toast.error(restoration.serverError || "Failed to create restoration.");
|
||||
}
|
||||
}})
|
||||
|
||||
@@ -90,7 +90,7 @@ export const backupColumns: ColumnDef<Backup>[] = [
|
||||
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
||||
{status == "success" ?
|
||||
<>
|
||||
<TooltipCustom disabled={extendedProps} text="Already a restauration waiting">
|
||||
<TooltipCustom disabled={extendedProps} text="Already a restoration waiting">
|
||||
<DropdownMenuItem disabled={mutationRestore.isPending || extendedProps}
|
||||
onClick={async () => {
|
||||
await handleRestore()
|
||||
|
||||
@@ -12,11 +12,11 @@ import {
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Download, MoreHorizontal, Trash2} from "lucide-react";
|
||||
import {ReloadIcon} from "@radix-ui/react-icons";
|
||||
import {Restauration} from "@prisma/client";
|
||||
import {Restoration} from "@prisma/client";
|
||||
|
||||
|
||||
|
||||
export const restoreColumns: ColumnDef<Restauration>[] = [
|
||||
export const restoreColumns: ColumnDef<Restoration>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "Reference",
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
"use server"
|
||||
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {z} from "zod";
|
||||
import {prisma} from "@/prisma";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {Restauration} from "@prisma/client";
|
||||
import {Restoration} from "@prisma/client";
|
||||
|
||||
|
||||
export const createRestaurationAction = userAction
|
||||
export const createRestorationAction = userAction
|
||||
.schema(z.object({
|
||||
backupId: z.string(),
|
||||
databaseId: z.string(),
|
||||
}))
|
||||
.action(async ({parsedInput, ctx}): Promise<ServerActionResult<Restauration>> => {
|
||||
.action(async ({parsedInput, ctx}): Promise<ServerActionResult<Restoration>> => {
|
||||
|
||||
try {
|
||||
const restauration = await prisma.restauration.create({
|
||||
const restoration = await prisma.restoration.create({
|
||||
data: {
|
||||
databaseId: parsedInput.databaseId,
|
||||
backupId: parsedInput.backupId,
|
||||
@@ -24,14 +25,14 @@ export const createRestaurationAction = userAction
|
||||
|
||||
return {
|
||||
success: true,
|
||||
value: restauration,
|
||||
value: restoration,
|
||||
actionSuccess: {
|
||||
message: "Restoration has been successfully created.",
|
||||
messageParams: { restaurationId: restauration.id },
|
||||
messageParams: { restorationId: restoration.id },
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error creating restauration:", error);
|
||||
console.error("Error creating restoration:", error);
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
|
||||
@@ -53,7 +53,7 @@ export const databases = [
|
||||
"lastContact": "2024-11-28T08:30:00.000Z",
|
||||
"projectId": "proj-789",
|
||||
"backups": [],
|
||||
"restaurations": []
|
||||
"restorations": []
|
||||
},
|
||||
{
|
||||
"id": "1e4f9265-5f10-4bd4-8e5c-3283746cfd7a",
|
||||
@@ -67,7 +67,7 @@ export const databases = [
|
||||
"lastContact": "2024-11-25T10:15:00.000Z",
|
||||
"projectId": null,
|
||||
"backups": [],
|
||||
"restaurations": []
|
||||
"restorations": []
|
||||
},
|
||||
{
|
||||
"id": "b6f92bd7-834b-41c1-b6b3-dc4214b1de08",
|
||||
@@ -81,7 +81,7 @@ export const databases = [
|
||||
"lastContact": null,
|
||||
"projectId": "proj-456",
|
||||
"backups": [],
|
||||
"restaurations": []
|
||||
"restorations": []
|
||||
}
|
||||
]
|
||||
|
||||
@@ -108,7 +108,7 @@ export const backups = [
|
||||
{'id': 'backup-11', 'createdAt': '2023-11-25T11:26:54.871000Z', 'status': 'failed'}
|
||||
]
|
||||
|
||||
export const restaurations = [
|
||||
export const restorations = [
|
||||
{'id': 'restore-1', 'backupId': 'backup-1', 'createdAt': '2023-11-27T11:26:54.870914Z', 'status': 'pending'},
|
||||
{'id': 'restore-2', 'backupId': 'backup-2', 'createdAt': '2023-12-03T11:26:54.870927Z', 'status': 'failed'},
|
||||
{'id': 'restore-3', 'backupId': 'backup-3', 'createdAt': '2023-12-12T11:26:54.870937Z', 'status': 'success'},
|
||||
|
||||
Reference in New Issue
Block a user