Commit 553cdc90 authored by Mike Greiling's avatar Mike Greiling

Merge branch '50962-create-new-group-rename-form-fields-and-update-ui' into 'master'

Resolve "Create new group: Rename form fields and update UI"

Closes #50962

See merge request gitlab-org/gitlab-ce!22418
parents e9814aae 66e8ecff
import $ from 'jquery'; import $ from 'jquery';
import { slugifyWithHyphens } from './lib/utils/text_utility';
export default class Group { export default class Group {
constructor() { constructor() {
...@@ -7,17 +8,18 @@ export default class Group { ...@@ -7,17 +8,18 @@ export default class Group {
this.updateHandler = this.update.bind(this); this.updateHandler = this.update.bind(this);
this.resetHandler = this.reset.bind(this); this.resetHandler = this.reset.bind(this);
if (this.groupName.val() === '') { if (this.groupName.val() === '') {
this.groupPath.on('keyup', this.updateHandler); this.groupName.on('keyup', this.updateHandler);
this.groupName.on('keydown', this.resetHandler); this.groupPath.on('keydown', this.resetHandler);
} }
} }
update() { update() {
this.groupName.val(this.groupPath.val()); const slug = slugifyWithHyphens(this.groupName.val());
this.groupPath.val(slug);
} }
reset() { reset() {
this.groupPath.off('keyup', this.updateHandler); this.groupName.off('keyup', this.updateHandler);
this.groupName.off('keydown', this.resetHandler); this.groupPath.off('keydown', this.resetHandler);
} }
} }
- @hide_breadcrumbs = true - @hide_breadcrumbs = true
- @hide_top_links = true - @hide_top_links = true
- page_title 'New Group' - page_title _('New Group')
- header_title "Groups", dashboard_groups_path - header_title _("Groups"), dashboard_groups_path
.page-title-holder
%h1.page-title= _('New group')
.row.prepend-top-default .row.prepend-top-default
.col-lg-3.profile-settings-sidebar .col-lg-3.profile-settings-sidebar
%h4.prepend-top-0
= _('New group')
%p %p
- group_docs_path = help_page_path('user/group/index') - group_docs_path = help_page_path('user/group/index')
- group_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: group_docs_path } - group_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: group_docs_path }
...@@ -15,24 +15,29 @@ ...@@ -15,24 +15,29 @@
- subgroup_docs_path = help_page_path('user/group/subgroups/index') - subgroup_docs_path = help_page_path('user/group/subgroups/index')
- subgroup_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: subgroup_docs_path } - subgroup_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: subgroup_docs_path }
= s_('Groups can also be nested by creating %{subgroup_docs_link_start}subgroups%{subgroup_docs_link_end}.').html_safe % { subgroup_docs_link_start: subgroup_docs_link_start, subgroup_docs_link_end: '</a>'.html_safe } = s_('Groups can also be nested by creating %{subgroup_docs_link_start}subgroups%{subgroup_docs_link_end}.').html_safe % { subgroup_docs_link_start: subgroup_docs_link_start, subgroup_docs_link_end: '</a>'.html_safe }
%p
= _('Projects that belong to a group are prefixed with the group namespace. Existing projects may be moved into a group.')
.col-lg-9 .col-lg-9
= form_for @group, html: { class: 'group-form gl-show-field-errors' } do |f| = form_for @group, html: { class: 'group-form gl-show-field-errors' } do |f|
= form_errors(@group) = form_errors(@group)
= render 'shared/group_form', f: f, autofocus: true = render 'shared/group_form', f: f, autofocus: true
.form-group.row.group-description-holder .row
= f.label :avatar, "Group avatar", class: 'col-form-label col-sm-2' .form-group.group-description-holder.col-sm-12
.col-sm-10 = f.label :avatar, _("Group avatar"), class: 'label-bold'
= render 'shared/choose_group_avatar_button', f: f %div
= render 'shared/choose_group_avatar_button', f: f
= render 'shared/old_visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group, with_label: false
= render 'create_chat_team', f: f if Gitlab.config.mattermost.enabled .form-group.col-sm-12
%label.label-bold
= _('Visibility level')
%p
= _('Who will be able to see this group?')
= link_to _('View the documentation'), help_page_path("public_access/public_access"), target: '_blank'
= render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group, with_label: false
.form-group.row = render 'create_chat_team', f: f if Gitlab.config.mattermost.enabled
.offset-sm-2.col-sm-10
= render 'shared/group_tips'
.form-actions .form-actions
= f.submit 'Create group', class: "btn btn-success" = f.submit 'Create group', class: "btn btn-success"
......
...@@ -2,10 +2,19 @@ ...@@ -2,10 +2,19 @@
- group_path = root_url - group_path = root_url
- group_path << parent.full_path + '/' if parent - group_path << parent.full_path + '/' if parent
.form-group.row .row
= f.label :path, class: 'col-form-label col-sm-2' do .form-group.group-name-holder.col-sm-12
Group path = f.label :name, class: 'label-bold' do
.col-sm-10 = _("Group name")
= f.text_field :name, placeholder: 'My Awesome Group', class: 'form-control input-lg',
required: true,
title: _('Please fill in a descriptive name for your group.'),
autofocus: true
.row
.form-group.col-xs-12.col-sm-8
= f.label :path, class: 'label-bold' do
= _("Group URL")
.input-group.gl-field-error-anchor .input-group.gl-field-error-anchor
.group-root-path.input-group-prepend.has-tooltip{ title: group_path, :'data-placement' => 'bottom' } .group-root-path.input-group-prepend.has-tooltip{ title: group_path, :'data-placement' => 'bottom' }
.input-group-text .input-group-text
...@@ -13,10 +22,10 @@ ...@@ -13,10 +22,10 @@
- if parent - if parent
%strong= parent.full_path + '/' %strong= parent.full_path + '/'
= f.hidden_field :parent_id = f.hidden_field :parent_id
= f.text_field :path, placeholder: 'open-source', class: 'form-control', = f.text_field :path, placeholder: 'my-awesome-group', class: 'form-control',
autofocus: local_assigns[:autofocus] || false, required: true, autofocus: local_assigns[:autofocus] || false, required: true,
pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS, pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS,
title: 'Please choose a group path with no special characters.', title: _('Please choose a group URL with no special characters.'),
"data-bind-in" => "#{'create_chat_team' if Gitlab.config.mattermost.enabled}" "data-bind-in" => "#{'create_chat_team' if Gitlab.config.mattermost.enabled}"
- if @group.persisted? - if @group.persisted?
...@@ -25,23 +34,17 @@ ...@@ -25,23 +34,17 @@
= succeed '.' do = succeed '.' do
= link_to 'Learn more', help_page_path('user/group/index', anchor: 'changing-a-groups-path'), target: '_blank' = link_to 'Learn more', help_page_path('user/group/index', anchor: 'changing-a-groups-path'), target: '_blank'
.form-group.row.group-name-holder
= f.label :name, class: 'col-form-label col-sm-2' do
Group name
.col-sm-10
= f.text_field :name, class: 'form-control',
required: true,
title: 'You can choose a descriptive name different from the path.'
- if @group.persisted? - if @group.persisted?
.form-group.row.group-name-holder .row
= f.label :id, class: 'col-form-label col-sm-2' do .form-group.group-name-holder.col-sm-8
= _("Group ID") = f.label :id, class: 'label-bold' do
.col-sm-10 = _("Group ID")
= f.text_field :id, class: 'form-control', readonly: true = f.text_field :id, class: 'form-control', readonly: true
.form-group.row.group-description-holder .row
= f.label :description, class: 'col-form-label col-sm-2' .form-group.group-description-holder.col-sm-8
.col-sm-10 = f.label :description, class: 'label-bold' do
= _("Group description")
%span (optional)
= f.text_area :description, maxlength: 250, = f.text_area :description, maxlength: 250,
class: 'form-control js-gfm-input', rows: 4 class: 'form-control js-gfm-input', rows: 4
---
title: 'Create new group: Rename form fields and update UI'
merge_request:
author:
type: other
...@@ -8,6 +8,8 @@ en: ...@@ -8,6 +8,8 @@ en:
issue_link: issue_link:
source: Source issue source: Source issue
target: Target issue target: Target issue
group:
path: Group URL
errors: errors:
messages: messages:
label_already_exists_at_group_level: "already exists at group level for %{group}. Please choose another one." label_already_exists_at_group_level: "already exists at group level for %{group}. Please choose another one."
......
...@@ -3014,9 +3014,15 @@ msgstr "" ...@@ -3014,9 +3014,15 @@ msgstr ""
msgid "Group Runners" msgid "Group Runners"
msgstr "" msgstr ""
msgid "Group URL"
msgstr ""
msgid "Group avatar" msgid "Group avatar"
msgstr "" msgstr ""
msgid "Group description"
msgstr ""
msgid "Group description (optional)" msgid "Group description (optional)"
msgstr "" msgstr ""
...@@ -4557,12 +4563,18 @@ msgstr "" ...@@ -4557,12 +4563,18 @@ msgstr ""
msgid "Please accept the Terms of Service before continuing." msgid "Please accept the Terms of Service before continuing."
msgstr "" msgstr ""
msgid "Please choose a group URL with no special characters."
msgstr ""
msgid "Please convert them to %{link_to_git}, and go through the %{link_to_import_flow} again." msgid "Please convert them to %{link_to_git}, and go through the %{link_to_import_flow} again."
msgstr "" msgstr ""
msgid "Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again." msgid "Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again."
msgstr "" msgstr ""
msgid "Please fill in a descriptive name for your group."
msgstr ""
msgid "Please note that this application is not provided by GitLab and you should verify its authenticity before allowing access." msgid "Please note that this application is not provided by GitLab and you should verify its authenticity before allowing access."
msgstr "" msgstr ""
...@@ -4914,6 +4926,9 @@ msgstr "" ...@@ -4914,6 +4926,9 @@ msgstr ""
msgid "Projects shared with %{group_name}" msgid "Projects shared with %{group_name}"
msgstr "" msgstr ""
msgid "Projects that belong to a group are prefixed with the group namespace. Existing projects may be moved into a group."
msgstr ""
msgid "ProjectsDropdown|Frequently visited" msgid "ProjectsDropdown|Frequently visited"
msgstr "" msgstr ""
...@@ -6804,6 +6819,9 @@ msgstr "" ...@@ -6804,6 +6819,9 @@ msgstr ""
msgid "View replaced file @ " msgid "View replaced file @ "
msgstr "" msgstr ""
msgid "View the documentation"
msgstr ""
msgid "Visibility and access controls" msgid "Visibility and access controls"
msgstr "" msgstr ""
...@@ -6855,6 +6873,9 @@ msgstr "" ...@@ -6855,6 +6873,9 @@ msgstr ""
msgid "Who can see this group?" msgid "Who can see this group?"
msgstr "" msgstr ""
msgid "Who will be able to see this group?"
msgstr ""
msgid "Wiki" msgid "Wiki"
msgstr "" msgstr ""
......
...@@ -53,13 +53,33 @@ describe 'Admin Groups' do ...@@ -53,13 +53,33 @@ describe 'Admin Groups' do
expect_selected_visibility(internal) expect_selected_visibility(internal)
end end
it 'when entered in group path, it auto filled the group name', :js do it 'when entered in group name, it auto filled the group path', :js do
visit admin_groups_path visit admin_groups_path
click_link "New group" click_link "New group"
group_path = 'gitlab' group_name = 'gitlab'
fill_in 'group_name', with: group_name
path_field = find('input#group_path')
expect(path_field.value).to eq group_name
end
it 'auto populates the group path with the group name', :js do
visit admin_groups_path
click_link "New group"
group_name = 'my gitlab project'
fill_in 'group_name', with: group_name
path_field = find('input#group_path')
expect(path_field.value).to eq 'my-gitlab-project'
end
it 'when entering in group path, group name does not change anymore', :js do
visit admin_groups_path
click_link "New group"
group_path = 'my-gitlab-project'
group_name = 'My modified gitlab project'
fill_in 'group_path', with: group_path fill_in 'group_path', with: group_path
name_field = find('input#group_name') fill_in 'group_name', with: group_name
expect(name_field.value).to eq group_path path_field = find('input#group_path')
expect(path_field.value).to eq 'my-gitlab-project'
end end
end end
......
...@@ -14,15 +14,15 @@ RSpec.describe 'Dashboard Group' do ...@@ -14,15 +14,15 @@ RSpec.describe 'Dashboard Group' do
it 'creates new group', :js do it 'creates new group', :js do
visit dashboard_groups_path visit dashboard_groups_path
find('.btn-success').click find('.btn-success').click
new_path = 'Samurai' new_name = 'Samurai'
new_description = 'Tokugawa Shogunate' new_description = 'Tokugawa Shogunate'
fill_in 'group_path', with: new_path fill_in 'group_name', with: new_name
fill_in 'group_description', with: new_description fill_in 'group_description', with: new_description
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq group_path(Group.find_by(name: new_path)) expect(current_path).to eq group_path(Group.find_by(name: new_name))
expect(page).to have_content(new_path) expect(page).to have_content(new_name)
expect(page).to have_content(new_description) expect(page).to have_content(new_description)
end end
end end
...@@ -29,7 +29,7 @@ describe 'Top Plus Menu', :js do ...@@ -29,7 +29,7 @@ describe 'Top Plus Menu', :js do
click_topmenuitem("New group") click_topmenuitem("New group")
expect(page).to have_content('Group path') expect(page).to have_content('Group URL')
expect(page).to have_content('Group name') expect(page).to have_content('Group name')
end end
...@@ -79,7 +79,7 @@ describe 'Top Plus Menu', :js do ...@@ -79,7 +79,7 @@ describe 'Top Plus Menu', :js do
click_topmenuitem("New subgroup") click_topmenuitem("New subgroup")
expect(page).to have_content('Group path') expect(page).to have_content('Group URL')
expect(page).to have_content('Group name') expect(page).to have_content('Group name')
end end
......
...@@ -7,7 +7,7 @@ describe 'Group' do ...@@ -7,7 +7,7 @@ describe 'Group' do
matcher :have_namespace_error_message do matcher :have_namespace_error_message do
match do |page| match do |page|
page.has_content?("Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-' or end in '.', '.git' or '.atom'.") page.has_content?("Group URL can contain only letters, digits, '_', '-' and '.'. Cannot start with '-' or end in '.', '.git' or '.atom'.")
end end
end end
...@@ -18,7 +18,7 @@ describe 'Group' do ...@@ -18,7 +18,7 @@ describe 'Group' do
describe 'with space in group path' do describe 'with space in group path' do
it 'renders new group form with validation errors' do it 'renders new group form with validation errors' do
fill_in 'Group path', with: 'space group' fill_in 'Group URL', with: 'space group'
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq(groups_path) expect(current_path).to eq(groups_path)
...@@ -28,7 +28,7 @@ describe 'Group' do ...@@ -28,7 +28,7 @@ describe 'Group' do
describe 'with .atom at end of group path' do describe 'with .atom at end of group path' do
it 'renders new group form with validation errors' do it 'renders new group form with validation errors' do
fill_in 'Group path', with: 'atom_group.atom' fill_in 'Group URL', with: 'atom_group.atom'
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq(groups_path) expect(current_path).to eq(groups_path)
...@@ -38,7 +38,7 @@ describe 'Group' do ...@@ -38,7 +38,7 @@ describe 'Group' do
describe 'with .git at end of group path' do describe 'with .git at end of group path' do
it 'renders new group form with validation errors' do it 'renders new group form with validation errors' do
fill_in 'Group path', with: 'git_group.git' fill_in 'Group URL', with: 'git_group.git'
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq(groups_path) expect(current_path).to eq(groups_path)
...@@ -94,7 +94,8 @@ describe 'Group' do ...@@ -94,7 +94,8 @@ describe 'Group' do
end end
it 'creates a nested group' do it 'creates a nested group' do
fill_in 'Group path', with: 'bar' fill_in 'Group name', with: 'bar'
fill_in 'Group URL', with: 'bar'
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq(group_path('foo/bar')) expect(current_path).to eq(group_path('foo/bar'))
...@@ -112,7 +113,8 @@ describe 'Group' do ...@@ -112,7 +113,8 @@ describe 'Group' do
visit new_group_path(group, parent_id: group.id) visit new_group_path(group, parent_id: group.id)
fill_in 'Group path', with: 'bar' fill_in 'Group name', with: 'bar'
fill_in 'Group URL', with: 'bar'
click_button 'Create group' click_button 'Create group'
expect(current_path).to eq(group_path('foo/bar')) expect(current_path).to eq(group_path('foo/bar'))
......
...@@ -177,7 +177,7 @@ describe Groups::TransferService, :postgresql do ...@@ -177,7 +177,7 @@ describe Groups::TransferService, :postgresql do
it 'should add an error on group' do it 'should add an error on group' do
transfer_service.execute(new_parent_group) transfer_service.execute(new_parent_group)
expect(transfer_service.error).to eq('Transfer failed: Validation failed: Path has already been taken') expect(transfer_service.error).to eq('Transfer failed: Validation failed: Group URL has already been taken')
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