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): remove redundant tag deletion success toast (#44754)

okhtd94125d94c20
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index d3838c5c3d9..732e02a5867 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -7136,9 +7136,6 @@
}
},
"web/features/tag-management/components/tag-item-editor.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 2
- },
"jsx-a11y/no-autofocus": {
"count": 1
}
diff --git a/web/features/tag-management/__tests__/tag-item-editor.spec.tsx b/web/features/tag-management/__tests__/tag-item-editor.spec.tsx
index 8d9280a19cb..6eff1afa1fc 100644
--- a/web/features/tag-management/__tests__/tag-item-editor.spec.tsx
+++ b/web/features/tag-management/__tests__/tag-item-editor.spec.tsx
@@ -4,6 +4,8 @@ import userEvent from '@testing-library/user-event'
import { createQueryClientWrapper } from '@/test/console/query-client'
import { createTestQueryClient } from '@/test/query-client'
import { TagItemEditor } from '../components/tag-item-editor'
+import { TagManagementModal } from '../components/tag-management-modal'
+import { renderWithTags } from './render'
const tagMocks = vi.hoisted(() => {
const record = vi.fn()
@@ -50,6 +52,13 @@ vi.mock('@/app/notifications', () => ({
toast: tagMocks.api,
}))
+vi.mock('@/context/permission-state', async () => {
+ const { createPermissionStateModuleMock } = await import('@/test/console/state-fixture')
+ return createPermissionStateModuleMock(() => ({
+ workspacePermissionKeys: ['app.tag.manage'],
+ }))
+})
+
const baseTag: Tag = {
id: 'tag-1',
name: 'Frontend',
@@ -66,6 +75,12 @@ const i18n = {
const render = (ui: Parameters<typeof renderComponent>[0]) =>
renderComponent(ui, { wrapper: createQueryClientWrapper(createTestQueryClient()) })
+const renderManagementModal = () =>
+ renderWithTags(<TagManagementModal type="app" show onClose={vi.fn()} />, [
+ { ...baseTag, binding_count: '' },
+ { ...baseTag, id: 'tag-2', name: 'Backend', binding_count: '' },
+ ])
+
describe('TagItemEditor', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -172,10 +187,9 @@ describe('TagItemEditor', () => {
// Remove behavior for direct delete and confirm modal paths.
describe('Remove Flow', () => {
- it('should delete immediately when binding count is zero', async () => {
+ it('removes an unbound tag from the list without a success toast', async () => {
const user = userEvent.setup()
- const removableTag: Tag = { ...baseTag, binding_count: '' }
- render(<TagItemEditor tag={removableTag} />)
+ renderManagementModal()
const removeButton = screen.getByRole('button', { name: i18n.removeTag })
expect(removeButton).toBeInTheDocument()
@@ -184,12 +198,9 @@ describe('TagItemEditor', () => {
await waitFor(() => {
expect(tagMocks.deleteTag).toHaveBeenCalledWith({ params: { tag_id: 'tag-1' } })
})
- await waitFor(() =>
- expect(tagMocks.record).toHaveBeenCalledWith({
- type: 'success',
- message: 'common.actionMsg.modifiedSuccessfully',
- }),
- )
+ await waitFor(() => expect(screen.queryByText('Frontend')).not.toBeInTheDocument())
+ expect(screen.getByText('Backend')).toBeInTheDocument()
+ expect(tagMocks.api.success).not.toHaveBeenCalled()
})
it('does not send another delete while the first request is pending', async () => {
@@ -266,8 +277,7 @@ describe('TagItemEditor', () => {
it('should notify error and keep tag when delete request fails', async () => {
const user = userEvent.setup()
vi.mocked(tagMocks.deleteTag).mockRejectedValueOnce(new Error('delete failed'))
- const removableTag: Tag = { ...baseTag, binding_count: '' }
- render(<TagItemEditor tag={removableTag} />)
+ renderManagementModal()
const removeButton = screen.getByRole('button', { name: i18n.removeTag })
await user.click(removeButton)
@@ -281,6 +291,9 @@ describe('TagItemEditor', () => {
message: 'common.actionMsg.modifiedUnsuccessfully',
}),
)
+ expect(screen.getByText('Frontend')).toBeInTheDocument()
+ expect(screen.getByText('Backend')).toBeInTheDocument()
+ expect(tagMocks.api.success).not.toHaveBeenCalled()
})
})
})
diff --git a/web/features/tag-management/components/tag-item-editor.tsx b/web/features/tag-management/components/tag-item-editor.tsx
index b3667f0b0f4..a350a2dd7ed 100644
--- a/web/features/tag-management/components/tag-item-editor.tsx
+++ b/web/features/tag-management/components/tag-item-editor.tsx
@@ -71,7 +71,6 @@ export const TagItemEditor = ({ tag, onTagsChange }: TagItemEditorProps) => {
},
{
onSuccess: () => {
- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))
onTagsChange?.()
},
onError: () => {
@@ -90,7 +89,7 @@ export const TagItemEditor = ({ tag, onTagsChange }: TagItemEditorProps) => {
<>
<div
className={cn(
- 'flex shrink-0 items-center gap-0.5 rounded-lg border border-components-panel-border py-1 pr-1 pl-2 text-sm/5 text-text-secondary',
+ 'flex shrink-0 items-center gap-0.5 rounded-lg border border-components-panel-border py-1 ps-2 pe-1 text-sm/5 text-text-secondary',
)}
>
{!isEditing && (