diff options
author | Luke Bennett <lbennett@gitlab.com> | 2019-03-21 22:24:48 +0000 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2019-04-12 17:04:40 +0100 |
commit | e295c9ab5de9237514d264d740d1dfc98ff9761c (patch) | |
tree | eb1b914dbca278047bd4f282a5ef15bfe236a697 | |
parent | de44f3e176a1891238f5c79ef5203ab06cbe6927 (diff) | |
download | gitlab-ce-ce-show-disabled-mirrors.tar.gz |
Show disabled project repo mirrorsce-show-disabled-mirrors
Show disabled mirrors with a badge so that they
can be deleted by project owners.
-rw-r--r-- | app/views/projects/mirrors/_disabled_mirror_badge.html.haml | 1 | ||||
-rw-r--r-- | app/views/projects/mirrors/_mirror_repos.html.haml | 8 | ||||
-rw-r--r-- | app/views/shared/_remote_mirror_update_button.html.haml | 2 | ||||
-rw-r--r-- | locale/gitlab.pot | 3 | ||||
-rw-r--r-- | spec/features/projects/settings/repository_settings_spec.rb | 19 |
5 files changed, 29 insertions, 4 deletions
diff --git a/app/views/projects/mirrors/_disabled_mirror_badge.html.haml b/app/views/projects/mirrors/_disabled_mirror_badge.html.haml new file mode 100644 index 00000000000..4ce03815d67 --- /dev/null +++ b/app/views/projects/mirrors/_disabled_mirror_badge.html.haml @@ -0,0 +1 @@ +.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') diff --git a/app/views/projects/mirrors/_mirror_repos.html.haml b/app/views/projects/mirrors/_mirror_repos.html.haml index c031815200b..f804532e44f 100644 --- a/app/views/projects/mirrors/_mirror_repos.html.haml +++ b/app/views/projects/mirrors/_mirror_repos.html.haml @@ -49,12 +49,14 @@ %tbody.js-mirrors-table-body = render_if_exists 'projects/mirrors/table_pull_row' - @project.remote_mirrors.each_with_index do |mirror, index| - - if mirror.enabled - %tr.qa-mirrored-repository-row + - if mirror.valid? + %tr.qa-mirrored-repository-row{ class: ('bg-secondary' unless mirror.enabled) } %td.qa-mirror-repository-url= mirror.safe_url %td= _('Push') %td.qa-mirror-last-update-at= mirror.last_update_at.present? ? time_ago_with_tooltip(mirror.last_update_at) : _('Never') %td + - unless mirror.enabled + = render 'projects/mirrors/disabled_mirror_badge' - if mirror.last_error.present? .badge.mirror-error-badge{ data: { toggle: 'tooltip', html: 'true' }, title: html_escape(mirror.last_error.try(:strip)) }= _('Error') %td @@ -62,4 +64,4 @@ - if mirror.ssh_key_auth? = 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.btn.btn-danger{ type: 'button', data: { mirror_id: mirror.id, toggle: 'tooltip', container: 'body' }, title: _('Remove') }= icon('trash-o') + %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') diff --git a/app/views/shared/_remote_mirror_update_button.html.haml b/app/views/shared/_remote_mirror_update_button.html.haml index 721a2af8069..68b65fe27a7 100644 --- a/app/views/shared/_remote_mirror_update_button.html.haml +++ b/app/views/shared/_remote_mirror_update_button.html.haml @@ -1,6 +1,6 @@ - if remote_mirror.update_in_progress? %button.btn.disabled{ type: 'button', data: { toggle: 'tooltip', container: 'body' }, title: _('Updating') } = 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 = icon("refresh") diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 4f401acccf9..9b603f25bf0 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -3139,6 +3139,9 @@ msgstr "" msgid "Disabled" msgstr "" +msgid "Disabled mirrors can only be enabled by instance owners. It is recommended that you delete them." +msgstr "" + msgid "Discard" msgstr "" diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 1259ad45791..ab160b73b21 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -217,5 +217,24 @@ describe 'Projects > Settings > Repository settings' do expect(RepositoryCleanupWorker.jobs.count).to eq(1) end end + + context 'with a disabled mirror' do + let(:mirrored_project) { create(:project, :repository, :remote_mirror) } + + before do + mirrored_project.remote_mirrors.first.update(enabled: false) + mirrored_project.add_maintainer(user) + + visit project_settings_repository_path(mirrored_project) + end + + it 'shows the disabled mirror' do + 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 |