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
  1. In group's settings configure the template group in the Settings > General > Custom Project Templates, select the template_group.
  2. In subgroup's settings configure the subgroup_template_group as the custom project templates group.
  3. Enable the constrain_group_project_templates feature flag Feature.enable(:constrain_group_project_templates) in rails console
  4. From the project dashboard /dashboard/projects page, click + New Project. Then click on Create from template
  5. The groups tab should be hidden
  6. Now navigate to the group Group and click on + New Project. It should show the groups tab with a count of 2, clicking on the tab should display the group collapsed, opening it should show template_group_project_1 and template_group_project_2
  7. Now navigate to the group/subgroup and do the same, the count should show 3 and there should be 2 collapsed sections, first for group with the same templates as before and one for group/subgroup
  8. Now navitate to group/project_group and check that it displays the same templates as step 6 (templates in subgroup are 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.

Edited by Joe Woodward

Merge request reports

Loading