features.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {
  2. memo,
  3. useCallback,
  4. } from 'react'
  5. import { useTranslation } from 'react-i18next'
  6. import { RiCloseLine } from '@remixicon/react'
  7. import { useStore } from './store'
  8. import {
  9. useIsChatMode,
  10. useNodesReadOnly,
  11. useNodesSyncDraft,
  12. } from './hooks'
  13. import {
  14. FeaturesChoose,
  15. FeaturesPanel,
  16. } from '@/app/components/base/features'
  17. const Features = () => {
  18. const { t } = useTranslation()
  19. const isChatMode = useIsChatMode()
  20. const setShowFeaturesPanel = useStore(s => s.setShowFeaturesPanel)
  21. const { nodesReadOnly } = useNodesReadOnly()
  22. const { handleSyncWorkflowDraft } = useNodesSyncDraft()
  23. const handleFeaturesChange = useCallback(() => {
  24. handleSyncWorkflowDraft()
  25. }, [handleSyncWorkflowDraft])
  26. return (
  27. <div className='fixed top-16 left-2 bottom-2 w-[600px] rounded-2xl border-[0.5px] border-gray-200 bg-white shadow-xl z-10'>
  28. <div className='flex items-center justify-between px-4 pt-3'>
  29. {t('workflow.common.features')}
  30. <div className='flex items-center'>
  31. {
  32. isChatMode && (
  33. <>
  34. <FeaturesChoose
  35. disabled={nodesReadOnly}
  36. onChange={handleFeaturesChange}
  37. />
  38. <div className='mx-3 w-[1px] h-[14px] bg-gray-200'></div>
  39. </>
  40. )
  41. }
  42. <div
  43. className='flex items-center justify-center w-6 h-6 cursor-pointer'
  44. onClick={() => setShowFeaturesPanel(false)}
  45. >
  46. <RiCloseLine className='w-4 h-4 text-gray-500' />
  47. </div>
  48. </div>
  49. </div>
  50. <div className='p-4'>
  51. <FeaturesPanel
  52. disabled={nodesReadOnly}
  53. onChange={handleFeaturesChange}
  54. openingStatementProps={{
  55. onAutoAddPromptVariable: () => {},
  56. }}
  57. />
  58. </div>
  59. </div>
  60. )
  61. }
  62. export default memo(Features)