@@ -26,7 +26,6 @@ import {
26
26
FormSection ,
27
27
HorizontalForm ,
28
28
} from "components/Form/Form" ;
29
- import { PageHeader , PageHeaderTitle } from "components/PageHeader/PageHeader" ;
30
29
import { getFormHelpers } from "utils/formUtils" ;
31
30
32
31
export type CreateEditRolePageViewProps = {
@@ -48,11 +47,6 @@ export const CreateEditRolePageView: FC<CreateEditRolePageViewProps> = ({
48
47
49
48
return (
50
49
< >
51
- < PageHeader css = { { paddingTop : 8 } } >
52
- < PageHeaderTitle >
53
- { role ? "Edit" : "Create" } custom role
54
- </ PageHeaderTitle >
55
- </ PageHeader >
56
50
< HorizontalForm onSubmit = { form . handleSubmit } >
57
51
< FormSection
58
52
title = "Role settings"
@@ -101,6 +95,14 @@ interface ActionCheckboxesProps {
101
95
form : ReturnType < typeof useFormik < Role > > & { values : Role } ;
102
96
}
103
97
98
+ const ResourceActionComparator = (
99
+ p : Permission ,
100
+ resource : string ,
101
+ action : string ,
102
+ ) =>
103
+ p . resource_type === resource &&
104
+ ( p . action . toString ( ) === "*" || p . action === action ) ;
105
+
104
106
const ActionCheckboxes : FC < ActionCheckboxesProps > = ( { permissions, form } ) => {
105
107
const [ checkedActions , setCheckActions ] = useState ( permissions ) ;
106
108
@@ -146,18 +148,19 @@ const ActionCheckboxes: FC<ActionCheckboxesProps> = ({ permissions, form }) => {
146
148
< Checkbox
147
149
name = { `${ resourceKey } :${ actionKey } ` }
148
150
checked = {
149
- checkedActions ?. some (
150
- ( p ) =>
151
- p . resource_type === resourceKey &&
152
- ( p . action . toString ( ) === "*" ||
153
- p . action === actionKey ) ,
151
+ checkedActions ?. some ( ( p ) =>
152
+ ResourceActionComparator (
153
+ p ,
154
+ resourceKey ,
155
+ actionKey ,
156
+ ) ,
154
157
) || false
155
158
}
156
159
onChange = { ( e ) => handleCheckChange ( e , form ) }
157
160
/>
158
161
{ actionKey }
159
162
</ span > { " " }
160
- - { " " }
163
+ – { " " }
161
164
< span css = { styles . actionDescription } > { value } </ span >
162
165
</ li >
163
166
) ;
0 commit comments