Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
import React, { useState } from 'react';
import Modal from './ui/Modal';
import LocationPanelLayout from './parameterPanel/LocationPanelLayout';
import { useParameterPanel } from '../hooks/useParameterPanel';
import { ExecutionService } from '../services/executionService';
import { ActionButton } from './ui/action-button';
const LocationParameterPanel: React.FC = () => {
const {
selectedNode,
nodeDefinition,
parameters,
hasUnsavedChanges,
handleParameterChange,
handleSave,
handleCancel,
} = useParameterPanel();
// Execution state (kept for potential future location node execution)
const [isExecuting, setIsExecuting] = useState(false);
const handleModalClose = () => {
handleCancel();
};
// Execute the current node (simplified - location nodes typically don't execute)
const handleRun = async () => {
if (!selectedNode || !nodeDefinition) return;
if (hasUnsavedChanges) {
await handleSave();
}
setIsExecuting(true);
try {
// Location nodes like gmaps_create typically don't need backend execution
// They're configuration nodes that output map instances
} catch (error: any) {
console.error('Location node execution failed:', error);
} finally {
setIsExecuting(false);
}
};
// Check if node can be executed
const canExecute = selectedNode && nodeDefinition &&
ExecutionService.isNodeTypeSupported(nodeDefinition.name);
if (!selectedNode || !nodeDefinition) {
return null;
}
// Only show LocationParameterPanel for nodes flagged via uiHints; legacy
// name fallback for nodes not yet annotated.
const showPanel = nodeDefinition.uiHints?.showLocationPanel
?? (nodeDefinition.name === 'gmaps_create');
if (!showPanel) {
return null;
}
// Header actions with node name and buttons in middle area
const headerActions = (
<div className="flex items-center gap-4">
<div className="flex items-center gap-2 text-[15px] font-semibold text-foreground">
<span>{nodeDefinition.icon}</span>
<span>{nodeDefinition.displayName}</span>
{hasUnsavedChanges && <span className="text-warning">*</span>}
</div>
<div className="flex items-center gap-2">
{canExecute && (
<ActionButton
intent="run"
onClick={handleRun}
disabled={isExecuting}
title={isExecuting ? 'Execution in progress...' : 'Execute this node'}
>
{isExecuting ? 'Running...' : 'Run'}
</ActionButton>
)}
<ActionButton intent="tools" onClick={handleSave} disabled={!hasUnsavedChanges}>
Save
</ActionButton>
<ActionButton intent="stop" onClick={handleCancel}>
Cancel
</ActionButton>
</div>
</div>
);
return (
<Modal
isOpen={!!selectedNode}
onClose={handleModalClose}
title="Node Configuration"
maxWidth="95vw"
maxHeight="95vh"
headerActions={headerActions}
>
{/* Modular Location Panel Layout */}
<LocationPanelLayout
selectedNode={selectedNode}
nodeDefinition={nodeDefinition}
parameters={parameters}
hasUnsavedChanges={hasUnsavedChanges}
onParameterChange={handleParameterChange}
showInputSection={true}
/>
</Modal>
);
};
export default LocationParameterPanel;