Commit c6c31507 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'fix-default-path-when-creating-project-from-group-template' into 'master'

fix default path when using group template

See merge request gitlab-org/gitlab!79638
parents 22175dc2 8f4734ec
......@@ -58,7 +58,12 @@ const bindEvents = () => {
if (subgroupId) {
const subgroupFullPath = $(this).data('subgroup-full-path');
eventHub.$emit('select-template', subgroupId, subgroupFullPath);
const targetGroupFullPath = $(this).data('target-group-full-path');
eventHub.$emit(
'select-template',
targetGroupFullPath ? groupId : subgroupId,
targetGroupFullPath || subgroupFullPath,
);
$subgroupWithTemplatesIdInput.val(subgroupId);
$namespaceSelect.val(groupId).trigger('change');
......
......@@ -47,6 +47,9 @@ module EE
def load_group_project_templates
render_404 unless user == current_user
@target_group ||= # rubocop:disable Gitlab/ModuleWithInstanceVariables
GroupFinder.new(current_user).execute(id: params[:group_id])
@groups_with_project_templates ||= # rubocop:disable Gitlab/ModuleWithInstanceVariables
user.available_subgroups_with_custom_project_templates(params[:group_id])
.page(params[:page])
......
......@@ -32,7 +32,7 @@
%a.btn.gl-button.btn-default.gl-mr-3{ href: project_path(project), rel: 'noopener noreferrer', target: '_blank' }
= _('Preview')
%label.btn.gl-button.btn-success.custom-template-button.choose-template.gl-mb-0{ for: project.name }
%input{ type: "radio", autocomplete: "off", name: "project[template_project_id]", id: project.name, value: project.id, data: { subgroup_full_path: project.namespace.full_path, subgroup_id: project.namespace_id, template_name: project.name, parent_group_id: namespace_id || group.parent_id } }
%input{ type: "radio", autocomplete: "off", name: "project[template_project_id]", id: project.name, value: project.id, data: { subgroup_full_path: project.namespace.full_path, target_group_full_path: target_group&.full_path, subgroup_id: project.namespace_id, template_name: project.name, parent_group_id: target_group&.id || group.parent_id } }
%span.qa-use-template-button
= _('Use template')
......
:plain
var target = $(".project-templates-buttons#custom-group-project-templates");
target.empty();
target.html("#{escape_javascript(render('custom_project_templates_from_groups', groups_with_project_templates: @groups_with_project_templates, namespace_id: params[:group_id]))}");
target.html("#{escape_javascript(render('custom_project_templates_from_groups', groups_with_project_templates: @groups_with_project_templates, target_group: @target_group))}");
target.trigger("ajax:success");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment