fix(core): Comply with custom default for workflow saving settings (#7634)

https://linear.app/n8n/issue/PAY-982
This commit is contained in:
Iván Ovejero
2023-11-07 16:26:55 +01:00
committed by GitHub
parent ac877014ed
commit 48c068f97b
2 changed files with 86 additions and 29 deletions

View File

@@ -1,20 +1,24 @@
import config from '@/config';
import type { IWorkflowSettings } from 'n8n-workflow';
const DEFAULTS = {
ERROR: config.getEnv('executions.saveDataOnError'),
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
MANUAL: config.getEnv('executions.saveDataManualExecutions'),
};
/**
* Return whether a workflow execution is configured to be saved or not,
* for error executions, success executions, and manual executions.
*/
export function toSaveSettings(workflowSettings: IWorkflowSettings = {}) {
const DEFAULTS = {
ERROR: config.getEnv('executions.saveDataOnError'),
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
MANUAL: config.getEnv('executions.saveDataManualExecutions'),
};
return {
error: workflowSettings.saveDataErrorExecution !== 'none' ?? DEFAULTS.ERROR !== 'none',
success: workflowSettings.saveDataSuccessExecution !== 'none' ?? DEFAULTS.SUCCESS !== 'none',
error: workflowSettings.saveDataErrorExecution
? workflowSettings.saveDataErrorExecution !== 'none'
: DEFAULTS.ERROR !== 'none',
success: workflowSettings.saveDataSuccessExecution
? workflowSettings.saveDataSuccessExecution !== 'none'
: DEFAULTS.SUCCESS !== 'none',
manual: workflowSettings?.saveManualExecutions ?? DEFAULTS.MANUAL,
};
}