1- import { Box } from 'grommet'
2- import { Span , Switch } from 'honorable'
3- import { Tab , TabList , TabPanel } from '@pluralsh/design-system'
1+ import { Switch , Tab , TabList , TabPanel } from '@pluralsh/design-system'
42import { useCallback , useRef , useState } from 'react'
53
6- import { ListItem } from '../profile/ListItem'
4+ import { useTheme } from 'styled-components'
5+
76import { GqlError } from '../utils/Alert'
87
8+ import { List , ListItem } from '../utils/List'
9+
910import { PermissionTypes } from './types'
1011
1112import { GeneralAttributes } from './Role'
@@ -18,6 +19,7 @@ function PermissionToggle({
1819 first,
1920 last,
2021} : any ) {
22+ const theme = useTheme ( )
2123 const toggle = useCallback (
2224 ( enable ) => {
2325 if ( enable ) {
@@ -41,15 +43,37 @@ function PermissionToggle({
4143 < ListItem
4244 first = { first }
4345 last = { last }
44- background = "fill-two"
4546 >
46- < Box fill = "horizontal" >
47- < Span fontWeight = { 500 } > { permission . toLowerCase ( ) } </ Span >
48- < Span color = "text-light" > { description } </ Span >
49- </ Box >
47+ < div
48+ css = { {
49+ display : 'flex' ,
50+ flexDirection : 'column' ,
51+ width : '100%' ,
52+ } }
53+ >
54+ < h4
55+ className = "stuff"
56+ css = { {
57+ ...theme . partials . text . body1Bold ,
58+ margin : 0 ,
59+ } }
60+ >
61+ { permission . toLowerCase ( ) }
62+ </ h4 >
63+ < p
64+ css = { {
65+ ...theme . partials . text . body2 ,
66+ color : theme . colors [ 'text-light' ] ,
67+ margin : 0 ,
68+ } }
69+ color = "text-light"
70+ >
71+ { description }
72+ </ p >
73+ </ div >
5074 < Switch
5175 checked = { ! ! attributes . permissions . find ( ( perm ) => perm === permission ) }
52- onChange = { ( { target : { checked } } ) => toggle ( checked ) }
76+ onChange = { ( checked ) => toggle ( checked ) }
5377 />
5478 </ ListItem >
5579 )
@@ -61,24 +85,31 @@ const TABS = {
6185}
6286
6387export function RoleForm ( {
64- // eslint-disable-next-line
6588 error,
6689 attributes,
6790 setAttributes,
6891 bindings,
6992 setBindings,
70- ...box
71- } ) : any {
93+ } : {
94+ error : any
95+ attributes : any
96+ setAttributes : any
97+ bindings : any
98+ setBindings : any
99+ } ) {
100+ const theme = useTheme ( )
72101 const [ view , setView ] = useState ( 'General' )
73102 const permissions = Object . entries ( PermissionTypes )
74103 const len = permissions . length
75104 const tabStateRef = useRef < any > ( null )
76105
77106 return (
78- < Box
79- flex = { false }
80- gap = "small"
81- { ...box }
107+ < div
108+ css = { {
109+ display : 'flex' ,
110+ flexDirection : 'column' ,
111+ gap : theme . spacing . medium ,
112+ } }
82113 >
83114 { error && (
84115 < GqlError
@@ -108,14 +139,34 @@ export function RoleForm({
108139 />
109140 ) }
110141 { view === 'Permissions' && (
111- < Box gap = "small" >
112- < Box >
113- < Span fontWeight = "bold" > Permissions</ Span >
114- < Span >
142+ < div
143+ css = { {
144+ display : 'flex' ,
145+ flexDirection : 'column' ,
146+ gap : theme . spacing . small ,
147+ } }
148+ >
149+ < div
150+ css = { {
151+ display : 'flex' ,
152+ flexDirection : 'column' ,
153+ gap : theme . spacing . xxsmall ,
154+ } }
155+ >
156+ < h3 css = { { ...theme . partials . text . body1Bold , margin : 0 } } >
157+ Permissions
158+ </ h3 >
159+ < p
160+ css = { {
161+ ...theme . partials . text . body2 ,
162+ margin : 0 ,
163+ color : theme . colors [ 'text-light' ] ,
164+ } }
165+ >
115166 Grant permissions to all users and groups bound to this role
116- </ Span >
117- </ Box >
118- < Box >
167+ </ p >
168+ </ div >
169+ < List hue = "lighter" >
119170 { permissions . map ( ( [ perm , description ] , i ) => (
120171 < PermissionToggle
121172 key = { perm }
@@ -127,10 +178,10 @@ export function RoleForm({
127178 last = { i === len - 1 }
128179 />
129180 ) ) }
130- </ Box >
131- </ Box >
181+ </ List >
182+ </ div >
132183 ) }
133184 </ TabPanel >
134- </ Box >
185+ </ div >
135186 )
136187}
0 commit comments