Commit 6bdfeff6 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'help-landing-page-customizations' into 'master'

Allow more customization to Help landing page

See merge request !11878
parents 5771b946 e09ddc62
......@@ -100,6 +100,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:enabled_git_access_protocol,
:gravatar_enabled,
:help_page_text,
:help_page_hide_commercial_content,
:help_page_support_url,
:home_page_url,
:housekeeping_bitmaps_enabled,
:housekeeping_enabled,
......
......@@ -204,6 +204,10 @@ module ApplicationHelper
'https://' + promo_host
end
def support_url
current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
end
def page_filter_path(options = {})
without = options.delete(:without)
add_label = options.delete(:label)
......
......@@ -37,7 +37,12 @@ class ApplicationSetting < ActiveRecord::Base
validates :home_page_url,
allow_blank: true,
url: true,
if: :home_page_url_column_exist
if: :home_page_url_column_exists?
validates :help_page_support_url,
allow_blank: true,
url: true,
if: :help_page_support_url_column_exists?
validates :after_sign_out_path,
allow_blank: true,
......@@ -215,6 +220,7 @@ class ApplicationSetting < ActiveRecord::Base
domain_whitelist: Settings.gitlab['domain_whitelist'],
gravatar_enabled: Settings.gravatar['enabled'],
help_page_text: nil,
help_page_hide_commercial_content: false,
unique_ips_limit_per_user: 10,
unique_ips_limit_time_window: 3600,
unique_ips_limit_enabled: false,
......@@ -263,10 +269,14 @@ class ApplicationSetting < ActiveRecord::Base
end
end
def home_page_url_column_exist
def home_page_url_column_exists?
ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url)
end
def help_page_support_url_column_exists?
ActiveRecord::Base.connection.column_exists?(:application_settings, :help_page_support_url)
end
def sidekiq_throttling_column_exists?
ActiveRecord::Base.connection.column_exists?(:application_settings, :sidekiq_throttling_enabled)
end
......
......@@ -180,11 +180,25 @@
.col-sm-10
= f.text_area :sign_in_text, class: 'form-control', rows: 4
.help-block Markdown enabled
%fieldset
%legend Help Page
.form-group
= f.label :help_page_text, class: 'control-label col-sm-2'
.col-sm-10
= f.text_area :help_page_text, class: 'form-control', rows: 4
.help-block Markdown enabled
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :help_page_hide_commercial_content do
= f.check_box :help_page_hide_commercial_content
Hide marketing-related entries from help
.form-group
= f.label :help_page_support_url, 'Support page URL', class: 'control-label col-sm-2'
.col-sm-10
= f.text_field :help_page_support_url, class: 'form-control', placeholder: 'http://company.example.com/getting-help', :'aria-describedby' => 'support_help_block'
%span.help-block#support_help_block Alternate support URL for help page
%fieldset
%legend Pages
......
%div
- if current_application_settings.help_page_text.present?
= markdown_field(current_application_settings, :help_page_text)
%hr
- unless current_application_settings.help_page_hide_commercial_content?
%h1
GitLab
Community Edition
......@@ -18,13 +23,9 @@
Used by more than 100,000 organizations, GitLab is the most popular solution to manage git repositories on-premises.
%br
Read more about GitLab at #{link_to promo_host, promo_url, target: '_blank', rel: 'noopener noreferrer'}.
- if current_application_settings.help_page_text.present?
%hr
= markdown_field(current_application_settings, :help_page_text)
%hr
.row
.row.prepend-top-default
.col-md-8
.documentation-index
= markdown(@help_index)
......@@ -33,8 +34,9 @@
.panel-heading
Quick help
%ul.well-list
%li= link_to 'See our website for getting help', promo_url + '/getting-help/'
%li= link_to 'See our website for getting help', support_url
%li= link_to 'Use the search bar on the top of this page', '#', onclick: 'Shortcuts.focusSearch(event)'
%li= link_to 'Use shortcuts', '#', onclick: 'Shortcuts.toggleHelp()'
- unless current_application_settings.help_page_hide_commercial_content?
%li= link_to 'Get a support subscription', 'https://about.gitlab.com/pricing/'
%li= link_to 'Compare GitLab editions', 'https://about.gitlab.com/features/#compare'
- page_title @path.split("/").reverse.map(&:humanize)
.documentation.wiki
.documentation.wiki.prepend-top-default
= markdown @markdown
---
title: Help landing page customizations
merge_request: 11878
author: Robin Bobbitt
class AddHelpPageHideCommercialContentToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :application_settings, :help_page_hide_commercial_content, :boolean, default: false
end
end
class AddHelpPageSupportUrlToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :application_settings, :help_page_support_url, :string
end
end
......@@ -12,6 +12,7 @@
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170606202615) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "pg_trgm"
......@@ -123,6 +124,8 @@ ActiveRecord::Schema.define(version: 20170606202615) do
t.boolean "clientside_sentry_enabled", default: false, null: false
t.string "clientside_sentry_dsn"
t.boolean "prometheus_metrics_enabled", default: false, null: false
t.boolean "help_page_hide_commercial_content", default: false
t.string "help_page_support_url"
end
create_table "audit_events", force: :cascade do |t|
......
......@@ -603,6 +603,9 @@ module API
expose :plantuml_url
expose :terminal_max_session_time
expose :polling_interval_multiplier
expose :help_page_hide_commercial_content
expose :help_page_text
expose :help_page_support_url
end
class Release < Grape::Entity
......
......@@ -39,7 +39,9 @@ module API
:email_author_in_body,
:enabled_git_access_protocol,
:gravatar_enabled,
:help_page_hide_commercial_content,
:help_page_text,
:help_page_support_url,
:home_page_url,
:housekeeping_enabled,
:html_emails_enabled,
......@@ -101,7 +103,9 @@ module API
optional :home_page_url, type: String, desc: 'We will redirect non-logged in users to this page'
optional :after_sign_out_path, type: String, desc: 'We will redirect users to this page after they sign out'
optional :sign_in_text, type: String, desc: 'The sign in text of the GitLab application'
optional :help_page_hide_commercial_content, type: Boolean, desc: 'Hide marketing-related entries from help'
optional :help_page_text, type: String, desc: 'Custom text displayed on the help page'
optional :help_page_support_url, type: String, desc: 'Alternate support URL for help page'
optional :shared_runners_enabled, type: Boolean, desc: 'Enable shared runners for new projects'
given shared_runners_enabled: ->(val) { val } do
requires :shared_runners_text, type: String, desc: 'Shared runners text '
......
......@@ -20,10 +20,15 @@ feature 'Admin updates settings', feature: true do
uncheck 'Gravatar enabled'
fill_in 'Home page URL', with: 'https://about.gitlab.com/'
fill_in 'Help page text', with: 'Example text'
check 'Hide marketing-related entries from help'
fill_in 'Support page URL', with: 'http://example.com/help'
click_button 'Save'
expect(current_application_settings.gravatar_enabled).to be_falsey
expect(current_application_settings.home_page_url).to eq "https://about.gitlab.com/"
expect(current_application_settings.help_page_text).to eq "Example text"
expect(current_application_settings.help_page_hide_commercial_content).to be_truthy
expect(current_application_settings.help_page_support_url).to eq "http://example.com/help"
expect(page).to have_content "Application settings saved successfully"
end
......
......@@ -37,7 +37,7 @@ describe 'Help Pages', feature: true do
context 'in a production environment with version check enabled', :js do
before do
allow(Rails.env).to receive(:production?) { true }
allow(current_application_settings).to receive(:version_check_enabled) { true }
allow_any_instance_of(ApplicationSetting).to receive(:version_check_enabled) { true }
allow_any_instance_of(VersionCheck).to receive(:url) { '/version-check-url' }
login_as :user
......@@ -53,4 +53,27 @@ describe 'Help Pages', feature: true do
expect(find('.js-version-status-badge', visible: false)).not_to be_visible
end
end
describe 'when help page is customized' do
before do
allow_any_instance_of(ApplicationSetting).to receive(:help_page_hide_commercial_content?) { true }
allow_any_instance_of(ApplicationSetting).to receive(:help_page_text) { "My Custom Text" }
allow_any_instance_of(ApplicationSetting).to receive(:help_page_support_url) { "http://example.com/help" }
login_as :user
visit help_path
end
it 'should display custom help page text' do
expect(page).to have_text "My Custom Text"
end
it 'should hide marketing content when enabled' do
expect(page).not_to have_link "Get a support subscription"
end
it 'should use a custom support url' do
expect(page).to have_link "See our website for getting help", href: "http://example.com/help"
end
end
end
......@@ -257,4 +257,21 @@ describe ApplicationHelper do
it { expect(helper.active_when(true)).to eq('active') }
it { expect(helper.active_when(false)).to eq(nil) }
end
describe '#support_url' do
context 'when alternate support url is specified' do
let(:alternate_url) { 'http://company.example.com/getting-help' }
before { allow(current_application_settings).to receive(:help_page_support_url) { alternate_url } }
it 'returns the alternate support url' do
expect(helper.support_url).to eq(alternate_url)
end
end
context 'when alternate support url is not specified' do
it 'builds the support url from the promo_url' do
expect(helper.support_url).to eq(helper.promo_url + '/getting-help/')
end
end
end
end
......@@ -40,7 +40,10 @@ describe API::Settings, 'Settings' do
plantuml_url: 'http://plantuml.example.com',
default_snippet_visibility: 'internal',
restricted_visibility_levels: ['public'],
default_artifacts_expire_in: '2 days'
default_artifacts_expire_in: '2 days',
help_page_text: 'custom help text',
help_page_hide_commercial_content: true,
help_page_support_url: 'http://example.com/help'
expect(response).to have_http_status(200)
expect(json_response['default_projects_limit']).to eq(3)
expect(json_response['signin_enabled']).to be_falsey
......@@ -53,6 +56,9 @@ describe API::Settings, 'Settings' do
expect(json_response['default_snippet_visibility']).to eq('internal')
expect(json_response['restricted_visibility_levels']).to eq(['public'])
expect(json_response['default_artifacts_expire_in']).to eq('2 days')
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')
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