mirror of https://github.com/langgenius/dify.git
fix: type error
This commit is contained in:
parent
70767f756c
commit
c75adb8154
|
|
@ -16,7 +16,7 @@ const Slider: React.FC<ISliderProps> = ({ className, max, min, step, value, disa
|
|||
return (
|
||||
<ReactSlider
|
||||
disabled={disabled}
|
||||
value={isNaN(value) ? 0 : value}
|
||||
value={Number.isNaN(value) ? 0 : value}
|
||||
min={min || 0}
|
||||
max={max || 100}
|
||||
step={step || 1}
|
||||
|
|
@ -24,8 +24,13 @@ const Slider: React.FC<ISliderProps> = ({ className, max, min, step, value, disa
|
|||
thumbClassName={cn(s['slider-thumb'], 'top-[-7px] h-[18px] w-2 cursor-pointer rounded-[36px] border !border-black/8 bg-white shadow-md')}
|
||||
trackClassName={s['slider-track']}
|
||||
onChange={onChange}
|
||||
renderThumb={(props, state) => (
|
||||
<div {...props}>
|
||||
renderThumb={({ ref, ...props }, state) => (
|
||||
<div
|
||||
{...props}
|
||||
ref={(node) => {
|
||||
ref(node)
|
||||
}}
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
<div className="absolute left-[50%] top-[-16px] translate-x-[-50%] text-text-primary system-sm-semibold">
|
||||
{(state.valueNow / 100).toFixed(2)}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ import { VarType as WorkflowVarType } from '../../types'
|
|||
import { getOperators } from '../if-else/utils'
|
||||
import { OrderBy } from './types'
|
||||
|
||||
const filterableVarTypes: readonly VarType[] = [
|
||||
WorkflowVarType.arrayNumber,
|
||||
WorkflowVarType.arrayString,
|
||||
WorkflowVarType.arrayBoolean,
|
||||
WorkflowVarType.arrayFile,
|
||||
]
|
||||
|
||||
export const getItemVarType = (varType?: VarType) => {
|
||||
switch (varType) {
|
||||
case WorkflowVarType.arrayNumber:
|
||||
|
|
@ -33,12 +40,7 @@ export const getItemVarTypeShowName = (itemVarType?: VarType, hasVariable?: bool
|
|||
export const supportsSubVariable = (varType?: VarType) => varType === WorkflowVarType.arrayFile
|
||||
|
||||
export const canFilterVariable = (varPayload: Var) => {
|
||||
return [
|
||||
WorkflowVarType.arrayNumber,
|
||||
WorkflowVarType.arrayString,
|
||||
WorkflowVarType.arrayBoolean,
|
||||
WorkflowVarType.arrayFile,
|
||||
].includes(varPayload.type)
|
||||
return filterableVarTypes.includes(varPayload.type)
|
||||
}
|
||||
|
||||
export const buildFilterCondition = ({
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ vi.mock('../../_base/components/variable/utils', () => ({
|
|||
isSystemVar: (...args: unknown[]) => mockIsSystemVar(...args),
|
||||
}))
|
||||
|
||||
const createNode = (id: string, title: string, type = BlockEnum.Tool): Node => ({
|
||||
const createNode = (id: string, title: string, type: BlockEnum = BlockEnum.Tool): Node => ({
|
||||
id,
|
||||
position: { x: 0, y: 0 },
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ const createLoopNode = (overrides: Partial<LoopNodeType> = {}): LoopNodeType =>
|
|||
...overrides,
|
||||
})
|
||||
|
||||
const createVariableNode = (id: string, title: string, type = BlockEnum.Tool): Node => ({
|
||||
const createVariableNode = (id: string, title: string, type: BlockEnum = BlockEnum.Tool): Node => ({
|
||||
id,
|
||||
position: { x: 0, y: 0 },
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -6,14 +6,16 @@ import { ValueType, VarType } from '../../types'
|
|||
import { LogicalOperator } from './types'
|
||||
import { getOperators } from './utils'
|
||||
|
||||
const loopInputVarTypes: readonly VarType[] = [
|
||||
VarType.array,
|
||||
VarType.arrayString,
|
||||
VarType.arrayNumber,
|
||||
VarType.arrayObject,
|
||||
VarType.arrayFile,
|
||||
]
|
||||
|
||||
export const canUseAsLoopInput = (variable: Var) => {
|
||||
return [
|
||||
VarType.array,
|
||||
VarType.arrayString,
|
||||
VarType.arrayNumber,
|
||||
VarType.arrayObject,
|
||||
VarType.arrayFile,
|
||||
].includes(variable.type)
|
||||
return loopInputVarTypes.includes(variable.type)
|
||||
}
|
||||
|
||||
export const updateErrorHandleMode = (
|
||||
|
|
|
|||
|
|
@ -34,12 +34,18 @@ const {
|
|||
mockVariableTriggerState: {
|
||||
savePayload: undefined as EnvironmentVariable | undefined,
|
||||
},
|
||||
mockUpdateEnvironmentVariables: vi.fn(() => Promise.resolve()),
|
||||
mockUpdateEnvironmentVariables: vi.fn<({
|
||||
appId,
|
||||
environmentVariables,
|
||||
}: {
|
||||
appId: string
|
||||
environmentVariables: EnvironmentVariable[]
|
||||
}) => Promise<void>>(() => Promise.resolve()),
|
||||
mockSocketEmit: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/workflow', () => ({
|
||||
updateEnvironmentVariables: (...args: unknown[]) => mockUpdateEnvironmentVariables(...args),
|
||||
updateEnvironmentVariables: (payload: { appId: string, environmentVariables: EnvironmentVariable[] }) => mockUpdateEnvironmentVariables(payload),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/workflow/collaboration/core/websocket-manager', () => ({
|
||||
|
|
|
|||
Loading…
Reference in New Issue