From 7bb1decaf84a7a05be9e485b616ec43ec03e8759 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 20 Mar 2024 15:45:58 +0800 Subject: [PATCH] feat: support prompt readonly --- .../nodes/_base/components/prompt/editor.tsx | 78 ++++++++++--------- .../workflow/nodes/answer/panel.tsx | 1 + 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index 36fe87f047..87ec9a2e69 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -112,43 +112,47 @@ const Editor: FC = ({ )} hideResize={isExpand} > - { }, - }} - variableBlock={{ - variables: variables.map(item => ({ - name: item, - value: item, - })), - externalTools: [], - onAddExternalTool: () => { }, - }} - historyBlock={{ - show: justVar ? false : isShowHistory, - selectable: !hasSetBlockStatus?.history, - history: { - user: 'Human', - assistant: 'Assistant', - }, - onEditRole: () => { }, - }} - queryBlock={{ - show: justVar ? false : isShowQuery, - selectable: !hasSetBlockStatus?.query, - }} - onChange={onChange} - onBlur={setBlur} - onFocus={setFocus} - editable={!readOnly} - /> + <> + { }, + }} + variableBlock={{ + variables: variables.map(item => ({ + name: item, + value: item, + })), + externalTools: [], + onAddExternalTool: () => { }, + }} + historyBlock={{ + show: justVar ? false : isShowHistory, + selectable: !hasSetBlockStatus?.history, + history: { + user: 'Human', + assistant: 'Assistant', + }, + onEditRole: () => { }, + }} + queryBlock={{ + show: justVar ? false : isShowQuery, + selectable: !hasSetBlockStatus?.query, + }} + onChange={onChange} + onBlur={setBlur} + onFocus={setFocus} + editable={!readOnly} + /> + {/* to patch Editor not support dynamic change editable status */} + {readOnly &&
} + diff --git a/web/app/components/workflow/nodes/answer/panel.tsx b/web/app/components/workflow/nodes/answer/panel.tsx index 694d2fd97c..60ffa4e09d 100644 --- a/web/app/components/workflow/nodes/answer/panel.tsx +++ b/web/app/components/workflow/nodes/answer/panel.tsx @@ -45,6 +45,7 @@ const Panel: FC> = ({