mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on the Portabase debug.
This commit is contained in:
@@ -7,23 +7,22 @@ import { ButtonDeleteProject } from "@/components/wrappers/dashboard/projects/Bu
|
||||
import { CardsWithPagination } from "@/components/wrappers/common/cards-with-pagination";
|
||||
import { ProjectDatabaseCard } from "@/components/wrappers/dashboard/projects/ProjectCard/ProjectDatabaseCard";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getCurrentOrganizationSlug } from "@/features/dashboard/organization-cookie";
|
||||
|
||||
import { db } from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { organization as drizzleOrganization } from "@/db/schema";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ slug: string; projectId: string }>) {
|
||||
const { slug: organizationSlug, projectId } = await props.params;
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug();
|
||||
const organization = await getOrganization({organizationSlug});
|
||||
|
||||
if (currentOrganizationSlug !== organizationSlug) {
|
||||
if (!organization || organization?.slug !== organizationSlug) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const org = await db.query.organization.findFirst({
|
||||
where: eq(drizzleOrganization.slug, currentOrganizationSlug),
|
||||
where: eq(drizzleOrganization.slug, organization.slug),
|
||||
});
|
||||
|
||||
if (!org) notFound();
|
||||
@@ -42,7 +41,7 @@ export default async function RoutePage(props: PageParams<{ slug: string; projec
|
||||
<div className="justify-between gap-2 sm:flex">
|
||||
<PageTitle className="flex items-center">
|
||||
{proj.name}
|
||||
<Link className={buttonVariants({ variant: "outline" })} href={`/dashboard/${currentOrganizationSlug}/projects/${proj.id}/edit`}>
|
||||
<Link className={buttonVariants({ variant: "outline" })} href={`/dashboard/${organization.slug}/projects/${proj.id}/edit`}>
|
||||
<GearIcon className="w-7 h-7" />
|
||||
</Link>
|
||||
</PageTitle>
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
import { PageParams } from "@/types/next";
|
||||
import { Page, PageContent, PageHeader, PageTitle } from "@/features/layout/page";
|
||||
import { ProjectForm } from "@/components/wrappers/dashboard/projects/ProjectsForm/ProjectForm";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getCurrentOrganizationSlug } from "@/features/dashboard/organization-cookie";
|
||||
|
||||
import { db } from "@/db";
|
||||
import { DatabaseWith, organization as drizzleOrganization } from "@/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {ProjectForm} from "@/components/wrappers/dashboard/projects/ProjectsForm/ProjectForm";
|
||||
import {notFound} from "next/navigation";
|
||||
import {db} from "@/db";
|
||||
import {DatabaseWith, organization as drizzleOrganization} from "@/db/schema";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
const { slug: organizationSlug } = await props.params;
|
||||
const {slug: organizationSlug} = await props.params;
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug();
|
||||
if (currentOrganizationSlug !== organizationSlug) {
|
||||
const organization = await getOrganization({organizationSlug});
|
||||
|
||||
if (!organization || organization?.slug !== organizationSlug) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const availableDatabases = (
|
||||
await db.query.database.findMany({
|
||||
where: (db, { isNull }) => isNull(db.projectId),
|
||||
where: (db, {isNull}) => isNull(db.projectId),
|
||||
with: {
|
||||
agent: true,
|
||||
project: true,
|
||||
backups: true,
|
||||
restorations: true,
|
||||
},
|
||||
orderBy: (db, { desc }) => [desc(db.createdAt)],
|
||||
orderBy: (db, {desc}) => [desc(db.createdAt)],
|
||||
})
|
||||
).filter((db) => db.project !== null) as DatabaseWith[];
|
||||
|
||||
const org = await db.query.organization.findFirst({
|
||||
where: eq(drizzleOrganization.slug, currentOrganizationSlug),
|
||||
where: eq(drizzleOrganization.slug, organization.slug),
|
||||
});
|
||||
|
||||
if (!org) notFound();
|
||||
@@ -41,7 +41,7 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
<PageTitle>Create new project</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<ProjectForm databases={availableDatabases} organization={org} />
|
||||
<ProjectForm databases={availableDatabases} organization={org}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { PageParams } from "@/types/next";
|
||||
import { CardsWithPagination } from "@/components/wrappers/common/cards-with-pagination";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Page, PageActions, PageContent, PageHeader, PageTitle } from "@/features/layout/page";
|
||||
import { ProjectCard } from "@/components/wrappers/dashboard/projects/ProjectCard/ProjectCard";
|
||||
import { db } from "@/db";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getOrganization } from "@/lib/auth/auth";
|
||||
import {PageParams} from "@/types/next";
|
||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {ProjectCard} from "@/components/wrappers/dashboard/projects/ProjectCard/ProjectCard";
|
||||
import {db} from "@/db";
|
||||
import {notFound} from "next/navigation";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
const { slug: organizationSlug } = await props.params;
|
||||
const {slug: organizationSlug} = await props.params;
|
||||
|
||||
const organization = await getOrganization(organizationSlug);
|
||||
const organization = await getOrganization({organizationSlug});
|
||||
|
||||
if (!organization || organization?.slug !== organizationSlug) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const projects = await db.query.project.findMany({
|
||||
where: (project, { eq, and, not }) => and(eq(project.organizationId, organization.id), not(eq(project.isArchived, true))),
|
||||
where: (project, {
|
||||
eq,
|
||||
and,
|
||||
not
|
||||
}) => and(eq(project.organizationId, organization.id), not(eq(project.isArchived, true))),
|
||||
with: {
|
||||
databases: true,
|
||||
},
|
||||
@@ -40,7 +44,8 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
|
||||
<PageContent className="mt-10">
|
||||
{projects.length > 0 ? (
|
||||
<CardsWithPagination organizationSlug={organizationSlug} data={projects} cardItem={ProjectCard} cardsPerPage={4} numberOfColumns={1} />
|
||||
<CardsWithPagination organizationSlug={organizationSlug} data={projects} cardItem={ProjectCard}
|
||||
cardsPerPage={4} numberOfColumns={1}/>
|
||||
) : (
|
||||
<Link
|
||||
href={`/dashboard/${organizationSlug}/projects/new`}
|
||||
|
||||
@@ -5,47 +5,21 @@ import {prisma} from "@/prisma";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {notFound} from "next/navigation";
|
||||
import {OrganizationForm} from "@/components/wrappers/dashboard/organization/OrganizationForm/OrganizationForm";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{
|
||||
slug: string;
|
||||
}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
const user = await requiredCurrentUser()
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
|
||||
const {slug: organizationSlug} = await props.params;
|
||||
|
||||
const organization = await getOrganization({organizationSlug});
|
||||
|
||||
if (!organization) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where:{
|
||||
slug: currentOrganizationSlug,
|
||||
},
|
||||
include:{
|
||||
users:{
|
||||
include:{
|
||||
user:{
|
||||
}
|
||||
},
|
||||
where: {
|
||||
user: {
|
||||
id: {
|
||||
not: user.id, // Exclude user with id: 1
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
deleted: {not: true},
|
||||
id: {not: user.id}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
return(
|
||||
<Page>
|
||||
@@ -55,7 +29,7 @@ export default async function RoutePage(props: PageParams<{
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<OrganizationForm users={users} defaultValues={organization}/>
|
||||
<OrganizationForm members={organization.members} defaultValues={organization}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {prisma} from "@/prisma";
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {currentUser} from "@/lib/auth/current-user";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
import {notFound} from "next/navigation";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {SettingsTabs} from "@/components/wrappers/dashboard/settings/SettingsTabs/SettingsTabs";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
@@ -8,45 +10,52 @@ import {
|
||||
DeleteOrganizationButton
|
||||
} from "@/components/wrappers/dashboard/organization/DeleteOrganization/DeleteOrganizationButton";
|
||||
import {EditButtonSettings} from "@/components/wrappers/dashboard/settings/EditButtonSettings/EditButtonSettings";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
const user = await requiredCurrentUser()
|
||||
export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
const {slug: organizationSlug} = await props.params;
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
const user = await currentUser();
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where: {
|
||||
slug: currentOrganizationSlug,
|
||||
},
|
||||
include: {
|
||||
users:{
|
||||
include:{
|
||||
user: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const organization = await getOrganization({organizationSlug});
|
||||
|
||||
const currentOrganizationUser = await prisma.userOrganization.findFirst({
|
||||
where:{
|
||||
userId: user.id,
|
||||
organization:{
|
||||
slug: currentOrganizationSlug != "" ? currentOrganizationSlug : "default",
|
||||
}
|
||||
}
|
||||
})
|
||||
if (currentOrganizationUser.role != "admin") {
|
||||
notFound()
|
||||
if (!organization || organization?.slug !== organizationSlug) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
|
||||
const settings = await prisma.settings.findUnique({
|
||||
where: {
|
||||
name: "system"
|
||||
}
|
||||
})
|
||||
|
||||
// const organization = await prisma.organization.findUnique({
|
||||
// where: {
|
||||
// slug: currentOrganizationSlug,
|
||||
// },
|
||||
// include: {
|
||||
// users:{
|
||||
// include:{
|
||||
// user: {}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// const currentOrganizationUser = await prisma.userOrganization.findFirst({
|
||||
// where:{
|
||||
// userId: user.id,
|
||||
// organization:{
|
||||
// slug: currentOrganizationSlug != "" ? currentOrganizationSlug : "default",
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// if (currentOrganizationUser.role != "admin") {
|
||||
// notFound()
|
||||
// }
|
||||
//
|
||||
//
|
||||
// const settings = await prisma.settings.findUnique({
|
||||
// where: {
|
||||
// name: "system"
|
||||
// }
|
||||
// })
|
||||
|
||||
return (
|
||||
<Page>
|
||||
@@ -59,7 +68,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
</PageTitle>
|
||||
<PageActions>
|
||||
{organization.slug != "default" ?
|
||||
<DeleteOrganizationButton organizationSlug={currentOrganizationSlug}/>
|
||||
<DeleteOrganizationButton organizationSlug={organization.slug}/>
|
||||
: null}
|
||||
</PageActions>
|
||||
</PageHeader>
|
||||
@@ -67,7 +76,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
Manage your organization settings.
|
||||
</PageDescription>
|
||||
<PageContent>
|
||||
<SettingsTabs settings={settings} currentUser={user} users={organization.users}/>
|
||||
{/*<SettingsTabs settings={settings} currentUser={user} users={organization.users}/>*/}
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
|
||||
@@ -12,8 +12,6 @@ export default async function Layout({ children }: { children: React.ReactNode }
|
||||
if (!user) redirect("/login");
|
||||
|
||||
return (
|
||||
// <HydrationZustand>
|
||||
// <GlobalStoreProvider>
|
||||
<>
|
||||
<SidebarProvider>
|
||||
<div className="flex flex-col lg:flex-row w-full">
|
||||
@@ -25,7 +23,5 @@ export default async function Layout({ children }: { children: React.ReactNode }
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</>
|
||||
// </GlobalStoreProvider>
|
||||
// </HydrationZustand>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user