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 prompt generator action (#40328)

yyh83987b8eec5a
diff --git a/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx b/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx
new file mode 100644
index 00000000000..b91a0c1c835
--- /dev/null
+++ b/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx
@@ -0,0 +1,23 @@
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import PromptGeneratorBtn from '../prompt-generator-btn'
+
+vi.mock('@/app/components/app/configuration/config/automatic/get-automatic-res', () => ({
+ default: () => <div role="dialog" aria-label="prompt generator" />,
+}))
+
+vi.mock('@/app/components/workflow/hooks-store', () => ({
+ useHooksStore: (selector: (state: { configsMap: { flowId: string } }) => unknown) =>
+ selector({ configsMap: { flowId: 'flow-1' } }),
+}))
+
+describe('PromptGeneratorBtn', () => {
+ it('should open the prompt generator from the named action', async () => {
+ const user = userEvent.setup()
+ render(<PromptGeneratorBtn nodeId="node-1" />)
+
+ await user.click(screen.getByRole('button', { name: 'appDebug.operation.automatic' }))
+
+ expect(screen.getByRole('dialog', { name: 'prompt generator' })).toBeInTheDocument()
+ })
+})
diff --git a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
index 4068921793e..138bbb00dc6 100644
--- a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
+++ b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
@@ -5,6 +5,7 @@ import type { GenRes } from '@/service/debug'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useCallback, useState } from 'react'
+import { useTranslation } from 'react-i18next'
import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'
import { ActionButton } from '@/app/components/base/action-button'
import { Generator } from '@/app/components/base/icons/src/vender/other'
@@ -27,6 +28,7 @@ const PromptGeneratorBtn: FC<Props> = ({
editorId,
currentPrompt,
}) => {
+ const { t } = useTranslation()
const [showAutomatic, setShowAutomatic] = useState(false)
const handleAutomaticRes = useCallback(
(res: GenRes) => {
@@ -38,8 +40,12 @@ const PromptGeneratorBtn: FC<Props> = ({
const configsMap = useHooksStore((s) => s.configsMap)
return (
<div className={cn(className)}>
- <ActionButton className="hover:bg-[#155EFF]/8" onClick={() => setShowAutomatic(true)}>
- <Generator className="size-4 text-primary-600" />
+ <ActionButton
+ aria-label={t(($) => $['operation.automatic'], { ns: 'appDebug' })}
+ className="hover:bg-[#155EFF]/8"
+ onClick={() => setShowAutomatic(true)}
+ >
+ <Generator aria-hidden className="size-4 text-primary-600" />
</ActionButton>
{showAutomatic && (
<GetAutomaticResModal