Commit 7971026b authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '292441-vueify_shared_runners_toggle-cleanup' into 'master'

Remove vueify_shared_runners_toggle feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61043
parents 3983ee99 6ba6cf43
......@@ -36,10 +36,6 @@ document.addEventListener('DOMContentLoaded', () => {
initSettingsPipelinesTriggers();
initArtifactsSettings();
if (gon?.features?.vueifySharedRunnersToggle) {
initSharedRunnersToggle();
}
initSharedRunnersToggle();
initInstallRunner();
});
......@@ -52,23 +52,13 @@ class Projects::RunnersController < Projects::ApplicationController
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
......
......@@ -12,7 +12,6 @@ module Projects
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
......
- 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')
&nbsp; 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.')
......
......@@ -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
---
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
......@@ -11463,9 +11463,6 @@ msgstr ""
msgid "Disable public access to Pages sites"
msgstr ""
msgid "Disable shared runners"
msgstr ""
msgid "Disable two-factor authentication"
msgstr ""
......@@ -12203,9 +12200,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 ""
......@@ -29617,9 +29611,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 ""
......
......@@ -78,84 +78,40 @@ RSpec.describe Projects::RunnersController do
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
......@@ -225,34 +225,27 @@ RSpec.describe 'Runners' do
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
......
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