Commit 3149fcb8 authored by Toon Claes's avatar Toon Claes

Merge branch '32328_setup_documentation_url_configuration_option' into 'master'

Add Documentation URL option to Admin area

See merge request gitlab-org/gitlab!42702
parents 321baa4e f418d427
......@@ -230,6 +230,7 @@ module ApplicationSettingsHelper
:hashed_storage_enabled,
:help_page_hide_commercial_content,
:help_page_support_url,
:help_page_documentation_base_url,
:help_page_text,
:hide_third_party_offers,
:home_page_url,
......@@ -389,6 +390,10 @@ module ApplicationSettingsHelper
Gitlab::CurrentSettings.self_monitoring_project&.full_path
}
end
def show_documentation_base_url_field?
Feature.enabled?(:help_page_documentation_redirect)
end
end
ApplicationSettingsHelper.prepend_if_ee('EE::ApplicationSettingsHelper')
......
......@@ -91,6 +91,11 @@ class ApplicationSetting < ApplicationRecord
addressable_url: true,
if: :help_page_support_url_column_exists?
validates :help_page_documentation_base_url,
length: { maximum: 255, message: _("is too long (maximum is %{count} characters)") },
allow_blank: true,
addressable_url: true
validates :after_sign_out_path,
allow_blank: true,
addressable_url: true
......
......@@ -82,6 +82,7 @@ module ApplicationSettingImplementation
group_import_limit: 6,
help_page_hide_commercial_content: false,
help_page_text: nil,
help_page_documentation_base_url: nil,
hide_third_party_offers: false,
housekeeping_bitmaps_enabled: true,
housekeeping_enabled: true,
......
......@@ -18,4 +18,9 @@
= f.text_field :help_page_support_url, class: 'form-control', placeholder: 'http://company.example.com/getting-help', :'aria-describedby' => 'support_help_block'
%span.form-text.text-muted#support_help_block= _('Alternate support URL for help page and help dropdown')
- if show_documentation_base_url_field?
.form-group
= f.label :help_page_documentation_base_url, _('Documentation pages URL'), class: 'label-bold'
= f.text_field :help_page_documentation_base_url, class: 'form-control', placeholder: 'https://docs.gitlab.com'
= f.submit _('Save changes'), class: "btn btn-success"
---
title: Add Documentation URL to Admin Area
merge_request: 42702
author:
type: added
---
name: help_page_documentation_redirect
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42702
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/255328
group: group::static site editor
type: development
default_enabled: false
# frozen_string_literal: true
class AddHelpPageDocumentationUrlToApplicationSettings < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20200921113722_add_text_limit_to_help_page_documentation_url.rb
def change
add_column :application_settings, :help_page_documentation_base_url, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end
# frozen_string_literal: true
class AddTextLimitToHelpPageDocumentationUrl < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_text_limit :application_settings, :help_page_documentation_base_url, 255
end
def down
remove_text_limit :application_settings, :help_page_documentation_base_url
end
end
3343b646d0c0ca2d92982740abe4372fb80931cb4bb4386229959d5d61c86587
\ No newline at end of file
723812a28afbabb6b7884fd76dcaf658c5e35a33a46e90a9a94aef12e735e604
\ No newline at end of file
......@@ -9296,8 +9296,10 @@ CREATE TABLE application_settings (
gitpod_url text DEFAULT 'https://gitpod.io/'::text,
abuse_notification_email character varying,
require_admin_approval_after_user_signup boolean DEFAULT false NOT NULL,
help_page_documentation_base_url text,
CONSTRAINT check_2dba05b802 CHECK ((char_length(gitpod_url) <= 255)),
CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)),
CONSTRAINT check_57123c9593 CHECK ((char_length(help_page_documentation_base_url) <= 255)),
CONSTRAINT check_9c6c447a13 CHECK ((char_length(maintenance_mode_message) <= 255)),
CONSTRAINT check_d03919528d CHECK ((char_length(container_registry_vendor) <= 255)),
CONSTRAINT check_d820146492 CHECK ((char_length(spam_check_endpoint_url) <= 255)),
......
......@@ -74,6 +74,7 @@ module API
optional :gravatar_enabled, type: Boolean, desc: 'Flag indicating if the Gravatar service is enabled'
optional :help_page_hide_commercial_content, type: Boolean, desc: 'Hide marketing-related entries from help'
optional :help_page_support_url, type: String, desc: 'Alternate support URL for help page and help dropdown'
optional :help_page_documentation_base_url, type: String, desc: 'Alternate documentation pages URL'
optional :help_page_text, type: String, desc: 'Custom text displayed on the help page'
optional :home_page_url, type: String, desc: 'We will redirect non-logged in users to this page'
optional :housekeeping_enabled, type: Boolean, desc: 'Enable automatic repository housekeeping (git repack, git gc)'
......
......@@ -9182,6 +9182,9 @@ msgstr ""
msgid "Documentation for popular identity providers"
msgstr ""
msgid "Documentation pages URL"
msgstr ""
msgid "Documents reindexed: %{processed_documents} (%{percentage}%%)"
msgstr ""
......@@ -30613,6 +30616,9 @@ msgstr ""
msgid "is too long (%{current_value}). The maximum size is %{max_size}."
msgstr ""
msgid "is too long (maximum is %{count} characters)"
msgstr ""
msgid "is too long (maximum is 100 entries)"
msgstr ""
......
......@@ -529,18 +529,23 @@ RSpec.describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_n
end
it 'Change Help page' do
stub_feature_flags(help_page_documentation_redirect: true)
new_support_url = 'http://example.com/help'
new_documentation_url = 'https://docs.gitlab.com'
page.within('.as-help-page') do
fill_in 'Help page text', with: 'Example text'
check 'Hide marketing-related entries from help'
fill_in 'Support page URL', with: new_support_url
fill_in 'Documentation pages URL', with: new_documentation_url
click_button 'Save changes'
end
expect(current_settings.help_page_text).to eq "Example text"
expect(current_settings.help_page_hide_commercial_content).to be_truthy
expect(current_settings.help_page_support_url).to eq new_support_url
expect(current_settings.help_page_documentation_base_url).to eq new_documentation_url
expect(page).to have_content "Application settings saved successfully"
end
......
......@@ -146,4 +146,24 @@ RSpec.describe ApplicationSettingsHelper do
])
end
end
describe '.show_documentation_base_url_field?' do
subject { helper.show_documentation_base_url_field? }
before do
stub_feature_flags(help_page_documentation_redirect: feature_flag)
end
context 'when feature flag is enabled' do
let(:feature_flag) { true }
it { is_expected.to eq(true) }
end
context 'when feature flag is disabled' do
let(:feature_flag) { false }
it { is_expected.to eq(false) }
end
end
end
......@@ -112,6 +112,35 @@ RSpec.describe ApplicationSetting do
it { is_expected.to allow_value(nil).for(:repository_storages_weighted_default) }
it { is_expected.not_to allow_value({ default: 100, shouldntexist: 50 }).for(:repository_storages_weighted) }
context 'help_page_documentation_base_url validations' do
it { is_expected.to allow_value(nil).for(:help_page_documentation_base_url) }
it { is_expected.to allow_value('https://docs.gitlab.com').for(:help_page_documentation_base_url) }
it { is_expected.to allow_value('http://127.0.0.1').for(:help_page_documentation_base_url) }
it { is_expected.not_to allow_value('docs.gitlab.com').for(:help_page_documentation_base_url) }
context 'when url length validation' do
let(:value) { 'http://'.ljust(length, 'A') }
context 'when value string length is 255 characters' do
let(:length) { 255 }
it 'allows the value' do
is_expected.to allow_value(value).for(:help_page_documentation_base_url)
end
end
context 'when value string length exceeds 255 characters' do
let(:length) { 256 }
it 'does not allow the value' do
is_expected.not_to allow_value(value)
.for(:help_page_documentation_base_url)
.with_message('is too long (maximum is 255 characters)')
end
end
end
end
context 'grafana_url validations' do
before do
subject.instance_variable_set(:@parsed_grafana_url, nil)
......
......@@ -96,6 +96,7 @@ RSpec.describe API::Settings, 'Settings' do
help_page_text: 'custom help text',
help_page_hide_commercial_content: true,
help_page_support_url: 'http://example.com/help',
help_page_documentation_base_url: 'https://docs.gitlab.com',
project_export_enabled: false,
rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE,
dsa_key_restriction: 2048,
......@@ -138,6 +139,7 @@ RSpec.describe API::Settings, 'Settings' do
expect(json_response['help_page_text']).to eq('custom help text')
expect(json_response['help_page_hide_commercial_content']).to be_truthy
expect(json_response['help_page_support_url']).to eq('http://example.com/help')
expect(json_response['help_page_documentation_base_url']).to eq('https://docs.gitlab.com')
expect(json_response['project_export_enabled']).to be_falsey
expect(json_response['rsa_key_restriction']).to eq(ApplicationSetting::FORBIDDEN_KEY_VALUE)
expect(json_response['dsa_key_restriction']).to eq(2048)
......
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