1- import { useAuthorization } from '@/app/common/hooks/authorization-hooks ' ;
1+ import { PermissionGuard } from '@/app/common/components/permission-guard ' ;
22import { appConnectionsApi } from '@/app/features/connections/lib/app-connections-api' ;
33import { handleMutationError } from '@/app/interceptors/interceptor-utils' ;
44import { formatUtils } from '@/app/lib/utils' ;
55import {
66 BlockIcon ,
7- Button ,
87 DataTable ,
98 DataTableColumnHeader ,
109 DropdownMenu ,
1110 DropdownMenuContent ,
1211 DropdownMenuItem ,
1312 DropdownMenuTrigger ,
14- PageHeader ,
1513 PaginationParams ,
1614 RowDataWithActions ,
1715 StatusIconWithText ,
@@ -35,7 +33,6 @@ import { appConnectionsHooks } from '../lib/app-connections-hooks';
3533import { useConnectionsContext } from './connections-context' ;
3634import { DeleteConnectionDialog } from './delete-connection-dialog' ;
3735import { EditConnectionDialog } from './edit-connection-dialog' ;
38- import { NewConnectionTypeDialog } from './new-connection-type-dialog' ;
3936
4037type BlockIconWithBlockNameProps = {
4138 authProviderKey : string ;
@@ -107,38 +104,48 @@ const MenuConnectionColumn = ({
107104 < EllipsisVertical className = "h-10 w-10" />
108105 </ DropdownMenuTrigger >
109106 < DropdownMenuContent className = "w-[155px]" >
110- < DropdownMenuItem
111- key = "edit"
112- onSelect = { ( e ) => {
113- e . preventDefault ( ) ;
114- setIsEditConnectionDialog ( true ) ;
115- } }
107+ < PermissionGuard
108+ permission = { Permission . WRITE_APP_CONNECTION }
109+ tooltipClassName = "flex"
116110 >
117- < span className = "text-black text-sm font-medium cursor-pointer w-full" >
118- { t ( 'Edit' ) }
119- </ span >
120- </ DropdownMenuItem >
121- < DropdownMenuItem
122- key = "delete"
123- onSelect = { ( e ) => {
124- e . preventDefault ( ) ;
125- } }
111+ < DropdownMenuItem
112+ key = "edit"
113+ onSelect = { ( e ) => {
114+ e . preventDefault ( ) ;
115+ setIsEditConnectionDialog ( true ) ;
116+ } }
117+ >
118+ < span className = "text-black text-sm font-medium cursor-pointer w-full" >
119+ { t ( 'Edit' ) }
120+ </ span >
121+ </ DropdownMenuItem >
122+ </ PermissionGuard >
123+ < PermissionGuard
124+ permission = { Permission . DELETE_APP_CONNECTION }
125+ tooltipClassName = "flex"
126126 >
127- < DeleteConnectionDialog
128- connectionName = { row . name }
129- mutationFn = { deleteConnectionMutation }
130- isPending = { isPending }
131- linkedFlows = { linkedFlows }
127+ < DropdownMenuItem
128+ key = "delete"
129+ onSelect = { ( e ) => {
130+ e . preventDefault ( ) ;
131+ } }
132132 >
133- < button
134- onClick = { ( ) => mutate ( { connectionName : row . name } ) }
135- className = "text-black text-sm font-medium bg-transparent border-none p-0 m-0 cursor-pointer appearance-none w-full text-left"
136- type = "button"
133+ < DeleteConnectionDialog
134+ connectionName = { row . name }
135+ mutationFn = { deleteConnectionMutation }
136+ isPending = { isPending }
137+ linkedFlows = { linkedFlows }
137138 >
138- { t ( 'Delete' ) }
139- </ button >
140- </ DeleteConnectionDialog >
141- </ DropdownMenuItem >
139+ < button
140+ onClick = { ( ) => mutate ( { connectionName : row . name } ) }
141+ className = "text-black text-sm font-medium bg-transparent border-none p-0 m-0 cursor-pointer appearance-none w-full text-left"
142+ type = "button"
143+ >
144+ { t ( 'Delete' ) }
145+ </ button >
146+ </ DeleteConnectionDialog >
147+ </ DropdownMenuItem >
148+ </ PermissionGuard >
142149 </ DropdownMenuContent >
143150 </ DropdownMenu >
144151 { isEditConnectionDialog && (
@@ -260,32 +267,6 @@ const fetchData = async (
260267 } ) ;
261268} ;
262269
263- const ConnectionsHeader = ( ) => {
264- const { checkAccess } = useAuthorization ( ) ;
265- const userHasPermissionToWriteAppConnection = checkAccess (
266- Permission . WRITE_APP_CONNECTION ,
267- ) ;
268-
269- const { setRefresh } = useConnectionsContext ( ) ;
270-
271- return (
272- < PageHeader title = { t ( 'Connections' ) } >
273- < div className = "ml-auto mr-7" >
274- < NewConnectionTypeDialog
275- onConnectionCreated = { ( ) => setRefresh ( ( prev ) => ! prev ) }
276- >
277- < Button
278- variant = "default"
279- disabled = { ! userHasPermissionToWriteAppConnection }
280- >
281- { t ( 'New Connection' ) }
282- </ Button >
283- </ NewConnectionTypeDialog >
284- </ div >
285- </ PageHeader >
286- ) ;
287- } ;
288-
289270function AppConnectionsTable ( ) {
290271 const { refresh, setRefresh } = useConnectionsContext ( ) ;
291272
@@ -303,4 +284,4 @@ function AppConnectionsTable() {
303284 ) ;
304285}
305286
306- export { AppConnectionsTable , ConnectionsHeader } ;
287+ export { AppConnectionsTable } ;
0 commit comments