From 773147701d5cbed1a332a922ff1be9fc47772801 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 7 Mar 2025 17:19:14 +0530 Subject: [PATCH] (fix:ui) tool cards --- frontend/src/components/types/index.ts | 2 +- frontend/src/modals/AddToolModal.tsx | 79 ++++++++-------- frontend/src/settings/Tools.tsx | 126 ++++++++++--------------- 3 files changed, 92 insertions(+), 115 deletions(-) diff --git a/frontend/src/components/types/index.ts b/frontend/src/components/types/index.ts index 1d4b3a61..47fcd86f 100644 --- a/frontend/src/components/types/index.ts +++ b/frontend/src/components/types/index.ts @@ -8,10 +8,10 @@ export type InputProps = { maxLength?: number; name?: string; placeholder?: string; - label?: string; required?: boolean; className?: string; children?: React.ReactElement; + labelBgClassName?: string; onChange: ( e: React.ChangeEvent, ) => void; diff --git a/frontend/src/modals/AddToolModal.tsx b/frontend/src/modals/AddToolModal.tsx index 07360eb7..adaa82e3 100644 --- a/frontend/src/modals/AddToolModal.tsx +++ b/frontend/src/modals/AddToolModal.tsx @@ -94,57 +94,60 @@ export default function AddToolModal({ {modalState === 'ACTIVE' && ( setModalState('INACTIVE')} - className="h-[85vh] w-[90vw] md:w-[75vw]" + className="max-w-[950px] w-[90vw] md:w-[85vw] lg:w-[75vw] h-[85vh]" > -
+

{t('settings.tools.selectToolSetup')}

-
+
{loading ? ( -
+
) : ( - availableTools.map((tool, index) => ( -
{ - setSelectedTool(tool); - handleAddTool(tool); - }} - onKeyDown={(e) => { - if (e.key === 'Enter' || e.key === ' ') { +
+ {availableTools.map((tool, index) => ( +
{ setSelectedTool(tool); handleAddTool(tool); - } - }} - > -
-
- -
-
-

- {tool.displayName} -

-

- {tool.description} -

+ }} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + setSelectedTool(tool); + handleAddTool(tool); + } + }} + > +
+
+ {`${tool.name} +
+
+

+ {tool.displayName} +

+

+ {tool.description} +

+
-
- )) + ))} +
)}
diff --git a/frontend/src/settings/Tools.tsx b/frontend/src/settings/Tools.tsx index e697bb96..539fcd25 100644 --- a/frontend/src/settings/Tools.tsx +++ b/frontend/src/settings/Tools.tsx @@ -3,19 +3,16 @@ import { useTranslation } from 'react-i18next'; import userService from '../api/services/userService'; import CogwheelIcon from '../assets/cogwheel.svg'; -import NoFilesDarkIcon from '../assets/no-files-dark.svg'; -import NoFilesIcon from '../assets/no-files.svg'; import Input from '../components/Input'; import Spinner from '../components/Spinner'; -import { useDarkTheme } from '../hooks'; import AddToolModal from '../modals/AddToolModal'; import { ActiveState } from '../models/misc'; import ToolConfig from './ToolConfig'; import { APIToolType, UserToolType } from './types'; +import ToggleSwitch from '../components/ToggleSwitch'; export default function Tools() { const { t } = useTranslation(); - const [isDarkTheme] = useDarkTheme(); const [searchTerm, setSearchTerm] = React.useState(''); const [addToolModalState, setAddToolModalState] = React.useState('INACTIVE'); @@ -114,7 +111,7 @@ export default function Tools() { />
+
{loading ? (
@@ -129,90 +127,66 @@ export default function Tools() {
) : ( -
- {userTools.filter((tool) => - tool.displayName - .toLowerCase() - .includes(searchTerm.toLowerCase()), - ).length === 0 ? ( -
- No tools found - {t('settings.tools.noToolsFound')} -
- ) : ( - userTools - .filter((tool) => - tool.displayName - .toLowerCase() - .includes(searchTerm.toLowerCase()), - ) - .map((tool, index) => ( -
-
-
+
+ {userTools + .filter((tool) => + tool.displayName + .toLowerCase() + .includes(searchTerm.toLowerCase()), + ) + .map((tool, index) => ( +
+
+ +
+
{`${tool.displayName} - -
-
-

{tool.displayName}

-

+

{tool.description}

-
- +
+ + updateToolStatus(tool.id, checked) + } + size="small" + id={`toolToggle-${index}`} + ariaLabel={t('settings.tools.toggleToolAria', { + toolName: tool.displayName, + })} + />
- )) - )} +
+ ))}
)}