Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.9 KB
Raw Blame
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useStore } from '@/app/components/workflow/store'

const ChatVariableButton = ({ disabled }: { disabled: boolean }) => {
  const { t } = useTranslation(['workflow'])
  const showChatVariablePanel = useStore((s) => s.showChatVariablePanel)
  const setShowChatVariablePanel = useStore((s) => s.setShowChatVariablePanel)
  const setShowEnvPanel = useStore((s) => s.setShowEnvPanel)
  const setShowGlobalVariablePanel = useStore((s) => s.setShowGlobalVariablePanel)
  const setShowDebugAndPreviewPanel = useStore((s) => s.setShowDebugAndPreviewPanel)

  const handleClick = () => {
    setShowChatVariablePanel(true)
    setShowEnvPanel(false)
    setShowGlobalVariablePanel(false)
    setShowDebugAndPreviewPanel(false)
  }

  return (
    <Tooltip>
      <TooltipTrigger
        render={
          <IconButton
            aria-label={t(($) => $['chatVariable.panelTitle'], {
              ns: 'workflow',
            })}
            aria-expanded={showChatVariablePanel}
            size="lg"
            className={cn(
              'border border-transparent',
              showChatVariablePanel && 'dark:border-black/5 dark:bg-white/10 dark:backdrop-blur-xs',
            )}
            disabled={disabled}
            onClick={handleClick}
            variant="ghost"
          >
            <span
              aria-hidden
              className="i-custom-vender-line-others-bubble-x size-4 text-components-button-secondary-text"
            />
          </IconButton>
        }
      />

      <TooltipContent>
        {t(($) => $['chatVariable.panelTitle'], {
          ns: 'workflow',
        })}
      </TooltipContent>
    </Tooltip>
  )
}

export default memo(ChatVariableButton)