import { memo, } from 'react' import { RiCloseLine } from '@remixicon/react' import type { GlobalVariable } from '../../types' import Item from './item' import { useStore } from '@/app/components/workflow/store' import cn from '@/utils/classnames' import { useTranslation } from 'react-i18next' import { useIsChatMode } from '../../hooks' import { isInWorkflowPage } from '../../constants' const Panel = () => { const { t } = useTranslation() const isChatMode = useIsChatMode() const setShowPanel = useStore(s => s.setShowGlobalVariablePanel) const isWorkflowPage = isInWorkflowPage() const globalVariableList: GlobalVariable[] = [ ...(isChatMode ? [{ name: 'conversation_id', value_type: 'string' as const, description: t('workflow.globalVar.fieldsDescription.conversationId'), }, { name: 'dialog_count', value_type: 'number' as const, description: t('workflow.globalVar.fieldsDescription.dialogCount'), }] : []), { name: 'user_id', value_type: 'string', description: t('workflow.globalVar.fieldsDescription.userId'), }, { name: 'app_id', value_type: 'string', description: t('workflow.globalVar.fieldsDescription.appId'), }, { name: 'workflow_id', value_type: 'string', description: t('workflow.globalVar.fieldsDescription.workflowId'), }, { name: 'workflow_run_id', value_type: 'string', description: t('workflow.globalVar.fieldsDescription.workflowRunId'), }, // is workflow ...((isWorkflowPage && !isChatMode) ? [{ name: 'timestamp', value_type: 'number' as const, description: t('workflow.globalVar.fieldsDescription.triggerTimestamp'), }] : []), ] return (
{t('workflow.globalVar.title')}
setShowPanel(false)} >
{t('workflow.globalVar.description')}
{globalVariableList.map(item => ( ))}
) } export default memo(Panel)