style(env-panel): fix line endings and formatting in env-item component

pull/21556/head
Mminamiyama 11 months ago
parent 3e8ac9dc2b
commit e3439b2f74

@ -1,65 +1,65 @@
import { memo, useState } from 'react' import { memo, useState } from 'react'
import { capitalize } from 'lodash-es' import { capitalize } from 'lodash-es'
import { RiDeleteBinLine, RiEditLine, RiLock2Line } from '@remixicon/react' import { RiDeleteBinLine, RiEditLine, RiLock2Line } from '@remixicon/react'
import { Env } from '@/app/components/base/icons/src/vender/line/others' import { Env } from '@/app/components/base/icons/src/vender/line/others'
import { useStore } from '@/app/components/workflow/store' import { useStore } from '@/app/components/workflow/store'
import type { EnvironmentVariable } from '@/app/components/workflow/types' import type { EnvironmentVariable } from '@/app/components/workflow/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
type EnvItemProps = { type EnvItemProps = {
env: EnvironmentVariable env: EnvironmentVariable
onEdit: (env: EnvironmentVariable) => void onEdit: (env: EnvironmentVariable) => void
onDelete: (env: EnvironmentVariable) => void onDelete: (env: EnvironmentVariable) => void
} }
const EnvItem = ({ const EnvItem = ({
env, env,
onEdit, onEdit,
onDelete, onDelete,
}: EnvItemProps) => { }: EnvItemProps) => {
const envSecrets = useStore(s => s.envSecrets) const envSecrets = useStore(s => s.envSecrets)
const [destructive, setDestructive] = useState(false) const [destructive, setDestructive] = useState(false)
return ( return (
<div className={cn( <div className={cn(
'radius-md group mb-1 border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg shadow-xs hover:bg-components-panel-on-panel-item-bg-hover', 'radius-md group mb-1 border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg shadow-xs hover:bg-components-panel-on-panel-item-bg-hover',
destructive && 'border-state-destructive-border hover:bg-state-destructive-hover', destructive && 'border-state-destructive-border hover:bg-state-destructive-hover',
)}> )}>
<div className='px-2.5 py-2'> <div className='px-2.5 py-2'>
<div className='flex items-center justify-between'> <div className='flex items-center justify-between'>
<div className='flex grow items-center gap-1'> <div className='flex grow items-center gap-1'>
<Env className='h-4 w-4 text-util-colors-violet-violet-600' /> <Env className='h-4 w-4 text-util-colors-violet-violet-600' />
<div className='system-sm-medium text-text-primary'>{env.name}</div> <div className='system-sm-medium text-text-primary'>{env.name}</div>
<div className='system-xs-medium text-text-tertiary'>{capitalize(env.value_type)}</div> <div className='system-xs-medium text-text-tertiary'>{capitalize(env.value_type)}</div>
{env.value_type === 'secret' && <RiLock2Line className='h-3 w-3 text-text-tertiary' />} {env.value_type === 'secret' && <RiLock2Line className='h-3 w-3 text-text-tertiary' />}
</div> </div>
<div className='flex shrink-0 items-center gap-1 text-text-tertiary'> <div className='flex shrink-0 items-center gap-1 text-text-tertiary'>
<div className='radius-md cursor-pointer p-1 hover:bg-state-base-hover hover:text-text-secondary'> <div className='radius-md cursor-pointer p-1 hover:bg-state-base-hover hover:text-text-secondary'>
<RiEditLine className='h-4 w-4' onClick={() => onEdit(env)}/> <RiEditLine className='h-4 w-4' onClick={() => onEdit(env)}/>
</div> </div>
<div <div
className='radius-md cursor-pointer p-1 hover:bg-state-destructive-hover hover:text-text-destructive' className='radius-md cursor-pointer p-1 hover:bg-state-destructive-hover hover:text-text-destructive'
onMouseOver={() => setDestructive(true)} onMouseOver={() => setDestructive(true)}
onMouseOut={() => setDestructive(false)} onMouseOut={() => setDestructive(false)}
> >
<RiDeleteBinLine className='h-4 w-4' onClick={() => onDelete(env)} /> <RiDeleteBinLine className='h-4 w-4' onClick={() => onDelete(env)} />
</div> </div>
</div> </div>
</div> </div>
<div className='system-xs-regular truncate text-text-tertiary'>{env.value_type === 'secret' ? envSecrets[env.id] : env.value}</div> <div className='system-xs-regular truncate text-text-tertiary'>{env.value_type === 'secret' ? envSecrets[env.id] : env.value}</div>
</div> </div>
{env.description && ( {env.description && (
<> <>
<div className={'h-[0.5px] bg-divider-subtle'} /> <div className={'h-[0.5px] bg-divider-subtle'} />
<div className={cn('rounded-bl-[8px] rounded-br-[8px] bg-background-default-subtle px-2.5 py-2 group-hover:bg-transparent', <div className={cn('rounded-bl-[8px] rounded-br-[8px] bg-background-default-subtle px-2.5 py-2 group-hover:bg-transparent',
destructive && 'bg-state-destructive-hover hover:bg-state-destructive-hover', destructive && 'bg-state-destructive-hover hover:bg-state-destructive-hover',
)}> )}>
<div className='system-xs-regular truncate text-text-tertiary'>{env.description}</div> <div className='system-xs-regular truncate text-text-tertiary'>{env.description}</div>
</div> </div>
</> </>
)} )}
</div> </div>
) )
} }
export default memo(EnvItem) export default memo(EnvItem)

Loading…
Cancel
Save