mirror of
https://github.com/langgenius/dify.git
synced 2026-02-12 11:44:00 +00:00
Compare commits
1 Commits
refactor/w
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fd3eeb760 |
@@ -1,11 +1,9 @@
|
||||
import type {
|
||||
FileEntity,
|
||||
} from './types'
|
||||
import { isEqual } from 'es-toolkit/predicate'
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
} from 'react'
|
||||
import {
|
||||
@@ -57,20 +55,10 @@ export const FileContextProvider = ({
|
||||
onChange,
|
||||
}: FileProviderProps) => {
|
||||
const storeRef = useRef<FileStore | undefined>(undefined)
|
||||
|
||||
if (!storeRef.current)
|
||||
storeRef.current = createFileStore(value, onChange)
|
||||
|
||||
useEffect(() => {
|
||||
if (!storeRef.current)
|
||||
return
|
||||
if (isEqual(value, storeRef.current.getState().files))
|
||||
return
|
||||
|
||||
storeRef.current.setState({
|
||||
files: value ? [...value] : [],
|
||||
})
|
||||
}, [value])
|
||||
|
||||
return (
|
||||
<FileContext.Provider value={storeRef.current}>
|
||||
{children}
|
||||
|
||||
@@ -108,7 +108,7 @@ const FormItem: FC<Props> = ({
|
||||
const isIteratorItemFile = isIterator && payload.isFileItem
|
||||
const singleFileValue = useMemo(() => {
|
||||
if (payload.variable === '#files#')
|
||||
return value?.[0] || []
|
||||
return value || []
|
||||
|
||||
return value ? [value] : []
|
||||
}, [payload.variable, value])
|
||||
@@ -124,19 +124,19 @@ const FormItem: FC<Props> = ({
|
||||
return (
|
||||
<div className={cn(className)}>
|
||||
{!isArrayLikeType && !isBooleanType && (
|
||||
<div className="system-sm-semibold mb-1 flex h-6 items-center gap-1 text-text-secondary">
|
||||
<div className="mb-1 flex h-6 items-center gap-1 text-text-secondary system-sm-semibold">
|
||||
<div className="truncate">
|
||||
{typeof payload.label === 'object' ? nodeKey : payload.label}
|
||||
</div>
|
||||
{payload.hide === true
|
||||
? (
|
||||
<span className="system-xs-regular text-text-tertiary">
|
||||
<span className="text-text-tertiary system-xs-regular">
|
||||
{t('panel.optional_and_hidden', { ns: 'workflow' })}
|
||||
</span>
|
||||
)
|
||||
: (
|
||||
!payload.required && (
|
||||
<span className="system-xs-regular text-text-tertiary">
|
||||
<span className="text-text-tertiary system-xs-regular">
|
||||
{t('panel.optional', { ns: 'workflow' })}
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -4102,11 +4102,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"app/components/explore/app-card/index.spec.tsx": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"app/components/explore/app-card/index.tsx": {
|
||||
"tailwindcss/enforce-consistent-class-order": {
|
||||
"count": 1
|
||||
@@ -6201,9 +6196,6 @@
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx": {
|
||||
"tailwindcss/enforce-consistent-class-order": {
|
||||
"count": 3
|
||||
},
|
||||
"ts/no-explicit-any": {
|
||||
"count": 11
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user