diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/__tests__/plugin-item.spec.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/__tests__/plugin-item.spec.tsx index ea8257af2a..bda998f8b9 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/components/__tests__/plugin-item.spec.tsx +++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/__tests__/plugin-item.spec.tsx @@ -3,6 +3,12 @@ import { fireEvent, render, screen } from '@testing-library/react' import { PluginSource, TaskStatus } from '@/app/components/plugins/types' import PluginItem from '../plugin-item' +vi.mock('@/app/components/base/icons/src/vender/solid/mediaAndDevices', () => ({ + MagicBox: ({ className }: { className?: string }) => ( + + ), +})) + vi.mock('@/app/components/plugins/card/base/card-icon', () => ({ default: ({ src, size }: { src: string, size: string }) => (
@@ -108,6 +114,22 @@ describe('PluginItem', () => { expect(cardIcon).toHaveAttribute('data-src', 'https://example.com/icons/my-icon.svg') expect(cardIcon).toHaveAttribute('data-size', 'small') }) + + it('should show default tool icon when plugin icon is empty', () => { + const { container } = render( + } + statusText="status" + />, + ) + + expect(mockGetIconUrl).not.toHaveBeenCalled() + expect(screen.queryByTestId('card-icon')).not.toBeInTheDocument() + expect(container.querySelector('[data-testid="magic-box-icon"]')).toHaveClass('size-8', 'text-text-tertiary') + }) }) describe('Props', () => { diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx index 530544719a..e3d9dcaae9 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx +++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx @@ -1,6 +1,8 @@ import type { FC, ReactNode } from 'react' import type { PluginStatus } from '@/app/components/plugins/types' import type { Locale } from '@/i18n-config' +import { cn } from '@langgenius/dify-ui/cn' +import { MagicBox } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices' import CardIcon from '@/app/components/plugins/card/base/card-icon' type PluginItemProps = { @@ -24,14 +26,25 @@ const PluginItem: FC = ({ action, onClear, }) => { + const hasPluginIcon = !!plugin.icon + return (
- -
+ {hasPluginIcon + ? ( + + ) + // eslint-disable-next-line hyoban/prefer-tailwind-icons -- Reuse the same MagicBox component as the marketplace install button. + : } +
{statusIcon}