diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index ef1bf283d0c9c4a801cd94572f20d63da3ee6f57..358b896702bb99b639fbd29e6de4f304fafd8328 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -251,6 +251,7 @@ def visible_attributes :user_oauth_applications, :version_check_enabled, :allow_local_requests_from_hooks_and_services, + :hide_third_party_offers, :enforce_terms, :terms, :mirror_available diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb index c24d340d184ada9a86879663186d746db3b9450f..8fd0b6f14c675bc5a56674e02b06d99f0edbed3b 100644 --- a/app/helpers/clusters_helper.rb +++ b/app/helpers/clusters_helper.rb @@ -4,6 +4,7 @@ def has_multiple_clusters?(project) end def render_gcp_signup_offer + return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return unless show_gcp_signup_offer? content_tag :section, class: 'no-animate expanded' do diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index bddeb8b0352d2562dca1f7425261f632e262206f..f770b2194222d576eb221cbebf8fceb7b5966c65 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -294,6 +294,7 @@ def self.defaults gitaly_timeout_medium: 30, gitaly_timeout_default: 55, allow_local_requests_from_hooks_and_services: false, + hide_third_party_offers: false, mirror_available: true } end diff --git a/app/views/admin/application_settings/_third_party_offers.html.haml b/app/views/admin/application_settings/_third_party_offers.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..c5d775d4bf5c3c2536233563fe9fdfdc4a705ff7 --- /dev/null +++ b/app/views/admin/application_settings/_third_party_offers.html.haml @@ -0,0 +1,13 @@ +- application_setting = local_assigns.fetch(:application_setting) + += form_for application_setting, url: admin_application_settings_path, html: { class: 'fieldset-form' } do |f| + = form_errors(application_setting) + + %fieldset + .form-group + .form-check + = f.check_box :hide_third_party_offers, class: 'form-check-input' + = f.label :hide_third_party_offers, class: 'form-check-label' do + Do not display offers from third parties within GitLab + + = f.submit 'Save changes', class: "btn btn-success" diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml index bd43504dd37c8fb37203c1dd2410744d11e12f9c..5cb8001a364ad1a9e7d37c55aedfa7325b85452f 100644 --- a/app/views/admin/application_settings/show.html.haml +++ b/app/views/admin/application_settings/show.html.haml @@ -325,5 +325,16 @@ .settings-content = render partial: 'repository_mirrors_form' +%section.settings.as-third-party-offers.no-animate#js-third-party-offers-settings{ class: ('expanded' if expanded) } + .settings-header + %h4 + = _('Third party offers') + %button.btn.btn-default.js-settings-toggle{ type: 'button' } + = expanded ? _('Collapse') : _('Expand') + %p + = _('Control the display of third party offers.') + .settings-content + = render 'third_party_offers', application_setting: @application_setting + = render_if_exists 'admin/application_settings/pseudonymizer_settings', expanded: expanded diff --git a/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml b/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml new file mode 100644 index 0000000000000000000000000000000000000000..575767df9128027b0f2eeaf2949235f991cd270e --- /dev/null +++ b/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml @@ -0,0 +1,5 @@ +--- +title: Add option to hide third party offers in admin application settings +merge_request: 20379 +author: +type: added diff --git a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..6631c5d1b6c03e935264caba768053f5a2a4a41b --- /dev/null +++ b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb @@ -0,0 +1,18 @@ +class AddHideThirdPartyOffersToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:application_settings, :hide_third_party_offers, + :boolean, + default: false, + allow_null: false) + end + + def down + remove_column(:application_settings, :hide_third_party_offers) + end +end diff --git a/db/schema.rb b/db/schema.rb index 1898dfc6022f70ec042f2bdf6e0e8d24da717cf1..75a1960e2f819510c40cf7bb47678ebc7e5a233d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180702120647) do +ActiveRecord::Schema.define(version: 20180704204006) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -167,6 +167,7 @@ t.boolean "allow_local_requests_from_hooks_and_services", default: false, null: false t.boolean "enforce_terms", default: false t.boolean "mirror_available", default: true, null: false + t.boolean "hide_third_party_offers", default: false, null: false end create_table "audit_events", force: :cascade do |t| diff --git a/doc/administration/index.md b/doc/administration/index.md index 922cc45d8c45eff693dd6def97b14d3f3d967432..88190b2df5ff4521ebb969ad3151acf55b7536f1 100644 --- a/doc/administration/index.md +++ b/doc/administration/index.md @@ -45,6 +45,7 @@ Learn how to install, configure, update, and maintain your GitLab instance. - [Environment variables](environment_variables.md): Supported environment variables that can be used to override their defaults values in order to configure GitLab. - [Plugins](plugins.md): With custom plugins, GitLab administrators can introduce custom integrations without modifying GitLab's source code. - [Enforcing Terms of Service](../user/admin_area/settings/terms.md) +- [Third party offers](../user/admin_area/settings/third_party_offers.md) #### Customizing GitLab's appearance diff --git a/doc/user/admin_area/settings/third_party_offers.md b/doc/user/admin_area/settings/third_party_offers.md new file mode 100644 index 0000000000000000000000000000000000000000..177251b52b97865662ed312c2ff0026d13c6e839 --- /dev/null +++ b/doc/user/admin_area/settings/third_party_offers.md @@ -0,0 +1,6 @@ +# Third party offers + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20379) +> in [GitLab Core](https://about.gitlab.com/pricing/) 11.1 + +The display of third party offers can be controlled in the Admin Area -> Settings page. diff --git a/locale/gitlab.pot b/locale/gitlab.pot index b6fd7ccc1bbd3c964dd9c8ef0fc9fc005dd7b07e..f2e4eda576fd63efd60b82c3314894595815f5ee 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-09 19:16+0200\n" -"PO-Revision-Date: 2018-07-09 19:16+0200\n" +"POT-Creation-Date: 2018-07-10 08:56+0200\n" +"PO-Revision-Date: 2018-07-10 08:56+0200\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: \n" @@ -1644,6 +1644,9 @@ msgstr "" msgid "ContributorsPage|Please wait a moment, this page will automatically refresh when ready." msgstr "" +msgid "Control the display of third party offers." +msgstr "" + msgid "Copy URL to clipboard" msgstr "" @@ -4615,6 +4618,9 @@ msgstr "" msgid "They can be managed using the %{link}." msgstr "" +msgid "Third party offers" +msgstr "" + msgid "This GitLab instance does not provide any shared Runners yet. Instance administrators can register shared Runners in the admin area." msgstr "" diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 9c6758abe861ae6e2b25acccc4c59a67b256f61f..a852ca689e7b6a9fdae1432528f9c332fcf954cd 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -272,6 +272,16 @@ expect(Gitlab::CurrentSettings.allow_local_requests_from_hooks_and_services).to be true end + it 'Enable hiding third party offers' do + page.within('.as-third-party-offers') do + check 'Do not display offers from third parties within GitLab' + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(Gitlab::CurrentSettings.hide_third_party_offers).to be true + end + it 'Change Slack Notifications Service template settings' do first(:link, 'Service Templates').click click_link 'Slack notifications'