Commit 2e6aa4f2 authored by Z.J. van de Weg's avatar Z.J. van de Weg

After merge cleanup

parent aae947cb
...@@ -26,13 +26,9 @@ class ProjectsController < Projects::ApplicationController ...@@ -26,13 +26,9 @@ class ProjectsController < Projects::ApplicationController
render 'edit' render 'edit'
end end
def create def create
@project = @project = ::Projects::CreateService.new(current_user, project_params).execute
if project_from_template?
::Projects::CreateFromTemplateService.new(current_user, project_params).execute
else
::Projects::CreateService.new(current_user, project_params).execute
end
if @project.saved? if @project.saved?
cookies[:issue_board_welcome_hidden] = { path: project_path(@project), value: nil, expires: Time.at(0) } cookies[:issue_board_welcome_hidden] = { path: project_path(@project), value: nil, expires: Time.at(0) }
...@@ -351,10 +347,6 @@ class ProjectsController < Projects::ApplicationController ...@@ -351,10 +347,6 @@ class ProjectsController < Projects::ApplicationController
false false
end end
def project_from_template?
project_params[:template_name]&.present?
end
def project_view_files? def project_view_files?
if current_user if current_user
current_user.project_view == 'files' current_user.project_view == 'files'
......
...@@ -5,6 +5,10 @@ module Projects ...@@ -5,6 +5,10 @@ module Projects
end end
def execute def execute
if @params[:template_name]&.present?
return ::Projects::CreateFromTemplateService.new(current_user, params).execute
end
forked_from_project_id = params.delete(:forked_from_project_id) forked_from_project_id = params.delete(:forked_from_project_id)
import_data = params.delete(:import_data) import_data = params.delete(:import_data)
@skip_wiki = params.delete(:skip_wiki) @skip_wiki = params.delete(:skip_wiki)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
.form-group .form-group
= f.label :template_project, class: 'label-light' do = f.label :template_project, class: 'label-light' do
Create from template Create from template
= link_to icon('question-circle'), help_page_path("public_access/public_access"), aria: { label: "What's included in a template?" }, title: "What's included in a template?", class: 'has-tooltip', data: { placement: 'top'} = link_to icon('question-circle'), help_page_path("public_access/public_access"), aria: { label: "What’s included in a template?" }, title: "What’s included in a template?", class: 'has-tooltip', data: { placement: 'top'}
%div %div
= render 'project_templates', f: f = render 'project_templates', f: f
.second-column .second-column
......
---
title: Projects can be created from templates
merge_request: 13108
author:
...@@ -146,3 +146,20 @@ If new emoji are added, the spritesheet may change size. To compensate for ...@@ -146,3 +146,20 @@ If new emoji are added, the spritesheet may change size. To compensate for
such changes, first generate the `emoji.png` spritesheet with the above Rake such changes, first generate the `emoji.png` spritesheet with the above Rake
task, then check the dimensions of the new spritesheet and update the task, then check the dimensions of the new spritesheet and update the
`SPRITESHEET_WIDTH` and `SPRITESHEET_HEIGHT` constants accordingly. `SPRITESHEET_WIDTH` and `SPRITESHEET_HEIGHT` constants accordingly.
## Updating project templates
Starting a project from a template needs this project to be exported. On a
up to date master branch with run:
```
gdk run db
# In a new terminal window
bundle exec rake gitlab:update_project_templates
git checkout -b update-project-templates
git add vendor/project_templates
git commit
git push -u origin update-project-templates
```
Now create a merge request and merge that to master.
...@@ -24,16 +24,17 @@ namespace :gitlab do ...@@ -24,16 +24,17 @@ namespace :gitlab do
path: template.title, path: template.title,
skip_wiki: true skip_wiki: true
} }
puts "Creating project for #{template.name}" puts "Creating project for #{template.name}"
project = Projects::CreateService.new(admin, project).execute project = Projects::CreateService.new(admin, params).execute
loop do loop do
if project.import_status == "finished" if project.finished?
puts "Import finished for #{template.name}" puts "Import finished for #{template.name}"
break break
end end
if project.import_status == "failed" if project.failed?
puts "Failed to import from #{project_params[:import_url]}".red puts "Failed to import from #{project_params[:import_url]}".red
exit(1) exit(1)
end end
......
require 'spec_helper' require 'spec_helper'
<<<<<<< HEAD feature 'Project' do
feature 'Project', feature: true do
describe 'creating from template' do describe 'creating from template' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:template) { Gitlab::ProjectTemplate.find(:rails) } let(:template) { Gitlab::ProjectTemplate.find(:rails) }
...@@ -23,9 +22,6 @@ feature 'Project', feature: true do ...@@ -23,9 +22,6 @@ feature 'Project', feature: true do
end end
end end
=======
feature 'Project' do
>>>>>>> master
describe 'description' do describe 'description' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:path) { project_path(project) } let(:path) { project_path(project) }
......
...@@ -31,7 +31,7 @@ describe Gitlab::ProjectTemplate do ...@@ -31,7 +31,7 @@ describe Gitlab::ProjectTemplate do
describe 'instance methods' do describe 'instance methods' do
subject { described_class.new('phoenix', 'Phoenix Framework') } subject { described_class.new('phoenix', 'Phoenix Framework') }
it { is_expected.to respond_to(:logo_path, :file, :archive_path) } it { is_expected.to respond_to(:logo, :file, :archive_path) }
end end
describe 'validate all templates' do describe 'validate all templates' do
......
...@@ -5,7 +5,7 @@ describe Projects::CreateFromTemplateService do ...@@ -5,7 +5,7 @@ describe Projects::CreateFromTemplateService do
let(:project_params) do let(:project_params) do
{ {
path: user.to_param, path: user.to_param,
template_title: 'rails' template_name: 'rails'
} }
end end
...@@ -21,6 +21,6 @@ describe Projects::CreateFromTemplateService do ...@@ -21,6 +21,6 @@ describe Projects::CreateFromTemplateService do
project = subject.execute project = subject.execute
expect(project).to be_saved expect(project).to be_saved
expect(project.import_status).to eq('scheduled') expect(project.scheduled?).to be(true)
end end
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