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.

2.3 KB
Raw Blame
'use client'
import type { FC } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import {
  Dialog,
  DialogBody,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogTitle,
} from '@langgenius/dify-ui/dialog'
import { Field, FieldLabel } from '@langgenius/dify-ui/field'
import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'

type IRenameModalProps = {
  isShow: boolean
  saveLoading: boolean
  name: string
  onClose: () => void
  onSave: (name: string) => void
}

const RenameModal: FC<IRenameModalProps> = ({ isShow, saveLoading, name, onClose, onSave }) => {
  const { t } = useTranslation(['common'])
  const [tempName, setTempName] = useState(name)
  const conversationNamePlaceholder = t(($) => $['chat.conversationNamePlaceholder'], {
    ns: 'common',
  })

  return (
    <Dialog open={isShow} onOpenChange={(open) => !open && onClose()}>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>{t(($) => $['chat.renameConversation'], { ns: 'common' })}</DialogTitle>
        </DialogHeader>
        <Form
          className="contents"
          onFormSubmit={() => {
            if (!saveLoading) onSave(tempName)
          }}
        >
          <DialogBody>
            <Field name="conversationName">
              <FieldLabel className="text-sm leading-5.25 font-medium text-text-primary">
                {t(($) => $['chat.conversationName'], { ns: 'common' })}
              </FieldLabel>
              <Input
                className="h-10"
                value={tempName}
                onValueChange={setTempName}
                placeholder={conversationNamePlaceholder}
              />
            </Field>
          </DialogBody>
          <DialogFooter>
            <Button type="button" className="shrink-0" onClick={onClose}>
              {t(($) => $['operation.cancel'], { ns: 'common' })}
            </Button>
            <Button type="submit" variant="primary" className="shrink-0" loading={saveLoading}>
              {t(($) => $['operation.save'], { ns: 'common' })}
            </Button>
          </DialogFooter>
        </Form>
      </DialogContent>
    </Dialog>
  )
}
export default React.memo(RenameModal)