Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
8c7f4a3a
authored
Jul 31, 2024
by
heheer
Committed by
GitHub
Jul 31, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add check for reset (#2226)
parent
41da52d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx
+17
-11
No files found.
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx
View file @
8c7f4a3a
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useMemo
}
from
'react'
;
import
{
Controller
}
from
'react-hook-form'
;
import
{
Controller
}
from
'react-hook-form'
;
import
RenderPluginInput
from
'./renderPluginInput'
;
import
RenderPluginInput
from
'./renderPluginInput'
;
import
{
Button
,
Flex
}
from
'@chakra-ui/react'
;
import
{
Button
,
Flex
}
from
'@chakra-ui/react'
;
...
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
...
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
PluginRunContext
}
from
'../context'
;
import
{
PluginRunContext
}
from
'../context'
;
import
{
WorkflowIOValueTypeEnum
}
from
'@fastgpt/global/core/workflow/constants'
;
import
{
WorkflowIOValueTypeEnum
}
from
'@fastgpt/global/core/workflow/constants'
;
import
{
isEqual
}
from
'lodash'
;
const
RenderInput
=
()
=>
{
const
RenderInput
=
()
=>
{
const
{
pluginInputs
,
variablesForm
,
histories
,
onStartChat
,
onNewChat
,
onSubmit
,
isChatting
}
=
const
{
pluginInputs
,
variablesForm
,
histories
,
onStartChat
,
onNewChat
,
onSubmit
,
isChatting
}
=
...
@@ -16,20 +17,25 @@ const RenderInput = () => {
...
@@ -16,20 +17,25 @@ const RenderInput = () => {
control
,
control
,
handleSubmit
,
handleSubmit
,
reset
,
reset
,
getValues
,
formState
:
{
errors
}
formState
:
{
errors
}
}
=
variablesForm
;
}
=
variablesForm
;
useEffect
(()
=>
{
const
defaultFormValues
=
useMemo
(()
=>
{
reset
(
return
pluginInputs
.
reduce
(
pluginInputs
.
reduce
(
(
acc
,
input
)
=>
{
(
acc
,
input
)
=>
{
acc
[
input
.
key
]
=
input
.
defaultValue
;
acc
[
input
.
key
]
=
input
.
defaultValue
;
return
acc
;
return
acc
;
},
},
{}
as
Record
<
string
,
any
>
{}
as
Record
<
string
,
any
>
)
);
);
},
[
pluginInputs
,
histories
]);
},
[
pluginInputs
]);
useEffect
(()
=>
{
if
(
isEqual
(
getValues
(),
defaultFormValues
))
return
;
reset
(
defaultFormValues
);
},
[
defaultFormValues
,
histories
]);
const
isDisabledInput
=
histories
.
length
>
0
;
const
isDisabledInput
=
histories
.
length
>
0
;
return
(
return
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment