mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # src/components/wrappers/Dashboard/Projects/Database/DatabaseTabs.tsx
This commit is contained in:
@@ -1,16 +1,40 @@
|
||||
"use client"
|
||||
|
||||
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, Restoration} from "@prisma/client";
|
||||
import {Backup, Database, Restoration} from "@prisma/client";
|
||||
import {useEffect} from "react";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {eventUpdate} from "@/types/events";
|
||||
|
||||
export type DatabaseTabsProps = {
|
||||
backups: Backup[]
|
||||
restorations: Restoration[]
|
||||
isAlreadyRestore: boolean
|
||||
database: Database
|
||||
}
|
||||
|
||||
export const DatabaseTabs = (props: DatabaseTabsProps) => {
|
||||
|
||||
const router = useRouter();
|
||||
useEffect(() => {
|
||||
const eventSource = new EventSource('/api/events');
|
||||
|
||||
eventSource.addEventListener('modification', (event) => {
|
||||
const data: eventUpdate = JSON.parse(event.data)
|
||||
if (data.update) {
|
||||
console.log("update", data.update)
|
||||
router.refresh()
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
eventSource.close();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Tabs className="flex flex-col flex-1" defaultValue="backup">
|
||||
|
||||
@@ -20,7 +44,8 @@ export const DatabaseTabs = (props: DatabaseTabsProps) => {
|
||||
</TabsList>
|
||||
|
||||
<TabsContent className="h-full justify-between" value="backup">
|
||||
<DataTableWithPagination columns={backupColumns} data={props.backups} extendedProps={props.isAlreadyRestore}/>
|
||||
<DataTableWithPagination columns={backupColumns} data={props.backups}
|
||||
extendedProps={props.isAlreadyRestore}/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent className="h-full justify-between" value="restore">
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
export type eventUpdate = {
|
||||
update : boolean
|
||||
}
|
||||
Reference in New Issue
Block a user