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(web): name external API panel close (#40309)

yyhb3b3088a174d
diff --git a/web/app/components/datasets/external-api/external-api-panel/__tests__/index.spec.tsx b/web/app/components/datasets/external-api/external-api-panel/__tests__/index.spec.tsx
index e9bbbf1a503..29875defb61 100644
--- a/web/app/components/datasets/external-api/external-api-panel/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/external-api/external-api-panel/__tests__/index.spec.tsx
@@ -105,10 +105,8 @@ describe('ExternalAPIPanel', () => {
})
it('should render close button', () => {
- const { container } = render(<ExternalAPIPanel {...defaultProps} />)
- const closeButton =
- container.querySelector('[class*="action-button"]') || screen.getAllByRole('button')[0]
- expect(closeButton)!.toBeInTheDocument()
+ render(<ExternalAPIPanel {...defaultProps} />)
+ expect(screen.getByRole('button', { name: 'common.operation.close' })).toBeInTheDocument()
})
})
@@ -171,11 +169,7 @@ describe('ExternalAPIPanel', () => {
it('should call onClose when close button is clicked', () => {
const onClose = vi.fn()
render(<ExternalAPIPanel canManageExternalKnowledgeApi={true} onClose={onClose} />)
- // Find the close button (ActionButton with close icon)
- const buttons = screen.getAllByRole('button')
- const closeButton =
- buttons.find((btn) => btn.querySelector('svg[class*="ri-close"]')) || buttons[0]
- fireEvent.click(closeButton!)
+ fireEvent.click(screen.getByRole('button', { name: 'common.operation.close' }))
expect(onClose).toHaveBeenCalledTimes(1)
})
diff --git a/web/app/components/datasets/external-api/external-api-panel/index.tsx b/web/app/components/datasets/external-api/external-api-panel/index.tsx
index 35297cb9aad..6d7fc4dbce0 100644
--- a/web/app/components/datasets/external-api/external-api-panel/index.tsx
+++ b/web/app/components/datasets/external-api/external-api-panel/index.tsx
@@ -71,8 +71,11 @@ const ExternalAPIPanel: React.FC<ExternalAPIPanelProps> = ({
</a>
</div>
<div className="flex items-center">
- <ActionButton onClick={() => onClose()}>
- <RiCloseLine className="size-4 text-text-tertiary" />
+ <ActionButton
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ onClick={() => onClose()}
+ >
+ <RiCloseLine aria-hidden className="size-4 text-text-tertiary" />
</ActionButton>
</div>
</div>