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): restore app deletion autofill and knowledge scope label (#40583)

Crazywoola750fce7e5275
diff --git a/web/app/components/apps/__tests__/app-card.spec.tsx b/web/app/components/apps/__tests__/app-card.spec.tsx
index f6ad9d6e135..c243efa1ea8 100644
--- a/web/app/components/apps/__tests__/app-card.spec.tsx
+++ b/web/app/components/apps/__tests__/app-card.spec.tsx
@@ -1,5 +1,6 @@
import type { AppPartial } from '@dify/contracts/api/console/apps/types.gen'
import { fireEvent, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
import * as React from 'react'
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
import { AccessMode } from '@/models/access-control'
@@ -885,6 +886,24 @@ describe('AppCard', () => {
expect(await screen.findByRole('alertdialog')).toBeInTheDocument()
})
+ it('should autofill the app name for delete confirmation', async () => {
+ const user = userEvent.setup()
+ render(<AppCard app={mockApp} />)
+
+ await user.click(getOperationsTrigger())
+ await user.click(await screen.findByRole('menuitem', { name: 'common.operation.delete' }))
+
+ const deleteInput = await screen.findByRole('textbox')
+ const confirmButton = screen.getByRole('button', { name: 'common.operation.confirm' })
+
+ expect(confirmButton).toBeDisabled()
+
+ await user.click(screen.getByRole('button', { name: 'common.operation.fill' }))
+
+ expect(deleteInput).toHaveValue(mockApp.name)
+ expect(confirmButton).toBeEnabled()
+ })
+
it('should close confirm dialog when cancel is clicked', async () => {
render(<AppCard app={mockApp} />)
diff --git a/web/app/components/apps/app-card/action-bar/index.tsx b/web/app/components/apps/app-card/action-bar/index.tsx
index 396f668f4d1..e96a19e5ea7 100644
--- a/web/app/components/apps/app-card/action-bar/index.tsx
+++ b/web/app/components/apps/app-card/action-bar/index.tsx
@@ -516,15 +516,24 @@ export const AppCardActionBar = memo(
}}
/>
</FieldLabel>
- <FieldControl
- type="text"
- autoComplete="off"
- spellCheck={false}
- placeholder={t(($) => $.deleteAppConfirmInputPlaceholder, { ns: 'app' })}
- value={confirmDeleteInput}
- onValueChange={setConfirmDeleteInput}
- className="border-components-input-border-hover bg-components-input-bg-normal focus:border-components-input-border-active focus:bg-components-input-bg-active"
- />
+ <div className="relative">
+ <FieldControl
+ type="text"
+ autoComplete="off"
+ spellCheck={false}
+ placeholder={t(($) => $.deleteAppConfirmInputPlaceholder, { ns: 'app' })}
+ value={confirmDeleteInput}
+ onValueChange={setConfirmDeleteInput}
+ className="border-components-input-border-hover bg-components-input-bg-normal pr-20 focus:border-components-input-border-active focus:bg-components-input-bg-active"
+ />
+ <button
+ type="button"
+ onClick={() => setConfirmDeleteInput(app.name)}
+ className="absolute top-1/2 right-2 -translate-y-1/2 rounded-full bg-black/6 px-2.5 py-1 system-xs-medium text-text-secondary hover:bg-black/10 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ >
+ {t(($) => $['operation.fill'], { ns: 'common' })}
+ </button>
+ </div>
</Field>
</div>
<AlertDialogActions>
diff --git a/web/app/components/goto-anything/__tests__/index.spec.tsx b/web/app/components/goto-anything/__tests__/index.spec.tsx
index 55258a96cb5..573795cabbd 100644
--- a/web/app/components/goto-anything/__tests__/index.spec.tsx
+++ b/web/app/components/goto-anything/__tests__/index.spec.tsx
@@ -443,6 +443,23 @@ describe('GotoAnything', () => {
expect(input).toHaveValue('test query')
})
+ it('should show the localized description for the knowledge scope', async () => {
+ const user = userEvent.setup()
+ renderGotoAnything(<GotoAnything />)
+ triggerSearchShortcut()
+ const input = await screen.findByRole('combobox', {
+ name: 'app.gotoAnything.searchTitle',
+ })
+
+ await user.type(input, '@')
+
+ expect(
+ screen.getByRole('option', {
+ name: /@kb app\.gotoAnything\.actions\.searchKnowledgeBasesDesc/,
+ }),
+ ).toBeInTheDocument()
+ })
+
it('should not search providers with a stale scope prefix', async () => {
const user = userEvent.setup()
matchActionMock.mockImplementation((query: string) =>
diff --git a/web/app/components/goto-anything/index.tsx b/web/app/components/goto-anything/index.tsx
index d8284805fea..9d233a81f11 100644
--- a/web/app/components/goto-anything/index.tsx
+++ b/web/app/components/goto-anything/index.tsx
@@ -79,7 +79,7 @@ const slashCommandDescriptionKeys = {
const actionDescriptionKeys = {
'@app': 'gotoAnything.actions.searchApplicationsDesc',
'@plugin': 'gotoAnything.actions.searchPluginsDesc',
- '@knowledge': 'gotoAnything.actions.searchKnowledgeBasesDesc',
+ '@kb': 'gotoAnything.actions.searchKnowledgeBasesDesc',
'@node': 'gotoAnything.actions.searchWorkflowNodesDesc',
} as const