From 5097f77469a84b2ec65114c4d927f49ad2a5bfa6 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Tue, 27 May 2025 19:02:41 +0530 Subject: [PATCH] (feat:toolConfig) ui details, no actions placeholder --- frontend/src/settings/ToolConfig.tsx | 392 ++++++++++++++------------- 1 file changed, 211 insertions(+), 181 deletions(-) diff --git a/frontend/src/settings/ToolConfig.tsx b/frontend/src/settings/ToolConfig.tsx index de99fabf..53eb3984 100644 --- a/frontend/src/settings/ToolConfig.tsx +++ b/frontend/src/settings/ToolConfig.tsx @@ -16,6 +16,9 @@ import { selectToken } from '../preferences/preferenceSlice'; import { APIActionType, APIToolType, UserToolType } from './types'; import { useTranslation } from 'react-i18next'; import { areObjectsEqual } from '../utils/objectUtils'; +import { useDarkTheme } from '../hooks'; +import NoFilesIcon from '../assets/no-files.svg'; +import NoFilesDarkIcon from '../assets/no-files-dark.svg'; export default function ToolConfig({ tool, @@ -44,6 +47,7 @@ export default function ToolConfig({ const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false); const [showUnsavedModal, setShowUnsavedModal] = React.useState(false); const { t } = useTranslation(); + const [isDarkTheme] = useDarkTheme(); const handleBackClick = () => { if (hasUnsavedChanges) { @@ -211,201 +215,227 @@ export default function ToolConfig({
-
+

Actions

-
- {tool.name === 'api_tool' ? ( - <> - -
+ {tool.name === 'api_tool' && + (!tool.config.actions || + Object.keys(tool.config.actions).length === 0) && ( -
+ )} +
+ {tool.name === 'api_tool' ? ( + <> + {tool.config.actions && + Object.keys(tool.config.actions).length > 0 ? ( + + ) : ( +
+ No actions found +

+ No actions found +

+
+ )} ) : (
- {'actions' in tool && - tool.actions.map((action, actionIndex) => { - return ( -
-
-

- {action.name} -

- { - setTool({ - ...tool, - actions: tool.actions.map((act, index) => { - if (index === actionIndex) { - return { ...act, active: checked }; - } - return act; - }), - }); - }} - size="small" - id={`actionToggle-${actionIndex}`} - /> -
-
- { - setTool({ - ...tool, - actions: tool.actions.map((act, index) => { - if (index === actionIndex) { - return { - ...act, - description: e.target.value, - }; - } - return act; - }), - }); - }} - borderVariant="thin" - /> -
-
- - - - - - - - - - - - {Object.entries(action.parameters?.properties).map( - (param, index) => { - const uniqueKey = `${actionIndex}-${param[0]}`; - return ( - - - - - - - - ); - }, - )} - -
Field NameField TypeFilled by LLMFIeld descriptionValue
{param[0]}{param[1].type} - - - { - setTool({ - ...tool, - actions: tool.actions.map( - (act, index) => { - if (index === actionIndex) { - return { - ...act, - parameters: { - ...act.parameters, - properties: { - ...act.parameters - .properties, - [param[0]]: { - ...act.parameters - .properties[param[0]], - description: - e.target.value, - }, - }, - }, - }; - } - return act; - }, - ), - }); - }} - > - - { - setTool({ - ...tool, - actions: tool.actions.map( - (act, index) => { - if (index === actionIndex) { - return { - ...act, - parameters: { - ...act.parameters, - properties: { - ...act.parameters - .properties, - [param[0]]: { - ...act.parameters - .properties[param[0]], - value: e.target.value, - }, - }, - }, - }; - } - return act; - }, - ), - }); - }} - > -
-
+ {'actions' in tool && tool.actions && tool.actions.length > 0 ? ( + tool.actions.map((action, actionIndex) => ( +
+
+

+ {action.name} +

+ { + setTool({ + ...tool, + actions: tool.actions.map((act, index) => { + if (index === actionIndex) { + return { ...act, active: checked }; + } + return act; + }), + }); + }} + size="small" + id={`actionToggle-${actionIndex}`} + />
- ); - })} +
+ { + setTool({ + ...tool, + actions: tool.actions.map((act, index) => { + if (index === actionIndex) { + return { + ...act, + description: e.target.value, + }; + } + return act; + }), + }); + }} + borderVariant="thin" + /> +
+
+ + + + + + + + + + + + {Object.entries(action.parameters?.properties).map( + (param, index) => { + const uniqueKey = `${actionIndex}-${param[0]}`; + return ( + + + + + + + + ); + }, + )} + +
Field NameField TypeFilled by LLMFIeld descriptionValue
{param[0]}{param[1].type} + + + { + setTool({ + ...tool, + actions: tool.actions.map( + (act, index) => { + if (index === actionIndex) { + return { + ...act, + parameters: { + ...act.parameters, + properties: { + ...act.parameters + .properties, + [param[0]]: { + ...act.parameters + .properties[param[0]], + description: + e.target.value, + }, + }, + }, + }; + } + return act; + }, + ), + }); + }} + > + + { + setTool({ + ...tool, + actions: tool.actions.map( + (act, index) => { + if (index === actionIndex) { + return { + ...act, + parameters: { + ...act.parameters, + properties: { + ...act.parameters + .properties, + [param[0]]: { + ...act.parameters + .properties[param[0]], + value: e.target.value, + }, + }, + }, + }; + } + return act; + }, + ), + }); + }} + > +
+
+
+ )) + ) : ( +
+ No actions found +

+ No actions found +

+
+ )}
)}