@@ -14,6 +14,7 @@ import { ExternalLinkIcon, FolderGit2Icon, PlusCircle } from "lucide-react";
1414import { useRouter } from "next/navigation" ;
1515import { useState } from "react" ;
1616import { useSWRConfig } from "swr" ;
17+ import { usePermissions } from "@/contexts/PermissionsProvider" ;
1718import { Group } from "@/interfaces/Group" ;
1819import { useApiCall } from "@/utils/api" ;
1920import ModalHeader from "../modal/ModalHeader" ;
@@ -27,6 +28,7 @@ export const AddGroupButton = () => {
2728 const [ name , setName ] = useState < string > ( "" ) ;
2829 const [ open , setOpen ] = useState ( false ) ;
2930 const router = useRouter ( ) ;
31+ const { permission } = usePermissions ( ) ;
3032
3133 const createGroup = ( ) => {
3234 notify ( {
@@ -43,63 +45,71 @@ export const AddGroupButton = () => {
4345 } ;
4446
4547 return (
46- < Modal open = { open } onOpenChange = { setOpen } >
47- < ModalTrigger asChild >
48- < Button variant = { "primary" } size = { "sm" } className = { "ml-auto h-[42px]" } >
49- < PlusCircle size = { 16 } />
50- Create Group
51- </ Button >
52- </ ModalTrigger >
53- < ModalContent maxWidthClass = { "max-w-xl" } >
54- < ModalHeader
55- icon = { < FolderGit2Icon size = { 18 } /> }
56- title = "Create Group"
57- description = "Create a group to manage and organize access in your network"
58- color = "netbird"
59- />
60- < Separator />
61- < div className = { "px-8 flex-col flex gap-6 py-6" } >
62- < div >
63- < Label > Name</ Label >
64- < HelpText > Set an easily identifiable name for your group</ HelpText >
65- < Input
66- tabIndex = { 0 }
67- placeholder = { "e.g., Developers" }
68- value = { name }
69- onChange = { ( e ) => setName ( e . target . value ) }
70- />
48+ permission ?. groups ?. create && (
49+ < Modal open = { open } onOpenChange = { setOpen } >
50+ < ModalTrigger asChild >
51+ < Button
52+ variant = { "primary" }
53+ size = { "sm" }
54+ className = { "ml-auto h-[42px]" }
55+ >
56+ < PlusCircle size = { 16 } />
57+ Create Group
58+ </ Button >
59+ </ ModalTrigger >
60+ < ModalContent maxWidthClass = { "max-w-xl" } >
61+ < ModalHeader
62+ icon = { < FolderGit2Icon size = { 18 } /> }
63+ title = "Create Group"
64+ description = "Create a group to manage and organize access in your network"
65+ color = "netbird"
66+ />
67+ < Separator />
68+ < div className = { "px-8 flex-col flex gap-6 py-6" } >
69+ < div >
70+ < Label > Name</ Label >
71+ < HelpText >
72+ Set an easily identifiable name for your group
73+ </ HelpText >
74+ < Input
75+ tabIndex = { 0 }
76+ placeholder = { "e.g., Developers" }
77+ value = { name }
78+ onChange = { ( e ) => setName ( e . target . value ) }
79+ />
80+ </ div >
7181 </ div >
72- </ div >
73- < ModalFooter className = { "items-center" } >
74- < div className = { "w-full" } >
75- < Paragraph className = { "text-sm mt-auto" } >
76- Learn more about
77- < InlineLink
78- href = { "https://docs.netbird.io/how-to/manage-network-access" }
79- target = { "_blank" }
80- >
81- Groups
82- < ExternalLinkIcon size = { 12 } />
83- </ InlineLink >
84- </ Paragraph >
85- </ div >
86- < div className = { "flex gap-3 w-full justify-end" } >
87- < ModalClose asChild = { true } >
88- < Button variant = { "secondary" } > Cancel</ Button >
89- </ ModalClose >
82+ < ModalFooter className = { "items-center" } >
83+ < div className = { "w-full" } >
84+ < Paragraph className = { "text-sm mt-auto" } >
85+ Learn more about
86+ < InlineLink
87+ href = { "https://docs.netbird.io/how-to/manage-network-access" }
88+ target = { "_blank" }
89+ >
90+ Groups
91+ < ExternalLinkIcon size = { 12 } />
92+ </ InlineLink >
93+ </ Paragraph >
94+ </ div >
95+ < div className = { "flex gap-3 w-full justify-end" } >
96+ < ModalClose asChild = { true } >
97+ < Button variant = { "secondary" } > Cancel</ Button >
98+ </ ModalClose >
9099
91- < Button
92- variant = { "primary" }
93- data-cy = { "submit-route" }
94- disabled = { ! name }
95- onClick = { createGroup }
96- >
97- < PlusCircle size = { 16 } />
98- Create Group
99- </ Button >
100- </ div >
101- </ ModalFooter >
102- </ ModalContent >
103- </ Modal >
100+ < Button
101+ variant = { "primary" }
102+ data-cy = { "submit-route" }
103+ disabled = { ! name }
104+ onClick = { createGroup }
105+ >
106+ < PlusCircle size = { 16 } />
107+ Create Group
108+ </ Button >
109+ </ div >
110+ </ ModalFooter >
111+ </ ModalContent >
112+ </ Modal >
113+ )
104114 ) ;
105115} ;
0 commit comments