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.

workflow-children.tsx 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {
  2. memo,
  3. useState,
  4. } from 'react'
  5. import type { EnvironmentVariable } from '@/app/components/workflow/types'
  6. import { DSL_EXPORT_CHECK } from '@/app/components/workflow/constants'
  7. import { useStore } from '@/app/components/workflow/store'
  8. import Features from '@/app/components/workflow/features'
  9. import PluginDependency from '@/app/components/workflow/plugin-dependency'
  10. import UpdateDSLModal from '@/app/components/workflow/update-dsl-modal'
  11. import DSLExportConfirmModal from '@/app/components/workflow/dsl-export-confirm-modal'
  12. import {
  13. useDSL,
  14. usePanelInteractions,
  15. } from '@/app/components/workflow/hooks'
  16. import { useEventEmitterContextContext } from '@/context/event-emitter'
  17. import WorkflowHeader from './workflow-header'
  18. import WorkflowPanel from './workflow-panel'
  19. const WorkflowChildren = () => {
  20. const { eventEmitter } = useEventEmitterContextContext()
  21. const [secretEnvList, setSecretEnvList] = useState<EnvironmentVariable[]>([])
  22. const showFeaturesPanel = useStore(s => s.showFeaturesPanel)
  23. const showImportDSLModal = useStore(s => s.showImportDSLModal)
  24. const setShowImportDSLModal = useStore(s => s.setShowImportDSLModal)
  25. const {
  26. handlePaneContextmenuCancel,
  27. } = usePanelInteractions()
  28. const {
  29. exportCheck,
  30. handleExportDSL,
  31. } = useDSL()
  32. eventEmitter?.useSubscription((v: any) => {
  33. if (v.type === DSL_EXPORT_CHECK)
  34. setSecretEnvList(v.payload.data as EnvironmentVariable[])
  35. })
  36. return (
  37. <>
  38. <PluginDependency />
  39. {
  40. showFeaturesPanel && <Features />
  41. }
  42. {
  43. showImportDSLModal && (
  44. <UpdateDSLModal
  45. onCancel={() => setShowImportDSLModal(false)}
  46. onBackup={exportCheck}
  47. onImport={handlePaneContextmenuCancel}
  48. />
  49. )
  50. }
  51. {
  52. secretEnvList.length > 0 && (
  53. <DSLExportConfirmModal
  54. envList={secretEnvList}
  55. onConfirm={handleExportDSL}
  56. onClose={() => setSecretEnvList([])}
  57. />
  58. )
  59. }
  60. <WorkflowHeader />
  61. <WorkflowPanel />
  62. </>
  63. )
  64. }
  65. export default memo(WorkflowChildren)