Skip to content
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

feat(core): Allow transferring workflows from any project to any team project #9534

Merged
merged 12 commits into from
Jun 3, 2024

Conversation

despairblue
Copy link
Contributor

@despairblue despairblue commented May 29, 2024

Summary

This allows transferring workflows from any personal or team project to any other team project.

The user needs to have the permissions/scopes of workflow:move for the workflow and workflow:create for the destination project.

Workflows cannot be moved into their current home project.
Workflows cannot be moved into any personal project.
Workflows can only be moved out of personal and team projects. (For now there are only personal and team projects, but there are plans for other kinds of projects.)

Related tickets and issues

https://www.notion.so/n8n/Move-resources-workflow-credentials-between-projects-e737365c6ff446ce9e396df03e7a1255
https://linear.app/n8n/issue/DOC-886/feature-transfer-workflows-and-credentials-from-project-to-project
https://linear.app/n8n/issue/PAY-1428/move-resources-between-projects

Review / Merge checklist

  • PR title and summary are descriptive. Remember, the title automatically goes into the changelog. Use (no-changelog) otherwise. (conventions)
  • 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.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels May 29, 2024
Comment on lines +250 to +253
NotFoundError.isDefinedAndNotNull(
workflow,
`Could not find workflow with the id "${workflowId}". Make sure you have the permission to delete it.`,
);
Copy link
Contributor Author

@despairblue despairblue May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find type guards / assertion functions easier to read than conditional logic and creating an error.

But I don't feel strongly about it, so it's up for debate.

@Put('/:workflowId/transfer')
@Licensed('feat:advancedPermissions')
async transfer(req: WorkflowRequest.Transfer) {
const body = z.object({ toProject: z.string() }).parse(req.body);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also happy to use just typeof here and wait until we have a proper proposal for input validation.

Comment on lines -40 to -41
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON?(): any {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we have to disable the return type inference here.

@StarfallProjects
Copy link
Contributor

@despairblue this one probably needs docs - can you create a ticket and link relevant info/dev tickets etc.

@@ -460,4 +470,16 @@ export class WorkflowsController {
workflow,
});
}

@Put('/:workflowId/transfer')
@Licensed('feat:advancedPermissions')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure about this, we've put lots of other endpoints behind the admin feature flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was decided that this endpoint is not behind a license flag.

@despairblue
Copy link
Contributor Author

@despairblue this one probably needs docs - can you create a ticket and link relevant info/dev tickets etc.

For now this is only the internal API side. But I can create a doc ticket and link the notion page with the mock-ups, sure thing!

@despairblue despairblue marked this pull request as ready for review May 30, 2024 10:08
@despairblue despairblue force-pushed the transfer-workflows branch 2 times, most recently from abfbe78 to fa87bac Compare May 31, 2024 08:04
krynble
krynble previously approved these changes Jun 3, 2024
Copy link
Contributor

github-actions bot commented Jun 3, 2024

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link

cypress bot commented Jun 3, 2024

1 flaky test on run #5290 ↗︎

0 362 0 0 Flakiness 1

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 despairblue 🗃️ e2e/*
Project: n8n Commit: 81ad4d374e
Status: Passed Duration: 04:42 💡
Started: Jun 3, 2024 2:48 PM Ended: Jun 3, 2024 2:53 PM
Flakiness  cypress/e2e/5-ndv.cy.ts • 1 flaky test

View Output Video

Test Artifacts
NDV > should not retrieve remote options when required params throw errors Screenshots Video

Review all test suite changes for PR #9534 ↗︎

Copy link
Contributor

github-actions bot commented Jun 3, 2024

✅ All Cypress E2E specs passed

@despairblue despairblue merged commit d6db8cb into master Jun 3, 2024
28 checks passed
@despairblue despairblue deleted the transfer-workflows branch June 3, 2024 14:57
@github-actions github-actions bot mentioned this pull request Jun 5, 2024
@janober
Copy link
Member

janober commented Jun 5, 2024

Got released with n8n@1.45.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants