Skip to content

Commit 4dfe61d

Browse files
authored
refactor(web): remove success toasts for list changes and define toast types (#43832)
1 parent 5e56716 commit 4dfe61d

226 files changed

Lines changed: 45 additions & 535 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,21 @@ const AvatarWithEdit = (props: AvatarProps) => {
3737
try {
3838
await updateProfile({ body: { avatar: uploadedFileId } })
3939
setIsShowAvatarPicker(false)
40-
toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))
4140
} catch (e) {
4241
toast.error((e as Error).message)
4342
}
4443
},
45-
[t, updateProfile],
44+
[updateProfile],
4645
)
4746

4847
const handleDeleteAvatar = useCallback(async () => {
4948
try {
5049
await updateProfile({ body: { avatar: '' } })
51-
toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))
5250
setIsShowDeleteConfirm(false)
5351
} catch (e) {
5452
toast.error((e as Error).message)
5553
}
56-
}, [t, updateProfile])
54+
}, [updateProfile])
5755

5856
const handleDeleteAvatarClick = useCallback(() => {
5957
setIsShowAvatarPicker(false)

‎web/app/components/app/create-app-modal/__tests__/index.spec.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const mockUseRouter = vi.mocked(useRouter)
9797
const mockPush = vi.fn()
9898
const mockTrackCreateApp = vi.mocked(trackCreateApp)
9999
const mockGetRedirection = vi.mocked(getRedirection)
100-
const { mockToastSuccess, mockToastError } = toastMocks
100+
const { mockToastError } = toastMocks
101101

102102
let appQuota = { size: 0, limit: 1 }
103103

@@ -136,7 +136,7 @@ describe('CreateAppModal', () => {
136136
mockConsoleState.workspacePermissionKeys = ['app.create_and_management']
137137
})
138138

139-
it('creates an app, notifies success, and fires callbacks', async () => {
139+
it('creates an app and fires callbacks', async () => {
140140
const mockApp = createAppDetailFixture({
141141
mode: AppModeEnum.ADVANCED_CHAT,
142142
maintainer: 'user-1',
@@ -163,7 +163,6 @@ describe('CreateAppModal', () => {
163163
source: 'studio_blank',
164164
appMode: AppModeEnum.ADVANCED_CHAT,
165165
})
166-
expect(mockToastSuccess).toHaveBeenCalledWith('app.newApp.appCreated')
167166
expect(onClose).toHaveBeenCalledTimes(1)
168167
await waitFor(() =>
169168
expect(mockGetRedirection).toHaveBeenCalledWith(mockApp, mockPush, {
@@ -419,7 +418,7 @@ describe('CreateAppModal', () => {
419418

420419
resolveCreate?.(createAppDetailFixture({ id: 'slow-app', mode: AppModeEnum.ADVANCED_CHAT }))
421420
await waitFor(() => {
422-
expect(mockToastSuccess).toHaveBeenCalledWith('app.newApp.appCreated')
421+
expect(mockGetRedirection).toHaveBeenCalledTimes(1)
423422
})
424423
})
425424
})

‎web/app/components/app/create-app-modal/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ function CreateApp({ onClose, onCreateFromTemplate, defaultAppMode }: CreateAppP
133133
// Analytics should not turn a successful app creation into a failed flow.
134134
}
135135

136-
toast.success(t(($) => $['newApp.appCreated'], { ns: 'app' }))
137136
onClose()
138137
getRedirection(app, push, {
139138
currentUserId,

‎web/app/components/app/switch-app-modal/__tests__/index.spec.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ describe('SwitchAppModal', () => {
247247
it('should switch app and navigate with push when keeping original', async () => {
248248
const user = userEvent.setup()
249249
// Arrange
250-
const { appDetail, notify, onClose } = renderComponent()
250+
const { appDetail, onClose } = renderComponent()
251251
mockConvertToWorkflow.mockResolvedValueOnce({
252252
new_app_id: 'new-app-001',
253253
permission_keys: ['app.acl.view_layout'],
@@ -268,7 +268,6 @@ describe('SwitchAppModal', () => {
268268
},
269269
})
270270
expect(onClose).toHaveBeenCalledTimes(1)
271-
expect(notify).toHaveBeenCalledWith({ type: 'success', message: 'app.newApp.appCreated' })
272271
expect(mockPush).toHaveBeenCalledWith('/app/new-app-001/workflow')
273272
expect(mockReplace).not.toHaveBeenCalled()
274273
})

‎web/app/components/app/switch-app-modal/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ const SwitchAppModal = ({ show, sourceApp, onClose }: SwitchAppModalProps) => {
9898
},
9999
})
100100
onClose()
101-
toast.success(t(($) => $['newApp.appCreated'], { ns: 'app' }))
102101
if (removeOriginal)
103102
await deleteOriginalApp({
104103
params: { app_id: sourceApp.id },

‎web/app/components/apps/app-card/interactions.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ export function AppCardInteractions({
323323
{ params: { app_id: app.id } },
324324
{
325325
onSuccess: () => {
326-
toast.success(t(($) => $.appDeleted, { ns: 'app' }))
327326
setActiveDialog(null)
328327
setConfirmDeleteInput('')
329328
},
@@ -453,7 +452,6 @@ export function AppCardInteractions({
453452
}
454453

455454
setActiveDialog(null)
456-
toast.success(t(($) => $['newApp.appCreated'], { ns: 'app' }))
457455
getRedirection(newApp, push, {
458456
currentUserId,
459457
resourceMaintainer: newApp.maintainer ?? undefined,

‎web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,6 @@ describe('useChildSegmentData', () => {
327327
})
328328

329329
expect(mockUpdateChildSegment).toHaveBeenCalled()
330-
expect(mockNotify).toHaveBeenCalledWith({
331-
type: 'success',
332-
message: 'common.actionMsg.modifiedSuccessfully',
333-
})
334330
expect(onCloseChildSegmentDetail).toHaveBeenCalled()
335331
expect(updateSegmentInCache).toHaveBeenCalled()
336332
expect(refreshChunkListDataWithDetailChanged).toHaveBeenCalled()

‎web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export const useChildSegmentData = (
174174
{ datasetId, documentId, segmentId: segmentIdParam, childChunkId, body: params },
175175
{
176176
onSuccess: (res) => {
177-
toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))
178177
onCloseChildSegmentDetail()
179178
if (parentMode === 'paragraph') {
180179
// Update parent segment's child_chunks in cache

‎web/app/components/datasets/external-api/external-api-modal/__tests__/index.spec.tsx‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ describe('AddExternalAPIModal', () => {
190190
settings: { endpoint: 'https://test.com', api_key: 'key12345' },
191191
},
192192
})
193-
expect(mockNotify).toHaveBeenCalledWith({
194-
type: 'success',
195-
message: 'External API saved successfully',
196-
})
197193
expect(onSave).toHaveBeenCalledWith(mockResponse)
198194
expect(onCancel).toHaveBeenCalled()
199195
})
@@ -335,10 +331,6 @@ describe('AddExternalAPIModal', () => {
335331

336332
const confirmButton = screen.getByRole('button', { name: /confirm/i })
337333
fireEvent.click(confirmButton)
338-
339-
await waitFor(() => {
340-
expect(mockNotify).toHaveBeenCalledWith(expect.objectContaining({ type: 'success' }))
341-
})
342334
})
343335

344336
it('should close confirm dialog when cancel is clicked', async () => {

‎web/app/components/datasets/external-api/external-api-modal/index.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,9 @@ const AddExternalAPIModal: FC<AddExternalAPIModalProps> = ({
106106
...formData,
107107
settings: { ...formData.settings, api_key: apiKeyToSend },
108108
})
109-
toast.success('External API updated successfully')
110109
} else {
111110
const res = await createExternalAPI({ body: formData })
112-
if (res && res.id) {
113-
toast.success('External API saved successfully')
114-
onSave(res)
115-
}
111+
if (res && res.id) onSave(res)
116112
}
117113
onCancel()
118114
} catch (error) {

0 commit comments

Comments
 (0)