|
|
|
|
@ -21,30 +21,36 @@ import {
|
|
|
|
|
|
|
|
|
|
type RunModeProps = {
|
|
|
|
|
text?: string
|
|
|
|
|
isRunning?: boolean
|
|
|
|
|
onStopRun?: () => void
|
|
|
|
|
}
|
|
|
|
|
const RunMode = memo(({
|
|
|
|
|
text,
|
|
|
|
|
isRunning: running,
|
|
|
|
|
onStopRun,
|
|
|
|
|
}: RunModeProps) => {
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
const { handleWorkflowStartRunInWorkflow } = useWorkflowStartRun()
|
|
|
|
|
const { handleStopRun } = useWorkflowRun()
|
|
|
|
|
const workflowRunningData = useStore(s => s.workflowRunningData)
|
|
|
|
|
const isRunning = workflowRunningData?.result.status === WorkflowRunningStatus.Running
|
|
|
|
|
const mergedRunning = isRunning || running
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
'flex h-7 items-center rounded-md px-2.5 text-[13px] font-medium text-components-button-secondary-accent-text',
|
|
|
|
|
'flex h-7 items-center px-2.5 text-[13px] font-medium text-components-button-secondary-accent-text',
|
|
|
|
|
'cursor-pointer hover:bg-state-accent-hover',
|
|
|
|
|
isRunning && '!cursor-not-allowed bg-state-accent-hover',
|
|
|
|
|
mergedRunning && 'cursor-not-allowed bg-state-accent-hover',
|
|
|
|
|
mergedRunning ? 'rounded-l-md' : 'rounded-md',
|
|
|
|
|
)}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleWorkflowStartRunInWorkflow()
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
isRunning
|
|
|
|
|
mergedRunning
|
|
|
|
|
? (
|
|
|
|
|
<>
|
|
|
|
|
<RiLoader2Line className='mr-1 h-4 w-4 animate-spin' />
|
|
|
|
|
@ -60,12 +66,14 @@ const RunMode = memo(({
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
{
|
|
|
|
|
isRunning && (
|
|
|
|
|
mergedRunning && (
|
|
|
|
|
<div
|
|
|
|
|
className='ml-0.5 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md hover:bg-black/5'
|
|
|
|
|
onClick={() => handleStopRun(workflowRunningData?.task_id || '')}
|
|
|
|
|
className={cn(
|
|
|
|
|
'ml-[1px] flex h-7 w-7 cursor-pointer items-center justify-center rounded-r-md bg-state-accent-active',
|
|
|
|
|
)}
|
|
|
|
|
onClick={() => onStopRun ? onStopRun() : handleStopRun(workflowRunningData?.task_id || '')}
|
|
|
|
|
>
|
|
|
|
|
<StopCircle className='h-4 w-4 text-components-button-ghost-text' />
|
|
|
|
|
<StopCircle className='h-4 w-4 text-text-accent' />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@ -94,12 +102,16 @@ const PreviewMode = memo(() => {
|
|
|
|
|
export type RunAndHistoryProps = {
|
|
|
|
|
showRunButton?: boolean
|
|
|
|
|
runButtonText?: string
|
|
|
|
|
isRunning?: boolean
|
|
|
|
|
onStopRun?: () => void
|
|
|
|
|
showPreviewButton?: boolean
|
|
|
|
|
viewHistoryProps?: ViewHistoryProps
|
|
|
|
|
}
|
|
|
|
|
const RunAndHistory = ({
|
|
|
|
|
showRunButton,
|
|
|
|
|
runButtonText,
|
|
|
|
|
isRunning,
|
|
|
|
|
onStopRun,
|
|
|
|
|
showPreviewButton,
|
|
|
|
|
viewHistoryProps,
|
|
|
|
|
}: RunAndHistoryProps) => {
|
|
|
|
|
@ -108,7 +120,7 @@ const RunAndHistory = ({
|
|
|
|
|
return (
|
|
|
|
|
<div className='flex h-8 items-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-0.5 shadow-xs'>
|
|
|
|
|
{
|
|
|
|
|
showRunButton && <RunMode text={runButtonText} />
|
|
|
|
|
showRunButton && <RunMode text={runButtonText} isRunning={isRunning} onStopRun={onStopRun} />
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
showPreviewButton && <PreviewMode />
|
|
|
|
|
|