@@ -2,8 +2,8 @@ import { getErrorMessage } from "api/errors";
2
2
import { deleteOrganizationRole , organizationRoles } from "api/queries/roles" ;
3
3
import type { Role } from "api/typesGenerated" ;
4
4
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog" ;
5
+ import { EmptyState } from "components/EmptyState/EmptyState" ;
5
6
import { displayError , displaySuccess } from "components/GlobalSnackbar/utils" ;
6
- import { Loader } from "components/Loader/Loader" ;
7
7
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader" ;
8
8
import { Stack } from "components/Stack/Stack" ;
9
9
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility" ;
@@ -22,7 +22,7 @@ export const CustomRolesPage: FC = () => {
22
22
const { organization : organizationName } = useParams ( ) as {
23
23
organization : string ;
24
24
} ;
25
- const { organizationPermissions } = useOrganizationSettings ( ) ;
25
+ const { organization , organizationPermissions } = useOrganizationSettings ( ) ;
26
26
27
27
const [ roleToDelete , setRoleToDelete ] = useState < Role > ( ) ;
28
28
@@ -49,65 +49,67 @@ export const CustomRolesPage: FC = () => {
49
49
}
50
50
} , [ organizationRolesQuery . error ] ) ;
51
51
52
- if ( ! organizationPermissions ) {
53
- return < Loader /> ;
52
+ if ( ! organization ) {
53
+ return < EmptyState message = "Organization not found" /> ;
54
54
}
55
55
56
56
return (
57
- < RequirePermission
58
- isFeatureVisible = {
59
- organizationPermissions . assignOrgRoles ||
60
- organizationPermissions . createOrgRoles ||
61
- organizationPermissions . viewOrgRoles
62
- }
63
- >
57
+ < >
64
58
< Helmet >
65
- < title > { pageTitle ( "Custom Roles" ) } </ title >
59
+ < title >
60
+ { pageTitle (
61
+ "Custom Roles" ,
62
+ organization . display_name || organization . name ,
63
+ ) }
64
+ </ title >
66
65
</ Helmet >
67
-
68
- < Stack
69
- alignItems = "baseline"
70
- direction = "row"
71
- justifyContent = "space-between"
66
+ < RequirePermission
67
+ isFeatureVisible = { organizationPermissions ?. viewOrgRoles ?? false }
72
68
>
73
- < SettingsHeader
74
- title = "Roles"
75
- description = "Manage roles for this organization."
76
- />
77
- </ Stack >
69
+ < Stack
70
+ alignItems = "baseline"
71
+ direction = "row"
72
+ justifyContent = "space-between"
73
+ >
74
+ < SettingsHeader
75
+ title = "Roles"
76
+ description = "Manage roles for this organization."
77
+ />
78
+ </ Stack >
78
79
79
- < CustomRolesPageView
80
- builtInRoles = { builtInRoles }
81
- customRoles = { customRoles }
82
- onDeleteRole = { setRoleToDelete }
83
- canAssignOrgRole = { organizationPermissions . assignOrgRoles }
84
- canCreateOrgRole = { organizationPermissions . createOrgRoles }
85
- isCustomRolesEnabled = { isCustomRolesEnabled }
86
- />
80
+ < CustomRolesPageView
81
+ builtInRoles = { builtInRoles }
82
+ customRoles = { customRoles }
83
+ onDeleteRole = { setRoleToDelete }
84
+ canAssignOrgRole = { organizationPermissions ? .assignOrgRoles ?? false }
85
+ canCreateOrgRole = { organizationPermissions ? .createOrgRoles ?? false }
86
+ isCustomRolesEnabled = { isCustomRolesEnabled }
87
+ />
87
88
88
- < DeleteDialog
89
- key = { roleToDelete ?. name }
90
- isOpen = { roleToDelete !== undefined }
91
- confirmLoading = { deleteRoleMutation . isLoading }
92
- name = { roleToDelete ?. name ?? "" }
93
- entity = "role"
94
- onCancel = { ( ) => setRoleToDelete ( undefined ) }
95
- onConfirm = { async ( ) => {
96
- try {
97
- if ( roleToDelete ) {
98
- await deleteRoleMutation . mutateAsync ( roleToDelete . name ) ;
89
+ < DeleteDialog
90
+ key = { roleToDelete ?. name }
91
+ isOpen = { roleToDelete !== undefined }
92
+ confirmLoading = { deleteRoleMutation . isLoading }
93
+ name = { roleToDelete ?. name ?? "" }
94
+ entity = "role"
95
+ onCancel = { ( ) => setRoleToDelete ( undefined ) }
96
+ onConfirm = { async ( ) => {
97
+ try {
98
+ if ( roleToDelete ) {
99
+ await deleteRoleMutation . mutateAsync ( roleToDelete . name ) ;
100
+ }
101
+ setRoleToDelete ( undefined ) ;
102
+ await organizationRolesQuery . refetch ( ) ;
103
+ displaySuccess ( "Custom role deleted successfully!" ) ;
104
+ } catch ( error ) {
105
+ displayError (
106
+ getErrorMessage ( error , "Failed to delete custom role" ) ,
107
+ ) ;
99
108
}
100
- setRoleToDelete ( undefined ) ;
101
- await organizationRolesQuery . refetch ( ) ;
102
- displaySuccess ( "Custom role deleted successfully!" ) ;
103
- } catch ( error ) {
104
- displayError (
105
- getErrorMessage ( error , "Failed to delete custom role" ) ,
106
- ) ;
107
- }
108
- } }
109
- />
110
- </ RequirePermission >
109
+ } }
110
+ />
111
+ </ RequirePermission >
112
+ </ >
111
113
) ;
112
114
} ;
113
115
0 commit comments