Commit 73f324ca authored by Alper Akgun's avatar Alper Akgun Committed by David O'Regan

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

parent a32eb7a9
......@@ -16,7 +16,7 @@ export default class Group {
if (groupName.value === '') {
groupName.addEventListener('keyup', this.updateHandler);
groupName.addEventListener('blur', this.updateGroupPathSlugHandler);
groupName.addEventListener('keyup', this.updateGroupPathSlugHandler);
}
});
......
......@@ -12,7 +12,6 @@ const parentIdSelector = 'group_parent_id';
const successMessageSelector = '.validation-success';
const pendingMessageSelector = '.validation-pending';
const unavailableMessageSelector = '.validation-error';
const suggestionsMessageSelector = '.gl-path-suggestions';
const inputGroupSelector = '.input-group';
export default class GroupPathValidator extends InputValidator {
......@@ -57,7 +56,9 @@ export default class GroupPathValidator extends InputValidator {
);
if (data.exists) {
GroupPathValidator.showSuggestions(inputDomElement, data.suggests);
const [suggestedSlug] = data.suggests;
const targetDomElement = document.querySelector('.js-autofill-group-path');
targetDomElement.value = suggestedSlug;
}
})
.catch(() =>
......@@ -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) {
const messageElement = inputDomElement
.closest(inputGroupSelector)
......
......@@ -33,8 +33,7 @@
title: _('Please choose a group URL with no special characters.'),
"data-bind-in" => "#{'create_chat_team' if Gitlab.config.mattermost.enabled}"
%p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ')
%span.gl-path-suggestions
= _("Group path is already taken. We've suggested one that 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...')
.form-group
......
......@@ -28,8 +28,7 @@
title: _('Please choose a group URL with no special characters.'),
"data-bind-in" => "#{'create_chat_team' if Gitlab.config.mattermost.enabled}"
%p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ')
%span.gl-path-suggestions
= _("Group path is already taken. We've suggested one that 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...')
......
......@@ -35,8 +35,7 @@
pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS,
title: _('Please choose a group URL with no special characters.')
%p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ')
%span.gl-path-suggestions
= _("Group path is already taken. We've suggested one that 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...')
.row
......
......@@ -36,8 +36,7 @@
pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS,
title: _('Please choose a group URL with no special characters.')
%p.validation-error.gl-field-error.field-validation.hide
= _('Group path is already taken. Suggestions: ')
%span.gl-path-suggestions
= _("Group path is already taken. We've suggested one that 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...')
.row
......
......@@ -15346,7 +15346,7 @@ msgstr ""
msgid "Group overview content"
msgstr ""
msgid "Group path is already taken. Suggestions: "
msgid "Group path is already taken. We've suggested one that is available."
msgstr ""
msgid "Group path is available."
......
......@@ -77,7 +77,7 @@ RSpec.describe 'Import/Export - Group Import', :js do
click_link 'Import group'
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
......
......@@ -90,7 +90,7 @@ RSpec.describe 'Group' do
fill_in 'group_path', with: user.username
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
it 'does not break after an invalid form submit' do
......@@ -257,7 +257,7 @@ RSpec.describe 'Group' do
fill_in 'Group URL', with: subgroup.path
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
......
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