mirror of https://github.com/langgenius/dify.git
fix: lnit error
This commit is contained in:
parent
8897633e42
commit
441104ac3c
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import type { Recipient } from '@/app/components/workflow/nodes/human-input/types'
|
||||
import type { Member } from '@/models/common'
|
||||
import * as React from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Avatar from '@/app/components/base/avatar'
|
||||
|
|
@ -11,11 +11,11 @@ import { cn } from '@/utils/classnames'
|
|||
const i18nPrefix = 'nodes.humanInput'
|
||||
|
||||
type Props = {
|
||||
value: any[]
|
||||
value: Recipient[]
|
||||
searchValue: string
|
||||
onSearchChange: (value: string) => void
|
||||
list: Member[]
|
||||
onSelect: (value: any) => void
|
||||
onSelect: (value: string) => void
|
||||
email: string
|
||||
hideSearch?: boolean
|
||||
}
|
||||
|
|
@ -57,16 +57,16 @@ const MemberList: FC<Props> = ({ searchValue, list, value, onSearchChange, onSel
|
|||
key={account.id}
|
||||
className={cn(
|
||||
'group flex cursor-pointer items-center gap-2 rounded-lg py-1 pl-2 pr-3 hover:bg-state-base-hover',
|
||||
value.some((item: { user_id: string }) => item.user_id === account.id) && 'bg-transparent hover:bg-transparent',
|
||||
value.some(item => item.user_id === account.id) && 'bg-transparent hover:bg-transparent',
|
||||
)}
|
||||
onClick={() => {
|
||||
if (value.some((item: { user_id: string }) => item.user_id === account.id))
|
||||
if (value.some(item => item.user_id === account.id))
|
||||
return
|
||||
onSelect(account.id)
|
||||
}}
|
||||
>
|
||||
<Avatar className={cn(value.some((item: { user_id: string }) => item.user_id === account.id) && 'opacity-50')} avatar={account.avatar_url} size={24} name={account.name} />
|
||||
<div className={cn('grow', value.some((item: { user_id: string }) => item.user_id === account.id) && 'opacity-50')}>
|
||||
<Avatar className={cn(value.some(item => item.user_id === account.id) && 'opacity-50')} avatar={account.avatar_url} size={24} name={account.name} />
|
||||
<div className={cn('grow', value.some(item => item.user_id === account.id) && 'opacity-50')}>
|
||||
<div className="system-sm-medium text-text-secondary">
|
||||
{account.name}
|
||||
{account.status === 'pending' && <span className="system-xs-medium ml-1 text-text-warning">{t('members.pending', { ns: 'common' })}</span>}
|
||||
|
|
@ -74,10 +74,10 @@ const MemberList: FC<Props> = ({ searchValue, list, value, onSearchChange, onSel
|
|||
</div>
|
||||
<div className="system-xs-regular text-text-tertiary">{account.email}</div>
|
||||
</div>
|
||||
{!value.some((item: { user_id: string }) => item.user_id === account.id) && (
|
||||
{!value.some(item => item.user_id === account.id) && (
|
||||
<div className="system-xs-medium hidden text-text-accent group-hover:block">{t(`${i18nPrefix}.deliveryMethod.emailConfigure.memberSelector.add`, { ns: 'workflow' })}</div>
|
||||
)}
|
||||
{value.some((item: { user_id: string }) => item.user_id === account.id) && (
|
||||
{value.some(item => item.user_id === account.id) && (
|
||||
<div className="system-xs-regular text-text-tertiary">{t(`${i18nPrefix}.deliveryMethod.emailConfigure.memberSelector.added`, { ns: 'workflow' })}</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import type { Recipient } from '@/app/components/workflow/nodes/human-input/types'
|
||||
import type { Member } from '@/models/common'
|
||||
import {
|
||||
RiContactsBookLine,
|
||||
} from '@remixicon/react'
|
||||
import * as React from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Button from '@/app/components/base/button'
|
||||
|
|
@ -15,9 +15,9 @@ import MemberList from './member-list'
|
|||
const i18nPrefix = 'nodes.humanInput'
|
||||
|
||||
type Props = {
|
||||
value: any[]
|
||||
value: Recipient[]
|
||||
email: string
|
||||
onSelect: (value: any) => void
|
||||
onSelect: (value: string) => void
|
||||
list: Member[]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
'use client'
|
||||
import type { ButtonProps } from '@/app/components/base/button'
|
||||
import type { UserAction } from '@/app/components/workflow/nodes/human-input/types'
|
||||
import type { HumanInputFormData } from '@/types/workflow'
|
||||
import { RiArrowLeftLine } from '@remixicon/react'
|
||||
import * as React from 'react'
|
||||
|
|
@ -14,7 +16,7 @@ type Props = {
|
|||
data: HumanInputFormData
|
||||
showBackButton?: boolean
|
||||
handleBack?: () => void
|
||||
onSubmit?: (data: any) => Promise<void>
|
||||
onSubmit?: ({ inputs, action }: { inputs: Record<string, string>, action: string }) => Promise<void>
|
||||
}
|
||||
|
||||
const FormContent = ({
|
||||
|
|
@ -30,7 +32,7 @@ const FormContent = ({
|
|||
const [inputs, setInputs] = useState(defaultInputs)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
const handleInputsChange = (name: string, value: any) => {
|
||||
const handleInputsChange = (name: string, value: string) => {
|
||||
setInputs(prev => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
|
|
@ -66,11 +68,11 @@ const FormContent = ({
|
|||
/>
|
||||
))}
|
||||
<div className="flex flex-wrap gap-1 py-1">
|
||||
{data.actions.map((action: any) => (
|
||||
{data.actions.map((action: UserAction) => (
|
||||
<Button
|
||||
key={action.id}
|
||||
disabled={isSubmitting}
|
||||
variant={getButtonStyle(action.button_style) as any}
|
||||
variant={getButtonStyle(action.button_style) as ButtonProps['variant']}
|
||||
onClick={() => submit(action.id)}
|
||||
>
|
||||
{action.title}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
|||
timeout: 3,
|
||||
timeout_unit: 'day',
|
||||
},
|
||||
checkValid(payload: HumanInputNodeType, t: any) {
|
||||
checkValid(payload: HumanInputNodeType, t: (str: string, options: Record<string, unknown>) => string) {
|
||||
let errorMessages = ''
|
||||
if (!errorMessages && !payload.delivery_methods.length)
|
||||
errorMessages = t(`${i18nPrefix}.noDeliveryMethod`, { ns: 'workflow' })
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ const i18nPrefix = 'nodes.humanInput'
|
|||
type Params = {
|
||||
id: string
|
||||
payload: HumanInputNodeType
|
||||
runInputData: Record<string, any>
|
||||
runInputData: Record<string, string>
|
||||
getInputVars: (textList: string[]) => InputVar[]
|
||||
setRunInputData: (data: Record<string, any>) => void
|
||||
setRunInputData: (data: Record<string, string>) => void
|
||||
}
|
||||
const useSingleRunFormParams = ({
|
||||
id,
|
||||
|
|
@ -30,7 +30,7 @@ const useSingleRunFormParams = ({
|
|||
const { inputs } = useNodeCrud<HumanInputNodeType>(id, payload)
|
||||
const [showGeneratedForm, setShowGeneratedForm] = useState(false)
|
||||
const [formData, setFormData] = useState<HumanInputFormData | null>(null)
|
||||
const [requiredInputs, setRequiredInputs] = useState<Record<string, any>>({})
|
||||
const [requiredInputs, setRequiredInputs] = useState<Record<string, string>>({})
|
||||
const generatedInputs = useMemo(() => {
|
||||
const defaultInputs = inputs.inputs.reduce((acc, input) => {
|
||||
if (input.default.type === 'variable') {
|
||||
|
|
@ -76,10 +76,10 @@ const useSingleRunFormParams = ({
|
|||
}
|
||||
}, [appId, id, isWorkflowMode])
|
||||
|
||||
const handleFetchFormContent = useCallback(async (inputs: Record<string, any>) => {
|
||||
const handleFetchFormContent = useCallback(async (inputs: Record<string, string>) => {
|
||||
if (!fetchURL)
|
||||
return null
|
||||
let requestParamsObj: Record<string, any> = {}
|
||||
let requestParamsObj: Record<string, string> = {}
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (inputs[key] === undefined) {
|
||||
delete inputs[key]
|
||||
|
|
@ -92,7 +92,11 @@ const useSingleRunFormParams = ({
|
|||
return data
|
||||
}, [fetchURL])
|
||||
|
||||
const handleSubmitHumanInputForm = useCallback(async (formData: any) => {
|
||||
const handleSubmitHumanInputForm = useCallback(async (formData: {
|
||||
inputs: Record<string, string> | undefined
|
||||
form_inputs: Record<string, string> | undefined
|
||||
action: string
|
||||
}) => {
|
||||
await submitHumanInputNodeStepRunForm(fetchURL, {
|
||||
inputs: requiredInputs,
|
||||
form_inputs: formData.inputs,
|
||||
|
|
@ -100,7 +104,7 @@ const useSingleRunFormParams = ({
|
|||
})
|
||||
}, [fetchURL, requiredInputs])
|
||||
|
||||
const handleShowGeneratedForm = async (formValue: Record<string, any>) => {
|
||||
const handleShowGeneratedForm = async (formValue: Record<string, string>) => {
|
||||
setShowGeneratedForm(true)
|
||||
await handleFetchFormContent(formValue)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3304,16 +3304,6 @@
|
|||
"count": 5
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-list.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-selector.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/components/delivery-method/test-email-sender.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 2
|
||||
|
|
@ -3330,26 +3320,11 @@
|
|||
"count": 3
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/components/single-run-form.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 4
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/components/variable-in-markdown.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 8
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/default.ts": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 7
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 1
|
||||
|
|
@ -4422,11 +4397,6 @@
|
|||
"count": 10
|
||||
}
|
||||
},
|
||||
"service/workflow.ts": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"testing/testing.md": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 2
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export const submitHumanInputForm = (token: string, data: {
|
|||
export const fetchHumanInputNodeStepRunForm = (
|
||||
url: string,
|
||||
data: {
|
||||
inputs: Record<string, any>
|
||||
inputs: Record<string, string>
|
||||
},
|
||||
) => {
|
||||
return post<HumanInputFormData>(`${url}/preview`, { body: data })
|
||||
|
|
@ -117,8 +117,8 @@ export const fetchHumanInputNodeStepRunForm = (
|
|||
export const submitHumanInputNodeStepRunForm = (
|
||||
url: string,
|
||||
data: {
|
||||
inputs: Record<string, any> | undefined
|
||||
form_inputs: Record<string, any> | undefined
|
||||
inputs: Record<string, string> | undefined
|
||||
form_inputs: Record<string, string> | undefined
|
||||
action: string
|
||||
},
|
||||
) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue