mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-01 15:47:41 +08:00
fix(editor): Dismiss archive toast immediately after permanent delete (#35207)
This commit is contained in:
@@ -64,7 +64,7 @@ vi.mock('@/app/stores/pushConnection.store', () => ({
|
||||
vi.mock('@/app/composables/useToast', () => {
|
||||
const showError = vi.fn();
|
||||
const showMessage = vi.fn();
|
||||
const showToast = vi.fn();
|
||||
const showToast = vi.fn(() => ({ close: vi.fn() }));
|
||||
return {
|
||||
useToast: () => ({
|
||||
showError,
|
||||
@@ -600,6 +600,7 @@ describe('WorkflowDetails', () => {
|
||||
await userEvent.click(getByTestId('workflow-menu-item-archive'));
|
||||
|
||||
expect(toast.showToast).toHaveBeenCalledTimes(1);
|
||||
const archiveToast = vi.mocked(toast.showToast).mock.results[0].value;
|
||||
const toastConfig = vi.mocked(toast.showToast).mock.calls[0][0];
|
||||
expect(toastConfig.message).toContain('archive-toast-delete-permanently-link');
|
||||
expect(toastConfig.onClick).toBeDefined();
|
||||
@@ -611,6 +612,8 @@ describe('WorkflowDetails', () => {
|
||||
expect(workflowsListStore.deleteWorkflow).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
expect(workflowsListStore.deleteWorkflow).toHaveBeenCalledWith(workflow.id);
|
||||
// Archive toast is dismissed immediately so its stale CTA doesn't linger.
|
||||
expect(archiveToast.close).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should call onWorkflowMenuSelect on 'Unarchive' option click", async () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useInjectWorkflowId } from '@/app/composables/useInjectWorkflowId';
|
||||
import { useMessage } from '@/app/composables/useMessage';
|
||||
import { useTelemetry } from '@n8n/composables/useTelemetry';
|
||||
import { useToast } from '@/app/composables/useToast';
|
||||
import type { NotificationHandle } from '@n8n/composables/useToast';
|
||||
import { nodeViewEventBus } from '@/app/event-bus';
|
||||
import type { IWorkflowDb } from '@/Interface';
|
||||
import type { FolderShortInfo } from '@/features/core/folders/folders.types';
|
||||
@@ -258,7 +259,7 @@ async function handleArchiveWorkflow() {
|
||||
uiStore.markStateClean();
|
||||
const archivedWorkflowId = props.id;
|
||||
const archivedWorkflowName = props.name;
|
||||
toast.showToast({
|
||||
const archiveToast = toast.showToast({
|
||||
title: locale.baseText('mainSidebar.showMessage.handleArchive.title', {
|
||||
interpolate: { workflowName: archivedWorkflowName },
|
||||
}),
|
||||
@@ -266,7 +267,7 @@ async function handleArchiveWorkflow() {
|
||||
onClick: (event) => {
|
||||
if (event?.target instanceof HTMLAnchorElement) {
|
||||
event.preventDefault();
|
||||
void deleteArchivedWorkflow(archivedWorkflowId, archivedWorkflowName);
|
||||
void deleteArchivedWorkflow(archivedWorkflowId, archivedWorkflowName, archiveToast);
|
||||
}
|
||||
},
|
||||
type: 'success',
|
||||
@@ -284,7 +285,11 @@ async function handleArchiveWorkflow() {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteArchivedWorkflow(id: IWorkflowDb['id'], name: IWorkflowDb['name']) {
|
||||
async function deleteArchivedWorkflow(
|
||||
id: IWorkflowDb['id'],
|
||||
name: IWorkflowDb['name'],
|
||||
archiveToast: NotificationHandle,
|
||||
) {
|
||||
const deleteConfirmed = await message.confirm(
|
||||
locale.baseText('mainSidebar.confirmMessage.workflowDelete.message', {
|
||||
interpolate: { workflowName: name },
|
||||
@@ -312,6 +317,10 @@ async function deleteArchivedWorkflow(id: IWorkflowDb['id'], name: IWorkflowDb['
|
||||
return;
|
||||
}
|
||||
|
||||
// Dismiss the archive toast so its now-stale 'Delete permanently' CTA
|
||||
// disappears immediately instead of lingering until its duration elapses.
|
||||
archiveToast.close();
|
||||
|
||||
toast.showMessage({
|
||||
title: locale.baseText('mainSidebar.showMessage.handleSelect1.title', {
|
||||
interpolate: { workflowName: name },
|
||||
|
||||
Reference in New Issue
Block a user