You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

schema-modal.tsx 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import Modal from '@/app/components/base/modal'
  5. import VisualEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor'
  6. import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'
  7. import { MittProvider, VisualEditorContextProvider } from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context'
  8. import { useTranslation } from 'react-i18next'
  9. import { RiCloseLine } from '@remixicon/react'
  10. type Props = {
  11. isShow: boolean
  12. schema: SchemaRoot
  13. rootName: string
  14. onClose: () => void
  15. }
  16. const SchemaModal: FC<Props> = ({
  17. isShow,
  18. schema,
  19. rootName,
  20. onClose,
  21. }) => {
  22. const { t } = useTranslation()
  23. return (
  24. <Modal
  25. isShow={isShow}
  26. onClose={onClose}
  27. className='max-w-[960px] p-0'
  28. wrapperClassName='z-[9999]'
  29. >
  30. <div className='pb-6'>
  31. {/* Header */}
  32. <div className='relative flex p-6 pb-3 pr-14'>
  33. <div className='title-2xl-semi-bold grow truncate text-text-primary'>
  34. {t('workflow.nodes.agent.parameterSchema')}
  35. </div>
  36. <div className='absolute right-5 top-5 flex h-8 w-8 items-center justify-center p-1.5' onClick={onClose}>
  37. <RiCloseLine className='h-[18px] w-[18px] text-text-tertiary' />
  38. </div>
  39. </div>
  40. {/* Content */}
  41. <div className='flex max-h-[700px] overflow-y-auto px-6 py-2'>
  42. <MittProvider>
  43. <VisualEditorContextProvider>
  44. <VisualEditor
  45. className='w-full'
  46. schema={schema}
  47. rootName={rootName}
  48. readOnly
  49. ></VisualEditor>
  50. </VisualEditorContextProvider>
  51. </MittProvider>
  52. </div>
  53. </div>
  54. </Modal>
  55. )
  56. }
  57. export default React.memo(SchemaModal)