Commit 34034ea0 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'dz-improve-admin-features' into 'master'

Improve admin features widget

See merge request gitlab-org/gitlab!18666
parents 26c071db afcf11d2
...@@ -27,16 +27,25 @@ module DashboardHelper ...@@ -27,16 +27,25 @@ module DashboardHelper
false false
end 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' enabled_text = enabled ? 'on' : 'off'
label = "#{title}: status #{enabled_text}" label = "#{title}: status #{enabled_text}"
link_or_title = href && enabled ? tag.a(title, href: href) : title link_or_title = href && enabled ? tag.a(title, href: href) : title
tag.p(aria: { label: label }) do tag.p(aria: { label: label }) do
concat(link_or_title) concat(link_or_title)
concat(tag.span(class: ['light', 'float-right']) do concat(tag.span(class: ['light', 'float-right']) do
concat(boolean_to_icon(enabled)) boolean_to_icon(enabled)
end) 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
end end
......
...@@ -41,17 +41,38 @@ ...@@ -41,17 +41,38 @@
.info-well .info-well
.well-segment.admin-well.admin-well-features .well-segment.admin-well.admin-well-features
%h4 Features %h4 Features
= feature_entry(_('Sign up'), href: admin_application_settings_path(anchor: 'js-signup-settings'), enabled: allow_signup?) = feature_entry(_('Sign up'),
= feature_entry(_('LDAP'), enabled: Gitlab.config.ldap.enabled) href: admin_application_settings_path(anchor: 'js-signup-settings'),
= feature_entry(_('Gravatar'), href: admin_application_settings_path(anchor: 'js-account-settings'), enabled: gravatar_enabled?) enabled: allow_signup?)
= 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(_('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' = 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(_('Container Registry'),
= feature_entry(_('Gitlab Pages'), href: help_instance_configuration_url, enabled: Gitlab.config.pages.enabled) href: ci_cd_admin_application_settings_path(anchor: 'js-registry-settings'),
= feature_entry(_('Shared Runners'), href: admin_runners_path, enabled: Gitlab.config.gitlab_ci.shared_runners_enabled) 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 .col-md-4
.info-well .info-well
.well-segment.admin-well .well-segment.admin-well
......
---
title: Improve admin dashboard features
merge_request: 18666
author:
type: changed
...@@ -5742,6 +5742,9 @@ msgstr "" ...@@ -5742,6 +5742,9 @@ msgstr ""
msgid "Dockerfile" msgid "Dockerfile"
msgstr "" msgstr ""
msgid "Documentation"
msgstr ""
msgid "Documentation for popular identity providers" msgid "Documentation for popular identity providers"
msgstr "" msgstr ""
......
...@@ -25,39 +25,62 @@ describe DashboardHelper do ...@@ -25,39 +25,62 @@ describe DashboardHelper do
end end
describe '#feature_entry' do describe '#feature_entry' do
context 'when implicitly enabled' do shared_examples "a feature is enabled" do
it 'considers feature enabled by default' do it { is_expected.to include('<p aria-label="Demo: status on">') }
entry = feature_entry('Demo', href: 'demo.link') 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">') shared_examples "a feature without link" do
expect(entry).to include('<a href="demo.link">Demo</a>') it do
is_expected.not_to have_link('Demo')
is_expected.not_to have_link('Documentation')
end end
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 context 'when explicitly enabled' do
it 'returns a link' do context 'without links' do
entry = feature_entry('Demo', href: 'demo.link', enabled: true) subject { feature_entry('Demo', enabled: true) }
expect(entry).to include('<p aria-label="Demo: status on">') it_behaves_like 'a feature is enabled'
expect(entry).to include('<a href="demo.link">Demo</a>') it_behaves_like 'a feature without link'
end end
it 'returns text if href is not provided' do context 'with configure link' do
entry = feature_entry('Demo', enabled: true) subject { feature_entry('Demo', href: 'demo.link', enabled: true) }
expect(entry).to include('<p aria-label="Demo: status on">') it_behaves_like 'a feature with configuration'
expect(entry).not_to match(/<a[^>]+>/) 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
end end
context 'when disabled' do context 'when disabled' do
it 'returns text without link' do subject { feature_entry('Demo', href: 'demo.link', enabled: false) }
entry = feature_entry('Demo', href: 'demo.link', enabled: false)
expect(entry).to include('<p aria-label="Demo: status off">') it_behaves_like 'a feature is disabled'
expect(entry).not_to match(/<a[^>]+>/) it_behaves_like 'a feature without link'
expect(entry).to include('Demo')
end
end end
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