Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: rag pipeline accessibility (#42589)

Joel05df95137392
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index ee49b34c4e0..efe10fb0060 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -2978,14 +2978,6 @@
"count": 2
}
},
- "web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/option-card.tsx": {
- "jsx-a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx-a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/rag-pipeline/components/panel/test-run/preparation/document-processing/index.tsx": {
"typescript/no-explicit-any": {
"count": 1
@@ -3019,14 +3011,6 @@
"count": 4
}
},
- "web/app/components/rag-pipeline/components/publish-toast.tsx": {
- "jsx-a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx-a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/rag-pipeline/components/rag-pipeline-children.tsx": {
"typescript/no-explicit-any": {
"count": 1
@@ -4013,14 +3997,6 @@
"count": 6
}
},
- "web/app/components/workflow/nodes/knowledge-base/components/option-card.tsx": {
- "jsx-a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx-a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/hooks.tsx": {
"typescript/no-explicit-any": {
"count": 4
@@ -4949,12 +4925,6 @@
}
},
"web/app/components/workflow/variable-inspect/trigger.tsx": {
- "jsx-a11y/click-events-have-key-events": {
- "count": 5
- },
- "jsx-a11y/no-static-element-interactions": {
- "count": 5
- },
"typescript/no-explicit-any": {
"count": 1
}
diff --git a/web/app/components/base/badge.tsx b/web/app/components/base/badge.tsx
index 4d90e3eb3af..bf6aa59cc66 100644
--- a/web/app/components/base/badge.tsx
+++ b/web/app/components/base/badge.tsx
@@ -3,6 +3,7 @@ import { cn } from '@langgenius/dify-ui/cn'
import { memo } from 'react'
type BadgeProps = {
+ as?: 'div' | 'span'
className?: string
text?: ReactNode
children?: ReactNode
@@ -13,6 +14,7 @@ type BadgeProps = {
}
const Badge = ({
+ as: Component = 'div',
className,
text,
children,
@@ -22,7 +24,7 @@ const Badge = ({
hasRedCornerMark,
}: BadgeProps) => {
return (
- <div
+ <Component
className={cn(
'relative inline-flex items-center rounded-[5px] border border-divider-deep leading-3 whitespace-nowrap text-text-tertiary',
size === 'xs' ? 'min-w-4 justify-center px-1 py-0.5' : 'h-5 px-1.25',
@@ -32,10 +34,10 @@ const Badge = ({
)}
>
{hasRedCornerMark && (
- <div className="absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-xs border border-components-badge-status-light-error-border-inner bg-components-badge-status-light-error-bg shadow-sm"></div>
+ <span className="absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-xs border border-components-badge-status-light-error-border-inner bg-components-badge-status-light-error-bg shadow-sm"></span>
)}
{children || text}
- </div>
+ </Component>
)
}
diff --git a/web/app/components/datasets/extra-info/api-access/__tests__/index.spec.tsx b/web/app/components/datasets/extra-info/api-access/__tests__/index.spec.tsx
index fa71b6e0b04..25d0cfce861 100644
--- a/web/app/components/datasets/extra-info/api-access/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/extra-info/api-access/__tests__/index.spec.tsx
@@ -9,19 +9,22 @@ vi.mock('../card', () => ({
}))
describe('ApiAccess', () => {
- it('opens the API access details', async () => {
- const user = userEvent.setup()
- render(<ApiAccess expand apiEnabled />)
+ it.each([true, false])(
+ 'opens named API access details by keyboard when expanded=%s',
+ async (expand) => {
+ const user = userEvent.setup()
+ render(<ApiAccess expand={expand} apiEnabled />)
- const trigger = screen.getByRole('button', { name: 'common.appMenus.apiAccess' })
- expect(trigger).not.toHaveAttribute('data-popup-open')
- expect(trigger.firstElementChild).toHaveClass('hover:bg-state-base-hover')
+ const trigger = screen.getByRole('button', { name: 'common.appMenus.apiAccess' })
+ expect(trigger).not.toHaveAttribute('data-popup-open')
- await user.click(trigger)
+ await user.tab()
+ expect(trigger).toHaveFocus()
+ await user.keyboard('{Enter}')
- expect(trigger).toHaveAttribute('data-popup-open', '')
- expect(trigger.firstElementChild).toHaveClass('bg-state-base-hover')
+ expect(trigger).toHaveAttribute('data-popup-open', '')
- expect(screen.getByText('API enabled')).toBeInTheDocument()
- })
+ expect(screen.getByText('API enabled')).toBeInTheDocument()
+ },
+ )
})
diff --git a/web/app/components/datasets/extra-info/api-access/index.tsx b/web/app/components/datasets/extra-info/api-access/index.tsx
index 6fb48aa63e1..be2f13d29c0 100644
--- a/web/app/components/datasets/extra-info/api-access/index.tsx
+++ b/web/app/components/datasets/extra-info/api-access/index.tsx
@@ -24,7 +24,11 @@ const ApiAccess = ({ expand, apiEnabled }: ApiAccessProps) => {
<button
{...props}
type="button"
- className={cn('w-full border-none bg-transparent p-0 text-left', props.className)}
+ aria-label={!expand ? t(($) => $['appMenus.apiAccess'], { ns: 'common' }) : undefined}
+ className={cn(
+ 'nokey w-full rounded-lg border-none bg-transparent p-0 text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-state-accent-solid',
+ props.className,
+ )}
>
<div
className={cn(
diff --git a/web/app/components/rag-pipeline/components/__tests__/publish-toast.spec.tsx b/web/app/components/rag-pipeline/components/__tests__/publish-toast.spec.tsx
index 07a50c6f2e7..b92076db8db 100644
--- a/web/app/components/rag-pipeline/components/__tests__/publish-toast.spec.tsx
+++ b/web/app/components/rag-pipeline/components/__tests__/publish-toast.spec.tsx
@@ -1,110 +1,33 @@
-import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
import PublishToast from '../publish-toast'
let mockPublishedAt = 0
vi.mock('@/app/components/workflow/store', () => ({
- useStore: (selector: (state: Record<string, unknown>) => unknown) => {
- return selector({ publishedAt: mockPublishedAt })
- },
+ useStore: (selector: (state: { publishedAt: number }) => unknown) =>
+ selector({ publishedAt: mockPublishedAt }),
}))
-afterEach(() => {
- cleanup()
- vi.clearAllMocks()
-})
-
describe('PublishToast', () => {
beforeEach(() => {
mockPublishedAt = 0
})
- describe('rendering', () => {
- it('should render when publishedAt is 0', () => {
- mockPublishedAt = 0
- render(<PublishToast />)
-
- expect(screen.getByText('pipeline.publishToast.title')).toBeInTheDocument()
- })
-
- it('should render toast title', () => {
- render(<PublishToast />)
-
- expect(screen.getByText('pipeline.publishToast.title')).toBeInTheDocument()
- })
-
- it('should render toast description', () => {
- render(<PublishToast />)
-
- expect(screen.getByText('pipeline.publishToast.desc')).toBeInTheDocument()
- })
-
- it('should not render when publishedAt is set', () => {
- mockPublishedAt = Date.now()
- const { container } = render(<PublishToast />)
-
- expect(container.firstChild).toBeNull()
- })
-
- it('should render info icon', () => {
- const { container } = render(<PublishToast />)
-
- const iconContainer = container.querySelector('.text-text-accent')
- expect(iconContainer).toBeInTheDocument()
- })
-
- it('should render close button', () => {
- const { container } = render(<PublishToast />)
-
- const closeButton = container.querySelector('.cursor-pointer')
- expect(closeButton).toBeInTheDocument()
- })
+ it('does not show the unpublished notice for a published pipeline', () => {
+ mockPublishedAt = 1
+ render(<PublishToast />)
+ expect(screen.queryByText('pipeline.publishToast.title')).not.toBeInTheDocument()
})
- describe('user interactions', () => {
- it('should hide toast when close button is clicked', () => {
- const { container } = render(<PublishToast />)
-
- const closeButton = container.querySelector('.cursor-pointer')
- expect(screen.getByText('pipeline.publishToast.title')).toBeInTheDocument()
-
- fireEvent.click(closeButton!)
-
- expect(screen.queryByText('pipeline.publishToast.title')).not.toBeInTheDocument()
- })
-
- it('should remain hidden after close button is clicked', () => {
- const { container, rerender } = render(<PublishToast />)
-
- const closeButton = container.querySelector('.cursor-pointer')
- fireEvent.click(closeButton!)
-
- rerender(<PublishToast />)
-
- expect(screen.queryByText('pipeline.publishToast.title')).not.toBeInTheDocument()
- })
- })
-
- describe('styling', () => {
- it('should have gradient overlay', () => {
- const { container } = render(<PublishToast />)
-
- const gradientOverlay = container.querySelector('.bg-linear-to-r')
- expect(gradientOverlay).toBeInTheDocument()
- })
-
- it('should have correct toast width', () => {
- render(<PublishToast />)
-
- const toastContainer = screen.getByText('pipeline.publishToast.title').closest('.w-105')
- expect(toastContainer).toBeInTheDocument()
- })
-
- it('should have rounded-sm border', () => {
- render(<PublishToast />)
-
- const toastContainer = screen.getByText('pipeline.publishToast.title').closest('.rounded-xl')
- expect(toastContainer).toBeInTheDocument()
- })
+ it('allows keyboard users to dismiss the notice and keeps it dismissed on rerender', async () => {
+ const user = userEvent.setup()
+ const { rerender } = render(<PublishToast />)
+ expect(screen.getByText('pipeline.publishToast.desc')).toBeInTheDocument()
+ await user.tab()
+ expect(screen.getByRole('button', { name: 'common.operation.close' })).toHaveFocus()
+ await user.keyboard('{Enter}')
+ expect(screen.queryByText('pipeline.publishToast.title')).not.toBeInTheDocument()
+ rerender(<PublishToast />)
+ expect(screen.queryByText('pipeline.publishToast.title')).not.toBeInTheDocument()
})
})
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-item.spec.tsx b/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-item.spec.tsx
index 1728bec9301..6ee2ccfe1f1 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-item.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-item.spec.tsx
@@ -1,5 +1,6 @@
import type { InputVar } from '@/models/pipeline'
-import { fireEvent, render, screen } from '@testing-library/react'
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
import { PipelineInputVarType } from '@/models/pipeline'
import FieldItem from '../field-item'
@@ -35,10 +36,11 @@ describe('FieldItem', () => {
expect(screen.getByText('workflow.nodes.start.required'))!.toBeInTheDocument()
})
- it('should show edit and delete controls on hover and trigger both callbacks', () => {
+ it('supports editing and deleting using the keyboard without hovering the row', async () => {
+ const user = userEvent.setup()
const onClickEdit = vi.fn()
const onRemove = vi.fn()
- const { container } = render(
+ render(
<FieldItem
payload={createInputVar({ variable: 'custom_field' })}
index={2}
@@ -47,10 +49,12 @@ describe('FieldItem', () => {
/>,
)
- fireEvent.mouseEnter(container.firstChild!)
- const buttons = screen.getAllByRole('button')
- fireEvent.click(buttons[0]!)
- fireEvent.click(buttons[1]!)
+ await user.tab()
+ expect(screen.getByRole('button', { name: 'common.operation.edit' })).toHaveFocus()
+ await user.keyboard('{Enter}')
+ await user.tab()
+ expect(screen.getByRole('button', { name: 'common.operation.remove' })).toHaveFocus()
+ await user.keyboard(' ')
expect(onClickEdit).toHaveBeenCalledWith('custom_field')
expect(onRemove).toHaveBeenCalledWith(2)
@@ -59,7 +63,7 @@ describe('FieldItem', () => {
it('should keep the row readonly when readonly is enabled', () => {
const onClickEdit = vi.fn()
const onRemove = vi.fn()
- const { container } = render(
+ render(
<FieldItem
readonly
payload={createInputVar()}
@@ -69,8 +73,6 @@ describe('FieldItem', () => {
/>,
)
- fireEvent.mouseEnter(container.firstChild!)
-
expect(screen.queryAllByRole('button')).toHaveLength(0)
expect(onClickEdit).not.toHaveBeenCalled()
expect(onRemove).not.toHaveBeenCalled()
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-list-container.spec.tsx b/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-list-container.spec.tsx
index 7b48c22932c..14711c75084 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-list-container.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/input-field/field-list/__tests__/field-list-container.spec.tsx
@@ -1,6 +1,8 @@
+import type { SortableItem } from '../types'
import type { InputVar } from '@/models/pipeline'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
+import { useState } from 'react'
import { PipelineInputVarType } from '@/models/pipeline'
import FieldListContainer from '../field-list-container'
@@ -42,6 +44,43 @@ describe('FieldListContainer', () => {
expect(onListSortChange).not.toHaveBeenCalled()
})
+ it('moves fields in both directions by clicking and disables movement past the ends', async () => {
+ const user = userEvent.setup()
+ const onListSortChange = vi.fn()
+ const EditableFields = () => {
+ const [fields, setFields] = useState(() => [
+ createInputVar('first'),
+ createInputVar('second'),
+ ])
+ const handleSort = (list: SortableItem[]) => {
+ onListSortChange(list)
+ setFields(list)
+ }
+ return (
+ <FieldListContainer
+ inputFields={fields}
+ onListSortChange={handleSort}
+ onRemoveField={vi.fn()}
+ onEditField={vi.fn()}
+ />
+ )
+ }
+ render(<EditableFields />)
+
+ expect(screen.getAllByRole('button', { name: 'common.operation.moveUp' })[0]).toBeDisabled()
+ expect(screen.getAllByRole('button', { name: 'common.operation.moveDown' })[1]).toBeDisabled()
+ await user.click(screen.getAllByRole('button', { name: 'common.operation.moveDown' })[0]!)
+ expect(onListSortChange).toHaveBeenLastCalledWith([
+ expect.objectContaining({ variable: 'second', id: 'second' }),
+ expect.objectContaining({ variable: 'first', id: 'first' }),
+ ])
+ await user.click(screen.getAllByRole('button', { name: 'common.operation.moveUp' })[1]!)
+ expect(onListSortChange).toHaveBeenLastCalledWith([
+ expect.objectContaining({ variable: 'first', id: 'first' }),
+ expect.objectContaining({ variable: 'second', id: 'second' }),
+ ])
+ })
+
it('should honor readonly mode for the rendered field rows', () => {
render(
<FieldListContainer
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-item.tsx b/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-item.tsx
index d40c76728d6..d9589333bfd 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-item.tsx
+++ b/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-item.tsx
@@ -4,10 +4,15 @@ import type { InputVarType } from '@/app/components/workflow/types'
import type { InputVar } from '@/models/pipeline'
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
-import { RiDeleteBinLine, RiDraggable, RiEditLine } from '@remixicon/react'
-import { useHover } from 'ahooks'
+import {
+ RiArrowDownLine,
+ RiArrowUpLine,
+ RiDeleteBinLine,
+ RiDraggable,
+ RiEditLine,
+} from '@remixicon/react'
import * as React from 'react'
-import { useCallback, useRef } from 'react'
+import { useCallback, useId } from 'react'
import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
import { InputField } from '@/app/components/base/icons/src/vender/pipeline'
@@ -20,6 +25,8 @@ type FieldItemProps = {
index: number
onClickEdit: (id: string) => void
onRemove: (index: number) => void
+ onMoveUp?: () => void
+ onMoveDown?: () => void
}
const FieldItem = ({
@@ -29,11 +36,12 @@ const FieldItem = ({
onClickEdit,
onRemove,
dragHandleProps,
+ onMoveUp,
+ onMoveDown,
}: FieldItemProps) => {
const { t } = useTranslation()
- const ref = useRef(null)
- const isHovering = useHover(ref)
+ const fieldNameId = useId()
const handleOnClickEdit = useCallback(
(e: React.MouseEvent) => {
@@ -55,13 +63,10 @@ const FieldItem = ({
return (
<div
- ref={ref}
className={cn(
- 'group flex h-8 cursor-pointer items-center justify-between gap-x-1 rounded-lg border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg py-1 pl-2 shadow-xs hover:shadow-sm',
- isHovering && !readonly ? 'cursor-all-scroll pr-1' : 'pr-2.5',
+ 'group flex min-h-8 items-center justify-between gap-x-1 rounded-lg border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg py-1 pr-1 pl-2 shadow-xs hover:shadow-sm',
readonly && 'cursor-default',
)}
- // onClick={handleOnClickEdit}
>
<div className="relative size-4 shrink-0">
<InputField
@@ -81,6 +86,7 @@ const FieldItem = ({
</div>
<div className="flex grow basis-0 items-center gap-x-1 overflow-hidden">
<div
+ id={fieldNameId}
title={payload.variable}
className="max-w-32.5 shrink-0 truncate system-sm-medium text-text-secondary"
>
@@ -98,16 +104,37 @@ const FieldItem = ({
</>
)}
</div>
- {isHovering && !readonly ? (
+ {!readonly && (
<div className="flex shrink-0 items-center gap-x-1">
+ {dragHandleProps && (
+ <>
+ <IconButton
+ aria-label={t(($) => $['operation.moveUp'], { ns: 'common' })}
+ aria-describedby={fieldNameId}
+ disabled={!onMoveUp}
+ onClick={onMoveUp}
+ >
+ <RiArrowUpLine aria-hidden="true" className="size-4" />
+ </IconButton>
+ <IconButton
+ aria-label={t(($) => $['operation.moveDown'], { ns: 'common' })}
+ aria-describedby={fieldNameId}
+ disabled={!onMoveDown}
+ onClick={onMoveDown}
+ >
+ <RiArrowDownLine aria-hidden="true" className="size-4" />
+ </IconButton>
+ </>
+ )}
<IconButton
+ aria-describedby={fieldNameId}
aria-label={t(($) => $['operation.edit'], { ns: 'common' })}
- className="mr-1"
onClick={handleOnClickEdit}
>
<RiEditLine aria-hidden="true" className="size-4 text-text-tertiary" />
</IconButton>
<IconButton
+ aria-describedby={fieldNameId}
aria-label={t(($) => $['operation.remove'], { ns: 'common' })}
onClick={handleRemove}
>
@@ -117,17 +144,16 @@ const FieldItem = ({
/>
</IconButton>
</div>
- ) : (
- <div className="flex shrink-0 items-center gap-x-2">
- {payload.required && (
- <Badge>{t(($) => $['nodes.start.required'], { ns: 'workflow' })}</Badge>
- )}
- <InputVarTypeIcon
- type={payload.type as unknown as InputVarType}
- className="size-3 text-text-tertiary"
- />
- </div>
)}
+ <div className="flex shrink-0 items-center gap-x-2">
+ {payload.required && (
+ <Badge>{t(($) => $['nodes.start.required'], { ns: 'workflow' })}</Badge>
+ )}
+ <InputVarTypeIcon
+ type={payload.type as unknown as InputVarType}
+ className="size-3 text-text-tertiary"
+ />
+ </div>
</div>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container.tsx b/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container.tsx
index cc22beaa56e..cc68a2ab844 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container.tsx
+++ b/web/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container.tsx
@@ -55,11 +55,21 @@ const FieldListContainer = ({
[isSorting, inputFields, onListSortChange],
)
+ const moveField = (index: number, direction: -1 | 1) => {
+ if (readonly || isSorting) return
+ const nextIndex = index + direction
+ if (nextIndex < 0 || nextIndex >= list.length) return
+ const reordered = [...list]
+ const [field] = reordered.splice(index, 1)
+ reordered.splice(nextIndex, 0, field!)
+ onListSortChange(reordered)
+ }
+
return (
<>
{announcement}
<ReactSortable<SortableItem>
- className={cn(className)}
+ className={cn('nokey', className)}
list={list}
setList={handleListSortChange}
handle=".handle"
@@ -69,13 +79,17 @@ const FieldListContainer = ({
>
{items.map((item, index) => (
<FieldItem
- key={getItemKey(index)}
+ key={item.variable}
dragHandleProps={getHandleProps(index)}
index={getItemKey(index)}
readonly={readonly}
payload={item}
onRemove={onRemoveField}
onClickEdit={onEditField}
+ onMoveUp={!isSorting && index > 0 ? () => moveField(index, -1) : undefined}
+ onMoveDown={
+ !isSorting && index < items.length - 1 ? () => moveField(index, 1) : undefined
+ }
/>
))}
</ReactSortable>
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/__tests__/header.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/__tests__/header.spec.tsx
index e4e4e69f8c9..77be95a1fb1 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/__tests__/header.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/__tests__/header.spec.tsx
@@ -35,7 +35,7 @@ describe('TestRun header', () => {
it('should render the title and reset preparing state on close', () => {
render(<Header />)
- fireEvent.click(screen.getByRole('button'))
+ fireEvent.click(screen.getByRole('button', { name: 'common.operation.close' }))
expect(screen.getByText('datasetPipeline.testRun.title')).toBeInTheDocument()
expect(mockSetIsPreparingDataSource).toHaveBeenCalledWith(false)
@@ -49,7 +49,7 @@ describe('TestRun header', () => {
})
render(<Header />)
- fireEvent.click(screen.getByRole('button'))
+ fireEvent.click(screen.getByRole('button', { name: 'common.operation.close' }))
expect(mockSetIsPreparingDataSource).not.toHaveBeenCalled()
expect(mockHandleCancelDebugAndPreviewPanel).toHaveBeenCalledTimes(1)
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/header.tsx b/web/app/components/rag-pipeline/components/panel/test-run/header.tsx
index 6521e91495a..2d3bfa98a06 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/header.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/header.tsx
@@ -1,3 +1,4 @@
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { RiCloseLine } from '@remixicon/react'
import * as React from 'react'
import { useCallback } from 'react'
@@ -22,13 +23,14 @@ const Header = () => {
<div className="grow pr-8 pl-1 system-xl-semibold text-text-primary">
{t(($) => $['testRun.title'], { ns: 'datasetPipeline' })}
</div>
- <button
- type="button"
- className="flex size-8 shrink-0 items-center justify-center p-1.5"
+ <IconButton
+ size="lg"
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ className="shrink-0"
onClick={handleClose}
>
- <RiCloseLine className="size-4 text-text-tertiary" />
- </button>
+ <RiCloseLine aria-hidden="true" className="size-4 text-text-tertiary" />
+ </IconButton>
</div>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx
index ff8a37d6f7c..3dfca173efa 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx
@@ -8,7 +8,7 @@ const TestRunPanel = () => {
const isPreparingDataSource = useStore((state) => state.isPreparingDataSource)
return (
- <div className="relative flex h-full w-120 flex-col rounded-l-2xl border-y-[0.5px] border-l-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl shadow-shadow-shadow-1">
+ <div className="nokey relative flex h-full w-120 flex-col rounded-l-2xl border-y-[0.5px] border-l-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl shadow-shadow-shadow-1">
<Header />
{isPreparingDataSource ? (
<DataSourceProvider>
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/__tests__/step-indicator.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/__tests__/step-indicator.spec.tsx
index d5985f29694..3bfc505f08a 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/__tests__/step-indicator.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/preparation/__tests__/step-indicator.spec.tsx
@@ -1,41 +1,21 @@
-import { render, screen } from '@testing-library/react'
+import { render, screen, within } from '@testing-library/react'
import StepIndicator from '../step-indicator'
describe('StepIndicator', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- })
-
- it('should render all step labels and highlight the current step', () => {
- const { container } = render(
- <StepIndicator
- currentStep={2}
- steps={[
- { label: 'Select source', value: 'source' },
- { label: 'Process docs', value: 'process' },
- { label: 'Run test', value: 'run' },
- ]}
- />,
- )
-
- expect(screen.getByText('Select source')).toBeInTheDocument()
- expect(screen.getByText('Process docs')).toBeInTheDocument()
- expect(screen.getByText('Run test')).toBeInTheDocument()
- expect(container.querySelector('.bg-state-accent-solid')).toBeInTheDocument()
- expect(screen.getByText('Process docs').parentElement).toHaveClass('text-state-accent-solid')
- })
-
- it('should keep inactive steps in the tertiary state', () => {
- render(
- <StepIndicator
- currentStep={1}
- steps={[
- { label: 'Select source', value: 'source' },
- { label: 'Process docs', value: 'process' },
- ]}
- />,
- )
-
- expect(screen.getByText('Process docs').parentElement).toHaveClass('text-text-tertiary')
+ it('identifies the current step in the ordered preparation flow', () => {
+ const steps = [
+ { label: 'Select source', value: 'source' },
+ { label: 'Process docs', value: 'process' },
+ { label: 'Run test', value: 'run' },
+ ]
+ const { rerender } = render(<StepIndicator currentStep={2} steps={steps} />)
+ const items = within(screen.getByRole('list')).getAllByRole('listitem')
+ expect(items).toHaveLength(3)
+ expect(items[1]).toHaveAttribute('aria-current', 'step')
+ expect(items[1]).toHaveTextContent('Process docs')
+ expect(items[0]).not.toHaveAttribute('aria-current')
+ rerender(<StepIndicator currentStep={3} steps={steps} />)
+ expect(items[1]).not.toHaveAttribute('aria-current')
+ expect(items[2]).toHaveAttribute('aria-current', 'step')
})
})
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/index.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/index.spec.tsx
index 16ba41f8e1d..8cc0c3da4f2 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/index.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/index.spec.tsx
@@ -11,20 +11,8 @@ vi.mock('../../hooks', () => ({
useDatasourceOptions: () => options,
}))
-vi.mock('../option-card', () => ({
- default: ({
- label,
- value,
- onClick,
- }: {
- label: string
- value: string
- onClick: (value: string) => void
- }) => (
- <button type="button" onClick={() => onClick(value)}>
- {label}
- </button>
- ),
+vi.mock('@/app/components/workflow/hooks/use-tool-icon', () => ({
+ useToolIcon: () => undefined,
}))
describe('DataSourceOptions', () => {
@@ -39,10 +27,19 @@ describe('DataSourceOptions', () => {
it('selects the datasource chosen by the user', async () => {
const user = userEvent.setup()
const onSelect = vi.fn()
- render(<DataSourceOptions dataSourceNodeId="website" onSelect={onSelect} />)
+ const { rerender } = render(
+ <DataSourceOptions dataSourceNodeId="website" onSelect={onSelect} />,
+ )
- await user.click(screen.getByRole('button', { name: 'Drive' }))
+ await user.tab()
+ expect(screen.getByRole('radio', { name: 'Website' })).toHaveFocus()
+ expect(screen.getByRole('radio', { name: 'Website' })).toBeChecked()
+ await user.keyboard('{ArrowRight}')
+ expect(screen.getByRole('radio', { name: 'Drive' })).toHaveFocus()
expect(onSelect).toHaveBeenCalledWith({ nodeId: 'drive', nodeData: options[1]!.data })
+ rerender(<DataSourceOptions dataSourceNodeId="drive" onSelect={onSelect} />)
+ expect(screen.getByRole('radio', { name: 'Drive' })).toBeChecked()
+ expect(screen.getByRole('radio', { name: 'Website' })).not.toBeChecked()
})
})
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/option-card.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/option-card.spec.tsx
deleted file mode 100644
index 4c10ee9fe08..00000000000
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/__tests__/option-card.spec.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
-import { fireEvent, render, screen } from '@testing-library/react'
-import OptionCard from '../option-card'
-
-vi.mock('@/app/components/workflow/hooks/use-tool-icon', () => ({
- useToolIcon: () => 'source-icon',
-}))
-
-vi.mock('@/app/components/workflow/block-icon', () => ({
- default: ({ toolIcon }: { toolIcon: string }) => <div data-testid="block-icon">{toolIcon}</div>,
-}))
-
-describe('OptionCard', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- })
-
- it('should render the datasource label and icon', () => {
- render(
- <OptionCard
- label="Website Crawl"
- value="website"
- selected={false}
- nodeData={{ title: 'Website Crawl' } as DataSourceNodeType}
- />,
- )
-
- expect(screen.getByTestId('block-icon')).toHaveTextContent('source-icon')
- expect(screen.getByText('Website Crawl')).toBeInTheDocument()
- })
-
- it('should call onClick with the card value and apply selected styles', () => {
- const onClick = vi.fn()
- render(
- <OptionCard
- label="Online Drive"
- value="online-drive"
- selected
- nodeData={{ title: 'Online Drive' } as DataSourceNodeType}
- onClick={onClick}
- />,
- )
-
- fireEvent.click(screen.getByText('Online Drive'))
-
- expect(onClick).toHaveBeenCalledWith('online-drive')
- })
-})
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/index.tsx
index e2c32502d29..ee8ce98e761 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/index.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/index.tsx
@@ -1,5 +1,7 @@
import type { Datasource } from '../../types'
+import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { useCallback, useEffect } from 'react'
+import { useTranslation } from 'react-i18next'
import { useDatasourceOptions } from '../hooks'
import OptionCard from './option-card'
@@ -10,6 +12,7 @@ type DataSourceOptionsProps = {
const DataSourceOptions = ({ dataSourceNodeId, onSelect }: DataSourceOptionsProps) => {
const options = useDatasourceOptions()
+ const { t } = useTranslation()
const handelSelect = useCallback(
(value: string) => {
@@ -29,7 +32,12 @@ const DataSourceOptions = ({ dataSourceNodeId, onSelect }: DataSourceOptionsProp
}, [])
return (
- <div className="grid w-full grid-cols-4 gap-1">
+ <RadioGroup
+ value={dataSourceNodeId}
+ onValueChange={handelSelect}
+ aria-label={t(($) => $['testRun.steps.dataSource'], { ns: 'datasetPipeline' })}
+ className="grid w-full grid-cols-4 gap-1"
+ >
{options.map((option) => (
<OptionCard
key={option.value}
@@ -37,10 +45,9 @@ const DataSourceOptions = ({ dataSourceNodeId, onSelect }: DataSourceOptionsProp
value={option.value}
nodeData={option.data}
selected={dataSourceNodeId === option.value}
- onClick={handelSelect}
/>
))}
- </div>
+ </RadioGroup>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/option-card.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/option-card.tsx
index c8f948fff02..d89b5ae0178 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/option-card.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/preparation/data-source-options/option-card.tsx
@@ -1,7 +1,7 @@
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import { cn } from '@langgenius/dify-ui/cn'
+import { RadioItem } from '@langgenius/dify-ui/radio-group'
import * as React from 'react'
-import { useCallback } from 'react'
import BlockIcon from '@/app/components/workflow/block-icon'
import { useToolIcon } from '@/app/components/workflow/hooks/use-tool-icon'
import { BlockEnum } from '@/app/components/workflow/types'
@@ -11,27 +11,25 @@ type OptionCardProps = {
value: string
selected: boolean
nodeData: DataSourceNodeType
- onClick?: (value: string) => void
}
-const OptionCard = ({ label, value, selected, nodeData, onClick }: OptionCardProps) => {
+const OptionCard = ({ label, value, selected, nodeData }: OptionCardProps) => {
const toolIcon = useToolIcon(nodeData)
- const handleClickCard = useCallback(() => {
- onClick?.(value)
- }, [value, onClick])
-
return (
- <div
+ <RadioItem
+ value={value}
className={cn(
- 'flex cursor-pointer flex-col gap-1 rounded-xl border border-components-option-card-option-border bg-components-option-card-option-bg p-2.5 shadow-shadow-shadow-3',
+ 'flex cursor-pointer flex-col gap-1 rounded-xl border border-components-option-card-option-border bg-components-option-card-option-bg p-2.5 text-left shadow-shadow-shadow-3 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',
selected
? 'border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg shadow-xs inset-ring-[0.5px] inset-ring-components-option-card-option-selected-border'
: 'hover:border-components-option-card-option-border-hover hover:shadow-xs',
)}
- onClick={handleClickCard}
>
- <div className="flex size-7 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-components-panel-border bg-background-default-dodge p-1">
+ <div
+ aria-hidden="true"
+ className="flex size-7 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-components-panel-border bg-background-default-dodge p-1"
+ >
<BlockIcon type={BlockEnum.DataSource} toolIcon={toolIcon} />
</div>
<div
@@ -43,7 +41,7 @@ const OptionCard = ({ label, value, selected, nodeData, onClick }: OptionCardPro
>
{label}
</div>
- </div>
+ </RadioItem>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/preparation/step-indicator.tsx b/web/app/components/rag-pipeline/components/panel/test-run/preparation/step-indicator.tsx
index 69e1cbf4349..f4b0eaad7ed 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/preparation/step-indicator.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/preparation/step-indicator.tsx
@@ -14,12 +14,16 @@ type StepIndicatorProps = {
const StepIndicator = ({ currentStep, steps }: StepIndicatorProps) => {
return (
- <div className="flex items-center gap-x-2 px-4 pb-2">
+ <ol className="flex items-center gap-x-2 px-4 pb-2">
{steps.map((step, index) => {
const isCurrentStep = index === currentStep - 1
const isLastStep = index === steps.length - 1
return (
- <div key={index} className="flex items-center gap-x-2">
+ <li
+ key={step.value}
+ aria-current={isCurrentStep ? 'step' : undefined}
+ className="flex items-center gap-x-2"
+ >
<div
className={cn(
'flex items-center gap-x-1',
@@ -38,10 +42,10 @@ const StepIndicator = ({ currentStep, steps }: StepIndicatorProps) => {
/>
</div>
)}
- </div>
+ </li>
)
})}
- </div>
+ </ol>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/__tests__/index.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/result/__tests__/index.spec.tsx
index d6cd01e0de9..b58ed2118ab 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/result/__tests__/index.spec.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/result/__tests__/index.spec.tsx
@@ -35,10 +35,18 @@ describe('Result', () => {
expect(screen.getByRole('button', { name: 'Result preview' })).toBeInTheDocument()
- await user.click(screen.getByRole('button', { name: 'runLog.detail' }))
+ await user.tab()
+ expect(screen.getByRole('tab', { name: 'runLog.result', selected: true })).toHaveFocus()
+ await user.keyboard('{ArrowRight}{Enter}')
+ const detailTab = screen.getByRole('tab', { name: 'runLog.detail', selected: true })
+ expect(detailTab).toHaveFocus()
+ expect(screen.getByRole('tabpanel', { name: 'runLog.detail' })).toHaveAttribute(
+ 'id',
+ detailTab.getAttribute('aria-controls'),
+ )
expect(screen.getByText('Result detail')).toBeInTheDocument()
- await user.click(screen.getByRole('button', { name: 'runLog.tracing' }))
+ await user.click(screen.getByRole('tab', { name: 'runLog.tracing' }))
expect(screen.getByText('Tracing detail')).toBeInTheDocument()
})
})
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/result/index.tsx
index 977905dbc5f..e03a105e400 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/result/index.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/result/index.tsx
@@ -1,3 +1,4 @@
+import { TabsPanel, Tabs as TabsRoot } from '@langgenius/dify-ui/tabs'
import { memo, useState } from 'react'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import ResultPanel from '@/app/components/workflow/run/result-panel'
@@ -16,14 +17,10 @@ const Result = () => {
}
return (
- <div className="flex grow flex-col">
- <Tabs
- currentTab={currentTab}
- workflowRunningData={workflowRunningData}
- switchTab={switchTab}
- />
+ <TabsRoot value={currentTab} onValueChange={setCurrentTab} className="flex grow flex-col">
+ <Tabs workflowRunningData={workflowRunningData} />
<div className="flex h-0 grow flex-col overflow-y-auto">
- {currentTab === 'RESULT' && (
+ <TabsPanel value="RESULT" className="flex grow flex-col">
<ResultPreview
isRunning={
!workflowRunningData?.result ||
@@ -33,8 +30,8 @@ const Result = () => {
error={workflowRunningData?.result?.error}
onSwitchToDetail={() => switchTab('DETAIL')}
/>
- )}
- {currentTab === 'DETAIL' && (
+ </TabsPanel>
+ <TabsPanel value="DETAIL" className="flex grow flex-col">
<ResultPanel
inputs={workflowRunningData?.result?.inputs}
outputs={workflowRunningData?.result?.outputs}
@@ -47,25 +44,25 @@ const Result = () => {
steps={workflowRunningData?.result?.total_steps}
exceptionCounts={workflowRunningData?.result?.exceptions_count}
/>
- )}
- {currentTab === 'DETAIL' && !workflowRunningData?.result && (
- <div className="flex grow items-center justify-center">
- <LoadingPlaceholder />
- </div>
- )}
- {currentTab === 'TRACING' && (
+ {!workflowRunningData?.result && (
+ <div className="flex grow items-center justify-center">
+ <LoadingPlaceholder />
+ </div>
+ )}
+ </TabsPanel>
+ <TabsPanel value="TRACING" className="flex grow flex-col">
<TracingPanel
className="bg-background-section-burn"
list={workflowRunningData?.tracing || []}
/>
- )}
- {currentTab === 'TRACING' && !workflowRunningData?.tracing?.length && (
- <div className="flex grow items-center justify-center">
- <LoadingPlaceholder />
- </div>
- )}
+ {!workflowRunningData?.tracing?.length && (
+ <div className="flex grow items-center justify-center">
+ <LoadingPlaceholder />
+ </div>
+ )}
+ </TabsPanel>
</div>
- </div>
+ </TabsRoot>
)
}
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/__tests__/tab.spec.tsx b/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/__tests__/tab.spec.tsx
deleted file mode 100644
index 810664edc63..00000000000
--- a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/__tests__/tab.spec.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import type { WorkflowRunningData } from '@/app/components/workflow/types'
-import { fireEvent, render, screen } from '@testing-library/react'
-import Tab from '../tab'
-
-const createWorkflowRunningData = (): WorkflowRunningData => ({
- task_id: 'task-1',
- message_id: 'message-1',
- conversation_id: 'conversation-1',
- result: {
- workflow_id: 'workflow-1',
- inputs: '{}',
- inputs_truncated: false,
- process_data: '{}',
- process_data_truncated: false,
- outputs: '{}',
- outputs_truncated: false,
- status: 'succeeded',
- elapsed_time: 10,
- total_tokens: 20,
- created_at: Date.now(),
- finished_at: Date.now(),
- steps: 1,
- total_steps: 1,
- },
- tracing: [],
-})
-
-describe('Tab', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- })
-
- it('should render an active tab and pass its value on click', () => {
- const onClick = vi.fn()
- render(
- <Tab
- isActive
- label="Preview"
- value="preview"
- workflowRunningData={createWorkflowRunningData()}
- onClick={onClick}
- />,
- )
-
- fireEvent.click(screen.getByRole('button', { name: 'Preview' }))
-
- expect(screen.getByRole('button')).toHaveClass('border-util-colors-blue-brand-blue-brand-600')
- expect(onClick).toHaveBeenCalledWith('preview')
- })
-
- it('should disable the tab when workflow run data is unavailable', () => {
- render(<Tab isActive={false} label="Trace" value="trace" onClick={vi.fn()} />)
-
- expect(screen.getByRole('button', { name: 'Trace' })).toBeDisabled()
- expect(screen.getByRole('button', { name: 'Trace' })).toHaveClass('opacity-30')
- })
-})
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/index.tsx
index 2a19c79ea6d..87b8e611061 100644
--- a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/index.tsx
+++ b/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/index.tsx
@@ -1,41 +1,35 @@
import type { WorkflowRunningData } from '@/app/components/workflow/types'
-import * as React from 'react'
+import { TabsList, TabsTab } from '@langgenius/dify-ui/tabs'
import { useTranslation } from 'react-i18next'
-import Tab from './tab'
type TabsProps = {
- currentTab: string
workflowRunningData?: WorkflowRunningData
- switchTab: (tab: string) => void
}
-const Tabs = ({ currentTab, workflowRunningData, switchTab }: TabsProps) => {
+const Tabs = ({ workflowRunningData }: TabsProps) => {
const { t } = useTranslation()
+ const tabs = [
+ { value: 'RESULT', label: t(($) => $.result, { ns: 'runLog' }) },
+ { value: 'DETAIL', label: t(($) => $.detail, { ns: 'runLog' }) },
+ { value: 'TRACING', label: t(($) => $.tracing, { ns: 'runLog' }) },
+ ]
return (
- <div className="flex shrink-0 items-center gap-x-6 border-b-[0.5px] border-divider-subtle px-4">
- <Tab
- isActive={currentTab === 'RESULT'}
- label={t(($) => $.result, { ns: 'runLog' })}
- value="RESULT"
- workflowRunningData={workflowRunningData}
- onClick={switchTab}
- />
- <Tab
- isActive={currentTab === 'DETAIL'}
- label={t(($) => $.detail, { ns: 'runLog' })}
- value="DETAIL"
- workflowRunningData={workflowRunningData}
- onClick={switchTab}
- />
- <Tab
- isActive={currentTab === 'TRACING'}
- label={t(($) => $.tracing, { ns: 'runLog' })}
- value="TRACING"
- workflowRunningData={workflowRunningData}
- onClick={switchTab}
- />
- </div>
+ <TabsList
+ aria-label={t(($) => $['testRun.title'], { ns: 'datasetPipeline' })}
+ className="shrink-0 items-center gap-x-6 border-b-[0.5px] border-divider-subtle px-4"
+ >
+ {tabs.map((tab) => (
+ <TabsTab
+ key={tab.value}
+ value={tab.value}
+ disabled={!workflowRunningData}
+ className="py-3 system-sm-semibold-uppercase!"
+ >
+ {tab.label}
+ </TabsTab>
+ ))}
+ </TabsList>
)
}
-export default React.memo(Tabs)
+export default Tabs
diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/tab.tsx b/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/tab.tsx
deleted file mode 100644
index 77deed0546b..00000000000
--- a/web/app/components/rag-pipeline/components/panel/test-run/result/tabs/tab.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import type { WorkflowRunningData } from '@/app/components/workflow/types'
-import { cn } from '@langgenius/dify-ui/cn'
-import * as React from 'react'
-import { useCallback } from 'react'
-
-type TabProps = {
- isActive: boolean
- label: string
- value: string
- workflowRunningData?: WorkflowRunningData
- onClick: (value: string) => void
-}
-
-const Tab = ({ isActive, label, value, workflowRunningData, onClick }: TabProps) => {
- const handleClick = useCallback(() => {
- onClick(value)
- }, [value, onClick])
-
- return (
- <button
- type="button"
- className={cn(
- 'cursor-pointer border-b-2 border-transparent py-3 system-sm-semibold-uppercase text-text-tertiary',
- isActive && 'border-util-colors-blue-brand-blue-brand-600 text-text-primary',
- !workflowRunningData && 'cursor-not-allowed! opacity-30',
- )}
- onClick={handleClick}
- disabled={!workflowRunningData}
- >
- {label}
- </button>
- )
-}
-
-export default React.memo(Tab)
diff --git a/web/app/components/rag-pipeline/components/publish-toast.tsx b/web/app/components/rag-pipeline/components/publish-toast.tsx
index da73f927a0b..5d846e3ce25 100644
--- a/web/app/components/rag-pipeline/components/publish-toast.tsx
+++ b/web/app/components/rag-pipeline/components/publish-toast.tsx
@@ -1,3 +1,4 @@
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { RiCloseLine, RiInformation2Fill } from '@remixicon/react'
import { memo, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -25,12 +26,13 @@ const PublishToast = () => {
{t(($) => $['publishToast.desc'], { ns: 'pipeline' })}
</div>
</div>
- <div
- className="pointer-events-auto flex size-6 cursor-pointer items-center justify-center"
+ <IconButton
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ className="nokey pointer-events-auto shrink-0"
onClick={() => setHideToast(true)}
>
- <RiCloseLine className="size-4 text-text-tertiary" />
- </div>
+ <RiCloseLine aria-hidden="true" className="size-4 text-text-tertiary" />
+ </IconButton>
</div>
</div>
)
diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/run-mode.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/run-mode.spec.tsx
index 10d72478fb6..4e623bc18a3 100644
--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/run-mode.spec.tsx
+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/__tests__/run-mode.spec.tsx
@@ -183,7 +183,9 @@ describe('RunMode', () => {
it('should call handleStopRun with task_id when stop clicked', () => {
render(<RunMode />)
- fireEvent.click(screen.getByTestId('stop-icon').closest('button')!)
+ fireEvent.click(
+ screen.getByRole('button', { name: 'workflow.debug.variableInspect.trigger.stop' }),
+ )
expect(mockHandleStopRun).toHaveBeenCalledWith('task-1')
})
@@ -227,7 +229,7 @@ describe('RunMode', () => {
it('should cancel preparing when close clicked', () => {
render(<RunMode />)
- fireEvent.click(screen.getByTestId('close-icon').closest('button')!)
+ fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
expect(mockSetIsPreparingDataSource).toHaveBeenCalledWith(false)
expect(mockSetShowDebugAndPreviewPanel).toHaveBeenCalledWith(false)
diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/run-mode.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/run-mode.tsx
index 273b7cd8567..80737fe9d14 100644
--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/run-mode.tsx
+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/run-mode.tsx
@@ -59,7 +59,7 @@ export function RunMode({ text }: RunModeProps) {
if (!canRun) return null
return (
- <div className="flex items-center gap-x-px">
+ <div className="nokey flex items-center gap-x-px">
<button
type="button"
className={cn(
@@ -102,22 +102,24 @@ export function RunMode({ text }: RunModeProps) {
<button
type="button"
className={cn(
- 'flex size-7 items-center justify-center rounded-r-md bg-state-accent-active',
+ 'flex size-7 items-center justify-center rounded-r-md bg-state-accent-active focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',
)}
+ aria-label={t(($) => $['debug.variableInspect.trigger.stop'], { ns: 'workflow' })}
onClick={handleStop}
>
- <StopCircle className="size-4 text-text-accent" />
+ <StopCircle aria-hidden="true" className="size-4 text-text-accent" />
</button>
)}
{isPreparingDataSource && (
<button
type="button"
className={cn(
- 'flex size-7 items-center justify-center rounded-r-md bg-state-accent-active',
+ 'flex size-7 items-center justify-center rounded-r-md bg-state-accent-active focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',
)}
+ aria-label={t(($) => $['operation.cancel'], { ns: 'common' })}
onClick={handleCancelPreparingDataSource}
>
- <RiCloseLine className="size-4 text-text-accent" />
+ <RiCloseLine aria-hidden="true" className="size-4 text-text-accent" />
</button>
)}
</div>
diff --git a/web/app/components/workflow/nodes/knowledge-base/components/__tests__/option-card.spec.tsx b/web/app/components/workflow/nodes/knowledge-base/components/__tests__/option-card.spec.tsx
index 799baf06ca7..59b4eda8459 100644
--- a/web/app/components/workflow/nodes/knowledge-base/components/__tests__/option-card.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/components/__tests__/option-card.spec.tsx
@@ -46,24 +46,44 @@ describe('OptionCard', () => {
expect(onClick).not.toHaveBeenCalled()
})
- it('should support function-based wrapper, class, and icon props without enabling selection', () => {
- render(
- <OptionCard
- id="inactive"
- selectedId="qualified"
- title="Inactive card"
- enableSelect={false}
- wrapperClassName={(isActive) => (isActive ? 'wrapper-active' : 'wrapper-inactive')}
- className={(isActive) => (isActive ? 'body-active' : 'body-inactive')}
- icon={(isActive) => (
- <span data-testid="option-icon">{isActive ? 'active' : 'inactive'}</span>
- )}
- />,
+ it('should expose selection to keyboard users while keeping expanded inputs separate', async () => {
+ const user = userEvent.setup()
+ const onClick = vi.fn()
+ const { rerender } = render(
+ <OptionCard id="economical" title="Economical" onClick={onClick} />,
+ )
+
+ const choice = screen.getByRole('button', { name: 'Economical' })
+ expect(choice).toHaveAttribute('aria-pressed', 'false')
+ await user.tab()
+ expect(choice).toHaveFocus()
+ await user.keyboard('{Enter}')
+ expect(onClick).toHaveBeenCalledWith('economical')
+
+ rerender(
+ <OptionCard id="economical" selectedId="economical" title="Economical" onClick={onClick}>
+ <label>
+ Keywords
+ <input type="number" defaultValue={5} />
+ </label>
+ </OptionCard>,
)
- expect(screen.getByText('Inactive card').closest('.wrapper-inactive')).toBeInTheDocument()
- expect(screen.getByTestId('option-icon')).toHaveTextContent('inactive')
- expect(screen.getByText('Inactive card').closest('.body-inactive')).toBeInTheDocument()
+ expect(choice).toHaveAttribute('aria-pressed', 'true')
+ onClick.mockClear()
+ await user.tab()
+ const input = screen.getByRole('spinbutton', { name: 'Keywords' })
+ expect(input).toHaveFocus()
+ await user.clear(input)
+ await user.type(input, '10')
+ expect(input).toHaveValue(10)
+ expect(onClick).not.toHaveBeenCalled()
+ })
+
+ it('should keep a nonselectable summary outside the tab order', () => {
+ render(<OptionCard id="general" title="General" enableSelect={false} />)
+ expect(screen.getByText('General')).toBeInTheDocument()
+ expect(screen.queryByRole('button')).not.toBeInTheDocument()
})
})
})
diff --git a/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/__tests__/selector.spec.tsx b/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/__tests__/selector.spec.tsx
index 3392ff9fddd..9aaf928f7e3 100644
--- a/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/__tests__/selector.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/__tests__/selector.spec.tsx
@@ -1,7 +1,15 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { useKeyPress } from 'reactflow'
import { ChunkStructureEnum } from '../../../types'
import Selector from '../selector'
+// Exercise the same document-level shortcut mounted by the workflow canvas.
+function CanvasPanShortcut() {
+ useKeyPress('Space')
+ return null
+}
+
const options = [
{
id: ChunkStructureEnum.general,
@@ -21,17 +29,26 @@ const options = [
describe('ChunkStructureSelector', () => {
it('should open the selector panel and close it after selecting an option', async () => {
+ const user = userEvent.setup()
const onChange = vi.fn()
- render(<Selector options={options} value={ChunkStructureEnum.general} onChange={onChange} />)
+ render(
+ <>
+ <CanvasPanShortcut />
+ <Selector options={options} value={ChunkStructureEnum.general} onChange={onChange} />
+ </>,
+ )
- fireEvent.click(screen.getByRole('button', { name: 'workflow.panel.change' }))
+ await user.click(screen.getByRole('button', { name: 'workflow.panel.change' }))
expect(
- screen.getByText('workflow.nodes.knowledgeBase.changeChunkStructure'),
+ screen.getByRole('dialog', { name: 'workflow.nodes.knowledgeBase.changeChunkStructure' }),
).toBeInTheDocument()
- fireEvent.click(screen.getByText('Parent child'))
+ expect(screen.getByRole('button', { name: /General/, pressed: true })).toBeInTheDocument()
+ const choice = screen.getByRole('button', { name: /Parent child/, pressed: false })
+ choice.focus()
+ await user.keyboard(' ')
expect(onChange).toHaveBeenCalledWith(ChunkStructureEnum.parent_child)
await waitFor(() => {
@@ -41,7 +58,27 @@ describe('ChunkStructureSelector', () => {
})
})
- it('should not open the selector when readonly is enabled', () => {
+ it('should expose one custom trigger and open it from the keyboard', async () => {
+ const user = userEvent.setup()
+ render(
+ <>
+ <CanvasPanShortcut />
+ <Selector
+ options={options}
+ onChange={vi.fn()}
+ trigger={<button type="button">Choose structure</button>}
+ />
+ </>,
+ )
+ expect(screen.getAllByRole('button')).toHaveLength(1)
+ await user.tab()
+ expect(screen.getByRole('button', { name: 'Choose structure' })).toHaveFocus()
+ await user.keyboard(' ')
+ expect(await screen.findByRole('button', { name: /General/ })).toBeInTheDocument()
+ })
+
+ it('should not open the selector when readonly is enabled', async () => {
+ const user = userEvent.setup()
render(
<Selector
options={options}
@@ -51,8 +88,9 @@ describe('ChunkStructureSelector', () => {
/>,
)
- const trigger = screen.getByText('custom-trigger').closest('[role="button"]')
- fireEvent.click(trigger!)
+ const trigger = screen.getByRole('button', { name: 'custom-trigger' })
+ expect(trigger).toBeDisabled()
+ await user.click(trigger)
expect(
screen.queryByText('workflow.nodes.knowledgeBase.changeChunkStructure'),
diff --git a/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/selector.tsx b/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/selector.tsx
index 42e768069c6..f95cad742a8 100644
--- a/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/selector.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/components/chunk-structure/selector.tsx
@@ -1,8 +1,8 @@
-import type { ReactNode } from 'react'
+import type { ReactElement } from 'react'
import type { ChunkStructureEnum } from '../../types'
import type { Option } from './type'
import { Button } from '@langgenius/dify-ui/button'
-import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
+import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import OptionCard from '../option-card'
@@ -12,7 +12,7 @@ type SelectorProps = {
value?: ChunkStructureEnum
onChange: (key: ChunkStructureEnum) => void
readonly?: boolean
- trigger?: ReactNode
+ trigger?: ReactElement
}
const Selector = ({ options, value, onChange, readonly, trigger }: SelectorProps) => {
const { t } = useTranslation()
@@ -35,12 +35,15 @@ const Selector = ({ options, value, onChange, readonly, trigger }: SelectorProps
return (
<Popover open={open} onOpenChange={handleOpenChange}>
+ {/* Keep Space activation outside React Flow's document-level pan shortcut. */}
{trigger ? (
- <PopoverTrigger nativeButton={false} render={<div />}>
- {trigger}
- </PopoverTrigger>
+ <PopoverTrigger className="nokey" disabled={readonly} render={trigger} />
) : (
- <PopoverTrigger render={<Button size="small" variant="ghost-accent" />}>
+ <PopoverTrigger
+ className="nokey"
+ disabled={readonly}
+ render={<Button size="small" variant="ghost-accent" />}
+ >
{t(($) => $['panel.change'], { ns: 'workflow' })}
</PopoverTrigger>
)}
@@ -51,9 +54,9 @@ const Selector = ({ options, value, onChange, readonly, trigger }: SelectorProps
className="border-none bg-transparent shadow-none"
>
<div className="w-101 rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-xl backdrop-blur-[5px]">
- <div className="px-3 pt-3.5 system-sm-semibold text-text-primary">
+ <PopoverTitle className="px-3 pt-3.5 system-sm-semibold text-text-primary">
{t(($) => $['nodes.knowledgeBase.changeChunkStructure'], { ns: 'workflow' })}
- </div>
+ </PopoverTitle>
<div className="space-y-1 p-3 pt-2">
{options.map((option) => (
<OptionCard
diff --git a/web/app/components/workflow/nodes/knowledge-base/components/option-card.tsx b/web/app/components/workflow/nodes/knowledge-base/components/option-card.tsx
index a66028da05d..14fae86dff0 100644
--- a/web/app/components/workflow/nodes/knowledge-base/components/option-card.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/components/option-card.tsx
@@ -1,5 +1,6 @@
import type { ReactNode } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
+import { Toggle } from '@langgenius/dify-ui/toggle'
import { memo, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
@@ -62,7 +63,8 @@ const OptionCard = memo(
const effectElement = useMemo(() => {
if (effectColor) {
return (
- <div
+ <span
+ aria-hidden="true"
className={cn(
'absolute -top-0.5 -left-0.5 hidden h-14 w-14 rounded-full',
'group-hover:block',
@@ -70,13 +72,15 @@ const OptionCard = memo(
)}
>
{HEADER_EFFECT_MAP[effectColor]}
- </div>
+ </span>
)
}
return null
}, [effectColor, isActive])
+ const Header = enableSelect ? Toggle : 'div'
+
return (
<div
className={cn(
@@ -91,47 +95,62 @@ const OptionCard = memo(
? wrapperClassName(isActive)
: wrapperClassName),
)}
- onClick={(e) => {
- e.stopPropagation()
- if (!readonly && enableSelect && id) onClick?.(id)
- }}
>
- <div
+ <Header
+ {...(enableSelect
+ ? {
+ pressed: isActive,
+ disabled: readonly,
+ onPressedChange: () => {
+ if (id !== undefined) onClick?.(id)
+ },
+ onClick: (event: React.MouseEvent) => event.stopPropagation(),
+ }
+ : {})}
className={cn(
- 'relative flex rounded-t-xl p-2',
+ 'relative flex w-full rounded-t-xl p-2 text-left',
+ // React Flow otherwise consumes Space before the native button can activate.
+ enableSelect &&
+ 'nokey cursor-pointer focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden focus-visible:ring-inset disabled:cursor-not-allowed',
className && (typeof className === 'function' ? className(isActive) : className),
)}
>
{effectElement}
{!!icon && (
- <div className="mr-1 flex h-4.5 w-4.5 shrink-0 items-center justify-center">
+ <span
+ aria-hidden="true"
+ className="mr-1 flex h-4.5 w-4.5 shrink-0 items-center justify-center"
+ >
{typeof icon === 'function' ? icon(isActive) : icon}
- </div>
+ </span>
)}
- <div className="grow py-1 pt-px">
- <div className="flex items-center">
- <div className="flex grow items-center system-sm-medium text-text-secondary">
+ <span className="block grow py-1 pt-px">
+ <span className="flex items-center">
+ <span className="flex grow items-center system-sm-medium text-text-secondary">
{title}
{isRecommended && (
- <Badge className="ml-1 h-4 border-text-accent-secondary text-text-accent-secondary">
+ <Badge
+ as="span"
+ className="ml-1 h-4 border-text-accent-secondary text-text-accent-secondary"
+ >
{t(($) => $['stepTwo.recommend'], { ns: 'datasetCreation' })}
</Badge>
)}
- </div>
+ </span>
{enableRadio && (
- <div
+ <span
className={cn(
'ml-2 size-4 shrink-0 rounded-full border border-components-radio-border bg-components-radio-bg',
isActive && 'border-[5px] border-components-radio-border-checked',
)}
- ></div>
+ ></span>
)}
- </div>
+ </span>
{description && (
- <div className="mt-1 system-xs-regular text-text-tertiary">{description}</div>
+ <span className="mt-1 block system-xs-regular text-text-tertiary">{description}</span>
)}
- </div>
- </div>
+ </span>
+ </Header>
{!!(children && isActive) && (
<div className="relative rounded-b-xl bg-components-panel-bg p-3">
<ArrowShape className="absolute -top-2.75 left-3.5 h-4 w-4 text-components-panel-bg" />
diff --git a/web/app/components/workflow/variable-inspect/__tests__/trigger.spec.tsx b/web/app/components/workflow/variable-inspect/__tests__/trigger.spec.tsx
index f819d37e015..f2c87159098 100644
--- a/web/app/components/workflow/variable-inspect/__tests__/trigger.spec.tsx
+++ b/web/app/components/workflow/variable-inspect/__tests__/trigger.spec.tsx
@@ -1,10 +1,12 @@
import type { NodeWithVar, VarInInspect } from '@/types/workflow'
import { fireEvent, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
import { VarInInspectType } from '@/types/workflow'
import { createNode } from '../../__tests__/fixtures'
import { baseRunningData, renderWorkflowFlowComponent } from '../../__tests__/workflow-test-env'
import { BlockEnum, NodeRunningStatus, VarType, WorkflowRunningStatus } from '../../types'
import VariableInspectTrigger from '../trigger'
+import { EVENT_WORKFLOW_STOP } from '../types'
type InspectVarsState = {
conversationVars: VarInInspect[]
@@ -88,10 +90,16 @@ describe('VariableInspectTrigger', () => {
).not.toBeInTheDocument()
})
- it('should open the panel from the normal trigger state', () => {
+ it('should open the panel from the normal trigger state with the keyboard', async () => {
+ const user = userEvent.setup()
const { store } = renderTrigger()
- fireEvent.click(screen.getByText('workflow.debug.variableInspect.trigger.normal'))
+ await user.tab()
+ await user.tab()
+ expect(
+ screen.getByRole('button', { name: 'workflow.debug.variableInspect.trigger.normal' }),
+ ).toHaveFocus()
+ await user.keyboard('{Enter}')
expect(store.getState().showVariableInspectPanel).toBe(true)
})
@@ -108,7 +116,8 @@ describe('VariableInspectTrigger', () => {
expect(store.getState().showVariableInspectPanel).toBe(false)
})
- it('should clear cached variables and reset the focused node', () => {
+ it('should clear cached variables and reset the focused node with the keyboard', async () => {
+ const user = userEvent.setup()
inspectVarsState = {
conversationVars: [
createVariable({
@@ -126,13 +135,36 @@ describe('VariableInspectTrigger', () => {
},
})
- fireEvent.click(screen.getByText('workflow.debug.variableInspect.trigger.clear'))
+ await user.tab()
+ await user.tab()
+ await user.tab()
+ expect(
+ screen.getByRole('button', { name: 'workflow.debug.variableInspect.trigger.clear' }),
+ ).toHaveFocus()
+ await user.keyboard(' ')
expect(screen.getByText('workflow.debug.variableInspect.trigger.cached')).toBeInTheDocument()
expect(mockDeleteAllInspectorVars).toHaveBeenCalledTimes(1)
expect(store.getState().currentFocusNodeId).toBe('')
})
+ it('exposes a named stop button that works from the keyboard', async () => {
+ const user = userEvent.setup()
+ renderTrigger({
+ initialStoreState: {
+ workflowRunningData: baseRunningData({ result: { status: WorkflowRunningStatus.Running } }),
+ },
+ })
+ await user.tab()
+ await user.tab()
+ await user.tab()
+ expect(
+ screen.getByRole('button', { name: 'workflow.debug.variableInspect.trigger.stop' }),
+ ).toHaveFocus()
+ await user.keyboard('{Enter}')
+ expect(mockEmit).toHaveBeenCalledWith({ type: EVENT_WORKFLOW_STOP })
+ })
+
it('should show the running state and open the panel while running', () => {
const { store } = renderTrigger({
nodes: [
diff --git a/web/app/components/workflow/variable-inspect/trigger.tsx b/web/app/components/workflow/variable-inspect/trigger.tsx
index bc1f21c666e..97bb19a63ae 100644
--- a/web/app/components/workflow/variable-inspect/trigger.tsx
+++ b/web/app/components/workflow/variable-inspect/trigger.tsx
@@ -1,6 +1,8 @@
import type { FC } from 'react'
import type { CommonNodeType } from '@/app/components/workflow/types'
+import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { RiLoader2Line, RiStopCircleFill } from '@remixicon/react'
import { useMemo } from 'react'
@@ -62,12 +64,16 @@ const VariableInspectTrigger: FC = () => {
if (showVariableInspectPanel) return null
+ // React Flow reserves Space for panning unless the target is inside .nokey.
return (
- <div className={cn('flex shrink-0 flex-nowrap items-center gap-1 whitespace-nowrap')}>
+ <div className={cn('nokey flex shrink-0 flex-nowrap items-center gap-1 whitespace-nowrap')}>
{!isRunning && !currentVars.length && (
- <div
+ <Button
+ size="small"
+ variant="secondary"
+ disabled={nodesReadOnly}
className={cn(
- 'flex h-5 shrink-0 cursor-pointer items-center gap-1 rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-2 system-2xs-semibold-uppercase text-text-tertiary shadow-lg backdrop-blur-xs hover:bg-background-default-hover',
+ 'flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-2 system-2xs-semibold-uppercase text-text-tertiary shadow-lg backdrop-blur-xs hover:bg-background-default-hover',
nodesReadOnly &&
'cursor-not-allowed text-text-disabled hover:bg-transparent hover:text-text-disabled',
)}
@@ -77,11 +83,14 @@ const VariableInspectTrigger: FC = () => {
}}
>
{t(($) => $['debug.variableInspect.trigger.normal'], { ns: 'workflow' })}
- </div>
+ </Button>
)}
{!isRunning && currentVars.length > 0 && (
<>
- <div
+ <Button
+ size="small"
+ variant="secondary"
+ disabled={nodesReadOnly}
className={cn(
'flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-2 system-xs-medium text-text-accent shadow-lg backdrop-blur-xs hover:bg-components-actionbar-bg-accent',
nodesReadOnly &&
@@ -93,8 +102,11 @@ const VariableInspectTrigger: FC = () => {
}}
>
{t(($) => $['debug.variableInspect.trigger.cached'], { ns: 'workflow' })}
- </div>
- <div
+ </Button>
+ <Button
+ size="small"
+ variant="secondary"
+ disabled={nodesReadOnly}
className={cn(
'flex h-6 shrink-0 cursor-pointer items-center rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-1 system-xs-medium text-text-tertiary shadow-lg backdrop-blur-xs hover:bg-components-actionbar-bg-accent hover:text-text-accent',
nodesReadOnly &&
@@ -106,30 +118,38 @@ const VariableInspectTrigger: FC = () => {
}}
>
{t(($) => $['debug.variableInspect.trigger.clear'], { ns: 'workflow' })}
- </div>
+ </Button>
</>
)}
{isRunning && (
<>
- <div
+ <Button
+ size="small"
+ variant="secondary"
className="flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-2 system-xs-medium text-text-accent shadow-lg backdrop-blur-xs hover:bg-components-actionbar-bg-accent"
onClick={() => setShowVariableInspectPanel(true)}
>
- <RiLoader2Line className="size-4 shrink-0 animate-spin" />
+ <RiLoader2Line aria-hidden="true" className="size-4 shrink-0 animate-spin" />
<span className="text-text-accent">
{t(($) => $['debug.variableInspect.trigger.running'], { ns: 'workflow' })}
</span>
- </div>
+ </Button>
{isPreviewRunning && (
<Tooltip>
<TooltipTrigger
render={
- <div
+ <IconButton
+ aria-label={t(($) => $['debug.variableInspect.trigger.stop'], {
+ ns: 'workflow',
+ })}
className="flex h-6 shrink-0 cursor-pointer items-center rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-1 shadow-lg backdrop-blur-xs hover:bg-components-actionbar-bg-accent"
onClick={handleStop}
>
- <RiStopCircleFill className="size-4 shrink-0 text-text-accent" />
- </div>
+ <RiStopCircleFill
+ aria-hidden="true"
+ className="size-4 shrink-0 text-text-accent"
+ />
+ </IconButton>
}
/>
<TooltipContent>
diff --git a/web/i18n/locales/ar-TN/common.json b/web/i18n/locales/ar-TN/common.json
index 5a1dd71e03e..c06e2d3902b 100644
--- a/web/i18n/locales/ar-TN/common.json
+++ b/web/i18n/locales/ar-TN/common.json
@@ -476,6 +476,8 @@
"operation.more": "المزيد",
"operation.moreActions": "المزيد من الإجراءات",
"operation.moreActionsFor": "المزيد من الإجراءات لـ {{name}}",
+ "operation.moveDown": "نقل لأسفل",
+ "operation.moveUp": "نقل لأعلى",
"operation.no": "لا",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "لم يتم العثور على {{content}}",
diff --git a/web/i18n/locales/az-AZ/common.json b/web/i18n/locales/az-AZ/common.json
index b949a4f674a..d1c9a718fcc 100644
--- a/web/i18n/locales/az-AZ/common.json
+++ b/web/i18n/locales/az-AZ/common.json
@@ -476,6 +476,8 @@
"operation.more": "Daha çox",
"operation.moreActions": "Daha çox əməliyyat",
"operation.moreActionsFor": "{{name}} üçün daha çox əməliyyat",
+ "operation.moveDown": "Aşağı köçür",
+ "operation.moveUp": "Yuxarı köçür",
"operation.no": "Xeyr",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Heç bir {{content}} tapılmadı",
diff --git a/web/i18n/locales/de-DE/common.json b/web/i18n/locales/de-DE/common.json
index 61ec16b4796..4ccbd079cb2 100644
--- a/web/i18n/locales/de-DE/common.json
+++ b/web/i18n/locales/de-DE/common.json
@@ -476,6 +476,8 @@
"operation.more": "Mehr",
"operation.moreActions": "Weitere Aktionen",
"operation.moreActionsFor": "Weitere Aktionen für {{name}}",
+ "operation.moveDown": "Nach unten verschieben",
+ "operation.moveUp": "Nach oben verschieben",
"operation.no": "Nein",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Es wurden keine {{content}} gefunden",
diff --git a/web/i18n/locales/en-US/common.json b/web/i18n/locales/en-US/common.json
index ed96073fe59..cc2482935d7 100644
--- a/web/i18n/locales/en-US/common.json
+++ b/web/i18n/locales/en-US/common.json
@@ -476,6 +476,8 @@
"operation.more": "More",
"operation.moreActions": "More actions",
"operation.moreActionsFor": "More actions for {{name}}",
+ "operation.moveDown": "Move down",
+ "operation.moveUp": "Move up",
"operation.no": "No",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "No {{content}} were found",
diff --git a/web/i18n/locales/es-ES/common.json b/web/i18n/locales/es-ES/common.json
index 2d64c0240cc..d7889aee532 100644
--- a/web/i18n/locales/es-ES/common.json
+++ b/web/i18n/locales/es-ES/common.json
@@ -476,6 +476,8 @@
"operation.more": "Más",
"operation.moreActions": "Más acciones",
"operation.moreActionsFor": "Más acciones para {{name}}",
+ "operation.moveDown": "Mover hacia abajo",
+ "operation.moveUp": "Mover hacia arriba",
"operation.no": "No",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "No se encontraron {{content}}",
diff --git a/web/i18n/locales/fa-IR/common.json b/web/i18n/locales/fa-IR/common.json
index 2c4a6558de5..c23dce1f56b 100644
--- a/web/i18n/locales/fa-IR/common.json
+++ b/web/i18n/locales/fa-IR/common.json
@@ -476,6 +476,8 @@
"operation.more": "بیشتر",
"operation.moreActions": "اقدامات بیشتر",
"operation.moreActionsFor": "اقدامات بیشتر برای {{name}}",
+ "operation.moveDown": "انتقال به پایین",
+ "operation.moveUp": "انتقال به بالا",
"operation.no": "نه",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "هیچ {{content}} یافت نشد",
diff --git a/web/i18n/locales/fr-FR/common.json b/web/i18n/locales/fr-FR/common.json
index 6e603bf1a89..9d000284187 100644
--- a/web/i18n/locales/fr-FR/common.json
+++ b/web/i18n/locales/fr-FR/common.json
@@ -476,6 +476,8 @@
"operation.more": "Plus",
"operation.moreActions": "Plus d'actions",
"operation.moreActionsFor": "Plus d'actions pour {{name}}",
+ "operation.moveDown": "Déplacer vers le bas",
+ "operation.moveUp": "Déplacer vers le haut",
"operation.no": "Non",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Aucun {{content}} n'a été trouvé",
diff --git a/web/i18n/locales/hi-IN/common.json b/web/i18n/locales/hi-IN/common.json
index d021242dec2..2d015292b2b 100644
--- a/web/i18n/locales/hi-IN/common.json
+++ b/web/i18n/locales/hi-IN/common.json
@@ -476,6 +476,8 @@
"operation.more": "अधिक",
"operation.moreActions": "अधिक कार्रवाइयाँ",
"operation.moreActionsFor": "{{name}} के लिए अधिक कार्रवाइयाँ",
+ "operation.moveDown": "नीचे ले जाएँ",
+ "operation.moveUp": "ऊपर ले जाएँ",
"operation.no": "नहीं",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "कोई {{content}} नहीं मिला",
diff --git a/web/i18n/locales/id-ID/common.json b/web/i18n/locales/id-ID/common.json
index 20b4b2f1564..76d0b245a28 100644
--- a/web/i18n/locales/id-ID/common.json
+++ b/web/i18n/locales/id-ID/common.json
@@ -476,6 +476,8 @@
"operation.more": "Lebih",
"operation.moreActions": "Tindakan lainnya",
"operation.moreActionsFor": "Tindakan lainnya untuk {{name}}",
+ "operation.moveDown": "Pindahkan ke bawah",
+ "operation.moveUp": "Pindahkan ke atas",
"operation.no": "Tidak",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Tidak ada {{content}} yang ditemukan",
diff --git a/web/i18n/locales/it-IT/common.json b/web/i18n/locales/it-IT/common.json
index 7a1bfecdbf1..49bf1571639 100644
--- a/web/i18n/locales/it-IT/common.json
+++ b/web/i18n/locales/it-IT/common.json
@@ -476,6 +476,8 @@
"operation.more": "Di più",
"operation.moreActions": "Altre azioni",
"operation.moreActionsFor": "Altre azioni per {{name}}",
+ "operation.moveDown": "Sposta giù",
+ "operation.moveUp": "Sposta su",
"operation.no": "No",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Nessun {{content}} è stato trovato",
diff --git a/web/i18n/locales/ja-JP/common.json b/web/i18n/locales/ja-JP/common.json
index 897442fa655..f1f49ad33a5 100644
--- a/web/i18n/locales/ja-JP/common.json
+++ b/web/i18n/locales/ja-JP/common.json
@@ -476,6 +476,8 @@
"operation.more": "もっと",
"operation.moreActions": "その他の操作",
"operation.moreActionsFor": "{{name}} のその他の操作",
+ "operation.moveDown": "下に移動",
+ "operation.moveUp": "上に移動",
"operation.no": "いいえ",
"operation.noSearchCount": "0件の{{content}}",
"operation.noSearchResults": "{{content}}は見つかりませんでした",
diff --git a/web/i18n/locales/ko-KR/common.json b/web/i18n/locales/ko-KR/common.json
index 37ee6c85712..e894fac8205 100644
--- a/web/i18n/locales/ko-KR/common.json
+++ b/web/i18n/locales/ko-KR/common.json
@@ -476,6 +476,8 @@
"operation.more": "더 많은",
"operation.moreActions": "추가 작업",
"operation.moreActionsFor": "{{name}}에 대한 추가 작업",
+ "operation.moveDown": "아래로 이동",
+ "operation.moveUp": "위로 이동",
"operation.no": "아니요",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "{{content}}가(이) 발견되지 않았습니다",
diff --git a/web/i18n/locales/lo-LA/common.json b/web/i18n/locales/lo-LA/common.json
index 2ecf751f81e..5f8ed87c603 100644
--- a/web/i18n/locales/lo-LA/common.json
+++ b/web/i18n/locales/lo-LA/common.json
@@ -476,6 +476,8 @@
"operation.more": "ເພີ່ມເຕີມ",
"operation.moreActions": "ການດຳເນີນການເພີ່ມເຕີມ",
"operation.moreActionsFor": "ການດຳເນີນການເພີ່ມເຕີມສຳລັບ {{name}}",
+ "operation.moveDown": "ຍ້າຍລົງ",
+ "operation.moveUp": "ຍ້າຍຂຶ້ນ",
"operation.no": "ບໍ່",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "ບໍ່ພົບ {{content}}",
diff --git a/web/i18n/locales/nl-NL/common.json b/web/i18n/locales/nl-NL/common.json
index 03c9c83e0e7..5bc3eb7b68c 100644
--- a/web/i18n/locales/nl-NL/common.json
+++ b/web/i18n/locales/nl-NL/common.json
@@ -476,6 +476,8 @@
"operation.more": "More",
"operation.moreActions": "Meer acties",
"operation.moreActionsFor": "Meer acties voor {{name}}",
+ "operation.moveDown": "Omlaag verplaatsen",
+ "operation.moveUp": "Omhoog verplaatsen",
"operation.no": "No",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "No {{content}} were found",
diff --git a/web/i18n/locales/pl-PL/common.json b/web/i18n/locales/pl-PL/common.json
index 6172dcec0bb..4a12a71f9ee 100644
--- a/web/i18n/locales/pl-PL/common.json
+++ b/web/i18n/locales/pl-PL/common.json
@@ -476,6 +476,8 @@
"operation.more": "Więcej",
"operation.moreActions": "Więcej akcji",
"operation.moreActionsFor": "Więcej akcji dla {{name}}",
+ "operation.moveDown": "Przenieś w dół",
+ "operation.moveUp": "Przenieś w górę",
"operation.no": "Nie",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Nie znaleziono {{content}}",
diff --git a/web/i18n/locales/pt-BR/common.json b/web/i18n/locales/pt-BR/common.json
index 556a6d6ad0e..29dd09fdefd 100644
--- a/web/i18n/locales/pt-BR/common.json
+++ b/web/i18n/locales/pt-BR/common.json
@@ -476,6 +476,8 @@
"operation.more": "Mais",
"operation.moreActions": "Mais ações",
"operation.moreActionsFor": "Mais ações para {{name}}",
+ "operation.moveDown": "Mover para baixo",
+ "operation.moveUp": "Mover para cima",
"operation.no": "Não",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Nenhum {{content}} foi encontrado",
diff --git a/web/i18n/locales/ro-RO/common.json b/web/i18n/locales/ro-RO/common.json
index d89fa020a7a..2d5385dcb48 100644
--- a/web/i18n/locales/ro-RO/common.json
+++ b/web/i18n/locales/ro-RO/common.json
@@ -476,6 +476,8 @@
"operation.more": "Mai mult",
"operation.moreActions": "Mai multe acțiuni",
"operation.moreActionsFor": "Mai multe acțiuni pentru {{name}}",
+ "operation.moveDown": "Mută în jos",
+ "operation.moveUp": "Mută în sus",
"operation.no": "Nu",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Nu au fost găsite {{content}}",
diff --git a/web/i18n/locales/ru-RU/common.json b/web/i18n/locales/ru-RU/common.json
index 76bd9dccefc..08c952602fd 100644
--- a/web/i18n/locales/ru-RU/common.json
+++ b/web/i18n/locales/ru-RU/common.json
@@ -476,6 +476,8 @@
"operation.more": "Больше",
"operation.moreActions": "Дополнительные действия",
"operation.moreActionsFor": "Дополнительные действия для {{name}}",
+ "operation.moveDown": "Переместить вниз",
+ "operation.moveUp": "Переместить вверх",
"operation.no": "Нет",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Ничего {{content}} не найдено",
diff --git a/web/i18n/locales/sl-SI/common.json b/web/i18n/locales/sl-SI/common.json
index 13e6e2f0573..eac280ec899 100644
--- a/web/i18n/locales/sl-SI/common.json
+++ b/web/i18n/locales/sl-SI/common.json
@@ -476,6 +476,8 @@
"operation.more": "Več",
"operation.moreActions": "Več dejanj",
"operation.moreActionsFor": "Več dejanj za {{name}}",
+ "operation.moveDown": "Premakni navzdol",
+ "operation.moveUp": "Premakni navzgor",
"operation.no": "Ne",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Ni bilo najdenih {{content}}",
diff --git a/web/i18n/locales/th-TH/common.json b/web/i18n/locales/th-TH/common.json
index 308d4c19ce4..9c974b2a019 100644
--- a/web/i18n/locales/th-TH/common.json
+++ b/web/i18n/locales/th-TH/common.json
@@ -476,6 +476,8 @@
"operation.more": "มากขึ้น",
"operation.moreActions": "การดำเนินการเพิ่มเติม",
"operation.moreActionsFor": "การดำเนินการเพิ่มเติมสำหรับ {{name}}",
+ "operation.moveDown": "เลื่อนลง",
+ "operation.moveUp": "เลื่อนขึ้น",
"operation.no": "ไม่",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "ไม่พบ {{content}}",
diff --git a/web/i18n/locales/tr-TR/common.json b/web/i18n/locales/tr-TR/common.json
index 9cb07c67e63..4da7a22b49a 100644
--- a/web/i18n/locales/tr-TR/common.json
+++ b/web/i18n/locales/tr-TR/common.json
@@ -476,6 +476,8 @@
"operation.more": "Daha fazla",
"operation.moreActions": "Daha fazla işlem",
"operation.moreActionsFor": "{{name}} için daha fazla işlem",
+ "operation.moveDown": "Aşağı taşı",
+ "operation.moveUp": "Yukarı taşı",
"operation.no": "Hayır",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Hiç {{content}} bulunamadı",
diff --git a/web/i18n/locales/uk-UA/common.json b/web/i18n/locales/uk-UA/common.json
index aae88b62314..a1c8a8353a3 100644
--- a/web/i18n/locales/uk-UA/common.json
+++ b/web/i18n/locales/uk-UA/common.json
@@ -476,6 +476,8 @@
"operation.more": "Більше",
"operation.moreActions": "Більше дій",
"operation.moreActionsFor": "Більше дій для {{name}}",
+ "operation.moveDown": "Перемістити вниз",
+ "operation.moveUp": "Перемістити вгору",
"operation.no": "Ні",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Жодного {{content}} не знайдено",
diff --git a/web/i18n/locales/vi-VN/common.json b/web/i18n/locales/vi-VN/common.json
index 6e024c0f136..4dc23d0f672 100644
--- a/web/i18n/locales/vi-VN/common.json
+++ b/web/i18n/locales/vi-VN/common.json
@@ -476,6 +476,8 @@
"operation.more": "Hơn",
"operation.moreActions": "Thêm hành động",
"operation.moreActionsFor": "Thêm hành động cho {{name}}",
+ "operation.moveDown": "Di chuyển xuống",
+ "operation.moveUp": "Di chuyển lên",
"operation.no": "Không",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "Không tìm thấy {{content}} nào",
diff --git a/web/i18n/locales/zh-Hans/common.json b/web/i18n/locales/zh-Hans/common.json
index 2756dd5acd4..c9c2e94dbc7 100644
--- a/web/i18n/locales/zh-Hans/common.json
+++ b/web/i18n/locales/zh-Hans/common.json
@@ -476,6 +476,8 @@
"operation.more": "更多",
"operation.moreActions": "更多操作",
"operation.moreActionsFor": "{{name}} 的更多操作",
+ "operation.moveDown": "下移",
+ "operation.moveUp": "上移",
"operation.no": "否",
"operation.noSearchCount": "0 个 {{content}}",
"operation.noSearchResults": "没有找到{{content}}",
diff --git a/web/i18n/locales/zh-Hant/common.json b/web/i18n/locales/zh-Hant/common.json
index b813e993fb8..19e2a10e096 100644
--- a/web/i18n/locales/zh-Hant/common.json
+++ b/web/i18n/locales/zh-Hant/common.json
@@ -476,6 +476,8 @@
"operation.more": "更多",
"operation.moreActions": "更多操作",
"operation.moreActionsFor": "{{name}} 的更多操作",
+ "operation.moveDown": "下移",
+ "operation.moveUp": "上移",
"operation.no": "不",
"operation.noSearchCount": "0 {{content}}",
"operation.noSearchResults": "未找到 {{content}}",