Commit fb688545 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'show-disabled-mirrors' into 'master'

CE Show disabled project repo mirrors

See merge request gitlab-org/gitlab-ce!27326
parents f2aa884b 87533848
...@@ -133,6 +133,10 @@ class RemoteMirror < ApplicationRecord ...@@ -133,6 +133,10 @@ class RemoteMirror < ApplicationRecord
end end
alias_method :enabled?, :enabled alias_method :enabled?, :enabled
def disabled?
!enabled?
end
def updated_since?(timestamp) def updated_since?(timestamp)
last_update_started_at && last_update_started_at > timestamp && !update_failed? last_update_started_at && last_update_started_at > timestamp && !update_failed?
end end
......
.badge.badge-warning.qa-disabled-mirror-badge{ data: { toggle: 'tooltip', html: 'true' }, title: _('Disabled mirrors can only be enabled by instance owners. It is recommended that you delete them.') }= _('Disabled')
...@@ -49,17 +49,19 @@ ...@@ -49,17 +49,19 @@
%tbody.js-mirrors-table-body %tbody.js-mirrors-table-body
= render_if_exists 'projects/mirrors/table_pull_row' = render_if_exists 'projects/mirrors/table_pull_row'
- @project.remote_mirrors.each_with_index do |mirror, index| - @project.remote_mirrors.each_with_index do |mirror, index|
- if mirror.enabled - next if mirror.new_record?
%tr.qa-mirrored-repository-row %tr.qa-mirrored-repository-row{ class: ('bg-secondary' if mirror.disabled?) }
%td.qa-mirror-repository-url= mirror.safe_url %td.qa-mirror-repository-url= mirror.safe_url
%td= _('Push') %td= _('Push')
%td.qa-mirror-last-update-at= mirror.last_update_at.present? ? time_ago_with_tooltip(mirror.last_update_at) : _('Never') %td.qa-mirror-last-update-at= mirror.last_update_at.present? ? time_ago_with_tooltip(mirror.last_update_at) : _('Never')
%td %td
- if mirror.last_error.present? - if mirror.disabled?
.badge.mirror-error-badge{ data: { toggle: 'tooltip', html: 'true' }, title: html_escape(mirror.last_error.try(:strip)) }= _('Error') = render 'projects/mirrors/disabled_mirror_badge'
%td - if mirror.last_error.present?
.btn-group.mirror-actions-group.pull-right{ role: 'group' } .badge.mirror-error-badge{ data: { toggle: 'tooltip', html: 'true' }, title: html_escape(mirror.last_error.try(:strip)) }= _('Error')
- if mirror.ssh_key_auth? %td
= clipboard_button(text: mirror.ssh_public_key, class: 'btn btn-default', title: _('Copy SSH public key')) .btn-group.mirror-actions-group.pull-right{ role: 'group' }
= render 'shared/remote_mirror_update_button', remote_mirror: mirror - if mirror.ssh_key_auth?
%button.js-delete-mirror.btn.btn-danger{ type: 'button', data: { mirror_id: mirror.id, toggle: 'tooltip', container: 'body' }, title: _('Remove') }= icon('trash-o') = clipboard_button(text: mirror.ssh_public_key, class: 'btn btn-default', title: _('Copy SSH public key'))
= render 'shared/remote_mirror_update_button', remote_mirror: mirror
%button.js-delete-mirror.qa-delete-mirror.btn.btn-danger{ type: 'button', data: { mirror_id: mirror.id, toggle: 'tooltip', container: 'body' }, title: _('Remove') }= icon('trash-o')
- if remote_mirror.update_in_progress? - if remote_mirror.update_in_progress?
%button.btn.disabled{ type: 'button', data: { toggle: 'tooltip', container: 'body' }, title: _('Updating') } %button.btn.disabled{ type: 'button', data: { toggle: 'tooltip', container: 'body' }, title: _('Updating') }
= icon("refresh spin") = icon("refresh spin")
- else - elsif remote_mirror.enabled?
= link_to update_now_project_mirror_path(@project, sync_remote: true), method: :post, class: "btn qa-update-now-button", data: { toggle: 'tooltip', container: 'body' }, title: _('Update now') do = link_to update_now_project_mirror_path(@project, sync_remote: true), method: :post, class: "btn qa-update-now-button", data: { toggle: 'tooltip', container: 'body' }, title: _('Update now') do
= icon("refresh") = icon("refresh")
---
title: Show disabled project repo mirrors in settings
merge_request: 27326
author:
type: other
...@@ -3401,6 +3401,9 @@ msgstr "" ...@@ -3401,6 +3401,9 @@ msgstr ""
msgid "Disabled" msgid "Disabled"
msgstr "" msgstr ""
msgid "Disabled mirrors can only be enabled by instance owners. It is recommended that you delete them."
msgstr ""
msgid "Discard" msgid "Discard"
msgstr "" msgstr ""
......
...@@ -236,5 +236,17 @@ describe 'Projects > Settings > Repository settings' do ...@@ -236,5 +236,17 @@ describe 'Projects > Settings > Repository settings' do
expect(mirrored_project.remote_mirrors.count).to eq(0) expect(mirrored_project.remote_mirrors.count).to eq(0)
end end
end end
it 'shows a disabled mirror' do
create(:remote_mirror, project: project, enabled: false)
visit project_settings_repository_path(project)
mirror = find('.qa-mirrored-repository-row')
expect(mirror).to have_selector('.qa-delete-mirror')
expect(mirror).to have_selector('.qa-disabled-mirror-badge')
expect(mirror).not_to have_selector('.qa-update-now-button')
end
end end
end end
...@@ -373,6 +373,22 @@ describe RemoteMirror, :mailer do ...@@ -373,6 +373,22 @@ describe RemoteMirror, :mailer do
end end
end end
describe '#disabled?' do
subject { remote_mirror.disabled? }
context 'when disabled' do
let(:remote_mirror) { build(:remote_mirror, enabled: false) }
it { is_expected.to be_truthy }
end
context 'when enabled' do
let(:remote_mirror) { build(:remote_mirror, enabled: true) }
it { is_expected.to be_falsy }
end
end
def create_mirror(params) def create_mirror(params)
project = FactoryBot.create(:project, :repository) project = FactoryBot.create(:project, :repository)
project.remote_mirrors.create!(params) project.remote_mirrors.create!(params)
......
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