-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Show actual execution data for production executions even if pin data exists #6302
Changes from 4 commits
fe06348
b5f62e9
2f40037
ef42bf9
80948a7
3c2e0ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||
import { shouldReplaceInputDataWithPinData } from '../workflowHelpers'; | ||||||
import { createTestingPinia } from '@pinia/testing'; | ||||||
import { useWorkflowsStore } from '@/stores'; | ||||||
|
||||||
let pinia: ReturnType<typeof createTestingPinia>; | ||||||
beforeAll(() => { | ||||||
pinia = createTestingPinia(); | ||||||
}); | ||||||
|
||||||
describe('workflowHelpers', () => { | ||||||
describe('shouldReplaceInputDataWithPinData', () => { | ||||||
beforeEach(() => { | ||||||
pinia.state.value = { | ||||||
workflows: useWorkflowsStore(), | ||||||
}; | ||||||
}); | ||||||
|
||||||
it('should return true if no active execution is set', () => { | ||||||
const result = shouldReplaceInputDataWithPinData(); | ||||||
expect(result).toBe(true); | ||||||
}); | ||||||
|
||||||
it('should return true if active execution is set and mode is manual', async () => { | ||||||
pinia.state.value.workflows.activeWorkflowExecution = { mode: 'manual' }; | ||||||
|
||||||
const result = shouldReplaceInputDataWithPinData(); | ||||||
expect(result).toBe(true); | ||||||
}); | ||||||
|
||||||
it('should return false if active execution is set and mode is not manual', async () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
pinia.state.value.workflows.activeWorkflowExecution = { mode: 'webhook' }; | ||||||
|
||||||
const result = shouldReplaceInputDataWithPinData(); | ||||||
expect(result).toBe(false); | ||||||
}); | ||||||
}); | ||||||
}); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -189,6 +189,15 @@ function getNodeTypes(): INodeTypes { | |||||
return useWorkflowsStore().getNodeTypes(); | ||||||
} | ||||||
|
||||||
export function shouldReplaceInputDataWithPinData() { | ||||||
const workflowsStore = useWorkflowsStore(); | ||||||
return ( | ||||||
!workflowsStore.activeWorkflowExecution || | ||||||
(workflowsStore.activeWorkflowExecution && | ||||||
workflowsStore.activeWorkflowExecution.mode === 'manual') | ||||||
); | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or shorter: export function shouldReplaceInputDataWithPinData() {
const { activeWorkflowExecution } = useWorkflowsStore();
return !activeWorkflowExecution || activeWorkflowExecution?.mode === 'manual';
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could make this a getter in the workflows store? To avoid adding to mixins. |
||||||
|
||||||
// Returns connectionInputData to be able to execute an expression. | ||||||
function connectionInputData( | ||||||
parentNode: string[], | ||||||
|
@@ -223,32 +232,36 @@ function connectionInputData( | |||||
} | ||||||
} | ||||||
|
||||||
const parentPinData = parentNode.reduce((acc: INodeExecutionData[], parentNodeName, index) => { | ||||||
const pinData = useWorkflowsStore().pinDataByNodeName(parentNodeName); | ||||||
const workflowsStore = useWorkflowsStore(); | ||||||
|
||||||
if (pinData) { | ||||||
acc.push({ | ||||||
json: pinData[0], | ||||||
pairedItem: { | ||||||
item: index, | ||||||
input: 1, | ||||||
}, | ||||||
}); | ||||||
} | ||||||
if (shouldReplaceInputDataWithPinData()) { | ||||||
const parentPinData = parentNode.reduce((acc: INodeExecutionData[], parentNodeName, index) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const pinData = workflowsStore.pinDataByNodeName(parentNodeName); | ||||||
|
||||||
return acc; | ||||||
}, []); | ||||||
if (pinData) { | ||||||
acc.push({ | ||||||
json: pinData[0], | ||||||
pairedItem: { | ||||||
item: index, | ||||||
input: 1, | ||||||
}, | ||||||
}); | ||||||
} | ||||||
|
||||||
if (parentPinData.length > 0) { | ||||||
if (connectionInputData && connectionInputData.length > 0) { | ||||||
parentPinData.forEach((parentPinDataEntry) => { | ||||||
connectionInputData![0].json = { | ||||||
...connectionInputData![0].json, | ||||||
...parentPinDataEntry.json, | ||||||
}; | ||||||
}); | ||||||
} else { | ||||||
connectionInputData = parentPinData; | ||||||
return acc; | ||||||
}, []); | ||||||
|
||||||
if (parentPinData.length > 0) { | ||||||
if (connectionInputData && connectionInputData.length > 0) { | ||||||
parentPinData.forEach((parentPinDataEntry) => { | ||||||
connectionInputData![0].json = { | ||||||
...connectionInputData![0].json, | ||||||
...parentPinDataEntry.json, | ||||||
}; | ||||||
}); | ||||||
} else { | ||||||
connectionInputData = parentPinData; | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -271,21 +284,24 @@ function executeData( | |||||
// Add the input data to be able to also resolve the short expression format | ||||||
// which does not use the node name | ||||||
const parentNodeName = parentNode[0]; | ||||||
const workflowsStore = useWorkflowsStore(); | ||||||
|
||||||
const parentPinData = useWorkflowsStore().getPinData![parentNodeName]; | ||||||
if (shouldReplaceInputDataWithPinData()) { | ||||||
const parentPinData = workflowsStore.getPinData![parentNodeName]; | ||||||
|
||||||
// populate `executeData` from `pinData` | ||||||
// populate `executeData` from `pinData` | ||||||
|
||||||
if (parentPinData) { | ||||||
executeData.data = { main: [parentPinData] }; | ||||||
executeData.source = { main: [{ previousNode: parentNodeName }] }; | ||||||
if (parentPinData) { | ||||||
executeData.data = { main: [parentPinData] }; | ||||||
executeData.source = { main: [{ previousNode: parentNodeName }] }; | ||||||
|
||||||
return executeData; | ||||||
return executeData; | ||||||
} | ||||||
} | ||||||
|
||||||
// populate `executeData` from `runData` | ||||||
|
||||||
const workflowRunData = useWorkflowsStore().getWorkflowRunData; | ||||||
const workflowRunData = workflowsStore.getWorkflowRunData; | ||||||
if (workflowRunData === null) { | ||||||
return executeData; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3604,6 +3604,8 @@ export default defineComponent({ | |||||
type: 'error', | ||||||
}); | ||||||
} | ||||||
} else if (json && json.command === 'setActiveExecution') { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.workflowsStore.activeWorkflowExecution = json.execution; | ||||||
} | ||||||
} catch (e) {} | ||||||
}, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.