Commit 50fd1ac6 authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '325196-service-template-deprecation-update' into 'master'

Make service template deprecation callout global

See merge request gitlab-org/gitlab!58613
parents 8c0e6973 a9ae2de0
......@@ -7,6 +7,7 @@ const PERSISTENT_USER_CALLOUTS = [
'.js-buy-pipeline-minutes-notification-callout',
'.js-token-expiry-callout',
'.js-registration-enabled-callout',
'.js-service-templates-deprecated-callout',
'.js-new-user-signups-cap-reached',
'.js-eoa-bronze-plan-banner',
];
......
......@@ -5,7 +5,7 @@ module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'
GCP_SIGNUP_OFFER = 'gcp_signup_offer'
SUGGEST_POPOVER_DISMISSED = 'suggest_popover_dismissed'
SERVICE_TEMPLATES_DEPRECATED = 'service_templates_deprecated'
SERVICE_TEMPLATES_DEPRECATED_CALLOUT = 'service_templates_deprecated_callout'
TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight'
WEBHOOKS_MOVED = 'webhooks_moved'
CUSTOMIZE_HOMEPAGE = 'customize_homepage'
......@@ -41,8 +41,11 @@ module UserCalloutsHelper
!user_dismissed?(SUGGEST_POPOVER_DISMISSED)
end
def show_service_templates_deprecated?
!user_dismissed?(SERVICE_TEMPLATES_DEPRECATED)
def show_service_templates_deprecated_callout?
!Gitlab.com? &&
current_user&.admin? &&
Service.for_template.active.exists? &&
!user_dismissed?(SERVICE_TEMPLATES_DEPRECATED_CALLOUT)
end
def show_webhooks_moved_alert?
......
......@@ -17,7 +17,7 @@ class UserCallout < ApplicationRecord
threat_monitoring_info: 11, # EE-only
account_recovery_regular_check: 12, # EE-only
webhooks_moved: 13,
service_templates_deprecated: 14,
service_templates_deprecated_callout: 14,
admin_integrations_moved: 15,
web_ide_alert_dismissed: 16, # no longer in use
active_user_count_threshold: 18, # EE-only
......
......@@ -11,6 +11,7 @@
= render "layouts/broadcast"
= render "layouts/header/read_only_banner"
= render "layouts/header/registration_enabled_callout"
= render "layouts/header/service_templates_deprecation_callout"
= render "layouts/nav/classification_level_banner"
= yield :flash_message
= render "shared/ping_consent"
......
- return unless show_service_templates_deprecated_callout?
- doc_link_start = "<a href=\"#{integrations_help_page_path}\" target='_blank' rel='noopener noreferrer'>".html_safe
- settings_link_start = "<a href=\"#{integrations_admin_application_settings_path}\">".html_safe
%div{ class: [container_class, @content_class, 'gl-pt-5!'] }
.gl-alert.gl-alert-warning.js-service-templates-deprecated-callout{ role: 'alert', data: { feature_id: UserCalloutsHelper::SERVICE_TEMPLATES_DEPRECATED_CALLOUT, dismiss_endpoint: user_callouts_path } }
= sprite_icon('warning', size: 16, css_class: 'gl-alert-icon')
%button.gl-alert-dismiss.js-close{ type: 'button', aria: { label: _('Close') }, data: { testid: 'close-service-templates-deprecated-callout' } }
= sprite_icon('close', size: 16)
.gl-alert-title
= s_('AdminSettings|Service templates are deprecated and will be removed in GitLab 14.0.')
.gl-alert-body
= html_escape_once(s_('AdminSettings|You should migrate to %{doc_link_start}Project integration management%{link_end}, available at %{settings_link_start}Settings &gt; Integrations.%{link_end}')).html_safe % { doc_link_start: doc_link_start, settings_link_start: settings_link_start, link_end: '</a>'.html_safe }
.gl-alert-actions
= link_to admin_application_settings_services_path, class: 'btn gl-alert-action btn-info btn-md gl-button' do
%span.gl-button-text
= s_('AdminSettings|See affected service templates')
= link_to "https://gitlab.com/gitlab-org/gitlab/-/issues/325905", class: 'btn gl-alert-action btn-default btn-md gl-button', target: '_blank', rel: 'noopener noreferrer' do
%span.gl-button-text
= _('Leave feedback')
---
title: Add global callout for Service template deprecation
merge_request: 58613
author:
type: changed
......@@ -8416,7 +8416,7 @@ Name of the feature that the callout is for.
| `NEW_USER_SIGNUPS_CAP_REACHED` | Callout feature name for new_user_signups_cap_reached. |
| `PERSONAL_ACCESS_TOKEN_EXPIRY` | Callout feature name for personal_access_token_expiry. |
| `REGISTRATION_ENABLED_CALLOUT` | Callout feature name for registration_enabled_callout. |
| `SERVICE_TEMPLATES_DEPRECATED` | Callout feature name for service_templates_deprecated. |
| `SERVICE_TEMPLATES_DEPRECATED_CALLOUT` | Callout feature name for service_templates_deprecated_callout. |
| `SUGGEST_PIPELINE` | Callout feature name for suggest_pipeline. |
| `SUGGEST_POPOVER_DISMISSED` | Callout feature name for suggest_popover_dismissed. |
| `TABS_POSITION_HIGHLIGHT` | Callout feature name for tabs_position_highlight. |
......
......@@ -2327,6 +2327,9 @@ msgstr ""
msgid "AdminSettings|Required pipeline configuration"
msgstr ""
msgid "AdminSettings|See affected service templates"
msgstr ""
msgid "AdminSettings|Select a pipeline configuration file"
msgstr ""
......@@ -2363,6 +2366,9 @@ msgstr ""
msgid "AdminSettings|You can't add new templates. To migrate or remove a Service template, create a new integration at %{settings_link_start}Settings &gt; Integrations%{link_end}. Learn more about %{doc_link_start}Project integration management%{link_end}."
msgstr ""
msgid "AdminSettings|You should migrate to %{doc_link_start}Project integration management%{link_end}, available at %{settings_link_start}Settings &gt; Integrations.%{link_end}"
msgstr ""
msgid "AdminStatistics|Active Users"
msgstr ""
......@@ -18705,6 +18711,9 @@ msgstr ""
msgid "Leave edit mode? All unsaved changes will be lost."
msgstr ""
msgid "Leave feedback"
msgstr ""
msgid "Leave group"
msgstr ""
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Service templates deprecation callout' do
let_it_be(:admin) { create(:admin) }
let_it_be(:non_admin) { create(:user) }
let_it_be(:callout_content) { 'Service templates are deprecated and will be removed in GitLab 14.0.' }
context 'when a non-admin is logged in' do
before do
sign_in(non_admin)
visit root_dashboard_path
end
it 'does not display callout' do
expect(page).not_to have_content callout_content
end
end
context 'when an admin is logged in' do
before do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit root_dashboard_path
end
context 'with no active service templates' do
it 'does not display callout' do
expect(page).not_to have_content callout_content
end
end
context 'with active service template' do
before do
create(:service, :template, type: 'MattermostService', active: true)
visit root_dashboard_path
end
it 'displays callout' do
expect(page).to have_content callout_content
expect(page).to have_link 'See affected service templates', href: admin_application_settings_services_path
end
context 'when callout is dismissed', :js do
before do
find('[data-testid="close-service-templates-deprecated-callout"]').click
visit root_dashboard_path
end
it 'does not display callout' do
expect(page).not_to have_content callout_content
end
end
end
end
end
......@@ -81,23 +81,31 @@ RSpec.describe UserCalloutsHelper do
end
end
describe '.show_service_templates_deprecated?' do
subject { helper.show_service_templates_deprecated? }
describe '.show_service_templates_deprecated_callout?' do
using RSpec::Parameterized::TableSyntax
context 'when user has not dismissed' do
before do
allow(helper).to receive(:user_dismissed?).with(described_class::SERVICE_TEMPLATES_DEPRECATED) { false }
end
let_it_be(:admin) { create(:user, :admin) }
let_it_be(:non_admin) { create(:user) }
it { is_expected.to be true }
subject { helper.show_service_templates_deprecated_callout? }
where(:self_managed, :is_admin_user, :has_active_service_template, :callout_dismissed, :should_show_callout) do
true | true | true | false | true
true | true | true | true | false
true | false | true | false | false
false | true | true | false | false
true | true | false | false | false
end
context 'when user dismissed' do
with_them do
before do
allow(helper).to receive(:user_dismissed?).with(described_class::SERVICE_TEMPLATES_DEPRECATED) { true }
allow(::Gitlab).to receive(:com?).and_return(!self_managed)
allow(helper).to receive(:current_user).and_return(is_admin_user ? admin : non_admin)
allow(helper).to receive(:user_dismissed?).with(described_class::SERVICE_TEMPLATES_DEPRECATED_CALLOUT) { callout_dismissed }
create(:service, :template, type: 'MattermostService', active: has_active_service_template)
end
it { is_expected.to be false }
it { is_expected.to be should_show_callout }
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