import { useTranslation } from 'react-i18next' import { RiArrowGoBackLine, RiCloseLine, RiMenuLine, } from '@remixicon/react' import { useStore } from '../store' import type { BlockEnum } from '../types' import useCurrentVars from '../hooks/use-inspect-vars-crud' import Empty from './empty' import ValueContent from './value-content' import ActionButton from '@/app/components/base/action-button' import Badge from '@/app/components/base/badge' import CopyFeedback from '@/app/components/base/copy-feedback' import Tooltip from '@/app/components/base/tooltip' import BlockIcon from '@/app/components/workflow/block-icon' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import Loading from '@/app/components/base/loading' import type { currentVarType } from './panel' import { VarInInspectType } from '@/types/workflow' import cn from '@/utils/classnames' type Props = { currentNodeVar?: currentVarType handleOpenMenu: () => void isValueFetching?: boolean } const Right = ({ currentNodeVar, handleOpenMenu, isValueFetching, }: Props) => { const { t } = useTranslation() const bottomPanelWidth = useStore(s => s.bottomPanelWidth) const setShowVariableInspectPanel = useStore(s => s.setShowVariableInspectPanel) const setCurrentFocusNodeId = useStore(s => s.setCurrentFocusNodeId) const { resetConversationVar, resetToLastRunVar, editInspectVarValue, } = useCurrentVars() const handleValueChange = (varId: string, value: any) => { if (!currentNodeVar) return editInspectVarValue(currentNodeVar.nodeId, varId, value) } const resetValue = () => { if (!currentNodeVar) return resetToLastRunVar(currentNodeVar.nodeId, currentNodeVar.var.id) } const handleClose = () => { setShowVariableInspectPanel(false) setCurrentFocusNodeId('') } const handleClear = () => { if (!currentNodeVar) return resetConversationVar(currentNodeVar.var.id) } return (
{/* header */}
{bottomPanelWidth < 488 && ( )}
{currentNodeVar && ( <> {currentNodeVar.nodeType === VarInInspectType.environment && ( )} {currentNodeVar.nodeType === VarInInspectType.conversation && ( )} {currentNodeVar.nodeType === VarInInspectType.system && ( )} {currentNodeVar.nodeType !== VarInInspectType.environment && currentNodeVar.nodeType !== VarInInspectType.conversation && currentNodeVar.nodeType !== VarInInspectType.system && ( <>
{currentNodeVar.title}
/
)}
{currentNodeVar.var.name}
{currentNodeVar.var.value_type}
)}
{currentNodeVar && ( <> {currentNodeVar.var.edited && ( {t('workflow.debug.variableInspect.edited')} )} {currentNodeVar.var.edited && currentNodeVar.var.type !== VarInInspectType.conversation && ( )} {currentNodeVar.var.edited && currentNodeVar.var.type === VarInInspectType.conversation && ( )} {currentNodeVar.var.value_type !== 'secret' && ( )} )}
{/* content */}
{!currentNodeVar && } {isValueFetching && (
)} {currentNodeVar && !isValueFetching && }
) } export default Right