import type { GlobalVariable } from '../../types' import { cn } from '@langgenius/dify-ui/cn' import { RiCloseLine } from '@remixicon/react' import { memo } from 'react' import { useTranslation } from 'react-i18next' import { useStore } from '@/app/components/workflow/store' import { isInWorkflowPage } from '../../constants' import { useIsChatMode } from '../../hooks' import Item from './item' 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(($) => $['globalVar.fieldsDescription.conversationId'], { ns: 'workflow', }), }, { name: 'dialog_count', value_type: 'number' as const, description: t(($) => $['globalVar.fieldsDescription.dialogCount'], { ns: 'workflow' }), }, ] : []), { name: 'user_id', value_type: 'string', description: t(($) => $['globalVar.fieldsDescription.userId'], { ns: 'workflow' }), }, { name: 'app_id', value_type: 'string', description: t(($) => $['globalVar.fieldsDescription.appId'], { ns: 'workflow' }), }, { name: 'workflow_id', value_type: 'string', description: t(($) => $['globalVar.fieldsDescription.workflowId'], { ns: 'workflow' }), }, { name: 'workflow_run_id', value_type: 'string', description: t(($) => $['globalVar.fieldsDescription.workflowRunId'], { ns: 'workflow' }), }, // is workflow ...(isWorkflowPage && !isChatMode ? [ { name: 'timestamp', value_type: 'number' as const, description: t(($) => $['globalVar.fieldsDescription.triggerTimestamp'], { ns: 'workflow', }), }, ] : []), ] return (