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
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)
......
......@@ -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)
......
......@@ -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]
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......@@ -18,22 +21,6 @@
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2}
%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
.form-group
.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
= 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'
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)',
......
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