dsl-export-confirm-modal.tsx 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. 'use client'
  2. import React, { useState } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { RiCloseLine, RiLock2Line } from '@remixicon/react'
  5. import cn from '@/utils/classnames'
  6. import { Env } from '@/app/components/base/icons/src/vender/line/others'
  7. import Modal from '@/app/components/base/modal'
  8. import Checkbox from '@/app/components/base/checkbox'
  9. import Button from '@/app/components/base/button'
  10. import type { EnvironmentVariable } from '@/app/components/workflow/types'
  11. export type DSLExportConfirmModalProps = {
  12. envList: EnvironmentVariable[]
  13. onConfirm: (state: boolean) => void
  14. onClose: () => void
  15. }
  16. const DSLExportConfirmModal = ({
  17. envList = [],
  18. onConfirm,
  19. onClose,
  20. }: DSLExportConfirmModalProps) => {
  21. const { t } = useTranslation()
  22. const [exportSecrets, setExportSecrets] = useState<boolean>(false)
  23. const submit = () => {
  24. onConfirm(exportSecrets)
  25. onClose()
  26. }
  27. return (
  28. <Modal
  29. isShow={true}
  30. onClose={() => { }}
  31. className={cn('max-w-[480px] w-[480px]')}
  32. >
  33. <div className='relative pb-6 title-2xl-semi-bold text-text-primary'>{t('workflow.env.export.title')}</div>
  34. <div className='absolute right-4 top-4 p-2 cursor-pointer' onClick={onClose}>
  35. <RiCloseLine className='w-4 h-4 text-text-tertiary' />
  36. </div>
  37. <div className='relative'>
  38. <table className='w-full border-separate border-spacing-0 border border-divider-regular radius-md shadow-xs'>
  39. <thead className='system-xs-medium-uppercase text-text-tertiary'>
  40. <tr>
  41. <td width={220} className='h-7 pl-3 border-r border-b border-divider-regular'>NAME</td>
  42. <td className='h-7 pl-3 border-b border-divider-regular'>VALUE</td>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. {envList.map((env, index) => (
  47. <tr key={env.name}>
  48. <td className={cn('h-7 pl-3 border-r system-xs-medium', index + 1 !== envList.length && 'border-b')}>
  49. <div className='flex gap-1 items-center w-[200px]'>
  50. <Env className='shrink-0 w-4 h-4 text-util-colors-violet-violet-600' />
  51. <div className='text-text-primary truncate'>{env.name}</div>
  52. <div className='shrink-0 text-text-tertiary'>Secret</div>
  53. <RiLock2Line className='shrink-0 w-3 h-3 text-text-tertiary' />
  54. </div>
  55. </td>
  56. <td className={cn('h-7 pl-3', index + 1 !== envList.length && 'border-b')}>
  57. <div className='system-xs-regular text-text-secondary truncate'>{env.value}</div>
  58. </td>
  59. </tr>
  60. ))}
  61. </tbody>
  62. </table>
  63. </div>
  64. <div className='mt-4 flex gap-2'>
  65. <Checkbox
  66. className='shrink-0'
  67. checked={exportSecrets}
  68. onCheck={() => setExportSecrets(!exportSecrets)}
  69. />
  70. <div className='text-text-primary system-sm-medium cursor-pointer' onClick={() => setExportSecrets(!exportSecrets)}>{t('workflow.env.export.checkbox')}</div>
  71. </div>
  72. <div className='flex flex-row-reverse pt-6'>
  73. <Button className='ml-2' variant='primary' onClick={submit}>{exportSecrets ? t('workflow.env.export.export') : t('workflow.env.export.ignore')}</Button>
  74. <Button onClick={onClose}>{t('common.operation.cancel')}</Button>
  75. </div>
  76. </Modal>
  77. )
  78. }
  79. export default DSLExportConfirmModal