Commit 6ba6cf43 authored by Miguel Rincon's avatar Miguel Rincon

Update shared runners toggle for projects

Update appearance of "Enable shared runners for this project" toggle
in Project > Settings > CI/CD

This change removes the feature flag vueify_shared_runners_toggle
that has been rolled out successfully.

Changelog: changed
parent 233ab6aa
...@@ -36,10 +36,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -36,10 +36,6 @@ document.addEventListener('DOMContentLoaded', () => {
initSettingsPipelinesTriggers(); initSettingsPipelinesTriggers();
initArtifactsSettings(); initArtifactsSettings();
initSharedRunnersToggle();
if (gon?.features?.vueifySharedRunnersToggle) {
initSharedRunnersToggle();
}
initInstallRunner(); initInstallRunner();
}); });
...@@ -52,23 +52,13 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -52,23 +52,13 @@ class Projects::RunnersController < Projects::ApplicationController
def toggle_shared_runners def toggle_shared_runners
if !project.shared_runners_enabled && project.group && project.group.shared_runners_setting == 'disabled_and_unoverridable' if !project.shared_runners_enabled && project.group && project.group.shared_runners_setting == 'disabled_and_unoverridable'
render json: { error: _('Cannot enable shared runners because parent group does not allow it') }, status: :unauthorized
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
return return
end end
project.toggle!(:shared_runners_enabled) project.toggle!(:shared_runners_enabled)
if Feature.enabled?(:vueify_shared_runners_toggle, @project) render json: {}, status: :ok
render json: {}, status: :ok
else
redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings')
end
end end
def toggle_group_runners def toggle_group_runners
......
...@@ -12,7 +12,6 @@ module Projects ...@@ -12,7 +12,6 @@ module Projects
before_action :define_variables before_action :define_variables
before_action do before_action do
push_frontend_feature_flag(:ajax_new_deploy_token, @project) push_frontend_feature_flag(:ajax_new_deploy_token, @project)
push_frontend_feature_flag(:vueify_shared_runners_toggle, @project)
end end
helper_method :highlight_badge helper_method :highlight_badge
......
- isVueifySharedRunnersToggleEnabled = Feature.enabled?(:vueify_shared_runners_toggle, @project) = render 'shared/runners/shared_runners_description'
= render layout: 'shared/runners/shared_runners_description' do #toggle-shared-runners-form{ data: toggle_shared_runners_settings_data(@project) }
- 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')
&nbsp; for this project
- if isVueifySharedRunnersToggleEnabled
#toggle-shared-runners-form{ data: toggle_shared_runners_settings_data(@project) }
- if @shared_runners_count == 0 - 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.') = _('This GitLab instance does not provide any shared runners yet. Instance administrators can register shared runners in the admin area.')
......
...@@ -9,4 +9,3 @@ ...@@ -9,4 +9,3 @@
= markdown(Gitlab::CurrentSettings.current_application_settings.shared_runners_text) = markdown(Gitlab::CurrentSettings.current_application_settings.shared_runners_text)
- else - 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 } %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
---
title: Update appearance of "Enable shared runners for this project" toggle in Project > Settings > CI/CD
merge_request: 61043
author:
type: changed
---
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
...@@ -11439,9 +11439,6 @@ msgstr "" ...@@ -11439,9 +11439,6 @@ msgstr ""
msgid "Disable public access to Pages sites" msgid "Disable public access to Pages sites"
msgstr "" msgstr ""
msgid "Disable shared runners"
msgstr ""
msgid "Disable two-factor authentication" msgid "Disable two-factor authentication"
msgstr "" msgstr ""
...@@ -12185,9 +12182,6 @@ 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}" 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 "" msgstr ""
msgid "Enable shared runners"
msgstr ""
msgid "Enable shared runners for all projects and subgroups in this group." msgid "Enable shared runners for all projects and subgroups in this group."
msgstr "" msgstr ""
...@@ -29506,9 +29500,6 @@ msgstr "" ...@@ -29506,9 +29500,6 @@ msgstr ""
msgid "Shared runners are disabled on group level" msgid "Shared runners are disabled on group level"
msgstr "" msgstr ""
msgid "Shared runners disabled on group level"
msgstr ""
msgid "Shared runners help link" msgid "Shared runners help link"
msgstr "" msgstr ""
......
...@@ -78,84 +78,40 @@ RSpec.describe Projects::RunnersController do ...@@ -78,84 +78,40 @@ RSpec.describe Projects::RunnersController do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, group: group) } let(:project) { create(:project, group: group) }
context 'without feature flag' do it 'toggles shared_runners_enabled when the group allows shared runners' do
before do project.update!(shared_runners_enabled: true)
stub_feature_flags(vueify_shared_runners_toggle: false)
end
it 'toggles shared_runners_enabled when the group allows shared runners' do post :toggle_shared_runners, params: params
project.update!(shared_runners_enabled: true)
post :toggle_shared_runners, params: params project.reload
project.reload expect(response).to have_gitlab_http_status(:ok)
expect(project.shared_runners_enabled).to eq(false)
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
end end
context 'with feature flag: vueify_shared_runners_toggle' do it 'toggles shared_runners_enabled when the group disallows shared runners but allows overrides' do
it 'toggles shared_runners_enabled when the group allows shared runners' do group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: true)
project.update!(shared_runners_enabled: true) project.update!(shared_runners_enabled: false)
post :toggle_shared_runners, params: params
project.reload
expect(response).to have_gitlab_http_status(:ok) post :toggle_shared_runners, params: params
expect(project.shared_runners_enabled).to eq(false)
end
it 'toggles shared_runners_enabled when the group disallows shared runners but allows overrides' do project.reload
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 expect(response).to have_gitlab_http_status(:ok)
expect(project.shared_runners_enabled).to eq(true)
project.reload 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 it 'does not enable if the group disallows shared runners' do
group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false) group.update!(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false)
project.update!(shared_runners_enabled: 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(response).to have_gitlab_http_status(:unauthorized)
expect(project.shared_runners_enabled).to eq(false) 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') expect(json_response['error']).to eq('Cannot enable shared runners because parent group does not allow it')
end
end end
end end
end end
...@@ -225,34 +225,27 @@ RSpec.describe 'Runners' do ...@@ -225,34 +225,27 @@ RSpec.describe 'Runners' do
end end
end end
context 'when a project has disabled shared_runners' do context 'enable shared runners in project settings', :js do
let(:project) { create(:project, shared_runners_enabled: false) } before do
project.add_maintainer(user)
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
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') it 'shared runners toggle is on' do
expect(page).not_to have_selector('#toggle-shared-runners-form') expect(page).to have_selector('[data-testid="toggle-shared-runners"]')
expect(page).to have_selector('[data-testid="toggle-shared-runners"] .is-checked')
end end
end end
context 'when feature flag: vueify_shared_runners_toggle is enabled' do context 'when a project has disabled shared_runners' do
before do let(:project) { create(:project, shared_runners_enabled: false) }
project.add_maintainer(user)
end
it 'user enables shared runners' do
visit project_runners_path(project)
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 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