Commit afcf11d2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve admin features widget

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c47991bc
......@@ -27,16 +27,25 @@ module DashboardHelper
false
end
def feature_entry(title, href: nil, enabled: true)
def feature_entry(title, href: nil, enabled: true, doc_href: nil)
enabled_text = enabled ? 'on' : 'off'
label = "#{title}: status #{enabled_text}"
link_or_title = href && enabled ? tag.a(title, href: href) : title
tag.p(aria: { label: label }) do
concat(link_or_title)
concat(tag.span(class: ['light', 'float-right']) do
concat(boolean_to_icon(enabled))
boolean_to_icon(enabled)
end)
if doc_href.present?
link_to_doc = link_to(sprite_icon('question', size: 16), doc_href,
class: 'prepend-left-5', title: _('Documentation'),
target: '_blank', rel: 'noopener noreferrer')
concat(link_to_doc)
end
end
end
......
......@@ -41,17 +41,38 @@
.info-well
.well-segment.admin-well.admin-well-features
%h4 Features
= feature_entry(_('Sign up'), href: admin_application_settings_path(anchor: 'js-signup-settings'), enabled: allow_signup?)
= feature_entry(_('LDAP'), enabled: Gitlab.config.ldap.enabled)
= feature_entry(_('Gravatar'), href: admin_application_settings_path(anchor: 'js-account-settings'), enabled: gravatar_enabled?)
= feature_entry(_('OmniAuth'), href: admin_application_settings_path(anchor: 'js-signin-settings'), enabled: Gitlab::Auth.omniauth_enabled?)
= feature_entry(_('Reply by email'), enabled: Gitlab::IncomingEmail.enabled?)
= feature_entry(_('Sign up'),
href: admin_application_settings_path(anchor: 'js-signup-settings'),
enabled: allow_signup?)
= feature_entry(_('LDAP'),
enabled: Gitlab.config.ldap.enabled)
= feature_entry(_('Gravatar'),
href: admin_application_settings_path(anchor: 'js-account-settings'),
enabled: gravatar_enabled?)
= feature_entry(_('OmniAuth'),
href: admin_application_settings_path(anchor: 'js-signin-settings'),
enabled: Gitlab::Auth.omniauth_enabled?)
= feature_entry(_('Reply by email'),
enabled: Gitlab::IncomingEmail.enabled?)
= render_if_exists 'admin/dashboard/elastic_and_geo'
= feature_entry(_('Container Registry'), href: ci_cd_admin_application_settings_path(anchor: 'js-registry-settings'), enabled: Gitlab.config.registry.enabled)
= feature_entry(_('Gitlab Pages'), href: help_instance_configuration_url, enabled: Gitlab.config.pages.enabled)
= feature_entry(_('Shared Runners'), href: admin_runners_path, enabled: Gitlab.config.gitlab_ci.shared_runners_enabled)
= feature_entry(_('Container Registry'),
href: ci_cd_admin_application_settings_path(anchor: 'js-registry-settings'),
enabled: Gitlab.config.registry.enabled,
doc_href: help_page_path('user/packages/container_registry/index'))
= feature_entry(_('Gitlab Pages'),
enabled: Gitlab.config.pages.enabled,
doc_href: help_instance_configuration_url)
= feature_entry(_('Shared Runners'),
href: admin_runners_path,
enabled: Gitlab.config.gitlab_ci.shared_runners_enabled)
.col-md-4
.info-well
.well-segment.admin-well
......
---
title: Improve admin dashboard features
merge_request: 18666
author:
type: changed
......@@ -5751,6 +5751,9 @@ msgstr ""
msgid "Dockerfile"
msgstr ""
msgid "Documentation"
msgstr ""
msgid "Documentation for popular identity providers"
msgstr ""
......
......@@ -25,39 +25,62 @@ describe DashboardHelper do
end
describe '#feature_entry' do
context 'when implicitly enabled' do
it 'considers feature enabled by default' do
entry = feature_entry('Demo', href: 'demo.link')
shared_examples "a feature is enabled" do
it { is_expected.to include('<p aria-label="Demo: status on">') }
end
shared_examples "a feature is disabled" do
it { is_expected.to include('<p aria-label="Demo: status off">') }
end
expect(entry).to include('<p aria-label="Demo: status on">')
expect(entry).to include('<a href="demo.link">Demo</a>')
shared_examples "a feature without link" do
it do
is_expected.not_to have_link('Demo')
is_expected.not_to have_link('Documentation')
end
end
shared_examples "a feature with configuration" do
it { is_expected.to have_link('Demo', href: 'demo.link') }
end
shared_examples "a feature with documentation" do
it { is_expected.to have_link('Documentation', href: 'doc.link') }
end
context 'when implicitly enabled' do
subject { feature_entry('Demo') }
it_behaves_like 'a feature is enabled'
end
context 'when explicitly enabled' do
it 'returns a link' do
entry = feature_entry('Demo', href: 'demo.link', enabled: true)
context 'without links' do
subject { feature_entry('Demo', enabled: true) }
expect(entry).to include('<p aria-label="Demo: status on">')
expect(entry).to include('<a href="demo.link">Demo</a>')
it_behaves_like 'a feature is enabled'
it_behaves_like 'a feature without link'
end
it 'returns text if href is not provided' do
entry = feature_entry('Demo', enabled: true)
context 'with configure link' do
subject { feature_entry('Demo', href: 'demo.link', enabled: true) }
expect(entry).to include('<p aria-label="Demo: status on">')
expect(entry).not_to match(/<a[^>]+>/)
it_behaves_like 'a feature with configuration'
end
context 'with configure and documentation links' do
subject { feature_entry('Demo', href: 'demo.link', doc_href: 'doc.link', enabled: true) }
it_behaves_like 'a feature with configuration'
it_behaves_like 'a feature with documentation'
end
end
context 'when disabled' do
it 'returns text without link' do
entry = feature_entry('Demo', href: 'demo.link', enabled: false)
subject { feature_entry('Demo', href: 'demo.link', enabled: false) }
expect(entry).to include('<p aria-label="Demo: status off">')
expect(entry).not_to match(/<a[^>]+>/)
expect(entry).to include('Demo')
end
it_behaves_like 'a feature is disabled'
it_behaves_like 'a feature without link'
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