diff --git a/app/assets/javascripts/persistent_user_callouts.js b/app/assets/javascripts/persistent_user_callouts.js index 8170a1f8443670609842247303c665a5910bf87c..cadcab16f16afbee600d0e780443d25f7951b7a8 100644 --- a/app/assets/javascripts/persistent_user_callouts.js +++ b/app/assets/javascripts/persistent_user_callouts.js @@ -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', ]; diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb index d1db624432b45eb944393f0854b407679602ccab..7a90984cd777ee29f296100aa0f9a0723b8ea16f 100644 --- a/app/helpers/user_callouts_helper.rb +++ b/app/helpers/user_callouts_helper.rb @@ -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 @@ def show_suggest_popover? !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? diff --git a/app/models/user_callout.rb b/app/models/user_callout.rb index a1192ceaeda13ee24f53b6b56309faad12266e5f..34996b771a083d0f425659824e8e15d978dd3d23 100644 --- a/app/models/user_callout.rb +++ b/app/models/user_callout.rb @@ -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 diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index 1f2fcd1c70bf2cfc338b6031cb32bdf6970d9f23..c91d27e3ed1fa0c7ae74040f3a2dc3b6596d6293 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -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" diff --git a/app/views/layouts/header/_service_templates_deprecation_callout.html.haml b/app/views/layouts/header/_service_templates_deprecation_callout.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..b5afb306e86df96f701a2b392f48600fbe4c502b --- /dev/null +++ b/app/views/layouts/header/_service_templates_deprecation_callout.html.haml @@ -0,0 +1,21 @@ +- 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 > 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 integrations_admin_application_settings_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') diff --git a/changelogs/unreleased/325196-service-template-deprecation-update.yml b/changelogs/unreleased/325196-service-template-deprecation-update.yml new file mode 100644 index 0000000000000000000000000000000000000000..4aefb4a083abd35cc50f27e9321624a897e9ef71 --- /dev/null +++ b/changelogs/unreleased/325196-service-template-deprecation-update.yml @@ -0,0 +1,5 @@ +--- +title: Add global callout for Service template deprecation +merge_request: 58613 +author: +type: changed diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 8abeacd0d0e1225556f815043fff9d807d3e8f1c..9311082c86a623d71deff6b0d93a9cfd088fd496 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -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. | diff --git a/locale/gitlab.pot b/locale/gitlab.pot index c5bb6cb8737fe9fe1101996905640f0bf6c4aa9e..d96a57b840dde9506b1a573ec54304ef9050864e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -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 > 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 > Integrations.%{link_end}" +msgstr "" + msgid "AdminStatistics|Active Users" msgstr "" @@ -18672,6 +18678,9 @@ msgstr "" msgid "Leave edit mode? All unsaved changes will be lost." msgstr "" +msgid "Leave feedback" +msgstr "" + msgid "Leave group" msgstr "" diff --git a/spec/features/callouts/service_templates_deprecation_spec.rb b/spec/features/callouts/service_templates_deprecation_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..b4ede7073f6a79a2aa098439a49d691c10848e46 --- /dev/null +++ b/spec/features/callouts/service_templates_deprecation_spec.rb @@ -0,0 +1,59 @@ +# 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: integrations_admin_application_settings_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 diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb index a2d9495ce6c280db7fd94dc32ba3744faf515c9f..3dbaa655aebc909c7d74c95c39ef4adcc0915329 100644 --- a/spec/helpers/user_callouts_helper_spec.rb +++ b/spec/helpers/user_callouts_helper_spec.rb @@ -81,23 +81,31 @@ 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