Commit 1ed106d5 authored by David O'Regan's avatar David O'Regan

Merge branch...

Merge branch '331973-poor-error-handling-when-user-is-signing-up-and-selects-an-existing-group-name' into 'master'

Suggest a unique name for registration group path[RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!64394
parents 0821a25c 73f324ca
...@@ -16,7 +16,7 @@ export default class Group { ...@@ -16,7 +16,7 @@ export default class Group {
if (groupName.value === '') { if (groupName.value === '') {
groupName.addEventListener('keyup', this.updateHandler); groupName.addEventListener('keyup', this.updateHandler);
groupName.addEventListener('blur', this.updateGroupPathSlugHandler); groupName.addEventListener('keyup', this.updateGroupPathSlugHandler);
} }
}); });
......
...@@ -12,7 +12,6 @@ const parentIdSelector = 'group_parent_id'; ...@@ -12,7 +12,6 @@ const parentIdSelector = 'group_parent_id';
const successMessageSelector = '.validation-success'; const successMessageSelector = '.validation-success';
const pendingMessageSelector = '.validation-pending'; const pendingMessageSelector = '.validation-pending';
const unavailableMessageSelector = '.validation-error'; const unavailableMessageSelector = '.validation-error';
const suggestionsMessageSelector = '.gl-path-suggestions';
const inputGroupSelector = '.input-group'; const inputGroupSelector = '.input-group';
export default class GroupPathValidator extends InputValidator { export default class GroupPathValidator extends InputValidator {
...@@ -57,7 +56,9 @@ export default class GroupPathValidator extends InputValidator { ...@@ -57,7 +56,9 @@ export default class GroupPathValidator extends InputValidator {
); );
if (data.exists) { if (data.exists) {
GroupPathValidator.showSuggestions(inputDomElement, data.suggests); const [suggestedSlug] = data.suggests;
const targetDomElement = document.querySelector('.js-autofill-group-path');
targetDomElement.value = suggestedSlug;
} }
}) })
.catch(() => .catch(() =>
...@@ -68,14 +69,6 @@ export default class GroupPathValidator extends InputValidator { ...@@ -68,14 +69,6 @@ export default class GroupPathValidator extends InputValidator {
} }
} }
static showSuggestions(inputDomElement, suggestions) {
const messageElement = inputDomElement.parentElement.parentElement.querySelector(
suggestionsMessageSelector,
);
const textSuggestions = suggestions && suggestions.length > 0 ? suggestions.join(', ') : 'none';
messageElement.textContent = textSuggestions;
}
static setMessageVisibility(inputDomElement, messageSelector, isVisible = true) { static setMessageVisibility(inputDomElement, messageSelector, isVisible = true) {
const messageElement = inputDomElement const messageElement = inputDomElement
.closest(inputGroupSelector) .closest(inputGroupSelector)
......
...@@ -33,8 +33,7 @@ ...@@ -33,8 +33,7 @@
title: _('Please choose a group URL 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}"
%p.validation-error.gl-field-error.field-validation.hide %p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ') = _("Group path is already taken. We've suggested one that is available.")
%span.gl-path-suggestions
%p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.') %p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.')
%p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...') %p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...')
.form-group .form-group
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
title: _('Please choose a group URL 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}"
%p.validation-error.gl-field-error.field-validation.hide %p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ') = _("Group path is already taken. We've suggested one that is available.")
%span.gl-path-suggestions
%p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.') %p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.')
%p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group URL availability...') %p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group URL availability...')
......
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS, pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS,
title: _('Please choose a group URL with no special characters.') title: _('Please choose a group URL with no special characters.')
%p.validation-error.gl-field-error.field-validation.hide %p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ') = _("Group path is already taken. We've suggested one that is available.")
%span.gl-path-suggestions
%p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.') %p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.')
%p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...') %p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...')
.row .row
......
...@@ -36,8 +36,7 @@ ...@@ -36,8 +36,7 @@
pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS, pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS,
title: _('Please choose a group URL with no special characters.') title: _('Please choose a group URL with no special characters.')
%p.validation-error.gl-field-error.field-validation.hide %p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ') = _("Group path is already taken. We've suggested one that is available.")
%span.gl-path-suggestions
%p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.') %p.validation-success.gl-field-success.field-validation.hide= _('Group path is available.')
%p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...') %p.validation-pending.gl-field-error-ignore.field-validation.hide= _('Checking group path availability...')
.row .row
......
...@@ -15346,7 +15346,7 @@ msgstr "" ...@@ -15346,7 +15346,7 @@ msgstr ""
msgid "Group overview content" msgid "Group overview content"
msgstr "" msgstr ""
msgid "Group path is already taken. Suggestions: " msgid "Group path is already taken. We've suggested one that is available."
msgstr "" msgstr ""
msgid "Group path is available." msgid "Group path is available."
......
...@@ -77,7 +77,7 @@ RSpec.describe 'Import/Export - Group Import', :js do ...@@ -77,7 +77,7 @@ RSpec.describe 'Import/Export - Group Import', :js do
click_link 'Import group' click_link 'Import group'
fill_in :import_group_path, with: 'test-group-import' fill_in :import_group_path, with: 'test-group-import'
expect(page).to have_content 'Group path is already taken. Suggestions: test-group-import1' expect(page).to have_content "Group path is already taken. We've suggested one that is available."
end end
end end
end end
......
...@@ -90,7 +90,7 @@ RSpec.describe 'Group' do ...@@ -90,7 +90,7 @@ RSpec.describe 'Group' do
fill_in 'group_path', with: user.username fill_in 'group_path', with: user.username
wait_for_requests wait_for_requests
expect(page).to have_content('Group path is already taken') expect(page).to have_content("Group path is already taken. We've suggested one that is available.")
end end
it 'does not break after an invalid form submit' do it 'does not break after an invalid form submit' do
...@@ -257,7 +257,7 @@ RSpec.describe 'Group' do ...@@ -257,7 +257,7 @@ RSpec.describe 'Group' do
fill_in 'Group URL', with: subgroup.path fill_in 'Group URL', with: subgroup.path
wait_for_requests wait_for_requests
expect(page).to have_content('Group path is already taken') expect(page).to have_content("Group path is already taken. We've suggested one that is available.")
end end
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