mirror of
https://github.com/langgenius/dify.git
synced 2026-03-10 19:21:50 +08:00
user action add
This commit is contained in:
parent
b02199145e
commit
fb6c8fa01f
@ -24,6 +24,7 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const {
|
const {
|
||||||
inputs,
|
inputs,
|
||||||
|
handleUserActionAdd,
|
||||||
handleUserActionChange,
|
handleUserActionChange,
|
||||||
handleUserActionDelete,
|
handleUserActionDelete,
|
||||||
handleTimeoutChange,
|
handleTimeoutChange,
|
||||||
@ -41,7 +42,7 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
|||||||
<div className='flex items-center px-1'>
|
<div className='flex items-center px-1'>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
inputs.userActions.push({
|
handleUserActionAdd({
|
||||||
id: uuid4(),
|
id: uuid4(),
|
||||||
name: 'Action',
|
name: 'Action',
|
||||||
text: 'Button Text',
|
text: 'Button Text',
|
||||||
|
|||||||
@ -8,6 +8,13 @@ const useConfig = (id: string, payload: HumanInputNodeType) => {
|
|||||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||||
const { inputs, setInputs } = useNodeCrud<HumanInputNodeType>(id, payload)
|
const { inputs, setInputs } = useNodeCrud<HumanInputNodeType>(id, payload)
|
||||||
|
|
||||||
|
const handleUserActionAdd = (newAction: UserAction) => {
|
||||||
|
setInputs({
|
||||||
|
...inputs,
|
||||||
|
userActions: [...inputs.userActions, newAction],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleUserActionChange = (updatedAction: UserAction) => {
|
const handleUserActionChange = (updatedAction: UserAction) => {
|
||||||
const newActions = produce(inputs.userActions, (draft) => {
|
const newActions = produce(inputs.userActions, (draft) => {
|
||||||
const index = draft.findIndex(a => a.id === updatedAction.id)
|
const index = draft.findIndex(a => a.id === updatedAction.id)
|
||||||
@ -38,6 +45,7 @@ const useConfig = (id: string, payload: HumanInputNodeType) => {
|
|||||||
return {
|
return {
|
||||||
readOnly,
|
readOnly,
|
||||||
inputs,
|
inputs,
|
||||||
|
handleUserActionAdd,
|
||||||
handleUserActionChange,
|
handleUserActionChange,
|
||||||
handleUserActionDelete,
|
handleUserActionDelete,
|
||||||
handleTimeoutChange,
|
handleTimeoutChange,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user