Commit f6dd05a5 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-add-project-templates' into 'master'

Add support for pre-made and custom templates

See merge request gitlab-org/gitlab!31122
parents cb17f52b 40da4345
.custom-project-templates
- if custom_project_templates.present?
- custom_project_templates.each do |template|
.template-option.d-flex.align-items-center.qa-template-option-row
.template-option.d-flex.align-items-center{ data: { qa_selector: 'template_option_row' } }
.avatar-container.s40
= project_icon(template, alt: template.name, class: 'btn-template-icon avatar s40 avatar-tile', lazy: false)
.description
......@@ -15,7 +15,7 @@
= _('Preview')
%label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: 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{ data: { qa_selector: 'use_template_button' } }
= _('Use template')
= paginate custom_project_templates, params: {controller: 'users', action: 'available_project_templates', username: current_user.username}, theme: 'gitlab', remote: true
......
......@@ -417,6 +417,10 @@ module QA
module WebIDE
autoload :Alert, 'qa/page/component/web_ide/alert'
end
module Project
autoload :Templates, 'qa/page/component/project/templates'
end
end
end
......
......@@ -43,12 +43,6 @@ module QA
def instance_template_tab_badge_text
find_element(:instance_template_tab_badge).text
end
def use_template_for_project(project_name)
within find_element(:template_option_row, text: project_name) do
click_element :use_template_button
end
end
end
end
end
......
# frozen_string_literal: true
module QA
module Page::Component
module Project
module Templates
def use_template_for_project(project_name)
within find_element(:template_option_row, text: project_name) do
click_element :use_template_button
end
end
end
end
end
end
......@@ -5,6 +5,7 @@ module QA
module Project
class New < Page::Base
include Page::Component::Select2
include Page::Component::Project::Templates
view 'app/views/projects/new.html.haml' do
element :project_create_from_template_tab
......@@ -26,6 +27,11 @@ module QA
element :import_github, "icon('github', text: 'GitHub')" # rubocop:disable QA/ElementWithPattern
end
view 'app/views/projects/project_templates/_built_in_templates.html.haml' do
element :use_template_button
element :template_option_row
end
def choose_test_namespace
choose_namespace(Runtime::Namespace.path)
end
......
......@@ -20,6 +20,7 @@ module QA
attribute :standalone
attribute :runners_token
attribute :visibility
attribute :template_name
attribute :group do
Group.fabricate!
......@@ -52,6 +53,7 @@ module QA
@initialize_with_readme = false
@auto_devops_enabled = false
@visibility = :public
@template_name = nil
end
def name=(raw_name)
......@@ -64,6 +66,13 @@ module QA
Page::Group::Show.perform(&:go_to_new_project)
end
if @template_name
Page::Project::New.perform do |new_page|
new_page.click_create_from_template_tab
new_page.use_template_for_project(@template_name)
end
end
Page::Project::New.perform do |new_page|
new_page.choose_test_namespace
new_page.choose_name(@name)
......@@ -127,6 +136,7 @@ module QA
end
post_body[:repository_storage] = repository_storage if repository_storage
post_body[:template_name] = @template_name if @template_name
post_body
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