MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / _showHideOperation

Function _showHideOperation

packages/components/src/agentflowv2Generator.ts:577–673  ·  view source on GitHub ↗
(nodeData: Record<string, any>, inputParam: Record<string, any>, displayType: string, index?: number)

Source from the content-addressed store, hash-verified

575}
576
577const _showHideOperation = (nodeData: Record<string, any>, inputParam: Record<string, any>, displayType: string, index?: number) => {
578 const displayOptions = inputParam[displayType]
579 /* For example:
580 show: {
581 enableMemory: true
582 }
583 */
584 Object.keys(displayOptions).forEach((path) => {
585 const comparisonValue = displayOptions[path]
586 if (path.includes('$index') && index) {
587 path = path.replace('$index', index.toString())
588 }
589 let groundValue = get(nodeData.inputs, path, '')
590 if (groundValue && typeof groundValue === 'string' && groundValue.startsWith('[') && groundValue.endsWith(']')) {
591 groundValue = JSON.parse(groundValue)
592 }
593
594 // Handle case where groundValue is an array
595 if (Array.isArray(groundValue)) {
596 if (Array.isArray(comparisonValue)) {
597 // Both are arrays - check if there's any intersection
598 const hasIntersection = comparisonValue.some((val) => groundValue.includes(val))
599 if (displayType === 'show' && !hasIntersection) {
600 inputParam.display = false
601 }
602 if (displayType === 'hide' && hasIntersection) {
603 inputParam.display = false
604 }
605 } else if (typeof comparisonValue === 'string') {
606 // comparisonValue is string, groundValue is array - check if array contains the string
607 const matchFound = groundValue.some((val) => comparisonValue === val || new RegExp(comparisonValue).test(val))
608 if (displayType === 'show' && !matchFound) {
609 inputParam.display = false
610 }
611 if (displayType === 'hide' && matchFound) {
612 inputParam.display = false
613 }
614 } else if (typeof comparisonValue === 'boolean' || typeof comparisonValue === 'number') {
615 // For boolean/number comparison with array, check if array contains the value
616 const matchFound = groundValue.includes(comparisonValue)
617 if (displayType === 'show' && !matchFound) {
618 inputParam.display = false
619 }
620 if (displayType === 'hide' && matchFound) {
621 inputParam.display = false
622 }
623 } else if (typeof comparisonValue === 'object') {
624 // For object comparison with array, use deep equality check
625 const matchFound = groundValue.some((val) => isEqual(comparisonValue, val))
626 if (displayType === 'show' && !matchFound) {
627 inputParam.display = false
628 }
629 if (displayType === 'hide' && matchFound) {
630 inputParam.display = false
631 }
632 }
633 } else {
634 // Original logic for non-array groundValue

Callers 1

showHideInputsFunction · 0.70

Calls 3

getFunction · 0.85
testMethod · 0.80
parseMethod · 0.65

Tested by

no test coverage detected