Merge branch 'ssh-key-paste' into 'master'

Updates SSH key title after pasting key

Closes #28436

See merge request !9481
This commit is contained in:
Filipa Lacerda 2017-02-27 16:45:46 +00:00
commit 883342ce36
3 changed files with 9 additions and 4 deletions

View file

@ -84,13 +84,14 @@
} }
$(function() { $(function() {
$(document).on('focusout.ssh_key', '#key_key', function() { $(document).on('input.ssh_key', '#key_key', function() {
const $title = $('#key_title'); const $title = $('#key_title');
const comment = $(this).val().match(/^\S+ \S+ (.+)\n?$/); const comment = $(this).val().match(/^\S+ \S+ (.+)\n?$/);
if (comment && comment.length > 1 && $title.val() === '') {
// Extract the SSH Key title from its comment
if (comment && comment.length > 1) {
return $title.val(comment[1]).change(); return $title.val(comment[1]).change();
} }
// Extract the SSH Key title from its comment
}); });
if (global.utils.getPagePath() === 'profiles') { if (global.utils.getPagePath() === 'profiles') {
return new Profile(); return new Profile();

View file

@ -0,0 +1,4 @@
---
title: SSH key field updates title after pasting key
merge_request:
author:

View file

@ -15,7 +15,7 @@ feature 'Profile > SSH Keys', feature: true do
scenario 'auto-populates the title', js: true do scenario 'auto-populates the title', js: true do
fill_in('Key', with: attributes_for(:key).fetch(:key)) fill_in('Key', with: attributes_for(:key).fetch(:key))
expect(find_field('Title').value).to eq 'dummy@gitlab.com' expect(page).to have_field("Title", with: "dummy@gitlab.com")
end end
scenario 'saves the new key' do scenario 'saves the new key' do