@@ -25,6 +25,7 @@ import ButtonHelper from 'src/components/ButtonHelper'
2525import { AddDelegateModal } from 'src/routes/safe/components/Settings/Delegates/AddDelegateModal'
2626import { RemoveDelegateModal } from 'src/routes/safe/components/Settings/Delegates/RemoveDelegateModal'
2727import { EditDelegateModal } from 'src/routes/safe/components/Settings/Delegates/EditDelegateModal'
28+ import { grantedSelector } from 'src/routes/safe/container/selector'
2829
2930// TODO: these types will come from the Client GW SDK once #72 is merged
3031type Page < T > = {
@@ -51,6 +52,10 @@ const StyledHeading = styled(Heading)`
5152 padding-bottom: 0;
5253`
5354
55+ const StyledButtonLink = styled ( ButtonLink ) < { isDisabled : boolean } > `
56+ display: ${ ( { isDisabled } ) => ( isDisabled ? 'none' : 'flex' ) } ;
57+ `
58+
5459const useStyles = makeStyles ( styles )
5560
5661const Delegates = ( ) : ReactElement => {
@@ -65,6 +70,7 @@ const Delegates = (): ReactElement => {
6570 const [ addressToRemove , setAddressToRemove ] = useState < string > ( '' )
6671 const columns = generateColumns ( )
6772 const autoColumns = columns . filter ( ( { custom } ) => ! custom )
73+ const granted = useSelector ( grantedSelector )
6874
6975 const classes = useStyles ( styles )
7076
@@ -171,17 +177,18 @@ const Delegates = (): ReactElement => {
171177 < StyledBlock >
172178 < StyledHeading tag = "h2" > Manage Safe Delegates</ StyledHeading >
173179 < Paragraph > Get, add and delete delegates.</ Paragraph >
174- < ButtonLink
180+ < StyledButtonLink
175181 onClick = { ( ) => {
176182 setAddDelegateModalOpen ( true )
177183 } }
178184 color = "primary"
179185 iconType = "add"
180186 iconSize = "sm"
181187 textSize = "xl"
188+ isDisabled = { ! granted }
182189 >
183190 Add delegate
184- </ ButtonLink >
191+ </ StyledButtonLink >
185192 < pre > { JSON . stringify ( delegatesList , undefined , 2 ) } </ pre >
186193 < TableContainer >
187194 < Table
@@ -219,28 +226,32 @@ const Delegates = (): ReactElement => {
219226 } ) }
220227 < TableCell component = "td" >
221228 < Row align = "end" className = { classes . actions } >
222- < ButtonHelper
223- onClick = { ( ) => {
224- setDelegateToEdit ( row [ DELEGATE_ADDRESS_ID ] )
225- setEditDelegateModalOpen ( true )
226- } }
227- >
228- < Icon size = "sm" type = "edit" tooltip = "Edit delegate" className = { classes . editEntryButton } />
229- </ ButtonHelper >
230- < ButtonHelper
231- onClick = { ( ) => {
232- setAddressToRemove ( row [ DELEGATE_ADDRESS_ID ] )
233- setRemoveDelegateModalOpen ( true )
234- } }
235- >
236- < Icon
237- size = "sm"
238- type = "delete"
239- color = "error"
240- tooltip = "Remove delegate"
241- className = { classes . removeEntryButton }
242- />
243- </ ButtonHelper >
229+ { granted && (
230+ < >
231+ < ButtonHelper
232+ onClick = { ( ) => {
233+ setDelegateToEdit ( row [ DELEGATE_ADDRESS_ID ] )
234+ setEditDelegateModalOpen ( true )
235+ } }
236+ >
237+ < Icon size = "sm" type = "edit" tooltip = "Edit delegate" className = { classes . editEntryButton } />
238+ </ ButtonHelper >
239+ < ButtonHelper
240+ onClick = { ( ) => {
241+ setAddressToRemove ( row [ DELEGATE_ADDRESS_ID ] )
242+ setRemoveDelegateModalOpen ( true )
243+ } }
244+ >
245+ < Icon
246+ size = "sm"
247+ type = "delete"
248+ color = "error"
249+ tooltip = "Remove delegate"
250+ className = { classes . removeEntryButton }
251+ />
252+ </ ButtonHelper >
253+ </ >
254+ ) }
244255 </ Row >
245256 </ TableCell >
246257 </ TableRow >
0 commit comments