mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Ready for release 1.1.4
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import {notFound} from "next/navigation";
|
|
||||||
import {env} from "@/env.mjs";
|
import {env} from "@/env.mjs";
|
||||||
import {LoginForm} from "@/components/wrappers/auth/login/login-form/login-form";
|
import {LoginForm} from "@/components/wrappers/auth/login/login-form/login-form";
|
||||||
import {Metadata} from "next";
|
import {Metadata} from "next";
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import {PageParams} from "@/types/next";
|
import {PageParams} from "@/types/next";
|
||||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||||
import {notFound} from "next/navigation";
|
import {notFound} from "next/navigation";
|
||||||
import {RestoreForm} from "@/components/wrappers/dashboard/database/restore-form";
|
// import {RestoreForm} from "@/components/wrappers/dashboard/database/restore-form";
|
||||||
import {currentUser} from "@/lib/auth/current-user";
|
import {currentUser} from "@/lib/auth/current-user";
|
||||||
|
|
||||||
import {db} from "@/db";
|
import {db} from "@/db";
|
||||||
@@ -34,7 +34,7 @@ export default async function RoutePage(
|
|||||||
<PageTitle>Restore {dbToRestore.name}</PageTitle>
|
<PageTitle>Restore {dbToRestore.name}</PageTitle>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<PageContent>
|
<PageContent>
|
||||||
<RestoreForm databaseToRestore={dbToRestore} databases={dbsOfSameType} backups={successfulBackups}/>
|
{/*<RestoreForm databaseToRestore={dbToRestore} databases={dbsOfSameType} backups={successfulBackups}/>*/}
|
||||||
</PageContent>
|
</PageContent>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
@@ -1,186 +1,186 @@
|
|||||||
"use client";
|
// "use client";
|
||||||
|
//
|
||||||
import { useState } from "react";
|
// import { useState } from "react";
|
||||||
|
//
|
||||||
import { DateTimePicker } from "@/components/wrappers/common/day-time-picker";
|
// import { DateTimePicker } from "@/components/wrappers/common/day-time-picker";
|
||||||
import { Button } from "@/components/ui/button";
|
// import { Button } from "@/components/ui/button";
|
||||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm } from "@/components/ui/form";
|
// import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm } from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
// import { Input } from "@/components/ui/input";
|
||||||
import { RestoreSchema } from "@/components/wrappers/dashboard/database/restore-form.schema";
|
// import { RestoreSchema } from "@/components/wrappers/dashboard/database/restore-form.schema";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
// import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { ComboBox, ComboBoxFormItem } from "@/components/wrappers/common/combobox";
|
// import { ComboBox } from "@/components/wrappers/common/combobox";
|
||||||
import { Label } from "@/components/ui/label";
|
// import { Label } from "@/components/ui/label";
|
||||||
|
//
|
||||||
export type restoreFormProps = {
|
// export type restoreFormProps = {
|
||||||
databaseToRestore: any;
|
// databaseToRestore: any;
|
||||||
databases: any[];
|
// databases: any[];
|
||||||
backups: any[];
|
// backups: any[];
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
export const RestoreForm = (props: restoreFormProps) => {
|
// export const RestoreForm = (props: restoreFormProps) => {
|
||||||
const { databaseToRestore, databases, backups } = props;
|
// const { databaseToRestore, databases, backups } = props;
|
||||||
|
//
|
||||||
const backupLocations = [
|
// const backupLocations = [
|
||||||
{
|
// {
|
||||||
value: "remote-file",
|
// value: "remote-file",
|
||||||
label: "Remote File",
|
// label: "Remote File",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
value: "desktop-file",
|
// value: "desktop-file",
|
||||||
label: "Desktop File",
|
// label: "Desktop File",
|
||||||
},
|
// },
|
||||||
];
|
// ];
|
||||||
|
//
|
||||||
const executionModes = [
|
// const executionModes = [
|
||||||
{
|
// {
|
||||||
value: "immediate",
|
// value: "immediate",
|
||||||
label: "Immediate",
|
// label: "Immediate",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
value: "scheduled",
|
// value: "scheduled",
|
||||||
label: "Scheduled",
|
// label: "Scheduled",
|
||||||
},
|
// },
|
||||||
];
|
// ];
|
||||||
|
//
|
||||||
const [selectedDatabaseId, setSelectedDatabaseId] = useState(databaseToRestore.id);
|
// const [selectedDatabaseId, setSelectedDatabaseId] = useState(databaseToRestore.id);
|
||||||
|
//
|
||||||
const filteredBackups = backups.filter((backup) => backup.databaseId == selectedDatabaseId);
|
// const filteredBackups = backups.filter((backup) => backup.databaseId == selectedDatabaseId);
|
||||||
|
//
|
||||||
const defaultValues = {
|
// const defaultValues = {
|
||||||
executionMode: "immediate" as const,
|
// executionMode: "immediate" as const,
|
||||||
backupLocation: "remote-file" as const,
|
// backupLocation: "remote-file" as const,
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
const form = useZodForm({
|
// const form = useZodForm({
|
||||||
schema: RestoreSchema,
|
// schema: RestoreSchema,
|
||||||
defaultValues: defaultValues,
|
// defaultValues: defaultValues,
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
const values = form.getValues();
|
// const values = form.getValues();
|
||||||
|
//
|
||||||
return (
|
// return (
|
||||||
<div>
|
// <div>
|
||||||
<Form
|
// <Form
|
||||||
form={form}
|
// form={form}
|
||||||
onSubmit={async (values) => {
|
// onSubmit={async (values) => {
|
||||||
console.log(values);
|
// console.log(values);
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
<FormField
|
// <FormField
|
||||||
control={form.control}
|
// control={form.control}
|
||||||
name="backupLocation"
|
// name="backupLocation"
|
||||||
render={({ field }) => (
|
// render={({ field }) => (
|
||||||
<FormItem>
|
// <FormItem>
|
||||||
<FormLabel>Backup location</FormLabel>
|
// <FormLabel>Backup location</FormLabel>
|
||||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
// <Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
<FormControl>
|
// <FormControl>
|
||||||
<SelectTrigger>
|
// <SelectTrigger>
|
||||||
<SelectValue />
|
// <SelectValue />
|
||||||
</SelectTrigger>
|
// </SelectTrigger>
|
||||||
</FormControl>
|
// </FormControl>
|
||||||
<SelectContent>
|
// <SelectContent>
|
||||||
{backupLocations.map((backupLocation, key) => (
|
// {backupLocations.map((backupLocation, key) => (
|
||||||
<SelectItem key={key} value={backupLocation.value}>
|
// <SelectItem key={key} value={backupLocation.value}>
|
||||||
{backupLocation.label}
|
// {backupLocation.label}
|
||||||
</SelectItem>
|
// </SelectItem>
|
||||||
))}
|
// ))}
|
||||||
</SelectContent>
|
// </SelectContent>
|
||||||
</Select>
|
// </Select>
|
||||||
<FormMessage />
|
// <FormMessage />
|
||||||
</FormItem>
|
// </FormItem>
|
||||||
)}
|
// )}
|
||||||
/>
|
// />
|
||||||
|
//
|
||||||
{values.backupLocation == "remote-file" ? (
|
// {values.backupLocation == "remote-file" ? (
|
||||||
<>
|
// <>
|
||||||
<div className="flex flex-col">
|
// <div className="flex flex-col">
|
||||||
<Label>Database</Label>
|
// <Label>Database</Label>
|
||||||
<ComboBox
|
// <ComboBox
|
||||||
values={databases.map((database) => ({ value: database.id, label: database.name }))}
|
// values={databases.map((database) => ({ value: database.id, label: database.name }))}
|
||||||
onValueChange={setSelectedDatabaseId}
|
// onValueChange={setSelectedDatabaseId}
|
||||||
defaultValue={selectedDatabaseId}
|
// defaultValue={selectedDatabaseId}
|
||||||
searchField
|
// searchField
|
||||||
/>
|
// />
|
||||||
</div>
|
// </div>
|
||||||
<FormField
|
// <FormField
|
||||||
control={form.control}
|
// control={form.control}
|
||||||
name="remoteBackup"
|
// name="remoteBackup"
|
||||||
render={({ field }) => (
|
// render={({ field }) => (
|
||||||
<FormItem className="flex flex-col">
|
// <FormItem className="flex flex-col">
|
||||||
<FormLabel>Remote backup</FormLabel>
|
// <FormLabel>Remote backup</FormLabel>
|
||||||
<ComboBoxFormItem
|
// <ComboBoxFormItem
|
||||||
values={filteredBackups.map((backup) => ({
|
// values={filteredBackups.map((backup) => ({
|
||||||
value: backup.id,
|
// value: backup.id,
|
||||||
label: backup.createdAt.toString(),
|
// label: backup.createdAt.toString(),
|
||||||
}))}
|
// }))}
|
||||||
{...field}
|
// {...field}
|
||||||
/>
|
// />
|
||||||
<FormMessage />
|
// <FormMessage />
|
||||||
</FormItem>
|
// </FormItem>
|
||||||
)}
|
// )}
|
||||||
/>
|
// />
|
||||||
</>
|
// </>
|
||||||
) : null}
|
// ) : null}
|
||||||
|
//
|
||||||
{values.backupLocation == "desktop-file" ? (
|
// {values.backupLocation == "desktop-file" ? (
|
||||||
<FormField
|
// <FormField
|
||||||
control={form.control}
|
// control={form.control}
|
||||||
name="uploadedBackupFile"
|
// name="uploadedBackupFile"
|
||||||
render={({ field }) => (
|
// render={({ field }) => (
|
||||||
<FormItem>
|
// <FormItem>
|
||||||
<FormLabel>File</FormLabel>
|
// <FormLabel>File</FormLabel>
|
||||||
<FormControl>
|
// <FormControl>
|
||||||
<Input id="uploadedBackupFile" type="file" {...field} />
|
// <Input id="uploadedBackupFile" type="file" {...field} />
|
||||||
</FormControl>
|
// </FormControl>
|
||||||
<FormMessage />
|
// <FormMessage />
|
||||||
</FormItem>
|
// </FormItem>
|
||||||
)}
|
// )}
|
||||||
/>
|
// />
|
||||||
) : null}
|
// ) : null}
|
||||||
|
//
|
||||||
<FormField
|
// <FormField
|
||||||
control={form.control}
|
// control={form.control}
|
||||||
name="executionMode"
|
// name="executionMode"
|
||||||
render={({ field }) => (
|
// render={({ field }) => (
|
||||||
<FormItem>
|
// <FormItem>
|
||||||
<FormLabel>Execution mode</FormLabel>
|
// <FormLabel>Execution mode</FormLabel>
|
||||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
// <Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
<FormControl>
|
// <FormControl>
|
||||||
<SelectTrigger>
|
// <SelectTrigger>
|
||||||
<SelectValue />
|
// <SelectValue />
|
||||||
</SelectTrigger>
|
// </SelectTrigger>
|
||||||
</FormControl>
|
// </FormControl>
|
||||||
<SelectContent>
|
// <SelectContent>
|
||||||
{executionModes.map((executionMode, key) => (
|
// {executionModes.map((executionMode, key) => (
|
||||||
<SelectItem key={key} value={executionMode.value}>
|
// <SelectItem key={key} value={executionMode.value}>
|
||||||
{executionMode.label}
|
// {executionMode.label}
|
||||||
</SelectItem>
|
// </SelectItem>
|
||||||
))}
|
// ))}
|
||||||
</SelectContent>
|
// </SelectContent>
|
||||||
</Select>
|
// </Select>
|
||||||
<FormMessage />
|
// <FormMessage />
|
||||||
</FormItem>
|
// </FormItem>
|
||||||
)}
|
// )}
|
||||||
/>
|
// />
|
||||||
|
//
|
||||||
{values.executionMode == "scheduled" ? (
|
// {values.executionMode == "scheduled" ? (
|
||||||
<FormField
|
// <FormField
|
||||||
control={form.control}
|
// control={form.control}
|
||||||
name="scheduledDatetime"
|
// name="scheduledDatetime"
|
||||||
render={({ field }) => (
|
// render={({ field }) => (
|
||||||
<FormItem>
|
// <FormItem>
|
||||||
<FormLabel>Scheduled date</FormLabel>
|
// <FormLabel>Scheduled date</FormLabel>
|
||||||
<FormControl>
|
// <FormControl>
|
||||||
<DateTimePicker value={field.value} onSelect={field.onChange} />
|
// <DateTimePicker value={field.value} onSelect={field.onChange} />
|
||||||
</FormControl>
|
// </FormControl>
|
||||||
<FormMessage />
|
// <FormMessage />
|
||||||
</FormItem>
|
// </FormItem>
|
||||||
)}
|
// )}
|
||||||
/>
|
// />
|
||||||
) : null}
|
// ) : null}
|
||||||
|
//
|
||||||
<Button type="submit">Launch restore</Button>
|
// <Button type="submit">Launch restore</Button>
|
||||||
</Form>
|
// </Form>
|
||||||
</div>
|
// </div>
|
||||||
);
|
// );
|
||||||
};
|
// };
|
||||||
|
|||||||
Reference in New Issue
Block a user