Commit 242b62d9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-use-template-project-id' into 'master'

Fix incorrect selection of custom templates

Closes #9146

See merge request gitlab-org/gitlab!17205
parents c6911098 cf98f298
---
title: Fix incorrect selection of custom templates
merge_request: 17205
author:
type: fixed
...@@ -54,8 +54,8 @@ const bindEvents = () => { ...@@ -54,8 +54,8 @@ const bindEvents = () => {
} }
function chooseTemplate() { function chooseTemplate() {
const value = $(this).val();
const subgroupId = $(this).data('subgroup-id'); const subgroupId = $(this).data('subgroup-id');
const templateName = $(this).data('template-name');
if (subgroupId) { if (subgroupId) {
$subgroupWithTemplatesIdInput.val(subgroupId); $subgroupWithTemplatesIdInput.val(subgroupId);
...@@ -70,7 +70,7 @@ const bindEvents = () => { ...@@ -70,7 +70,7 @@ const bindEvents = () => {
$projectFieldsForm.addClass('selected'); $projectFieldsForm.addClass('selected');
$selectedIcon.empty(); $selectedIcon.empty();
$selectedTemplateText.text(value); $selectedTemplateText.text(templateName);
$(this) $(this)
.parents('.template-option') .parents('.template-option')
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
%a.btn.btn-default.append-right-10{ href: project_path(template), rel: 'noopener noreferrer', target: '_blank' } %a.btn.btn-default.append-right-10{ href: project_path(template), rel: 'noopener noreferrer', target: '_blank' }
= _('Preview') = _('Preview')
%label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: template.name } %label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: template.name }
%input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: template.name, value: template.name } %input{ type: "radio", autocomplete: "off", name: "project[template_project_id]", id: template.name, value: template.id, data: { template_name: template.name } }
%span.qa-use-template-button %span.qa-use-template-button
= _('Use template') = _('Use template')
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
%a.btn.btn-default.append-right-10{ href: project_path(project), rel: 'noopener noreferrer', target: '_blank' } %a.btn.btn-default.append-right-10{ href: project_path(project), rel: 'noopener noreferrer', target: '_blank' }
= _('Preview') = _('Preview')
%label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: project.name } %label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: project.name }
%input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: project.name, value: project.name, data: { subgroup_id: project.namespace_id } } %input{ type: "radio", autocomplete: "off", name: "project[template_project_id]", id: project.name, value: project.id, data: { subgroup_id: project.namespace_id, template_name: project.name } }
%span.qa-use-template-button %span.qa-use-template-button
= _('Use template') = _('Use template')
......
...@@ -224,7 +224,7 @@ describe 'New project' do ...@@ -224,7 +224,7 @@ describe 'New project' do
visit_create_from_group_template_tab visit_create_from_group_template_tab
page.within('.custom-project-templates') do page.within('.custom-project-templates') do
page.find(".template-option input[value='#{subgroup1_project1.name}']").first(:xpath, './/..').click page.find(".template-option input[value='#{subgroup1_project1.id}']").first(:xpath, './/..').click
wait_for_all_requests wait_for_all_requests
end end
end end
...@@ -253,7 +253,7 @@ describe 'New project' do ...@@ -253,7 +253,7 @@ describe 'New project' do
page.within('#create-from-template-pane') do page.within('#create-from-template-pane') do
click_button 'Change template' click_button 'Change template'
page.find(:xpath, "//input[@type='radio' and @value='#{subgroup1_project1.name}']/..").click page.find(:xpath, "//input[@type='radio' and @value='#{subgroup1_project1.id}']/..").click
wait_for_all_requests wait_for_all_requests
end end
......
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