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 filtering workflows by project and transferring workflows in Public API #10231

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Jul 29, 2024

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jul 29, 2024
@ivov ivov marked this pull request as ready for review July 30, 2024 09:58
if ((projectId && !role) || (!projectId && role)) {
return res.status(400).json({
message:
'When creating a workflow and specifying s project, please specify both projectId and role',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'When creating a workflow and specifying s project, please specify both projectId and role',
'When creating a workflow and specifying a project, please specify both projectId and role',

Comment on lines 214 to 220
const { projectId, role, ...rest } = req.body;

if ((projectId && !role) || (!projectId && role)) {
return res.status(400).json({
message: "When updating a workflow's project, please specify both projectId and role",
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Transferring workflows should probably be it's own endpoint

Comment on lines 104 to 107
return await Db.transaction(async (tx) => {
await tx.update(WorkflowEntity, workflowId, updateData);
await tx.update(SharedWorkflow, { workflowId }, { projectId, role });
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably call EnterpriseWorkflowService.transferOne, since more things need done to transfer a workflow

Comment on lines 62 to 73
const projectRepository = Container.get(ProjectRepository);

const project = projectId
? await projectRepository.getProjectForUserOrFail(projectId, userId)
: await projectRepository.getPersonalProjectForUserOrFail(userId);

const createdWorkflow = await createWorkflow(
workflow,
req.user,
project,
role ?? 'workflow:owner',
);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check the user's scopes on the project for workflow:create first

@ivov ivov changed the title feat(core): Add project-related params to Public API workflows endpoints feat(core): Allow filtering workflows by project and transferring workflows in Public API Jul 30, 2024
@ivov ivov requested a review from valya July 30, 2024 14:25
Copy link

cypress bot commented Jul 30, 2024



Test summary

389 0 0 0Flakiness 0


Run details

Project n8n
Status Passed
Commit 1b3c4a0
Started Jul 30, 2024 2:59 PM
Ended Jul 30, 2024 3:03 PM
Duration 04:37 💡
OS Linux Debian -
Browser Electron 118

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit d719899 into master Jul 30, 2024
32 checks passed
@ivov ivov deleted the pay-1788-add-project-related-params-to-public-api-workflows-endpoints branch July 30, 2024 15:05
cstuncsik pushed a commit that referenced this pull request Jul 31, 2024
@github-actions github-actions bot mentioned this pull request Jul 31, 2024
@janober
Copy link
Member

janober commented Jul 31, 2024

Got released with [email protected]

cstuncsik pushed a commit that referenced this pull request Aug 1, 2024
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.

3 participants