Constrain group project templates to current namespace
What does this MR do and why?
Constrain group project templates to current namespace
Related to Custom project templates unable to be created (#296815 - closed) and Update group-level template retrieval to use ne... (#590011 - closed)
Historically we have had performance and permissions issues around the group project templates.
We recently implemented a new finder Projects::GroupTemplatesFinder which requires a group ID to scope the query to a specific namespace. This group is where the project will be created. We actually already specify this before creating the project but not we require the user to specify it before being able to see the available templates.
This change is currently behind a disabled feature flag.
When the flag is enabled the group templates tab is only visible when creating a project inside a group. If creating a project from the dashboard the group tab will be hidden.
In a follow-up we'll add the ability for the user to select which group they are going to create the project in if one is not already selected.
How to set up and validate locally
First you'll need to configure some templates somewhere. Ideally you should have a nested group with mutiple templates at each level.
group
|- template_group
|-- template_group_project_1
|-- template_group_project_2
|- subgroup
|-- subgroup_template_group
|--- subgroup_template_group_project_1
|-- project_group
- In
group's settings configure the template group in the Settings > General > Custom Project Templates, select thetemplate_group. - In
subgroup's settings configure thesubgroup_template_groupas the custom project templates group. - Enable the
constrain_group_project_templatesfeature flagFeature.enable(:constrain_group_project_templates)in rails console - From the project dashboard
/dashboard/projectspage, click+ New Project. Then click onCreate from template - The groups tab should be hidden
- Now navigate to the
groupGroup and click on+ New Project. It should show the groups tab with a count of 2, clicking on the tab should display thegroupcollapsed, opening it should showtemplate_group_project_1andtemplate_group_project_2 - Now navigate to the
group/subgroupand do the same, the count should show 3 and there should be 2 collapsed sections, first forgroupwith the same templates as before and one forgroup/subgroup - Now navitate to
group/project_groupand check that it displays the same templates as step 6 (templates insubgroupare not available to this group)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.