Hide the copy button when there is no content to copy (#4546)

This commit is contained in:
非法操作 2024-05-22 11:15:13 +08:00 committed by GitHub
parent d5a33a0323
commit ee53f98d8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -119,20 +119,21 @@ const WorkflowPreview = () => {
error={workflowRunningData?.result?.error} error={workflowRunningData?.result?.error}
onClick={() => switchTab('DETAIL')} onClick={() => switchTab('DETAIL')}
/> />
<SimpleBtn {(workflowRunningData?.result.status !== WorkflowRunningStatus.Succeeded || !workflowRunningData?.resultText) && (
isDisabled={workflowRunningData?.result.status !== WorkflowRunningStatus.Succeeded} <SimpleBtn
className={cn('ml-4 mb-4 inline-flex space-x-1')} className={cn('ml-4 mb-4 inline-flex space-x-1')}
onClick={() => { onClick={() => {
const content = workflowRunningData?.resultText const content = workflowRunningData?.resultText
if (typeof content === 'string') if (typeof content === 'string')
copy(content) copy(content)
else else
copy(JSON.stringify(content)) copy(JSON.stringify(content))
Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') }) Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
}}> }}>
<Clipboard className='w-3.5 h-3.5' /> <Clipboard className='w-3.5 h-3.5' />
<div>{t('common.operation.copy')}</div> <div>{t('common.operation.copy')}</div>
</SimpleBtn> </SimpleBtn>
)}
</> </>
)} )}
{currentTab === 'DETAIL' && ( {currentTab === 'DETAIL' && (