diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-12-24 13:27:26 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-12-24 13:27:26 +0000 |
commit | 5cf2bd4c997d84e9a02d722d6ba870c24b06cc0f (patch) | |
tree | 6175021f35173b865cfa436548a92a7995368ea0 | |
parent | fe68c45aa566b436a122c1598c58006d37472e8d (diff) | |
parent | f775809910a2c8ebec1887ec39ba33325d00171a (diff) | |
download | gitlab-ce-5cf2bd4c997d84e9a02d722d6ba870c24b06cc0f.tar.gz |
Merge branch 'project-path' into 'master'
Project path
Fixes gitlab/gitlabhq#1781, gitlab/gitlabhq#1763
See merge request !1337
-rw-r--r-- | app/controllers/admin/groups_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/groups_controller.rb | 2 | ||||
-rw-r--r-- | app/services/projects/create_service.rb | 17 | ||||
-rw-r--r-- | app/views/admin/groups/_form.html.haml | 11 | ||||
-rw-r--r-- | app/views/projects/edit.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/new.html.haml | 25 | ||||
-rw-r--r-- | app/views/shared/_group_form.html.haml | 25 | ||||
-rw-r--r-- | features/steps/admin/groups.rb | 2 | ||||
-rw-r--r-- | features/steps/groups.rb | 3 | ||||
-rw-r--r-- | features/steps/project/create.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 2 |
11 files changed, 46 insertions, 47 deletions
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index e6d0c9323c1..8c7d90a5d9f 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -21,7 +21,7 @@ class Admin::GroupsController < Admin::ApplicationController def create @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 @group.add_owner(current_user) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 6cd12c35bf9..aad3709090e 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -21,7 +21,7 @@ class GroupsController < ApplicationController def create @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 @group.add_owner(current_user) diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 3672b623806..31226b7504b 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -12,12 +12,17 @@ module Projects @project.visibility_level = default_features.visibility_level end - # Parametrize path for project - # - # Ex. - # 'GitLab HQ'.parameterize => "gitlab-hq" - # - @project.path = @project.name.dup.parameterize unless @project.path.present? + # Set project name from path + if @project.name.present? && @project.path.present? + # if both name and path set - everything is ok + elsif @project.path.present? + # Set project name from path + @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 namespace_id = params[:namespace_id] diff --git a/app/views/admin/groups/_form.html.haml b/app/views/admin/groups/_form.html.haml index f4d7e25fd74..86a73200609 100644 --- a/app/views/admin/groups/_form.html.haml +++ b/app/views/admin/groups/_form.html.haml @@ -21,17 +21,6 @@ = link_to 'Cancel', admin_groups_path, class: "btn btn-cancel" - 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 = f.submit 'Save changes', class: "btn btn-primary" = link_to 'Cancel', admin_group_path(@group), class: "btn btn-cancel" diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index b85cf7d8d37..f2bb56b5664 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -136,6 +136,8 @@ .col-sm-9 .form-group .input-group + .input-group-addon + #{URI.join(root_url, @project.namespace.path)}/ = f.text_field :path, class: 'form-control' %span.input-group-addon .git %ul diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index e77ef84f51c..f320a2b505e 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -5,10 +5,13 @@ = form_for @project, html: { class: 'new_project form-horizontal' } do |f| .form-group.project-name-holder - = f.label :name, class: 'control-label' do - %strong Project name + = f.label :path, class: 'control-label' do + %strong Project path .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? .form-group @@ -23,22 +26,6 @@ .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 - .form-group - .col-sm-2 - .col-sm-10 - = link_to "#", class: 'js-toggle-button' do %i.fa.fa-upload %span Import existing repository? .js-toggle-content.hide diff --git a/app/views/shared/_group_form.html.haml b/app/views/shared/_group_form.html.haml index 93294e42505..5875f71bac2 100644 --- a/app/views/shared/_group_form.html.haml +++ b/app/views/shared/_group_form.html.haml @@ -1,9 +1,26 @@ +- 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 - = f.label :name, class: 'control-label' do - Group name + = f.label :path, class: 'control-label' do + Group path .col-sm-10 - = f.text_field :name, placeholder: 'Example Group', class: 'form-control', - autofocus: local_assigns[:autofocus] || false + .input-group + .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 = f.label :description, 'Details', class: 'control-label' diff --git a/features/steps/admin/groups.rb b/features/steps/admin/groups.rb index d69a87cd07e..4171398e568 100644 --- a/features/steps/admin/groups.rb +++ b/features/steps/admin/groups.rb @@ -22,7 +22,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps end 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' click_button "Create group" end diff --git a/features/steps/groups.rb b/features/steps/groups.rb index 66a32a51d75..0bd7a32f5cb 100644 --- a/features/steps/groups.rb +++ b/features/steps/groups.rb @@ -77,7 +77,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps end 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' click_button "Create group" end @@ -93,6 +93,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps step 'I change group "Owned" name to "new-name"' do fill_in 'group_name', with: 'new-name' + fill_in 'group_path', with: 'new-name' click_button "Save group" end diff --git a/features/steps/project/create.rb b/features/steps/project/create.rb index e1062a6ce39..6b07b62f16f 100644 --- a/features/steps/project/create.rb +++ b/features/steps/project/create.rb @@ -3,7 +3,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps include SharedPaths step 'fill project form with valid data' do - fill_in 'project_name', with: 'Empty' + fill_in 'project_path', with: 'Empty' click_button "Create project" end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 2c4b68c10b6..f8c5d40b9bf 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -198,8 +198,6 @@ describe API::API, api: true do it 'should respond with 400 on failure' do post api("/projects/user/#{user.id}", admin) 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 == [ 'can\'t be blank', 'is too short (minimum is 0 characters)', |