Commit 5cf2bd4c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'project-path' into 'master'

Project path

Fixes gitlab/gitlabhq#1781, gitlab/gitlabhq#1763

See merge request !1337
parents fe68c45a f7758099
...@@ -21,7 +21,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -21,7 +21,7 @@ class Admin::GroupsController < Admin::ApplicationController
def create def create
@group = Group.new(group_params) @group = Group.new(group_params)
@group.path = @group.name.dup.parameterize if @group.name @group.name = @group.path.dup unless @group.name
if @group.save if @group.save
@group.add_owner(current_user) @group.add_owner(current_user)
......
...@@ -21,7 +21,7 @@ class GroupsController < ApplicationController ...@@ -21,7 +21,7 @@ class GroupsController < ApplicationController
def create def create
@group = Group.new(group_params) @group = Group.new(group_params)
@group.path = @group.name.dup.parameterize if @group.name @group.name = @group.path.dup unless @group.name
if @group.save if @group.save
@group.add_owner(current_user) @group.add_owner(current_user)
......
...@@ -12,12 +12,17 @@ module Projects ...@@ -12,12 +12,17 @@ module Projects
@project.visibility_level = default_features.visibility_level @project.visibility_level = default_features.visibility_level
end end
# Parametrize path for project # Set project name from path
# if @project.name.present? && @project.path.present?
# Ex. # if both name and path set - everything is ok
# 'GitLab HQ'.parameterize => "gitlab-hq" elsif @project.path.present?
# # Set project name from path
@project.path = @project.name.dup.parameterize unless @project.path.present? @project.name = @project.path.dup
elsif @project.name.present?
# For compatibility - set path from name
# TODO: remove this in 8.0
@project.path = @project.name.dup.parameterize
end
# get namespace id # get namespace id
namespace_id = params[:namespace_id] namespace_id = params[:namespace_id]
......
...@@ -21,17 +21,6 @@ ...@@ -21,17 +21,6 @@
= link_to 'Cancel', admin_groups_path, class: "btn btn-cancel" = link_to 'Cancel', admin_groups_path, class: "btn btn-cancel"
- else - else
.form-group.group_name_holder
= f.label :path, class: 'control-label' do
%span Group path
.col-sm-10
= f.text_field :path, placeholder: "example-group", class: "form-control danger"
.bs-callout.bs-callout-danger
%ul
%li Changing group path can have unintended side effects.
%li Renaming group path will rename directory for all related projects
%li It will change web url for access group and group projects.
%li It will change the git path to repositories under this group.
.form-actions .form-actions
= f.submit 'Save changes', class: "btn btn-primary" = f.submit 'Save changes', class: "btn btn-primary"
= link_to 'Cancel', admin_group_path(@group), class: "btn btn-cancel" = link_to 'Cancel', admin_group_path(@group), class: "btn btn-cancel"
......
...@@ -136,6 +136,8 @@ ...@@ -136,6 +136,8 @@
.col-sm-9 .col-sm-9
.form-group .form-group
.input-group .input-group
.input-group-addon
#{URI.join(root_url, @project.namespace.path)}/
= f.text_field :path, class: 'form-control' = f.text_field :path, class: 'form-control'
%span.input-group-addon .git %span.input-group-addon .git
%ul %ul
......
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
= form_for @project, html: { class: 'new_project form-horizontal' } do |f| = form_for @project, html: { class: 'new_project form-horizontal' } do |f|
.form-group.project-name-holder .form-group.project-name-holder
= f.label :name, class: 'control-label' do = f.label :path, class: 'control-label' do
%strong Project name %strong Project path
.col-sm-10 .col-sm-10
= f.text_field :name, placeholder: "Example Project", class: "form-control", tabindex: 1, autofocus: true .input-group
= f.text_field :path, placeholder: "my-awesome-project", class: "form-control", tabindex: 1, autofocus: true
.input-group-addon
\.git
- if current_user.can_select_namespace? - if current_user.can_select_namespace?
.form-group .form-group
...@@ -18,22 +21,6 @@ ...@@ -18,22 +21,6 @@
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2} = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2}
%hr %hr
.js-toggle-container
.form-group
.col-sm-2
.col-sm-10
= link_to "#", class: 'js-toggle-button' do
%i.fa.fa-pencil-square-o
%span Customize repository name?
.js-toggle-content.hide
.form-group
= f.label :path, class: 'control-label' do
%span Repository name
.col-sm-10
.input-group
= f.text_field :path, class: 'form-control'
%span.input-group-addon .git
.js-toggle-container .js-toggle-container
.form-group .form-group
.col-sm-2 .col-sm-2
......
- if @group.persisted?
.form-group
= f.label :name, class: 'control-label' do
Group name
.col-sm-10
= f.text_field :name, placeholder: 'open-source', class: 'form-control'
.form-group .form-group
= f.label :name, class: 'control-label' do = f.label :path, class: 'control-label' do
Group name Group path
.col-sm-10 .col-sm-10
= f.text_field :name, placeholder: 'Example Group', class: 'form-control', .input-group
autofocus: local_assigns[:autofocus] || false .input-group-addon
= root_url
= f.text_field :path, placeholder: 'open-source', class: 'form-control',
autofocus: local_assigns[:autofocus] || false
- if @group.persisted?
.bs-callout.bs-callout-danger
%ul
%li Changing group path can have unintended side effects.
%li Renaming group path will rename directory for all related projects
%li It will change web url for access group and group projects.
%li It will change the git path to repositories under this group.
.form-group.group-description-holder .form-group.group-description-holder
= f.label :description, 'Details', class: 'control-label' = f.label :description, 'Details', class: 'control-label'
......
...@@ -22,7 +22,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps ...@@ -22,7 +22,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
end end
step 'submit form with new group info' do step 'submit form with new group info' do
fill_in 'group_name', with: 'gitlab' fill_in 'group_path', with: 'gitlab'
fill_in 'group_description', with: 'Group description' fill_in 'group_description', with: 'Group description'
click_button "Create group" click_button "Create group"
end end
......
...@@ -77,7 +77,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -77,7 +77,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end end
step 'submit form with new group "Samurai" info' do step 'submit form with new group "Samurai" info' do
fill_in 'group_name', with: 'Samurai' fill_in 'group_path', with: 'Samurai'
fill_in 'group_description', with: 'Tokugawa Shogunate' fill_in 'group_description', with: 'Tokugawa Shogunate'
click_button "Create group" click_button "Create group"
end end
...@@ -93,6 +93,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -93,6 +93,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I change group "Owned" name to "new-name"' do step 'I change group "Owned" name to "new-name"' do
fill_in 'group_name', with: 'new-name' fill_in 'group_name', with: 'new-name'
fill_in 'group_path', with: 'new-name'
click_button "Save group" click_button "Save group"
end end
......
...@@ -3,7 +3,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps ...@@ -3,7 +3,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
include SharedPaths include SharedPaths
step 'fill project form with valid data' do step 'fill project form with valid data' do
fill_in 'project_name', with: 'Empty' fill_in 'project_path', with: 'Empty'
click_button "Create project" click_button "Create project"
end end
......
...@@ -198,8 +198,6 @@ describe API::API, api: true do ...@@ -198,8 +198,6 @@ describe API::API, api: true do
it 'should respond with 400 on failure' do it 'should respond with 400 on failure' do
post api("/projects/user/#{user.id}", admin) post api("/projects/user/#{user.id}", admin)
response.status.should == 400 response.status.should == 400
json_response['message']['creator'].should == ['can\'t be blank']
json_response['message']['namespace'].should == ['can\'t be blank']
json_response['message']['name'].should == [ json_response['message']['name'].should == [
'can\'t be blank', 'can\'t be blank',
'is too short (minimum is 0 characters)', 'is too short (minimum is 0 characters)',
......
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