mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on role in workspace.
This commit is contained in:
-2
@@ -21,8 +21,6 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(users)
|
||||
|
||||
const settings = await prisma.settings.findUnique({
|
||||
where: {
|
||||
name: "system"
|
||||
-4
@@ -1,7 +1,6 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {AgentForm} from "@/components/wrappers/dashboard/agent/AgentForm/AgentForm";
|
||||
import {requiredCurrentUser} from "@/auth/current-user";
|
||||
import {prisma} from "@/prisma";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
@@ -11,8 +10,6 @@ export default async function RoutePage(props: PageParams<{
|
||||
}>) {
|
||||
|
||||
const {agentId} = await props.params
|
||||
|
||||
const user = await requiredCurrentUser()
|
||||
const agent = await prisma.agent.findUnique({
|
||||
where: {
|
||||
id: agentId,
|
||||
@@ -23,7 +20,6 @@ export default async function RoutePage(props: PageParams<{
|
||||
notFound();
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
+2
-5
@@ -1,14 +1,11 @@
|
||||
import Link from "next/link";
|
||||
import {GearIcon} from "@radix-ui/react-icons";
|
||||
import {KeyRound} from "lucide-react";
|
||||
|
||||
import {prisma} from "@/prisma";
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageTitle} from "@/features/layout/page";
|
||||
import {Page, PageContent, PageDescription, PageTitle} from "@/features/layout/page";
|
||||
import {formatDateLastContact} from "@/utils/date-formatting";
|
||||
import {Button, buttonVariants} from "@/components/ui/button";
|
||||
import {buttonVariants} from "@/components/ui/button";
|
||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
||||
import {AgentModalKey} from "@/components/wrappers/dashboard/agent/AgentModalKey/AgentModalKey";
|
||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||
import {DatabaseCard} from "@/components/wrappers/dashboard/projects/ProjectCard/ProjectDatabaseCard";
|
||||
import {AgentCardKey} from "@/components/wrappers/dashboard/agent/AgentCardKey/AgentCardKey";
|
||||
+8
@@ -1,10 +1,18 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {AgentForm} from "@/components/wrappers/dashboard/agent/AgentForm/AgentForm";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const user = await currentUser();
|
||||
|
||||
if(user.role != "admin"){
|
||||
notFound()
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
+1
-7
@@ -5,20 +5,14 @@ import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagin
|
||||
import {Button} from "@/components/ui/button";
|
||||
import Link from 'next/link'
|
||||
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
// import {db} from "@/db";
|
||||
import {enhance} from "@zenstackhq/runtime";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {db} from "@/db";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const user = await currentUser();
|
||||
const db = enhance(prisma, {user: user});
|
||||
|
||||
const agents = await db.agent.findMany()
|
||||
|
||||
console.log("aaaa", agents)
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from "react";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
export default async function Layout({children}: { children: React.ReactNode }) {
|
||||
|
||||
const user = await currentUser()
|
||||
if(user.role != "admin"){
|
||||
notFound()
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -3,15 +3,12 @@ import {PageParams} from "@/types/next";
|
||||
import {Page, PageActions, PageContent, PageDescription, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
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, buttonVariants} from "@/components/ui/button";
|
||||
import {ButtonWithConfirm} from "@/components/wrappers/common/button/button-with-confirm";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
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";
|
||||
import {notFound} from "next/navigation";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
@@ -22,21 +19,27 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where: {
|
||||
slug: currentOrganizationSlug,
|
||||
},
|
||||
include: {
|
||||
users:{
|
||||
include:{
|
||||
user: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
organizations: {
|
||||
some: {
|
||||
organizationId: organization.id
|
||||
},
|
||||
},
|
||||
deleted: {not: true},
|
||||
|
||||
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({
|
||||
@@ -64,7 +67,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
Manage your organization settings.
|
||||
</PageDescription>
|
||||
<PageContent>
|
||||
<SettingsTabs settings={settings} currentUser={user} users={users}/>
|
||||
<SettingsTabs settings={settings} currentUser={user} users={organization.users}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {redirect} from "next/navigation";
|
||||
import {getCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
import {getCurrentOrganizationSlug, setCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const currentOrganizationSlug = await getCurrentOrganizationSlug()
|
||||
if (currentOrganizationSlug == "") {
|
||||
redirect(`/dashboard/default/projects`)
|
||||
}
|
||||
redirect(`/dashboard/${currentOrganizationSlug}/projects`)
|
||||
}
|
||||
Reference in New Issue
Block a user