feat: last run new loading

This commit is contained in:
Joel 2025-04-30 14:47:57 +08:00
parent 6caf6714cd
commit 53f2a12cf7
3 changed files with 23 additions and 12 deletions

View File

@ -316,6 +316,7 @@ const BasePanel: FC<BasePanelProps> = ({
<LastRun <LastRun
appId={appDetail?.id || ''} appId={appDetail?.id || ''}
nodeId={id} nodeId={id}
canSingleRun={isSupportSingleRun}
runningStatus={runningStatus} runningStatus={runningStatus}
onSingleRunClicked={handleSingleRun} onSingleRunClicked={handleSingleRun}
/> />

View File

@ -5,11 +5,12 @@ import type { FC } from 'react'
import React from 'react' import React from 'react'
import NoData from './no-data' import NoData from './no-data'
import { useLastRun } from '@/service/use-workflow' import { useLastRun } from '@/service/use-workflow'
import Loading from '@/app/components/base/loading' import { RiLoader2Line } from '@remixicon/react'
type Props = { type Props = {
appId: string appId: string
nodeId: string nodeId: string
canSingleRun: boolean
runningStatus?: NodeRunningStatus runningStatus?: NodeRunningStatus
onSingleRunClicked: () => void onSingleRunClicked: () => void
} }
@ -17,21 +18,26 @@ type Props = {
const LastRun: FC<Props> = ({ const LastRun: FC<Props> = ({
appId, appId,
nodeId, nodeId,
canSingleRun,
runningStatus, runningStatus,
onSingleRunClicked, onSingleRunClicked,
}) => { }) => {
const isRunning = runningStatus === NodeRunningStatus.Running const isRunning = runningStatus === NodeRunningStatus.Running
const { data: runResult, isFetching } = useLastRun(appId, nodeId, !isRunning) const { data: runResult, isFetching } = useLastRun(appId, nodeId, !isRunning)
if (isFetching) if (isFetching) {
return <Loading /> return (
<div className='flex h-0 grow flex-col items-center justify-center'>
<RiLoader2Line className='size-4 animate-spin text-text-tertiary' />
</div>)
}
if (isRunning) if (isRunning)
return <ResultPanel status='running' showSteps={false} /> return <ResultPanel status='running' showSteps={false} />
if (!runResult) { if (!runResult) {
return ( return (
<NoData onSingleRun={onSingleRunClicked} /> <NoData canSingleRun={canSingleRun} onSingleRun={onSingleRunClicked} />
) )
} }
return ( return (

View File

@ -7,10 +7,12 @@ import { RiPlayLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
type Props = { type Props = {
canSingleRun: boolean
onSingleRun: () => void onSingleRun: () => void
} }
const NoData: FC<Props> = ({ const NoData: FC<Props> = ({
canSingleRun,
onSingleRun, onSingleRun,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -18,14 +20,16 @@ const NoData: FC<Props> = ({
<div className='flex h-0 grow flex-col items-center justify-center'> <div className='flex h-0 grow flex-col items-center justify-center'>
<ClockPlay className='h-8 w-8 text-text-quaternary' /> <ClockPlay className='h-8 w-8 text-text-quaternary' />
<div className='system-xs-regular my-2 text-text-tertiary'>{t('workflow.debug.noData.description')}</div> <div className='system-xs-regular my-2 text-text-tertiary'>{t('workflow.debug.noData.description')}</div>
<Button {canSingleRun && (
className='flex' <Button
size='small' className='flex'
onClick={onSingleRun} size='small'
> onClick={onSingleRun}
<RiPlayLine className='mr-1 h-3.5 w-3.5' /> >
<div>{t('workflow.debug.noData.runThisNode')}</div> <RiPlayLine className='mr-1 h-3.5 w-3.5' />
</Button> <div>{t('workflow.debug.noData.runThisNode')}</div>
</Button>
)}
</div> </div>
) )
} }