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.2 KB
Raw Blame
'use client'
import type { FC } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import * as React from 'react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDocLink } from '@/context/i18n'
import Input from './text-input'

const I18N_PREFIX = 'stepOne.website'

type Props = Readonly<{
  isRunning: boolean
  onRun: (url: string) => void
}>

const UrlInput: FC<Props> = ({ isRunning, onRun }) => {
  const { t } = useTranslation(['datasetCreation'])
  const docLink = useDocLink()
  const [url, setUrl] = useState('')
  const handleUrlChange = useCallback((url: string | number) => {
    setUrl(url as string)
  }, [])
  const handleOnRun = useCallback(() => {
    if (isRunning) return
    onRun(url)
  }, [isRunning, onRun, url])

  return (
    <div className="flex items-center justify-between gap-x-2">
      <Input value={url} onChange={handleUrlChange} placeholder={docLink()} />
      <Button variant="primary" onClick={handleOnRun} loading={isRunning}>
        {t(($) => $[`${I18N_PREFIX}.run`], { ns: 'datasetCreation' })}
      </Button>
    </div>
  )
}
export default React.memo(UrlInput)