installed.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import type { InstallStatusResponse, Plugin } from '../../../types'
  5. import Card from '@/app/components/plugins/card'
  6. import Button from '@/app/components/base/button'
  7. import { useTranslation } from 'react-i18next'
  8. import Badge, { BadgeState } from '@/app/components/base/badge/index'
  9. import useGetIcon from '../../base/use-get-icon'
  10. import { MARKETPLACE_API_PREFIX } from '@/config'
  11. type Props = {
  12. list: Plugin[]
  13. installStatus: InstallStatusResponse[]
  14. onCancel: () => void
  15. isHideButton?: boolean
  16. }
  17. const Installed: FC<Props> = ({
  18. list,
  19. installStatus,
  20. onCancel,
  21. isHideButton,
  22. }) => {
  23. const { t } = useTranslation()
  24. const { getIconUrl } = useGetIcon()
  25. return (
  26. <>
  27. <div className='flex flex-col px-6 py-3 justify-center items-start gap-4 self-stretch'>
  28. {/* <p className='text-text-secondary system-md-regular'>{(isFailed && errMsg) ? errMsg : t(`plugin.installModal.${isFailed ? 'installFailedDesc' : 'installedSuccessfullyDesc'}`)}</p> */}
  29. <div className='flex p-2 items-start content-start gap-1 self-stretch flex-wrap rounded-2xl bg-background-section-burn space-y-1'>
  30. {list.map((plugin, index) => {
  31. return (
  32. <Card
  33. key={plugin.plugin_id}
  34. className='w-full'
  35. payload={{
  36. ...plugin,
  37. icon: installStatus[index].isFromMarketPlace ? `${MARKETPLACE_API_PREFIX}/plugins/${plugin.org}/${plugin.name}/icon` : getIconUrl(plugin.icon),
  38. }}
  39. installed={installStatus[index].success}
  40. installFailed={!installStatus[index].success}
  41. titleLeft={plugin.version ? <Badge className='mx-1' size="s" state={BadgeState.Default}>{plugin.version}</Badge> : null}
  42. />
  43. )
  44. })}
  45. </div>
  46. </div>
  47. {/* Action Buttons */}
  48. {!isHideButton && (
  49. <div className='flex p-6 pt-5 justify-end items-center gap-2 self-stretch'>
  50. <Button
  51. variant='primary'
  52. className='min-w-[72px]'
  53. onClick={onCancel}
  54. >
  55. {t('common.operation.close')}
  56. </Button>
  57. </div>
  58. )}
  59. </>
  60. )
  61. }
  62. export default React.memo(Installed)