refactor(core): Move execution save settings into lifecycle function (no-changelog) (#7370)

Move the handling of execution save settings into a tested lifecycle
function as discussed with Omar
This commit is contained in:
Iván Ovejero
2023-10-26 14:35:38 +02:00
committed by GitHub
parent 1055bd3762
commit 5477e3fb45
4 changed files with 98 additions and 48 deletions

View File

@@ -0,0 +1,20 @@
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 = {}) {
return {
error: workflowSettings.saveDataErrorExecution !== 'none' ?? DEFAULTS.ERROR !== 'none',
success: workflowSettings.saveDataSuccessExecution !== 'none' ?? DEFAULTS.SUCCESS !== 'none',
manual: workflowSettings?.saveManualExecutions ?? DEFAULTS.MANUAL,
};
}