1- import {
2- DeleteObjectModal ,
3- DeleteObjectModalProps ,
4- } from "@/entities/nodes/object/ui/delete-object-modal" ;
1+ import ObjectItemEditComponent from "@/entities/nodes/object-item-edit/object-item-edit-paginated" ;
2+ import { DeleteObjectModal } from "@/entities/nodes/object/ui/delete-object-modal" ;
53import { getObjectDetailsUrl2 } from "@/entities/nodes/utils" ;
64import { Permission } from "@/entities/permission/types" ;
5+ import { useSchema } from "@/entities/schema/hooks/useSchema" ;
6+ import { queryClient } from "@/shared/api/rest/client" ;
77import { Button } from "@/shared/components/buttons/button-primitive" ;
8+ import SlideOver , { SlideOverTitle } from "@/shared/components/display/slide-over" ;
9+ import ErrorScreen from "@/shared/components/errors/error-screen" ;
810import { TableCell } from "@/shared/components/table/table-cell" ;
911import {
1012 DropdownMenu ,
@@ -17,14 +19,22 @@ import { Icon } from "@iconify-icon/react";
1719import { useState } from "react" ;
1820import { Link } from "react-router" ;
1921
20- export interface ActionsCellProps extends Omit < DeleteObjectModalProps , "open" | "setOpen" > {
22+ export interface ActionsCellProps {
2123 permission : Permission ;
24+ objectId : string ;
25+ objectKind : string ;
26+ objectLabel : string ;
2227}
2328
2429export function ActionsCell ( { objectKind, objectId, objectLabel, permission } : ActionsCellProps ) {
2530 const [ showDeleteModal , setShowDeleteModal ] = useState ( false ) ;
31+ const [ showEditForm , setShowEditForm ] = useState ( false ) ;
32+ const { schema } = useSchema ( objectKind ) ;
33+ const isEditAllowed = permission . update . isAllowed ;
2634 const isDeleteAllowed = permission . delete . isAllowed ;
2735
36+ if ( ! schema ) return < ErrorScreen message = { `Schema not found for ${ objectKind } ` } /> ;
37+
2838 return (
2939 < >
3040 < TableCell className = "sticky right-0 border-l size-10 items-center justify-center bg-white -ml-px" >
@@ -49,6 +59,18 @@ export function ActionsCell({ objectKind, objectId, objectLabel, permission }: A
4959 </ Link >
5060 </ DropdownMenuItem >
5161
62+ < Tooltip enabled = { ! isEditAllowed } content = { permission . update . message } side = "left" >
63+ < div >
64+ < DropdownMenuItem
65+ disabled = { ! isEditAllowed }
66+ onClick = { ( ) => isEditAllowed && setShowEditForm ( true ) }
67+ >
68+ < Icon icon = "mdi:edit-outline" className = "text-base" />
69+ Edit
70+ </ DropdownMenuItem >
71+ </ div >
72+ </ Tooltip >
73+
5274 < Tooltip enabled = { ! isDeleteAllowed } content = { permission . delete . message } side = "left" >
5375 < div >
5476 < DropdownMenuItem
@@ -64,6 +86,31 @@ export function ActionsCell({ objectKind, objectId, objectLabel, permission }: A
6486 </ DropdownMenu >
6587 </ TableCell >
6688
89+ { showEditForm && (
90+ < SlideOver
91+ title = {
92+ < SlideOverTitle
93+ schema = { schema }
94+ currentObjectLabel = { objectLabel }
95+ title = { `Edit ${ objectLabel } ` }
96+ />
97+ }
98+ open = { true }
99+ setOpen = { ( ) => setShowEditForm ( false ) }
100+ >
101+ < ObjectItemEditComponent
102+ closeDrawer = { ( ) => setShowEditForm ( false ) }
103+ onUpdateComplete = { async ( ) => {
104+ await queryClient . invalidateQueries ( {
105+ predicate : ( query ) => query . queryKey . includes ( "objects" ) ,
106+ } ) ;
107+ } }
108+ objectid = { objectId }
109+ objectname = { objectKind }
110+ />
111+ </ SlideOver >
112+ ) }
113+
67114 { showDeleteModal && (
68115 < DeleteObjectModal
69116 objectKind = { objectKind }
0 commit comments