From aba48749da7ffb23e802ffa2cda2e1652b7756cc Mon Sep 17 00:00:00 2001 From: JzoNg Date: Sun, 27 Oct 2024 12:11:49 +0800 Subject: [PATCH] action panel header --- .../agent-tools/setting-built-in-tool.tsx | 168 ++++++++++-------- .../plugins/card/base/card-icon.tsx | 4 +- .../plugin-detail-panel/action-list.tsx | 1 + .../components/tools/provider/tool-item.tsx | 3 +- 4 files changed, 95 insertions(+), 81 deletions(-) diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx index 254e248c05..546e132700 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx @@ -3,21 +3,29 @@ import type { FC } from 'react' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' -import cn from '@/utils/classnames' -import Drawer from '@/app/components/base/drawer-plus' +import { + RiArrowLeftLine, + RiCloseLine, +} from '@remixicon/react' +import Drawer from '@/app/components/base/drawer' +import Loading from '@/app/components/base/loading' +import ActionButton from '@/app/components/base/action-button' +import Icon from '@/app/components/plugins/card/base/card-icon' +import OrgInfo from '@/app/components/plugins/card/base/org-info' +import Description from '@/app/components/plugins/card/base/description' +import Button from '@/app/components/base/button' import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { addDefaultValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import type { Collection, Tool } from '@/app/components/tools/types' import { CollectionType } from '@/app/components/tools/types' import { fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, fetchWorkflowToolList } from '@/service/tools' import I18n from '@/context/i18n' -import Button from '@/app/components/base/button' -import Loading from '@/app/components/base/loading' import { DiagonalDividingLine } from '@/app/components/base/icons/src/public/common' import { getLanguage } from '@/i18n/language' -import AppIcon from '@/app/components/base/app-icon' +import cn from '@/utils/classnames' -type Props = { +interface Props { + showBackButton?: boolean collection: Collection isBuiltIn?: boolean isModel?: boolean @@ -29,6 +37,7 @@ type Props = { } const SettingBuiltInTool: FC = ({ + showBackButton = false, collection, isBuiltIn = true, isModel = true, @@ -98,13 +107,6 @@ const SettingBuiltInTool: FC = ({ const infoUI = (
-
- {t('tools.setBuiltInTools.toolDescription')} -
-
- {currTool?.description[language]} -
- {infoSchemas.length > 0 && (
@@ -148,75 +150,83 @@ const SettingBuiltInTool: FC = ({ return ( - {typeof collection.icon === 'string' - ? ( -
- ) - : ( - - )} - -
{currTool?.label[language]}
- {(hasSetting && !readonly) && (<> - -
-
setCurrType('info')} - > - {t('tools.setBuiltInTools.info')} - {isInfoActive &&
} + isOpen + clickOutsideNotOpen={false} + onClose={onHide} + footer={null} + mask={false} + positionCenter={false} + panelClassname={cn('justify-start mt-[64px] mr-2 mb-2 !w-[420px] !max-w-[420px] !p-0 !bg-components-panel-bg rounded-2xl border-[0.5px] border-components-panel-border shadow-xl')} + > + <> + {isLoading && } + {!isLoading && ( + <> + {/* header */} +
+
+ + +
-
setCurrType('setting')} - > - {t('tools.setBuiltInTools.setting')} - {!isInfoActive &&
} -
-
- )} -
- )} - panelClassName='mt-[64px] mb-2 !w-[420px]' - maxWidthClassName='!max-w-[420px]' - height='calc(100vh - 64px)' - headerClassName='!border-b-black/5' - body={ -
- {isLoading - ?
- -
- : (
-
- {isInfoActive ? infoUI : settingUI} -
- {!readonly && !isInfoActive && ( -
- - + {showBackButton && ( +
+ + BACK
)} -
)} -
- } - isShowMask={false} - clickOutsideNotOpen={false} - /> +
+ + +
+
{currTool?.label[language]}
+ {!!currTool?.description[language] && ( + + )} +
+ {/* form */} +
+
+
+ {(hasSetting && !readonly) && (<> + +
+
setCurrType('info')} + > + {t('tools.setBuiltInTools.parameters')} + {isInfoActive &&
} +
+
setCurrType('setting')} + > + {t('tools.setBuiltInTools.setting')} + {!isInfoActive &&
} +
+
+ )} + {isInfoActive ? infoUI : settingUI} +
+ {!readonly && !isInfoActive && ( +
+ + +
+ )} +
+
+ + )} + + ) } export default React.memo(SettingBuiltInTool) diff --git a/web/app/components/plugins/card/base/card-icon.tsx b/web/app/components/plugins/card/base/card-icon.tsx index a30267bc43..34ff0d8fbc 100644 --- a/web/app/components/plugins/card/base/card-icon.tsx +++ b/web/app/components/plugins/card/base/card-icon.tsx @@ -7,6 +7,7 @@ const Icon = ({ src, installed = false, installFailed = false, + size, }: { className?: string src: string | { @@ -15,13 +16,14 @@ const Icon = ({ } installed?: boolean installFailed?: boolean + size?: 'xs' | 'tiny' | 'small' | 'medium' | 'large' }) => { const iconClassName = 'flex justify-center items-center gap-2 absolute bottom-[-4px] right-[-4px] w-[18px] h-[18px] rounded-full border-2 border-components-panel-bg' if (typeof src === 'object') { return (
{ const ActionList = () => { const { t } = useTranslation() + // TODO use tool-item add api in tool providers return (
diff --git a/web/app/components/tools/provider/tool-item.tsx b/web/app/components/tools/provider/tool-item.tsx index 537f43c1b6..897b549c38 100644 --- a/web/app/components/tools/provider/tool-item.tsx +++ b/web/app/components/tools/provider/tool-item.tsx @@ -7,7 +7,7 @@ import I18n from '@/context/i18n' import { getLanguage } from '@/i18n/language' import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool' -type Props = { +interface Props { disabled?: boolean collection: Collection tool: Tool @@ -37,6 +37,7 @@ const ToolItem = ({
{showDetail && (