File tree Expand file tree Collapse file tree 6 files changed +96
-2
lines changed Expand file tree Collapse file tree 6 files changed +96
-2
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,20 @@ 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
+
516
+ deleteOrganization = async ( orgId : string ) => {
517
+ await this . axios . delete < TypesGen . Organization > (
518
+ `/api/v2/organizations/${ orgId } ` ,
519
+ ) ;
520
+ } ;
521
+
508
522
getOrganization = async (
509
523
organizationId : string ,
510
524
) : 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
+ } ;
17
+
18
+ export const deleteOrganization = ( queryClient : QueryClient ) => {
19
+ return {
20
+ mutationFn : ( orgId : string ) => API . deleteOrganization ( orgId ) ,
21
+
22
+ onSuccess : async ( ) => {
23
+ await queryClient . invalidateQueries ( meKey ) ;
24
+ await queryClient . invalidateQueries ( myOrganizationsKey ) ;
25
+ } ,
26
+ } ;
27
+ } ;
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 ( {
@@ -250,9 +250,11 @@ export const updateAppearanceSettings = (
250
250
} ;
251
251
} ;
252
252
253
+ export const myOrganizationsKey = [ "organizations" , "me" ] as const ;
254
+
253
255
export const myOrganizations = ( ) => {
254
256
return {
255
- queryKey : [ "organizations" , "me" ] ,
257
+ queryKey : myOrganizationsKey ,
256
258
queryFn : ( ) => API . getOrganizations ( ) ,
257
259
} ;
258
260
} ;
Original file line number Diff line number Diff line change 1
1
import Brush from "@mui/icons-material/Brush" ;
2
+ import TeamsIcon from "@mui/icons-material/Groups" ;
2
3
import HubOutlinedIcon from "@mui/icons-material/HubOutlined" ;
3
4
import InsertChartIcon from "@mui/icons-material/InsertChart" ;
4
5
import LaunchOutlined from "@mui/icons-material/LaunchOutlined" ;
@@ -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 TextField from "@mui/material/TextField" ;
3
+ import { type FC , useState } from "react" ;
4
+ import { useMutation , useQuery , useQueryClient } from "react-query" ;
5
+ import {
6
+ createOrganization ,
7
+ deleteOrganization ,
8
+ } from "api/queries/organizations" ;
9
+ import { myOrganizations } from "api/queries/users" ;
10
+
11
+ const TeamsSettingsPage : FC = ( ) => {
12
+ const queryClient = useQueryClient ( ) ;
13
+ const addTeamMutation = useMutation ( createOrganization ( queryClient ) ) ;
14
+ const deleteTeamMutation = useMutation ( deleteOrganization ( queryClient ) ) ;
15
+ const organizationsQuery = useQuery ( myOrganizations ( ) ) ;
16
+ const [ newOrgName , setNewOrgName ] = useState ( "" ) ;
17
+ return (
18
+ < >
19
+ < TextField
20
+ label = "New organization name"
21
+ onChange = { ( event ) => setNewOrgName ( event . target . value ) }
22
+ />
23
+ < p > { String ( addTeamMutation . error ) } </ p >
24
+ < Button onClick = { ( ) => addTeamMutation . mutate ( { name : newOrgName } ) } >
25
+ add new team
26
+ </ Button >
27
+
28
+ < div > { String ( deleteTeamMutation . error ) } </ div >
29
+
30
+ { organizationsQuery . data ?. map ( ( org ) => (
31
+ < div key = { org . id } >
32
+ { org . name } { " " }
33
+ < Button onClick = { ( ) => deleteTeamMutation . mutate ( org . id ) } >
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