fix: correct hover state logic and refactor environment variable handling in FieldItem and usePipelineInit

pull/21398/head
twwu 1 year ago
parent 7898dbd5bf
commit 8eee344fbb

@ -34,10 +34,10 @@ const FieldItem = ({
return ( return (
<div <div
// ref={ref} ref={ref}
className={cn( className={cn(
'flex h-8 cursor-pointer items-center justify-between gap-x-1 rounded-lg border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg py-1 pl-2 shadow-xs hover:shadow-sm', 'flex h-8 cursor-pointer items-center justify-between gap-x-1 rounded-lg border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg py-1 pl-2 shadow-xs hover:shadow-sm',
(!isHovering || readonly) ? 'pr-2.5' : !readonly && 'pr-1', (isHovering && !readonly) ? 'pr-1' : 'pr-2.5',
)} )}
> >
<div className='flex grow basis-0 items-center gap-x-1'> <div className='flex grow basis-0 items-center gap-x-1'>
@ -64,16 +64,8 @@ const FieldItem = ({
</> </>
)} )}
</div> </div>
{(!isHovering || readonly) {(isHovering && !readonly)
? ( ? (
<div className='flex shrink-0 items-center gap-x-2'>
{payload.required && (
<Badge>{t('workflow.nodes.start.required')}</Badge>
)}
<InputVarTypeIcon type={payload.type as unknown as InputVarType} className='h-3 w-3 text-text-tertiary' />
</div>
)
: (!readonly && (
<div className='flex shrink-0 items-center gap-x-1'> <div className='flex shrink-0 items-center gap-x-1'>
<button <button
type='button' type='button'
@ -89,7 +81,15 @@ const FieldItem = ({
<RiDeleteBinLine className='size-4 text-text-tertiary group-hover:text-text-destructive' /> <RiDeleteBinLine className='size-4 text-text-tertiary group-hover:text-text-destructive' />
</button> </button>
</div> </div>
)) )
: (
<div className='flex shrink-0 items-center gap-x-2'>
{payload.required && (
<Badge>{t('workflow.nodes.start.required')}</Badge>
)}
<InputVarTypeIcon type={payload.type as unknown as InputVarType} className='h-3 w-3 text-text-tertiary' />
</div>
)
} }
</div> </div>
) )

@ -46,9 +46,9 @@ export const usePipelineInit = () => {
setDraftUpdatedAt(res.updated_at) setDraftUpdatedAt(res.updated_at)
setToolPublished(res.tool_published) setToolPublished(res.tool_published)
setEnvSecrets((res.environment_variables || []).filter(env => env.value_type === 'secret').reduce((acc, env) => { setEnvSecrets((res.environment_variables || []).filter(env => env.value_type === 'secret').reduce((acc, env) => {
acc[env.id] = env.value acc[env.id] = env.value
return acc return acc
}, {} as Record<string, string>)) }, {} as Record<string, string>))
setEnvironmentVariables(res.environment_variables?.map(env => env.value_type === 'secret' ? { ...env, value: '[__HIDDEN__]' } : env) || []) setEnvironmentVariables(res.environment_variables?.map(env => env.value_type === 'secret' ? { ...env, value: '[__HIDDEN__]' } : env) || [])
setSyncWorkflowDraftHash(res.hash) setSyncWorkflowDraftHash(res.hash)
setRagPipelineVariables?.(res.rag_pipeline_variables || []) setRagPipelineVariables?.(res.rag_pipeline_variables || [])

Loading…
Cancel
Save