diff --git a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js index f7e0d102b08c889f4cfc0ae01914fd1bda526651..10105af3561ddf51893701b00f1fa43a9047f9aa 100644 --- a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js +++ b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js @@ -36,10 +36,6 @@ document.addEventListener('DOMContentLoaded', () => { initSettingsPipelinesTriggers(); initArtifactsSettings(); - - if (gon?.features?.vueifySharedRunnersToggle) { - initSharedRunnersToggle(); - } - + initSharedRunnersToggle(); initInstallRunner(); }); diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index 04cc3428bf9de3da0bc771f94294d4d02e9f754c..ec1f57f090a012d3f673200de7f8ec666c36cc78 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -52,23 +52,13 @@ def show def toggle_shared_runners if !project.shared_runners_enabled && project.group && project.group.shared_runners_setting == 'disabled_and_unoverridable' - - if Feature.enabled?(:vueify_shared_runners_toggle, @project) - render json: { error: _('Cannot enable shared runners because parent group does not allow it') }, status: :unauthorized - else - redirect_to project_runners_path(@project), alert: _('Cannot enable shared runners because parent group does not allow it') - end - + render json: { error: _('Cannot enable shared runners because parent group does not allow it') }, status: :unauthorized return end project.toggle!(:shared_runners_enabled) - if Feature.enabled?(:vueify_shared_runners_toggle, @project) - render json: {}, status: :ok - else - redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings') - end + render json: {}, status: :ok end def toggle_group_runners diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index c67d7f53faf9ff152f2a3cbd479a98491f86351b..272968a257a728be1240150055f4daf500426fee 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -12,7 +12,6 @@ class CiCdController < Projects::ApplicationController before_action :define_variables before_action do push_frontend_feature_flag(:ajax_new_deploy_token, @project) - push_frontend_feature_flag(:vueify_shared_runners_toggle, @project) end helper_method :highlight_badge diff --git a/app/views/projects/runners/_shared_runners.html.haml b/app/views/projects/runners/_shared_runners.html.haml index f7248baeb2749ee9c5e1f9057d39c277a6717159..3df4f3a0bd0b952e1b8f2dac758a53d72ef8f7bf 100644 --- a/app/views/projects/runners/_shared_runners.html.haml +++ b/app/views/projects/runners/_shared_runners.html.haml @@ -1,23 +1,6 @@ -- isVueifySharedRunnersToggleEnabled = Feature.enabled?(:vueify_shared_runners_toggle, @project) += render 'shared/runners/shared_runners_description' -= render layout: 'shared/runners/shared_runners_description' do - - if !isVueifySharedRunnersToggleEnabled - %br - %br - - if @project.group&.shared_runners_setting == 'disabled_and_unoverridable' - %h5.gl-text-red-500 - = _('Shared runners disabled on group level') - - else - - if @project.shared_runners_enabled? - = link_to toggle_shared_runners_project_runners_path(@project), class: 'btn gl-button btn-default', method: :post do - = _('Disable shared runners') - - else - = link_to toggle_shared_runners_project_runners_path(@project), class: 'btn gl-button btn-confirm-secondary', method: :post do - = _('Enable shared runners') - for this project - -- if isVueifySharedRunnersToggleEnabled - #toggle-shared-runners-form{ data: toggle_shared_runners_settings_data(@project) } +#toggle-shared-runners-form{ data: toggle_shared_runners_settings_data(@project) } - if @shared_runners_count == 0 = _('This GitLab instance does not provide any shared runners yet. Instance administrators can register shared runners in the admin area.') diff --git a/app/views/shared/runners/_shared_runners_description.html.haml b/app/views/shared/runners/_shared_runners_description.html.haml index 6c8bc3a2316576d555444c1b3f30c12bc50dc615..a276f725576aff79feca02fdf1fdcf4bfbeac1e4 100644 --- a/app/views/shared/runners/_shared_runners_description.html.haml +++ b/app/views/shared/runners/_shared_runners_description.html.haml @@ -9,4 +9,3 @@ = markdown(Gitlab::CurrentSettings.current_application_settings.shared_runners_text) - else %p= _('The same shared runner executes code from multiple projects, unless you configure autoscaling with %{link} set to 1 (which it is on GitLab.com).').html_safe % { link: link } - = yield diff --git a/changelogs/unreleased/292441-vueify_shared_runners_toggle-cleanup.yml b/changelogs/unreleased/292441-vueify_shared_runners_toggle-cleanup.yml new file mode 100644 index 0000000000000000000000000000000000000000..7a541b9bf25c8c146e9dac2e53c4a1812d167355 --- /dev/null +++ b/changelogs/unreleased/292441-vueify_shared_runners_toggle-cleanup.yml @@ -0,0 +1,5 @@ +--- +title: Update appearance of "Enable shared runners for this project" toggle in Project > Settings > CI/CD +merge_request: 61043 +author: +type: changed diff --git a/config/feature_flags/development/vueify_shared_runners_toggle.yml b/config/feature_flags/development/vueify_shared_runners_toggle.yml deleted file mode 100644 index b1555c5e938edcbcf4553867ee39b94d8827be69..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/vueify_shared_runners_toggle.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: vueify_shared_runners_toggle -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48452 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/292441 -milestone: '13.7' -type: development -group: group::continuous integration -default_enabled: false diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3e1f87806bb3d88547fa24a251adedb9354c466e..97f3ce7c39e18b58615c09e229be5a54a9331794 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -11439,9 +11439,6 @@ msgstr "" msgid "Disable public access to Pages sites" msgstr "" -msgid "Disable shared runners" -msgstr "" - msgid "Disable two-factor authentication" msgstr "" @@ -12185,9 +12182,6 @@ msgstr "" msgid "Enable reCAPTCHA, Invisible Captcha, Akismet and set IP limits. For reCAPTCHA, we currently only support %{recaptcha_v2_link_start}v2%{recaptcha_v2_link_end}" msgstr "" -msgid "Enable shared runners" -msgstr "" - msgid "Enable shared runners for all projects and subgroups in this group." msgstr "" @@ -29506,9 +29500,6 @@ msgstr "" msgid "Shared runners are disabled on group level" msgstr "" -msgid "Shared runners disabled on group level" -msgstr "" - msgid "Shared runners help link" msgstr "" diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb index 3021ad42c9fd5199045f03d606f1d7c0734e8b17..39b45a7133cc2630cc4d7352e56457515b69837f 100644 --- a/spec/controllers/projects/runners_controller_spec.rb +++ b/spec/controllers/projects/runners_controller_spec.rb @@ -78,84 +78,40 @@ let(:group) { create(:group) } let(:project) { create(:project, group: group) } - context 'without feature flag' do - before do - stub_feature_flags(vueify_shared_runners_toggle: false) - end + it 'toggles shared_runners_enabled when the group allows shared runners' do + project.update!(shared_runners_enabled: true) - it 'toggles shared_runners_enabled when the group allows shared runners' do - project.update!(shared_runners_enabled: true) + post :toggle_shared_runners, params: params - post :toggle_shared_runners, params: params + project.reload - project.reload - - expect(response).to have_gitlab_http_status(:found) - expect(project.shared_runners_enabled).to eq(false) - end - - it 'toggles shared_runners_enabled when the group disallows shared runners but allows overrides' do - group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: true) - project.update!(shared_runners_enabled: false) - - post :toggle_shared_runners, params: params - - project.reload - - expect(response).to have_gitlab_http_status(:found) - expect(project.shared_runners_enabled).to eq(true) - end - - it 'does not enable if the group disallows shared runners' do - group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false) - project.update!(shared_runners_enabled: false) - - post :toggle_shared_runners, params: params - - project.reload - - expect(response).to have_gitlab_http_status(:found) - expect(project.shared_runners_enabled).to eq(false) - expect(flash[:alert]).to eq('Cannot enable shared runners because parent group does not allow it') - end + expect(response).to have_gitlab_http_status(:ok) + expect(project.shared_runners_enabled).to eq(false) end - context 'with feature flag: vueify_shared_runners_toggle' do - it 'toggles shared_runners_enabled when the group allows shared runners' do - project.update!(shared_runners_enabled: true) - - post :toggle_shared_runners, params: params - - project.reload + it 'toggles shared_runners_enabled when the group disallows shared runners but allows overrides' do + group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: true) + project.update!(shared_runners_enabled: false) - expect(response).to have_gitlab_http_status(:ok) - expect(project.shared_runners_enabled).to eq(false) - end + post :toggle_shared_runners, params: params - it 'toggles shared_runners_enabled when the group disallows shared runners but allows overrides' do - group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: true) - project.update!(shared_runners_enabled: false) + project.reload - post :toggle_shared_runners, params: params - - project.reload - - expect(response).to have_gitlab_http_status(:ok) - expect(project.shared_runners_enabled).to eq(true) - end + expect(response).to have_gitlab_http_status(:ok) + expect(project.shared_runners_enabled).to eq(true) + end - it 'does not enable if the group disallows shared runners' do - group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false) - project.update!(shared_runners_enabled: false) + it 'does not enable if the group disallows shared runners' do + group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false) + project.update!(shared_runners_enabled: false) - post :toggle_shared_runners, params: params + post :toggle_shared_runners, params: params - project.reload + project.reload - expect(response).to have_gitlab_http_status(:unauthorized) - expect(project.shared_runners_enabled).to eq(false) - expect(json_response['error']).to eq('Cannot enable shared runners because parent group does not allow it') - end + expect(response).to have_gitlab_http_status(:unauthorized) + expect(project.shared_runners_enabled).to eq(false) + expect(json_response['error']).to eq('Cannot enable shared runners because parent group does not allow it') end end end diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index 64250931006809972f16bd00fec1b1a0e40c03ac..b61a769185e1883e509a00a05c6938b5b0486aaf 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -225,34 +225,27 @@ end end - context 'when a project has disabled shared_runners' do - let(:project) { create(:project, shared_runners_enabled: false) } - - context 'when feature flag: vueify_shared_runners_toggle is disabled' do - before do - stub_feature_flags(vueify_shared_runners_toggle: false) - project.add_maintainer(user) - end + context 'enable shared runners in project settings', :js do + before do + project.add_maintainer(user) - it 'user enables shared runners' do - visit project_runners_path(project) + visit project_runners_path(project) + end - click_on 'Enable shared runners' + context 'when a project has enabled shared_runners' do + let(:project) { create(:project, shared_runners_enabled: true) } - expect(page.find("[data-testid='shared-runners-description']")).to have_content('Disable shared runners') - expect(page).not_to have_selector('#toggle-shared-runners-form') + it 'shared runners toggle is on' do + expect(page).to have_selector('[data-testid="toggle-shared-runners"]') + expect(page).to have_selector('[data-testid="toggle-shared-runners"] .is-checked') end end - context 'when feature flag: vueify_shared_runners_toggle is enabled' do - before do - project.add_maintainer(user) - end - - it 'user enables shared runners' do - visit project_runners_path(project) + context 'when a project has disabled shared_runners' do + let(:project) { create(:project, shared_runners_enabled: false) } - expect(page).to have_selector('#toggle-shared-runners-form') + it 'shared runners toggle is off' do + expect(page).not_to have_selector('[data-testid="toggle-shared-runners"] .is-checked') end end end