File tree Expand file tree Collapse file tree 7 files changed +90
-1
lines changed Expand file tree Collapse file tree 7 files changed +90
-1
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,14 @@ class ApiMethods {
505
505
return response . data ;
506
506
} ;
507
507
508
+ createOrganization = async ( params : TypesGen . CreateOrganizationRequest ) => {
509
+ const response = await this . axios . post < TypesGen . Organization > (
510
+ "/api/v2/organizations" ,
511
+ params ,
512
+ ) ;
513
+ return response . data ;
514
+ } ;
515
+
508
516
getOrganization = async (
509
517
organizationId : string ,
510
518
) : Promise < TypesGen . Organization > => {
Original file line number Diff line number Diff line change
1
+ import type { QueryClient } from "react-query" ;
2
+ import { API } from "api/api" ;
3
+ import type { CreateOrganizationRequest } from "api/typesGenerated" ;
4
+ import { meKey , myOrganizationsKey } from "./users" ;
5
+
6
+ export const createOrganization = ( queryClient : QueryClient ) => {
7
+ return {
8
+ mutationFn : ( params : CreateOrganizationRequest ) =>
9
+ API . createOrganization ( params ) ,
10
+
11
+ onSuccess : async ( ) => {
12
+ await queryClient . invalidateQueries ( meKey ) ;
13
+ await queryClient . invalidateQueries ( myOrganizationsKey ) ;
14
+ } ,
15
+ } ;
16
+ } ;
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ export const authMethods = () => {
124
124
} ;
125
125
} ;
126
126
127
- const meKey = [ "me" ] ;
127
+ export const meKey = [ "me" ] ;
128
128
129
129
export const me = ( metadata : MetadataState < User > ) => {
130
130
return cachedQuery ( {
@@ -249,3 +249,12 @@ export const updateAppearanceSettings = (
249
249
} ,
250
250
} ;
251
251
} ;
252
+
253
+ export const myOrganizationsKey = [ "organizations" , "me" ] as const ;
254
+
255
+ export const myOrganizations = ( ) => {
256
+ return {
257
+ queryKey : myOrganizationsKey ,
258
+ queryFn : ( ) => API . getOrganizations ( ) ,
259
+ } ;
260
+ } ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
Sidebar as BaseSidebar ,
13
13
SidebarNavItem ,
14
14
} from "components/Sidebar/Sidebar" ;
15
+ import TeamsIcon from "@mui/icons-material/Groups" ;
15
16
16
17
export const Sidebar : FC = ( ) => {
17
18
return (
@@ -22,6 +23,9 @@ export const Sidebar: FC = () => {
22
23
< SidebarNavItem href = "licenses" icon = { ApprovalIcon } >
23
24
Licenses
24
25
</ SidebarNavItem >
26
+ < SidebarNavItem href = "teams" icon = { TeamsIcon } >
27
+ Teams
28
+ </ SidebarNavItem >
25
29
< SidebarNavItem href = "appearance" icon = { Brush } >
26
30
Appearance
27
31
</ SidebarNavItem >
Original file line number Diff line number Diff line change
1
+ import Button from "@mui/material/Button" ;
2
+ import { type FC , useState } from "react" ;
3
+ import { useMutation , useQuery , useQueryClient } from "react-query" ;
4
+ import { createOrganization } from "api/queries/organizations" ;
5
+ import { myOrganizations } from "api/queries/users" ;
6
+ import { TextField } from "@mui/material" ;
7
+
8
+ const TeamsSettingsPage : FC = ( ) => {
9
+ const queryClient = useQueryClient ( ) ;
10
+ const addTeamMutation = useMutation ( createOrganization ( queryClient ) ) ;
11
+ const organizationsQuery = useQuery ( myOrganizations ( ) ) ;
12
+ const [ newOrgName , setNewOrgName ] = useState ( "" ) ;
13
+ return (
14
+ < >
15
+ < TextField
16
+ label = "New organization name"
17
+ onChange = { ( event ) => setNewOrgName ( event . target . value ) }
18
+ />
19
+ < p > { String ( addTeamMutation . error ) } </ p >
20
+ < Button onClick = { ( ) => addTeamMutation . mutate ( { name : newOrgName } ) } >
21
+ add new team
22
+ </ Button >
23
+
24
+ { organizationsQuery . data ?. map ( ( org ) => (
25
+ < div key = { org . id } >
26
+ { org . name } { " " }
27
+ < Button
28
+ onClick = { ( ) =>
29
+ console . log (
30
+ "I tried to delete an org and all I got was this log message" ,
31
+ )
32
+ }
33
+ >
34
+ Delete
35
+ </ Button >
36
+ </ div >
37
+ ) ) }
38
+ </ >
39
+ ) ;
40
+ } ;
41
+
42
+ export default TeamsSettingsPage ;
Original file line number Diff line number Diff line change @@ -220,6 +220,10 @@ const AddNewLicensePage = lazy(
220
220
( ) =>
221
221
import ( "./pages/DeploySettingsPage/LicensesSettingsPage/AddNewLicensePage" ) ,
222
222
) ;
223
+ const TeamsSettingsPage = lazy (
224
+ ( ) =>
225
+ import ( "./pages/DeploySettingsPage/TeamsSettingsPage/TeamsSettingsPage" ) ,
226
+ ) ;
223
227
const TemplateEmbedPage = lazy (
224
228
( ) => import ( "./pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage" ) ,
225
229
) ;
@@ -329,6 +333,7 @@ export const router = createBrowserRouter(
329
333
< Route path = "general" element = { < GeneralSettingsPage /> } />
330
334
< Route path = "licenses" element = { < LicensesSettingsPage /> } />
331
335
< Route path = "licenses/add" element = { < AddNewLicensePage /> } />
336
+ < Route path = "teams" element = { < TeamsSettingsPage /> } />
332
337
< Route path = "security" element = { < SecuritySettingsPage /> } />
333
338
< Route
334
339
path = "observability"
You can’t perform that action at this time.
0 commit comments