mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on add/delete users to workspace. Edit workspaces and some permissions.
This commit is contained in:
@@ -8,11 +8,21 @@ import {ButtonDeleteProject} from "@/components/wrappers/dashboard/projects/Butt
|
||||
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";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ projectId: string }>) {
|
||||
export default async function RoutePage(props: PageParams<{ slug:string, projectId: string }>) {
|
||||
|
||||
const {slug: organizationSlug, projectId} = await props.params
|
||||
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
|
||||
const {projectId} = await props.params
|
||||
|
||||
const project = await prisma.project.findUnique({
|
||||
where: {
|
||||
@@ -33,7 +43,7 @@ export default async function RoutePage(props: PageParams<{ projectId: string }>
|
||||
<PageTitle className="flex items-center">
|
||||
{project.name}
|
||||
<Link className={buttonVariants({variant: "outline"})}
|
||||
href={`/dashboard/projects/${project.id}/edit`}>
|
||||
href={`/dashboard/${currentOrganizationSlug}/projects/${project.id}/edit`}>
|
||||
<GearIcon className="w-7 h-7"/>
|
||||
</Link>
|
||||
</PageTitle>
|
||||
@@ -51,6 +61,7 @@ export default async function RoutePage(props: PageParams<{ projectId: string }>
|
||||
{project.databases.length > 0 ?
|
||||
<CardsWithPagination
|
||||
data={project.databases}
|
||||
organizationSlug={organizationSlug}
|
||||
cardItem={ProjectDatabaseCard}
|
||||
cardsPerPage={4}
|
||||
numberOfColumns={1}
|
||||
|
||||
@@ -2,9 +2,17 @@ import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {prisma} from "@/prisma";
|
||||
import {ProjectForm} from "@/components/wrappers/dashboard/projects/ProjectsForm/ProjectForm";
|
||||
import {notFound} from "next/navigation";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
|
||||
const availableDatabases = await prisma.database.findMany({
|
||||
where: {
|
||||
@@ -20,7 +28,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const organization = await prisma.organization.findFirst({
|
||||
where: {
|
||||
slug: 'default',
|
||||
slug: currentOrganizationSlug,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
</PageTitle>
|
||||
{projects.length > 0 && (
|
||||
<PageActions>
|
||||
<Link href={"/dashboard/projects/new"}>
|
||||
<Link href={`/dashboard/${currentOrganizationSlug}/projects/new`}>
|
||||
<Button>+ Create Project</Button>
|
||||
</Link>
|
||||
</PageActions>
|
||||
@@ -59,6 +59,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
|
||||
{projects.length > 0 ?
|
||||
<CardsWithPagination
|
||||
organizationSlug={currentOrganizationSlug}
|
||||
data={projects}
|
||||
cardItem={ProjectCard}
|
||||
cardsPerPage={4}
|
||||
@@ -66,7 +67,7 @@ export default async function RoutePage(props: PageParams<{slug: string}>) {
|
||||
/>
|
||||
:
|
||||
<Link
|
||||
href="/dashboard/projects/new"
|
||||
href={`/dashboard/${currentOrganizationSlug}/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>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {prisma} from "@/prisma";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {notFound} from "next/navigation";
|
||||
import {OrganizationForm} from "@/components/wrappers/dashboard/organization/OrganizationForm/OrganizationForm";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{
|
||||
slug: string;
|
||||
}>) {
|
||||
const {slug: organizationSlug} = await props.params
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
if(currentOrganizationSlug != organizationSlug) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where:{
|
||||
slug: currentOrganizationSlug,
|
||||
},
|
||||
include:{
|
||||
users:{
|
||||
include:{
|
||||
user:{}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
deleted: {not: true},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
return(
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle>
|
||||
Edit {organization.name}
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<OrganizationForm users={users} defaultValues={organization}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
@@ -4,11 +4,14 @@ import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle}
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {SettingsTabs} from "@/components/wrappers/dashboard/settings/SettingsTabs/SettingsTabs";
|
||||
import {getCurrentOrganizationId, getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Button, buttonVariants} from "@/components/ui/button";
|
||||
import {ButtonWithConfirm} from "@/components/wrappers/common/button/button-with-confirm";
|
||||
import {
|
||||
DeleteOrganizationButton
|
||||
} from "@/components/wrappers/dashboard/organization/DeleteOrganization/DeleteOrganizationButton";
|
||||
import {GearIcon} from "@radix-ui/react-icons";
|
||||
import Link from "next/link";
|
||||
import {EditButtonSettings} from "@/components/wrappers/dashboard/settings/EditButtonSettings/EditButtonSettings";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
@@ -17,7 +20,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where:{
|
||||
where: {
|
||||
slug: currentOrganizationSlug,
|
||||
}
|
||||
})
|
||||
@@ -35,6 +38,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
})
|
||||
|
||||
|
||||
|
||||
const settings = await prisma.settings.findUnique({
|
||||
where: {
|
||||
name: "system"
|
||||
@@ -44,12 +48,16 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle>
|
||||
<PageTitle className="flex items-center">
|
||||
Settings
|
||||
{organization.slug != "default" ?
|
||||
<EditButtonSettings/>
|
||||
: null}
|
||||
</PageTitle>
|
||||
<PageActions>
|
||||
{/*<Button variant="destructive">Delete Organization</Button>*/}
|
||||
<DeleteOrganizationButton organizationSlug={currentOrganizationSlug}/>
|
||||
{organization.slug != "default" ?
|
||||
<DeleteOrganizationButton organizationSlug={currentOrganizationSlug}/>
|
||||
: null}
|
||||
</PageActions>
|
||||
</PageHeader>
|
||||
<PageDescription>
|
||||
|
||||
@@ -38,7 +38,6 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
</PageHeader>
|
||||
<PageContent className="mt-10">
|
||||
<AdminTabs settings={settings} currentUser={user} users={users}/>
|
||||
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user