mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # app/(customer)/dashboard/agents/[agentId]/page.tsx
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageTitle} from "@/features/layout/page";
|
||||
import {Button, buttonVariants} from "@/components/ui/button";
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs";
|
||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
||||
@@ -12,6 +12,7 @@ import Link from "next/link";
|
||||
import {AgentModalKey} from "@/components/wrappers/Agent/AgentModalKey/AgentModalKey";
|
||||
import {KeyRound} from "lucide-react";
|
||||
import {BackupButton} from "@/components/wrappers/BackupButton/BackupButton";
|
||||
import {backups, restaurations} from "@/utils/mock-data";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ agentId: string }>) {
|
||||
@@ -24,42 +25,6 @@ export default async function RoutePage(props: PageParams<{ agentId: string }>)
|
||||
},
|
||||
})
|
||||
|
||||
const backups = [
|
||||
{'id': 'backup-1', 'createdAt': '2023-11-27T11:26:54.870914Z', 'status': 'pending'},
|
||||
{'id': 'backup-2', 'createdAt': '2023-12-03T11:26:54.870927Z', 'status': 'failed'},
|
||||
{'id': 'backup-3', 'createdAt': '2023-12-12T11:26:54.870937Z', 'status': 'success'},
|
||||
{'id': 'backup-4', 'createdAt': '2023-11-23T11:26:54.870946Z', 'status': 'processing'},
|
||||
{'id': 'backup-5', 'createdAt': '2023-12-09T11:26:54.870955Z', 'status': 'pending'},
|
||||
{'id': 'backup-6', 'createdAt': '2023-11-29T11:26:54.870964Z', 'status': 'failed'},
|
||||
{'id': 'backup-7', 'createdAt': '2023-12-07T11:26:54.870973Z', 'status': 'success'},
|
||||
{'id': 'backup-8', 'createdAt': '2023-11-18T11:26:54.870982Z', 'status': 'processing'},
|
||||
{'id': 'backup-9', 'createdAt': '2023-12-01T11:26:54.870991Z', 'status': 'pending'},
|
||||
{'id': 'backup-10', 'createdAt': '2023-11-25T11:26:54.871000Z', 'status': 'failed'},
|
||||
{'id': 'backup-1', 'createdAt': '2023-11-27T11:26:54.870914Z', 'status': 'pending'},
|
||||
{'id': 'backup-2', 'createdAt': '2023-12-03T11:26:54.870927Z', 'status': 'failed'},
|
||||
{'id': 'backup-3', 'createdAt': '2023-12-12T11:26:54.870937Z', 'status': 'success'},
|
||||
{'id': 'backup-4', 'createdAt': '2023-11-23T11:26:54.870946Z', 'status': 'processing'},
|
||||
{'id': 'backup-5', 'createdAt': '2023-12-09T11:26:54.870955Z', 'status': 'pending'},
|
||||
{'id': 'backup-6', 'createdAt': '2023-11-29T11:26:54.870964Z', 'status': 'failed'},
|
||||
{'id': 'backup-7', 'createdAt': '2023-12-07T11:26:54.870973Z', 'status': 'success'},
|
||||
{'id': 'backup-8', 'createdAt': '2023-11-18T11:26:54.870982Z', 'status': 'processing'},
|
||||
{'id': 'backup-9', 'createdAt': '2023-12-01T11:26:54.870991Z', 'status': 'pending'},
|
||||
{'id': 'backup-11', 'createdAt': '2023-11-25T11:26:54.871000Z', 'status': 'failed'}
|
||||
]
|
||||
|
||||
const restores = [
|
||||
{'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'},
|
||||
{'id': 'restore-4', 'backupId': 'backup-4', 'createdAt': '2023-11-23T11:26:54.870946Z', 'status': 'processing'},
|
||||
{'id': 'restore-5', 'backupId': 'backup-5', 'createdAt': '2023-12-09T11:26:54.870955Z', 'status': 'pending'},
|
||||
{'id': 'restore-6', 'backupId': 'backup-6', 'createdAt': '2023-11-29T11:26:54.870964Z', 'status': 'failed'},
|
||||
{'id': 'restore-7', 'backupId': 'backup-7', 'createdAt': '2023-12-07T11:26:54.870973Z', 'status': 'success'},
|
||||
{'id': 'restore-8', 'backupId': 'backup-8', 'createdAt': '2023-11-18T11:26:54.870982Z', 'status': 'processing'},
|
||||
{'id': 'restore-9', 'backupId': 'backup-9', 'createdAt': '2023-12-01T11:26:54.870991Z', 'status': 'pending'},
|
||||
{'id': 'restore-10', 'backupId': 'backup-10', 'createdAt': '2023-11-25T11:26:54.871000Z', 'status': 'failed'}
|
||||
]
|
||||
|
||||
const databaseId = 'db-123';
|
||||
|
||||
const totalBackups = await prisma.backup.count({
|
||||
@@ -77,26 +42,27 @@ export default async function RoutePage(props: PageParams<{ agentId: string }>)
|
||||
|
||||
const successRate = totalBackups > 0 ? (successfulBackups / totalBackups) * 100 : null
|
||||
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div className="justify-between gap-2 sm:flex">
|
||||
<PageTitle className="flex items-center">
|
||||
{agent.name}
|
||||
<Link className={buttonVariants({variant: "outline"})}
|
||||
href={`/dashboard/agents/${agent.id}/edit`}>
|
||||
<GearIcon className="w-7 h-7"/>
|
||||
</Link>
|
||||
<AgentModalKey agent={agent}>
|
||||
<Button variant="outline">
|
||||
<KeyRound/>
|
||||
</Button>
|
||||
</AgentModalKey>
|
||||
</PageTitle>
|
||||
<PageActions className="justify-between">
|
||||
<BackupButton/>
|
||||
<Button>Restore</Button>
|
||||
</PageActions>
|
||||
</div>
|
||||
<div className="justify-between gap-2 sm:flex">
|
||||
<PageTitle className="flex items-center">
|
||||
{agent.name}
|
||||
<Link className={buttonVariants({variant: "outline"})}
|
||||
href={`/dashboard/agents/${agent.id}/edit`}>
|
||||
<GearIcon className="w-7 h-7"/>
|
||||
</Link>
|
||||
<AgentModalKey agent={agent}>
|
||||
<Button variant="outline">
|
||||
<KeyRound/>
|
||||
</Button>
|
||||
</AgentModalKey>
|
||||
</PageTitle>
|
||||
<PageActions className="justify-between">
|
||||
<BackupButton/>
|
||||
<Button>Restore</Button>
|
||||
</PageActions>
|
||||
</div>
|
||||
<PageDescription className="mt-5 sm:mt-0">{agent.description}</PageDescription>
|
||||
<PageContent className="flex flex-col w-full h-full">
|
||||
<div className="flex flex-col sm:flex-row sm:justify-between gap-8 mb-6">
|
||||
@@ -135,7 +101,7 @@ export default async function RoutePage(props: PageParams<{ agentId: string }>)
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent className="h-full justify-between" value="restore">
|
||||
<DataTableWithPagination columns={restoreColumns} data={restores}/>
|
||||
<DataTableWithPagination columns={restoreColumns} data={restaurations}/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</PageContent>
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {redirect} from "next/navigation";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
redirect("/dashboard/agents")
|
||||
|
||||
// return(
|
||||
// <div>
|
||||
// <h1>Ok</h1>
|
||||
// <Button>Button</Button>
|
||||
// </div>
|
||||
// )
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {prisma} from "@/prisma";
|
||||
import {notFound} from "next/navigation";
|
||||
import {ProjectForm} from "@/components/wrappers/project/ProjectForm";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{
|
||||
projectId: string;
|
||||
}>) {
|
||||
|
||||
const {projectId} = await props.params
|
||||
|
||||
const user = await requiredCurrentUser()
|
||||
const project = await prisma.project.findUnique({
|
||||
where: {
|
||||
id: projectId,
|
||||
}
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle>
|
||||
Edit {project.name}
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<ProjectForm defaultValues={project} projectId={project.id}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageTitle} from "@/features/layout/page";
|
||||
import {buttonVariants} from "@/components/ui/button";
|
||||
|
||||
import {prisma} from "@/prisma";
|
||||
import {GearIcon} from "@radix-ui/react-icons";
|
||||
import Link from "next/link";
|
||||
import {projects} from "@/utils/mock-data";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ projectId: string }>) {
|
||||
|
||||
const {projectId} = await props.params
|
||||
|
||||
// const project = await prisma.project.findUnique({
|
||||
// where: {
|
||||
// id: projectId,
|
||||
// },
|
||||
// })
|
||||
|
||||
const project = projects.find(p => p.id === projectId)
|
||||
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div className="justify-between gap-2 sm:flex">
|
||||
<PageTitle className="flex items-center">
|
||||
{project.name}
|
||||
<Link className={buttonVariants({variant: "outline"})}
|
||||
href={`/dashboard/projects/${project.id}/edit`}>
|
||||
<GearIcon className="w-7 h-7"/>
|
||||
</Link>
|
||||
</PageTitle>
|
||||
<PageActions className="justify-between">
|
||||
|
||||
</PageActions>
|
||||
</div>
|
||||
{/*<PageDescription className="mt-5 sm:mt-0">{project.description}</PageDescription>*/}
|
||||
<PageContent className="flex flex-col w-full h-full">
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {prisma} from "@/prisma";
|
||||
import {ProjectForm} from "@/components/wrappers/project/ProjectForm";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const availableDatabases = await prisma.database.findMany({
|
||||
where: {
|
||||
projectId: null
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'desc',
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle>
|
||||
Create new project
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
Add databases
|
||||
{availableDatabases.map(database =>
|
||||
<div key={database.id}>
|
||||
{database.name}
|
||||
</div>)}
|
||||
<ProjectForm/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {prisma} from "@/prisma";
|
||||
import {CardsWithPagination} from "@/components/wrappers/cards-with-pagination";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import Link from 'next/link'
|
||||
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {projects} from "@/utils/mock-data";
|
||||
import {ProjectCard} from "@/components/wrappers/project/ProjectCard";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
// const projects = await prisma.project.findMany({})
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle>
|
||||
Projects
|
||||
</PageTitle>
|
||||
{projects.length > 0 && (
|
||||
<PageActions>
|
||||
<Link href={"/dashboard/projects/new"}>
|
||||
<Button>+ Create Project</Button>
|
||||
</Link>
|
||||
</PageActions>
|
||||
)}
|
||||
|
||||
</PageHeader>
|
||||
|
||||
<PageContent className="mt-10">
|
||||
|
||||
{projects.length > 0 ?
|
||||
<CardsWithPagination
|
||||
data={projects}
|
||||
cardItem={ProjectCard}
|
||||
cardsPerPage={4}
|
||||
numberOfColumns={1}
|
||||
/>
|
||||
:
|
||||
<Link
|
||||
href="/dashboard/projects/new"
|
||||
className=" flex item-center justify-center border-2 border-dashed transition-colors border-primary p-8 lg:p-12 w-full rounded-md">
|
||||
Create new Project
|
||||
</Link>
|
||||
|
||||
}
|
||||
|
||||
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user