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-panel.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { useMemo } from 'react'
  2. import { useShallow } from 'zustand/react/shallow'
  3. import { useStore } from '@/app/components/workflow/store'
  4. import {
  5. useIsChatMode,
  6. } from '../hooks'
  7. import { useStore as useAppStore } from '@/app/components/app/store'
  8. import type { PanelProps } from '@/app/components/workflow/panel'
  9. import Panel from '@/app/components/workflow/panel'
  10. import dynamic from 'next/dynamic'
  11. const MessageLogModal = dynamic(() => import('@/app/components/base/message-log-modal'), {
  12. ssr: false,
  13. })
  14. const Record = dynamic(() => import('@/app/components/workflow/panel/record'), {
  15. ssr: false,
  16. })
  17. const ChatRecord = dynamic(() => import('@/app/components/workflow/panel/chat-record'), {
  18. ssr: false,
  19. })
  20. const DebugAndPreview = dynamic(() => import('@/app/components/workflow/panel/debug-and-preview'), {
  21. ssr: false,
  22. })
  23. const WorkflowPreview = dynamic(() => import('@/app/components/workflow/panel/workflow-preview'), {
  24. ssr: false,
  25. })
  26. const ChatVariablePanel = dynamic(() => import('@/app/components/workflow/panel/chat-variable-panel'), {
  27. ssr: false,
  28. })
  29. const GlobalVariablePanel = dynamic(() => import('@/app/components/workflow/panel/global-variable-panel'), {
  30. ssr: false,
  31. })
  32. const VersionHistoryPanel = dynamic(() => import('@/app/components/workflow/panel/version-history-panel'), {
  33. ssr: false,
  34. })
  35. const WorkflowPanelOnLeft = () => {
  36. const { currentLogItem, setCurrentLogItem, showMessageLogModal, setShowMessageLogModal, currentLogModalActiveTab } = useAppStore(useShallow(state => ({
  37. currentLogItem: state.currentLogItem,
  38. setCurrentLogItem: state.setCurrentLogItem,
  39. showMessageLogModal: state.showMessageLogModal,
  40. setShowMessageLogModal: state.setShowMessageLogModal,
  41. currentLogModalActiveTab: state.currentLogModalActiveTab,
  42. })))
  43. return (
  44. <>
  45. {
  46. showMessageLogModal && (
  47. <MessageLogModal
  48. fixedWidth
  49. width={400}
  50. currentLogItem={currentLogItem}
  51. onCancel={() => {
  52. setCurrentLogItem()
  53. setShowMessageLogModal(false)
  54. }}
  55. defaultTab={currentLogModalActiveTab}
  56. />
  57. )
  58. }
  59. </>
  60. )
  61. }
  62. const WorkflowPanelOnRight = () => {
  63. const isChatMode = useIsChatMode()
  64. const historyWorkflowData = useStore(s => s.historyWorkflowData)
  65. const showDebugAndPreviewPanel = useStore(s => s.showDebugAndPreviewPanel)
  66. const showChatVariablePanel = useStore(s => s.showChatVariablePanel)
  67. const showGlobalVariablePanel = useStore(s => s.showGlobalVariablePanel)
  68. const showWorkflowVersionHistoryPanel = useStore(s => s.showWorkflowVersionHistoryPanel)
  69. return (
  70. <>
  71. {
  72. historyWorkflowData && !isChatMode && (
  73. <Record />
  74. )
  75. }
  76. {
  77. historyWorkflowData && isChatMode && (
  78. <ChatRecord />
  79. )
  80. }
  81. {
  82. showDebugAndPreviewPanel && isChatMode && (
  83. <DebugAndPreview />
  84. )
  85. }
  86. {
  87. showDebugAndPreviewPanel && !isChatMode && (
  88. <WorkflowPreview />
  89. )
  90. }
  91. {
  92. showChatVariablePanel && isChatMode && (
  93. <ChatVariablePanel />
  94. )
  95. }
  96. {
  97. showGlobalVariablePanel && (
  98. <GlobalVariablePanel />
  99. )
  100. }
  101. {
  102. showWorkflowVersionHistoryPanel && (
  103. <VersionHistoryPanel/>
  104. )
  105. }
  106. </>
  107. )
  108. }
  109. const WorkflowPanel = () => {
  110. const panelProps: PanelProps = useMemo(() => {
  111. return {
  112. components: {
  113. left: <WorkflowPanelOnLeft />,
  114. right: <WorkflowPanelOnRight />,
  115. },
  116. }
  117. }, [])
  118. return (
  119. <Panel {...panelProps} />
  120. )
  121. }
  122. export default WorkflowPanel