/********************************************************************************** * Copyright (c) 2025 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the MIT License as outlined in the LICENSE file. **********************************************************************************/ import React from 'react'; import { CommandDefinition } from '../../../../vscode/webview-types'; import { CDTTreeItem, CDTTreeItemResource, CDTTreeTableActionColumn, CDTTreeTableActionColumnCommand } from '../../../common'; export interface ActionCellProps { column: CDTTreeTableActionColumn; record: CDTTreeItem; actions: CDTTreeTableActionColumnCommand[]; onAction?: (event: React.UIEvent, command: CommandDefinition, value: unknown, record: CDTTreeItem) => void; } const ActionCell = ({ record, actions, onAction }: ActionCellProps) => { return (
{actions.map(action => { const handleAction = (e: React.MouseEvent | React.KeyboardEvent) => { e.stopPropagation(); e.preventDefault(); onAction?.(e, action, action.value, record); }; return ( e.key === 'Enter' && handleAction(e)} /> ); })}
); }; export default ActionCell;