Improve mirroring repositories UI

The layout is broken when pull mirrors is available.
parent 2e201c8d
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
.settings-content .settings-content
= form_for @project, url: project_mirror_path(@project), html: { class: 'gl-show-field-errors js-mirror-form', autocomplete: 'false', data: mirrors_form_data_attributes } do |f| = form_for @project, url: project_mirror_path(@project), html: { class: 'gl-show-field-errors js-mirror-form', autocomplete: 'false', data: mirrors_form_data_attributes } do |f|
.card .panel.panel-default
.card-header .panel-heading
%h3.card-title= _('Mirror a repository') %h3.panel-title= _('Mirror a repository')
.card-body .panel-body
%div= form_errors(@project) %div= form_errors(@project)
.form-group.has-feedback .form-group.has-feedback
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
.panel-footer .panel-footer
= f.submit _('Mirror repository'), class: 'btn btn-success', name: :update_remote_mirror = f.submit _('Mirror repository'), class: 'btn btn-success', name: :update_remote_mirror
.card .panel.panel-default
.table-responsive .table-responsive
%table.table.push-pull-table %table.table.push-pull-table
%thead %thead
......
...@@ -25,7 +25,9 @@ export default class MirrorPull { ...@@ -25,7 +25,9 @@ export default class MirrorPull {
this.$wellSSHAuth = this.$form.find('.js-well-ssh-auth'); this.$wellSSHAuth = this.$form.find('.js-well-ssh-auth');
this.$sshPublicKeyWrap = this.$form.find('.js-ssh-public-key-wrap'); this.$sshPublicKeyWrap = this.$form.find('.js-ssh-public-key-wrap');
this.$regeneratePublicSshKeyButton = this.$wellSSHAuth.find('.js-btn-regenerate-ssh-key'); this.$regeneratePublicSshKeyButton = this.$wellSSHAuth.find('.js-btn-regenerate-ssh-key');
this.$regeneratePublicSshKeyModal = this.$wellSSHAuth.find('.js-regenerate-public-ssh-key-confirm-modal'); this.$regeneratePublicSshKeyModal = this.$wellSSHAuth.find(
'.js-regenerate-public-ssh-key-confirm-modal',
);
} }
init() { init() {
...@@ -36,9 +38,15 @@ export default class MirrorPull { ...@@ -36,9 +38,15 @@ export default class MirrorPull {
this.$dropdownAuthType.on('change', e => this.handleAuthTypeChange(e)); this.$dropdownAuthType.on('change', e => this.handleAuthTypeChange(e));
this.$btnDetectHostKeys.on('click', e => this.handleDetectHostKeys(e)); this.$btnDetectHostKeys.on('click', e => this.handleDetectHostKeys(e));
this.$btnSSHHostsShowAdvanced.on('click', e => this.handleSSHHostsAdvanced(e)); this.$btnSSHHostsShowAdvanced.on('click', e => this.handleSSHHostsAdvanced(e));
this.$regeneratePublicSshKeyButton.on('click', () => this.$regeneratePublicSshKeyModal.toggle(true)); this.$regeneratePublicSshKeyButton.on('click', () =>
$('.js-confirm', this.$regeneratePublicSshKeyModal).on('click', e => this.regeneratePublicSshKey(e)); this.$regeneratePublicSshKeyModal.toggle(true),
$('.js-cancel', this.$regeneratePublicSshKeyModal).on('click', () => this.$regeneratePublicSshKeyModal.toggle(false)); );
$('.js-confirm', this.$regeneratePublicSshKeyModal).on('click', e =>
this.regeneratePublicSshKey(e),
);
$('.js-cancel', this.$regeneratePublicSshKeyModal).on('click', () =>
this.$regeneratePublicSshKeyModal.toggle(false),
);
} }
/** /**
...@@ -77,11 +85,11 @@ export default class MirrorPull { ...@@ -77,11 +85,11 @@ export default class MirrorPull {
handleDetectHostKeys() { handleDetectHostKeys() {
const projectMirrorSSHEndpoint = this.$form.data('project-mirror-ssh-endpoint'); const projectMirrorSSHEndpoint = this.$form.data('project-mirror-ssh-endpoint');
const repositoryUrl = this.$repositoryUrl.val(); const repositoryUrl = this.$repositoryUrl.val();
const $btnLoadSpinner = this.$btnDetectHostKeys.find('.detect-host-keys-load-spinner'); const $btnLoadSpinner = this.$btnDetectHostKeys.find('.js-spinner');
// Disable button while we make request // Disable button while we make request
this.$btnDetectHostKeys.disable(); this.$btnDetectHostKeys.disable();
$btnLoadSpinner.removeClass('hidden'); $btnLoadSpinner.removeClass('d-none');
// Make backOff polling to get data // Make backOff polling to get data
backOff((next, stop) => { backOff((next, stop) => {
...@@ -102,7 +110,7 @@ export default class MirrorPull { ...@@ -102,7 +110,7 @@ export default class MirrorPull {
.catch(stop); .catch(stop);
}) })
.then(res => { .then(res => {
$btnLoadSpinner.addClass('hidden'); $btnLoadSpinner.addClass('d-none');
// Once data is received, we show verification info along with Host keys and fingerprints // Once data is received, we show verification info along with Host keys and fingerprints
this.$hostKeysInformation this.$hostKeysInformation
.find('.js-fingerprint-verification') .find('.js-fingerprint-verification')
......
...@@ -28,6 +28,6 @@ ...@@ -28,6 +28,6 @@
= button_tag type: 'button', = button_tag type: 'button',
data: { endpoint: project_mirror_path(@project, project: { import_data_attributes: regen_data }) }, data: { endpoint: project_mirror_path(@project, project: { import_data_attributes: regen_data }) },
class: "btn btn-inverted btn-warning prepend-top-10 js-btn-regenerate-ssh-key#{ ' collapse' unless ssh_public_key_present }" do class: "btn btn-inverted btn-warning prepend-top-10 js-btn-regenerate-ssh-key#{ ' collapse' unless ssh_public_key_present }" do
%i.fa.fa-spinner.fa-spin.js-spinner = icon('spinner spin', class: 'js-spinner d-none')
= _('Regenerate key') = _('Regenerate key')
= render 'projects/mirrors/pull/regenerate_public_ssh_key_confirm_modal' = render 'projects/mirrors/pull/regenerate_public_ssh_key_confirm_modal'
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.form-group.js-ssh-host-keys-section{ class: ('collapse' unless import_data.ssh_import?) } .form-group.js-ssh-host-keys-section{ class: ('collapse' unless import_data.ssh_import?) }
%button.btn.btn-inverted.btn-success.inline.js-detect-host-keys.append-right-10{ type: 'button' } %button.btn.btn-inverted.btn-success.inline.js-detect-host-keys.append-right-10{ type: 'button' }
= icon('spinner spin', class: 'detect-host-keys-load-spinner hidden') = icon('spinner spin', class: 'js-spinner d-none')
= _('Detect host keys') = _('Detect host keys')
.fingerprint-ssh-info.js-fingerprint-ssh-info.prepend-top-10.append-bottom-10{ class: ('collapse' unless import_data.ssh_import?) } .fingerprint-ssh-info.js-fingerprint-ssh-info.prepend-top-10.append-bottom-10{ class: ('collapse' unless import_data.ssh_import?) }
%label.label-bold %label.label-bold
......
...@@ -139,8 +139,12 @@ describe 'Project mirror', :js do ...@@ -139,8 +139,12 @@ describe 'Project mirror', :js do
# Check regenerating the public key works # Check regenerating the public key works
click_without_sidekiq 'Regenerate key' click_without_sidekiq 'Regenerate key'
find('.js-regenerate-public-ssh-key-confirm-modal .js-confirm').click find('.js-regenerate-public-ssh-key-confirm-modal .js-confirm').click
expect(page).to have_selector(".fa-spinner")
wait_for_requests wait_for_requests
expect(page).not_to have_selector(".fa-spinner")
expect(page).not_to have_content(first_key) expect(page).not_to have_content(first_key)
expect(page).to have_content(import_data.reload.ssh_public_key) expect(page).to have_content(import_data.reload.ssh_public_key)
end end
...@@ -159,8 +163,12 @@ describe 'Project mirror', :js do ...@@ -159,8 +163,12 @@ describe 'Project mirror', :js do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
select('Pull', from: 'Mirror direction') select('Pull', from: 'Mirror direction')
click_on 'Detect host keys' click_on 'Detect host keys'
expect(page).to have_selector(".fa-spinner")
wait_for_requests wait_for_requests
expect(page).not_to have_selector(".fa-spinner")
expect(page).to have_content(key.fingerprint) expect(page).to have_content(key.fingerprint)
click_on 'Input host keys manually' click_on 'Input host keys manually'
...@@ -178,7 +186,12 @@ describe 'Project mirror', :js do ...@@ -178,7 +186,12 @@ describe 'Project mirror', :js do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
select('Pull', from: 'Mirror direction') select('Pull', from: 'Mirror direction')
click_on 'Detect host keys' click_on 'Detect host keys'
expect(page).to have_selector(".fa-spinner")
wait_for_requests wait_for_requests
expect(page).not_to have_selector(".fa-spinner")
end end
# Appears in the flash # Appears in the flash
......
...@@ -12,17 +12,36 @@ describe 'Project settings > [EE] repository' do ...@@ -12,17 +12,36 @@ describe 'Project settings > [EE] repository' do
end end
context 'unlicensed' do context 'unlicensed' do
before do it 'does not show pull mirror settings', :js do
stub_licensed_features(repository_mirrors: false) stub_licensed_features(repository_mirrors: false)
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
end
it 'does not show pull mirror settings', :js do page.within('.project-mirror-settings') do
expect(page).to have_no_selector('#project_mirror') expect(page).to have_selector('#url')
expect(page).to have_no_selector('#project_import_url') expect(page).to have_selector('#mirror_direction')
expect(page).to have_no_selector('#project_mirror', visible: false)
expect(page).to have_no_selector('#project_mirror_user_id', visible: false) expect(page).to have_no_selector('#project_mirror_user_id', visible: false)
expect(page).to have_no_selector('#project_mirror_overwrites_diverged_branches')
expect(page).to have_no_selector('#project_mirror_trigger_builds') expect(page).to have_no_selector('#project_mirror_trigger_builds')
end end
end end
end
context 'licensed' do
it 'shows pull mirror settings', :js do
stub_licensed_features(repository_mirrors: true)
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do
expect(page).to have_selector('#url')
expect(page).to have_selector('#mirror_direction')
expect(page).to have_selector('#project_mirror', visible: false)
expect(page).to have_selector('#project_mirror_user_id', visible: false)
expect(page).to have_selector('#project_mirror_overwrites_diverged_branches')
expect(page).to have_selector('#project_mirror_trigger_builds')
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