diff --git a/webui/react-ui/src/App.jsx b/webui/react-ui/src/App.jsx
index decbba7..2aeb250 100644
--- a/webui/react-ui/src/App.jsx
+++ b/webui/react-ui/src/App.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react'
-import { Outlet, Link, useOutletContext } from 'react-router-dom'
+import { Outlet, Link } from 'react-router-dom'
import './App.css'
function App() {
@@ -19,9 +19,6 @@ function App() {
setMobileMenuOpen(!mobileMenuOpen);
};
- // Provide showToast to children
- const context = { showToast };
-
return (
{/* Navigation Menu */}
@@ -113,7 +110,7 @@ function App() {
{/* Main Content Area */}
-
+
diff --git a/webui/react-ui/src/pages/ActionsPlayground.jsx b/webui/react-ui/src/pages/ActionsPlayground.jsx
index c3ed28c..355338e 100644
--- a/webui/react-ui/src/pages/ActionsPlayground.jsx
+++ b/webui/react-ui/src/pages/ActionsPlayground.jsx
@@ -1,15 +1,14 @@
import { useState, useEffect } from 'react';
import { useOutletContext, useNavigate } from 'react-router-dom';
import { actionApi } from '../utils/api';
-import FormFieldDefinition from '../components/common/FormFieldDefinition';
function ActionsPlayground() {
const { showToast } = useOutletContext();
+ const navigate = useNavigate();
const [actions, setActions] = useState([]);
const [selectedAction, setSelectedAction] = useState('');
- const [actionMeta, setActionMeta] = useState(null);
- const [configValues, setConfigValues] = useState({});
- const [paramsValues, setParamsValues] = useState({});
+ const [configJson, setConfigJson] = useState('{}');
+ const [paramsJson, setParamsJson] = useState('{}');
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);
const [loadingActions, setLoadingActions] = useState(true);
@@ -25,29 +24,19 @@ function ActionsPlayground() {
// Fetch available actions
useEffect(() => {
const fetchActions = async () => {
- const response = await actionApi.listActions();
- setActions(response);
- setLoadingActions(false);
+ try {
+ const response = await actionApi.listActions();
+ setActions(response);
+ } catch (err) {
+ console.error('Error fetching actions:', err);
+ showToast('Failed to load actions', 'error');
+ } finally {
+ setLoadingActions(false);
+ }
};
fetchActions();
- }, []);
-
- // Fetch action metadata when an action is selected
- useEffect(() => {
- if (selectedAction) {
- const fetchActionMeta = async () => {
- const response = await actionApi.getAgentConfigMeta();
- const meta = response.actions.find(a => a.name === selectedAction);
- setActionMeta(meta);
- // Reset values when action changes
- setConfigValues({});
- setParamsValues({});
- };
-
- fetchActionMeta();
- }
- }, [selectedAction]);
+ }, [showToast]);
// Handle action selection
const handleActionChange = (e) => {
@@ -55,20 +44,13 @@ function ActionsPlayground() {
setResult(null);
};
- // Handle config field changes
- const handleConfigChange = (fieldName, value) => {
- setConfigValues(prev => ({
- ...prev,
- [fieldName]: value
- }));
+ // Handle JSON input changes
+ const handleConfigChange = (e) => {
+ setConfigJson(e.target.value);
};
- // Handle params field changes
- const handleParamsChange = (fieldName, value) => {
- setParamsValues(prev => ({
- ...prev,
- [fieldName]: value
- }));
+ const handleParamsChange = (e) => {
+ setParamsJson(e.target.value);
};
// Execute the selected action
@@ -84,11 +66,31 @@ function ActionsPlayground() {
setResult(null);
try {
+ // Parse JSON inputs
+ let config = {};
+ let params = {};
+
+ try {
+ config = JSON.parse(configJson);
+ } catch (err) {
+ showToast('Invalid configuration JSON', 'error');
+ setLoading(false);
+ return;
+ }
+
+ try {
+ params = JSON.parse(paramsJson);
+ } catch (err) {
+ showToast('Invalid parameters JSON', 'error');
+ setLoading(false);
+ return;
+ }
+
// Prepare action data
const actionData = {
action: selectedAction,
- config: configValues,
- params: paramsValues
+ config: config,
+ params: params
};
// Execute action
@@ -96,65 +98,114 @@ function ActionsPlayground() {
setResult(response);
showToast('Action executed successfully', 'success');
} catch (err) {
- showToast('Failed to execute action', 'error');
+ console.error('Error executing action:', err);
+ showToast(`Failed to execute action: ${err.message}`, 'error');
} finally {
setLoading(false);
}
};
return (
-