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.

3.0 KB
Raw Blame
'use client'
import type { FC } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import {
  ENABLE_WEBSITE_FIRECRAWL,
  ENABLE_WEBSITE_JINAREADER,
  ENABLE_WEBSITE_WATERCRAWL,
} from '@/config'
import { DataSourceProvider } from '@/models/common'
import s from './index.module.css'

const I18N_PREFIX = 'stepOne.website'

type Props = Readonly<{
  onConfig: () => void
  provider: DataSourceProvider
}>

const NoData: FC<Props> = ({ onConfig, provider }) => {
  const { t } = useTranslation(['datasetCreation'])

  const providerConfig: Record<
    DataSourceProvider,
    {
      emoji: React.ReactNode
      title: string
      description: string
    } | null
  > = {
    [DataSourceProvider.jinaReader]: ENABLE_WEBSITE_JINAREADER
      ? {
          emoji: <span className={s.jinaLogo} />,
          title: t(($) => $[`${I18N_PREFIX}.jinaReaderNotConfigured`], { ns: 'datasetCreation' }),
          description: t(($) => $[`${I18N_PREFIX}.jinaReaderNotConfiguredDescription`], {
            ns: 'datasetCreation',
          }),
        }
      : null,
    [DataSourceProvider.fireCrawl]: ENABLE_WEBSITE_FIRECRAWL
      ? {
          emoji: '🔥',
          title: t(($) => $[`${I18N_PREFIX}.fireCrawlNotConfigured`], { ns: 'datasetCreation' }),
          description: t(($) => $[`${I18N_PREFIX}.fireCrawlNotConfiguredDescription`], {
            ns: 'datasetCreation',
          }),
        }
      : null,
    [DataSourceProvider.waterCrawl]: ENABLE_WEBSITE_WATERCRAWL
      ? {
          emoji: '💧',
          title: t(($) => $[`${I18N_PREFIX}.waterCrawlNotConfigured`], { ns: 'datasetCreation' }),
          description: t(($) => $[`${I18N_PREFIX}.waterCrawlNotConfiguredDescription`], {
            ns: 'datasetCreation',
          }),
        }
      : null,
  }

  const currentProvider = providerConfig[provider] || providerConfig.jinareader

  if (!currentProvider) return null

  return (
    <>
      <div className="mt-4 max-w-160 rounded-2xl bg-workflow-process-bg p-6">
        <div className="flex h-12 w-12 items-center justify-center rounded-[10px] border-[0.5px] border-components-card-border bg-components-card-bg shadow-lg shadow-shadow-shadow-5 backdrop-blur-[5px]">
          {currentProvider.emoji}
        </div>
        <div className="mt-2 mb-1 flex flex-col gap-y-1 pt-1 pb-3">
          <span className="system-md-semibold text-text-secondary">
            {currentProvider.title}
            <span
              aria-hidden
              className="relative -top-2.5 -left-1.5 i-custom-vender-line-others-icon-3-dots inline-block h-4 w-4 align-middle"
            />
          </span>
          <div className="system-sm-regular text-text-tertiary">{currentProvider.description}</div>
        </div>
        <Button variant="primary" onClick={onConfig}>
          {t(($) => $[`${I18N_PREFIX}.configure`], { ns: 'datasetCreation' })}
        </Button>
      </div>
    </>
  )
}
export default React.memo(NoData)