-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
web/app/components/workflow/panel/env-panel/variable-trigger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use client' | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { RiAddLine } from '@remixicon/react' | ||
import Button from '@/app/components/base/button' | ||
import VariableModal from '@/app/components/workflow/panel/env-panel/variable-modal' | ||
// import cn from '@/utils/classnames' | ||
import { | ||
PortalToFollowElem, | ||
PortalToFollowElemContent, | ||
PortalToFollowElemTrigger, | ||
} from '@/app/components/base/portal-to-follow-elem' | ||
import type { EnvironmentVariable } from '@/app/components/workflow/types' | ||
|
||
type Props = { | ||
open: boolean | ||
setOpen: (value: React.SetStateAction<boolean>) => void | ||
env?: EnvironmentVariable | ||
onClose: () => void | ||
onSave: (env: EnvironmentVariable) => void | ||
} | ||
|
||
const VariableTrigger = ({ | ||
open, | ||
setOpen, | ||
env, | ||
onClose, | ||
onSave, | ||
}: Props) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<PortalToFollowElem | ||
open={open} | ||
onOpenChange={() => { | ||
setOpen(v => !v) | ||
open && onClose() | ||
}} | ||
placement='left-start' | ||
offset={{ | ||
mainAxis: 8, | ||
alignmentAxis: -104, | ||
}} | ||
> | ||
<PortalToFollowElemTrigger onClick={() => { | ||
setOpen(v => !v) | ||
open && onClose() | ||
}}> | ||
<Button variant='primary'> | ||
<RiAddLine className='mr-1 w-4 h-4' /> | ||
<span className='system-sm-medium'>{t('workflow.env.envPanelButton')}</span> | ||
</Button> | ||
</PortalToFollowElemTrigger> | ||
<PortalToFollowElemContent className='z-[11]'> | ||
<VariableModal | ||
env={env} | ||
onSave={onSave} | ||
onClose={() => { | ||
onClose() | ||
setOpen(false) | ||
}} | ||
/> | ||
</PortalToFollowElemContent> | ||
</PortalToFollowElem> | ||
) | ||
} | ||
|
||
export default VariableTrigger |