feat(editor): Add template Id to workflow metadata (#8088)

## Summary
Adding a link between the workflow and the template it originated from
by saving `templateId` in the workflow metadata

## Related tickets and issues
ADO-1537

## Review / Merge checklist
- [x] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [x] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.
This commit is contained in:
Milorad FIlipović
2023-12-22 15:07:05 +01:00
committed by GitHub
parent c83d9f45ba
commit 517b050d0a
7 changed files with 48 additions and 5 deletions

View File

@@ -1064,6 +1064,7 @@ export default defineComponent({
await this.addNodes(data.workflow.nodes, data.workflow.connections);
this.workflowData = (await this.workflowsStore.getNewWorkflowData(data.name)) || {};
this.workflowsStore.addToWorkflowMetadata({ templateId });
await this.$nextTick();
this.canvasStore.zoomToFit();
this.uiStore.stateIsDirty = true;
@@ -1089,6 +1090,7 @@ export default defineComponent({
this.workflowsStore.setWorkflowSettings(workflow.settings || {});
this.workflowsStore.setWorkflowPinData(workflow.pinData || {});
this.workflowsStore.setWorkflowVersionId(workflow.versionId);
this.workflowsStore.setWorkflowMetadata(workflow.meta);
if (workflow.ownedBy) {
this.workflowsEEStore.setWorkflowOwnedBy({
@@ -1585,6 +1587,7 @@ export default defineComponent({
void this.getNodesToSave(nodes).then((data) => {
const workflowToCopy: IWorkflowToShare = {
meta: {
...(this.workflowsStore.workflow.meta ?? {}),
instanceId: this.rootStore.instanceId,
},
...data,