mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
feat(editor): Don't confirm archiving nonactive workflows (no-changelog) (#15182)
This commit is contained in:
@@ -298,10 +298,38 @@ describe('WorkflowDetails', () => {
|
||||
expect(queryByTestId('workflow-menu-item-unarchive')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should call onWorkflowMenuSelect on 'Archive' option click", async () => {
|
||||
it("should call onWorkflowMenuSelect on 'Archive' option click on nonactive workflow", async () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
props: {
|
||||
...workflow,
|
||||
active: false,
|
||||
readOnly: false,
|
||||
isArchived: false,
|
||||
scopes: ['workflow:delete'],
|
||||
},
|
||||
});
|
||||
|
||||
workflowsStore.archiveWorkflow.mockResolvedValue(undefined);
|
||||
|
||||
await userEvent.click(getByTestId('workflow-menu'));
|
||||
await userEvent.click(getByTestId('workflow-menu-item-archive'));
|
||||
|
||||
expect(message.confirm).toHaveBeenCalledTimes(0);
|
||||
expect(toast.showError).toHaveBeenCalledTimes(0);
|
||||
expect(toast.showMessage).toHaveBeenCalledTimes(1);
|
||||
expect(workflowsStore.archiveWorkflow).toHaveBeenCalledTimes(1);
|
||||
expect(workflowsStore.archiveWorkflow).toHaveBeenCalledWith(workflow.id);
|
||||
expect(router.push).toHaveBeenCalledTimes(1);
|
||||
expect(router.push).toHaveBeenCalledWith({
|
||||
name: VIEWS.WORKFLOWS,
|
||||
});
|
||||
});
|
||||
|
||||
it("should confirm onWorkflowMenuSelect on 'Archive' option click on active workflow", async () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
props: {
|
||||
...workflow,
|
||||
active: true,
|
||||
readOnly: false,
|
||||
isArchived: false,
|
||||
scopes: ['workflow:delete'],
|
||||
|
||||
@@ -535,24 +535,26 @@ async function onWorkflowMenuSelect(action: WORKFLOW_MENU_ACTIONS): Promise<void
|
||||
break;
|
||||
}
|
||||
case WORKFLOW_MENU_ACTIONS.ARCHIVE: {
|
||||
const archiveConfirmed = await message.confirm(
|
||||
locale.baseText('mainSidebar.confirmMessage.workflowArchive.message', {
|
||||
interpolate: { workflowName: props.name },
|
||||
}),
|
||||
locale.baseText('mainSidebar.confirmMessage.workflowArchive.headline'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: locale.baseText(
|
||||
'mainSidebar.confirmMessage.workflowArchive.confirmButtonText',
|
||||
),
|
||||
cancelButtonText: locale.baseText(
|
||||
'mainSidebar.confirmMessage.workflowArchive.cancelButtonText',
|
||||
),
|
||||
},
|
||||
);
|
||||
if (props.active) {
|
||||
const archiveConfirmed = await message.confirm(
|
||||
locale.baseText('mainSidebar.confirmMessage.workflowArchive.message', {
|
||||
interpolate: { workflowName: props.name },
|
||||
}),
|
||||
locale.baseText('mainSidebar.confirmMessage.workflowArchive.headline'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: locale.baseText(
|
||||
'mainSidebar.confirmMessage.workflowArchive.confirmButtonText',
|
||||
),
|
||||
cancelButtonText: locale.baseText(
|
||||
'mainSidebar.confirmMessage.workflowArchive.cancelButtonText',
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
if (archiveConfirmed !== MODAL_CONFIRM) {
|
||||
return;
|
||||
if (archiveConfirmed !== MODAL_CONFIRM) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user