From ec07636ce9eb2ec64e3ca8bd8fe97bf36ff85bd3 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 29 Aug 2025 16:21:39 +0800 Subject: [PATCH] feat: preveiw wrap --- .../components/form-content-preview.tsx | 57 +++++++++++++++++++ .../workflow/nodes/human-input/panel.tsx | 19 ++++++- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 web/app/components/workflow/nodes/human-input/components/form-content-preview.tsx diff --git a/web/app/components/workflow/nodes/human-input/components/form-content-preview.tsx b/web/app/components/workflow/nodes/human-input/components/form-content-preview.tsx new file mode 100644 index 0000000000..10d85b29ef --- /dev/null +++ b/web/app/components/workflow/nodes/human-input/components/form-content-preview.tsx @@ -0,0 +1,57 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import type { FormInputItem, UserAction } from '../types' +import { useStore } from '@/app/components/workflow/store' +import { Markdown } from '@/app/components/base/markdown' +import { getButtonStyle } from '@/app/components/base/chat/chat/answer/human-input-content/utils' +import Button from '@/app/components/base/button' +import Badge from '@/app/components/base/badge' +import { useTranslation } from 'react-i18next' +import ActionButton from '@/app/components/base/action-button' +import { RiCloseLine } from '@remixicon/react' + +const i18nPrefix = 'workflow.nodes.humanInput' + +type Props = { + content: string + formInputs: FormInputItem[] + userActions: UserAction[] + onClose: () => void +} + +const FormContentPreview: FC = ({ + content, + formInputs, + userActions, + onClose, +}) => { + const { t } = useTranslation() + const panelWidth = useStore(state => state.panelWidth) + + return ( +
+
+ {t(`${i18nPrefix}.formContent.preview`)} + +
+
+ +
+ {userActions.map((action: any) => ( + + ))} +
+
In preview mode, action buttons are not functional.
+
+
+ ) +} +export default React.memo(FormContentPreview) diff --git a/web/app/components/workflow/nodes/human-input/panel.tsx b/web/app/components/workflow/nodes/human-input/panel.tsx index fa046e9b81..0d9e083c24 100644 --- a/web/app/components/workflow/nodes/human-input/panel.tsx +++ b/web/app/components/workflow/nodes/human-input/panel.tsx @@ -29,6 +29,7 @@ import copy from 'copy-to-clipboard' import { useBoolean } from 'ahooks' import cn from '@/utils/classnames' import { useStore } from '@/app/components/workflow/store' +import FormContentPreview from './components/form-content-preview' const i18nPrefix = 'workflow.nodes.humanInput' @@ -63,6 +64,11 @@ const Panel: FC> = ({ }] = useBoolean(false) const panelWidth = useStore(state => state.panelWidth) + const [isPreview, { + toggle: togglePreview, + setFalse: hidePreview, + }] = useBoolean(false) + return (
{/* delivery methods */} @@ -76,7 +82,7 @@ const Panel: FC> = ({
{/* form content */} -
+
{t(`${i18nPrefix}.formContent.title`)}
@@ -85,7 +91,7 @@ const Panel: FC> = ({ />
- @@ -167,6 +173,15 @@ const Panel: FC> = ({ onChange={handleTimeoutChange} />
+ + {isPreview && ( + + )}
) }