fix: specail panel not show

pull/21369/head
Joel 1 year ago
parent 94d0ba5dd6
commit fa41668cc2

@ -3,7 +3,6 @@ import type { FC } from 'react'
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { import {
RiCloseLine,
RiLoader2Line, RiLoader2Line,
} from '@remixicon/react' } from '@remixicon/react'
import type { Props as FormProps } from './form' import type { Props as FormProps } from './form'
@ -20,8 +19,7 @@ import { getProcessedFiles } from '@/app/components/base/file-uploader/utils'
import type { BlockEnum } from '@/app/components/workflow/types' import type { BlockEnum } from '@/app/components/workflow/types'
import type { Emoji } from '@/app/components/tools/types' import type { Emoji } from '@/app/components/tools/types'
import type { SpecialResultPanelProps } from '@/app/components/workflow/run/special-result-panel' import type { SpecialResultPanelProps } from '@/app/components/workflow/run/special-result-panel'
import SpecialResultPanel from '@/app/components/workflow/run/special-result-panel' import PanelWrap from './panel-wrap'
// import { useWhyDidYouUpdate } from 'ahooks'
const i18nPrefix = 'workflow.singleRun' const i18nPrefix = 'workflow.singleRun'
export type BeforeRunFormProps = { export type BeforeRunFormProps = {
@ -66,18 +64,14 @@ function formatValue(value: string | any, type: InputVarType) {
} }
const BeforeRunForm: FC<BeforeRunFormProps> = ({ const BeforeRunForm: FC<BeforeRunFormProps> = ({
nodeName, nodeName,
nodeType,
toolIcon,
onHide, onHide,
onRun, onRun,
onStop, onStop,
runningStatus, runningStatus,
result, result,
forms, forms,
showSpecialResultPanel,
filteredExistVarForms, filteredExistVarForms,
existVarValuesInForms, existVarValuesInForms,
...restResultPanelParams
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -160,27 +154,10 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
return null return null
return ( return (
<div className='absolute inset-0 z-10 rounded-2xl bg-background-overlay-alt'> <PanelWrap
<div className='flex h-full flex-col rounded-2xl bg-components-panel-bg'> nodeName={nodeName}
<div className='flex h-8 shrink-0 items-center justify-between pl-4 pr-3 pt-3'> onHide={onHide}
<div className='truncate text-base font-semibold text-text-primary'> >
{t(`${i18nPrefix}.testRun`)} {nodeName}
</div>
<div className='ml-2 shrink-0 cursor-pointer p-1' onClick={() => {
onHide()
}}>
<RiCloseLine className='h-4 w-4 text-text-tertiary ' />
</div>
</div>
{
showSpecialResultPanel && (
<div className='h-0 grow overflow-y-auto pb-4'>
<SpecialResultPanel {...restResultPanelParams} />
</div>
)
}
{
!showSpecialResultPanel && (
<div className='h-0 grow overflow-y-auto pb-4'> <div className='h-0 grow overflow-y-auto pb-4'>
<div className='mt-3 space-y-4 px-4'> <div className='mt-3 space-y-4 px-4'>
{filteredExistVarForms.map((form, index) => ( {filteredExistVarForms.map((form, index) => (
@ -217,10 +194,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
</> </>
)} )}
</div> </div>
) </PanelWrap>
}
</div>
</div>
) )
} }
export default React.memo(BeforeRunForm) export default React.memo(BeforeRunForm)

@ -0,0 +1,41 @@
'use client'
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import {
RiCloseLine,
} from '@remixicon/react'
const i18nPrefix = 'workflow.singleRun'
export type Props = {
nodeName: string
onHide: () => void
children: React.ReactNode
}
const PanelWrap: FC<Props> = ({
nodeName,
onHide,
children,
}) => {
const { t } = useTranslation()
return (
<div className='absolute inset-0 z-10 rounded-2xl bg-background-overlay-alt'>
<div className='flex h-full flex-col rounded-2xl bg-components-panel-bg'>
<div className='flex h-8 shrink-0 items-center justify-between pl-4 pr-3 pt-3'>
<div className='truncate text-base font-semibold text-text-primary'>
{t(`${i18nPrefix}.testRun`)} {nodeName}
</div>
<div className='ml-2 shrink-0 cursor-pointer p-1' onClick={() => {
onHide()
}}>
<RiCloseLine className='h-4 w-4 text-text-tertiary ' />
</div>
</div>
{children}
</div>
</div>
)
}
export default React.memo(PanelWrap)

@ -54,6 +54,8 @@ import BeforeRunForm from '../before-run-form'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import { NODES_EXTRA_DATA } from '@/app/components/workflow/constants' import { NODES_EXTRA_DATA } from '@/app/components/workflow/constants'
import { useLogs } from '@/app/components/workflow/run/hooks' import { useLogs } from '@/app/components/workflow/run/hooks'
import PanelWrap from '../before-run-form/panel-wrap'
import SpecialResultPanel from '@/app/components/workflow/run/special-result-panel'
type BasePanelProps = { type BasePanelProps = {
children: ReactNode children: ReactNode
@ -173,7 +175,32 @@ const BasePanel: FC<BasePanelProps> = ({
return {} return {}
})() })()
if (isShowSingleRun || logParams.showSpecialResultPanel) { if(logParams.showSpecialResultPanel) {
return (
<div className={cn(
'relative mr-1 h-full',
)}>
<div
ref={containerRef}
className={cn('flex h-full flex-col rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg', showSingleRunPanel ? 'overflow-hidden' : 'overflow-y-auto')}
style={{
width: `${nodePanelWidth}px`,
}}
>
<PanelWrap
nodeName={data.title}
onHide={hideSingleRun}
>
<div className='h-0 grow overflow-y-auto pb-4'>
<SpecialResultPanel {...passedLogParams} />
</div>
</PanelWrap>
</div>
</div>
)
}
if (isShowSingleRun) {
return ( return (
<div className={cn( <div className={cn(
'relative mr-1 h-full', 'relative mr-1 h-full',

@ -182,6 +182,10 @@ const useLastRun = <T>({
if(!selector || selector.length === 0) if(!selector || selector.length === 0)
return return
const [nodeId, varName] = selector.slice(0, 2) const [nodeId, varName] = selector.slice(0, 2)
if(nodeId === id) { // inner vars like loop vars
values[variable] = true
return
}
const inspectVarValue = hasSetInspectVar(nodeId, varName, systemVars, conversationVars) // also detect system var , env and conversation var const inspectVarValue = hasSetInspectVar(nodeId, varName, systemVars, conversationVars) // also detect system var , env and conversation var
if (inspectVarValue) if (inspectVarValue)
values[variable] = true values[variable] = true
@ -204,6 +208,7 @@ const useLastRun = <T>({
const getFilteredExistVarForms = (forms: FormProps[]) => { const getFilteredExistVarForms = (forms: FormProps[]) => {
if (!forms || forms.length === 0) if (!forms || forms.length === 0)
return [] return []
const existVarValuesInForms = getExistVarValuesInForms(forms) const existVarValuesInForms = getExistVarValuesInForms(forms)
const res = forms.map((form, i) => { const res = forms.map((form, i) => {

@ -7,6 +7,7 @@ import type { CaseItem, Condition, LoopNodeType } from './types'
import { ValueType } from '@/app/components/workflow/types' import { ValueType } from '@/app/components/workflow/types'
type Params = { type Params = {
id: string
payload: LoopNodeType payload: LoopNodeType
runInputData: Record<string, any> runInputData: Record<string, any>
runResult: NodeTracing runResult: NodeTracing
@ -16,6 +17,7 @@ type Params = {
} }
const useSingleRunFormParams = ({ const useSingleRunFormParams = ({
id,
payload, payload,
runInputData, runInputData,
runResult, runResult,
@ -138,7 +140,8 @@ const useSingleRunFormParams = ({
if(loopVariable.value_type === ValueType.variable) if(loopVariable.value_type === ValueType.variable)
vars.push(loopVariable.value) vars.push(loopVariable.value)
}) })
return vars const hasFilterLoopVars = vars.filter(item => item[0] !== id)
return hasFilterLoopVars
} }
return { return {

@ -200,7 +200,7 @@ export type InputVar = {
options?: string[] options?: string[]
value_selector?: ValueSelector value_selector?: ValueSelector
getVarValueFromDependent?: boolean getVarValueFromDependent?: boolean
hide: boolean hide?: boolean
} & Partial<UploadFileSetting> } & Partial<UploadFileSetting>
export type ModelConfig = { export type ModelConfig = {

Loading…
Cancel
Save