mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
chore(web): enforce tooltip styling with shadcn lint (#42667)
This commit is contained in:
29 files changed
+409
-151
No files matched your search
+12
-4
@@ -1,5 +1,6 @@
|
||||
import type { IndexingStatusResponse } from '@/models/datasets'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
|
||||
import { DataSourceType } from '@/models/datasets'
|
||||
import IndexingProgressItem from '../indexing-progress-item'
|
||||
@@ -85,7 +86,8 @@ describe('IndexingProgressItem', () => {
|
||||
expect(screen.queryByText(/%/)).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render error icon with tooltip for error status', () => {
|
||||
it('opens the full indexing error from the warning button', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(
|
||||
<IndexingProgressItem
|
||||
detail={makeDetail({ indexing_status: 'error', error: 'Parse failed' })}
|
||||
@@ -93,10 +95,15 @@ describe('IndexingProgressItem', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByText('Parse failed')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Parse failed')).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: 'common.error' }))
|
||||
expect(await screen.findByRole('dialog')).toHaveTextContent('Parse failed')
|
||||
await user.keyboard('{Escape}')
|
||||
expect(screen.getByRole('button', { name: 'common.error' })).toHaveFocus()
|
||||
})
|
||||
|
||||
it('should use the localized fallback when an error has no message', () => {
|
||||
it('should use the localized fallback when an error has no message', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(
|
||||
<IndexingProgressItem
|
||||
detail={makeDetail({ indexing_status: 'error', error: null })}
|
||||
@@ -104,6 +111,7 @@ describe('IndexingProgressItem', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByText('common.error')).toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: 'common.error' }))
|
||||
expect(await screen.findByRole('dialog')).toHaveTextContent('common.error')
|
||||
})
|
||||
})
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { FC } from 'react'
|
||||
import type { IndexingStatusResponse } from '@/models/datasets'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
|
||||
import { RiCheckboxCircleFill, RiErrorWarningFill } from '@remixicon/react'
|
||||
import { RiCheckboxCircleFill } from '@remixicon/react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Infotip } from '@/app/components/base/infotip'
|
||||
import NotionIcon from '@/app/components/base/notion-icon'
|
||||
import PriorityLabel from '@/app/components/billing/priority-label'
|
||||
import { DataSourceType } from '@/models/datasets'
|
||||
@@ -28,15 +28,16 @@ const StatusIcon: FC<{ status: string; error?: string }> = ({ status, error }) =
|
||||
const errorLabel = error || t(($) => $.error, { ns: 'common' })
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span />}>
|
||||
<RiErrorWarningFill aria-hidden className="size-4 shrink-0 text-text-destructive" />
|
||||
<span className="sr-only">{errorLabel}</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent sideOffset={4} className="max-w-60 rounded-xl px-4 py-3.5 body-xs-regular">
|
||||
{errorLabel}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Infotip
|
||||
aria-label={t(($) => $.error, { ns: 'common' })}
|
||||
iconVariant="warning"
|
||||
iconSize="large"
|
||||
className="text-text-destructive"
|
||||
popupClassName="wrap-anywhere whitespace-pre-wrap"
|
||||
sideOffset={4}
|
||||
>
|
||||
{errorLabel}
|
||||
</Infotip>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user