diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 3348cdcb57d20fb8060ac567610eab207f519ba4..f94321adeafae557abc98d0f1d46e6b2509e25a8 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module DashboardHelper + include IconsHelper + def assigned_issues_dashboard_path issues_dashboard_path(assignee_username: current_user.username) end @@ -25,6 +27,19 @@ module DashboardHelper false end + def feature_entry(title, href: nil, enabled: true) + 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)) + end) + end + end + private def get_dashboard_nav_links diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 581f6ae07146884a23593d140a0d4a0dd98c361c..c29ecb43fe62bf1ce42f414c2d563c5887b3c4a8 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -76,51 +76,17 @@ .info-well .well-segment.admin-well.admin-well-features %h4 Features - - sign_up = "Sign up" - %p{ "aria-label" => "#{sign_up}: status " + (allow_signup? ? "on" : "off") } - = sign_up - %span.light.float-right - = boolean_to_icon allow_signup? - - ldap = "LDAP" - %p{ "aria-label" => "#{ldap}: status " + (Gitlab.config.ldap.enabled ? "on" : "off") } - = ldap - %span.light.float-right - = boolean_to_icon Gitlab.config.ldap.enabled - - gravatar = "Gravatar" - %p{ "aria-label" => "#{gravatar}: status " + (gravatar_enabled? ? "on" : "off") } - = gravatar - %span.light.float-right - = boolean_to_icon gravatar_enabled? - - omniauth = "OmniAuth" - %p{ "aria-label" => "#{omniauth}: status " + (Gitlab::Auth.omniauth_enabled? ? "on" : "off") } - = omniauth - %span.light.float-right - = boolean_to_icon Gitlab::Auth.omniauth_enabled? - - reply_email = "Reply by email" - %p{ "aria-label" => "#{reply_email}: status " + (Gitlab::IncomingEmail.enabled? ? "on" : "off") } - = reply_email - %span.light.float-right - = boolean_to_icon Gitlab::IncomingEmail.enabled? + = feature_entry(_('Sign up'), href: admin_application_settings_path(anchor: 'js-signup-settings')) + = 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' - - container_reg = "Container Registry" - %p{ "aria-label" => "#{container_reg}: status " + (Gitlab.config.registry.enabled ? "on" : "off") } - = container_reg - %span.light.float-right - = boolean_to_icon Gitlab.config.registry.enabled - - gitlab_pages = 'GitLab Pages' - - gitlab_pages_enabled = Gitlab.config.pages.enabled - %p{ "aria-label" => "#{gitlab_pages}: status " + (gitlab_pages_enabled ? "on" : "off") } - = gitlab_pages - %span.light.float-right - = boolean_to_icon gitlab_pages_enabled - - gitlab_shared_runners = 'Shared Runners' - - gitlab_shared_runners_enabled = Gitlab.config.gitlab_ci.shared_runners_enabled - %p{ "aria-label" => "#{gitlab_shared_runners}: status " + (gitlab_shared_runners_enabled ? "on" : "off") } - = gitlab_shared_runners - %span.light.float-right - = boolean_to_icon gitlab_shared_runners_enabled + = 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) .col-md-4 .info-well .well-segment.admin-well @@ -130,7 +96,8 @@ .float-right = version_status_badge %p - GitLab + %a{ href: admin_application_settings_path } + GitLab %span.float-right = Gitlab::VERSION = "(#{Gitlab.revision})" diff --git a/changelogs/unreleased/ce-xanf-add-links-to-admin-area.yml b/changelogs/unreleased/ce-xanf-add-links-to-admin-area.yml new file mode 100644 index 0000000000000000000000000000000000000000..9eb692c948b968f25034b7d3f565f93aa44e531d --- /dev/null +++ b/changelogs/unreleased/ce-xanf-add-links-to-admin-area.yml @@ -0,0 +1,5 @@ +--- +title: Add links to relevant configuration areas in admin area overview +merge_request: 29306 +author: +type: added diff --git a/package.json b/package.json index 3c95091c6eff983c6ac2e62b94e2e9965f0439f7..4264064c93dc49826a942f591a69971d49d4a500 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@babel/preset-env": "^7.4.4", "@gitlab/csslab": "^1.9.0", "@gitlab/svgs": "^1.67.0", - "@gitlab/ui": "^5.7.0", + "@gitlab/ui": "^5.7.1", "apollo-cache-inmemory": "^1.5.1", "apollo-client": "^2.5.1", "apollo-link": "^1.2.11", diff --git a/spec/helpers/dashboard_helper_spec.rb b/spec/helpers/dashboard_helper_spec.rb index 023238ee0ae7075fc5ab6f0b8902205c21be01d5..49e233663558f97457c48a1dbf0888f28eaade7b 100644 --- a/spec/helpers/dashboard_helper_spec.rb +++ b/spec/helpers/dashboard_helper_spec.rb @@ -22,6 +22,43 @@ describe DashboardHelper do end end + describe '#feature_entry' do + context 'when implicitly enabled' do + it 'considers feature enabled by default' do + entry = feature_entry('Demo', href: 'demo.link') + + expect(entry).to include('<p aria-label="Demo: status on">') + expect(entry).to include('<a href="demo.link">Demo</a>') + end + end + + context 'when explicitly enabled' do + it 'returns a link' do + entry = feature_entry('Demo', href: 'demo.link', enabled: true) + + expect(entry).to include('<p aria-label="Demo: status on">') + expect(entry).to include('<a href="demo.link">Demo</a>') + end + + it 'returns text if href is not provided' do + entry = feature_entry('Demo', enabled: true) + + expect(entry).to include('<p aria-label="Demo: status on">') + expect(entry).not_to match(/<a[^>]+>/) + end + end + + context 'when disabled' do + it 'returns text without link' do + entry = 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 + end + end + describe '.has_start_trial?' do subject { helper.has_start_trial? } diff --git a/yarn.lock b/yarn.lock index 7d1ef927e9cbc4b1c0c22d2df9efb441e1bef47c..4fa7665b000f0cbcad1bca0dfe4ed9b550ea1eca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -996,10 +996,10 @@ resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.67.0.tgz#c7b94eca13b99fd3aaa737fb6dcc0abc41d3c579" integrity sha512-hJOmWEs6RkjzyKkb1vc9wwKGZIBIP0coHkxu/KgOoxhBVudpGk4CH7xJ6UuB2TKpb0SEh5CC1CzRZfBYaFhsaA== -"@gitlab/ui@^5.7.0": - version "5.7.0" - resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-5.7.0.tgz#2ce6b431de262f09b2e1dbe77b047d6e8e1ca41d" - integrity sha512-zOPFNrCGyZrgqa8OXNhtfRg4aQ6pRCpIV2+alq3/4jllYb3HHHH+jIk/ejLrvNe8+fk7LRNSvJEvuInRLqBbEg== +"@gitlab/ui@^5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-5.7.1.tgz#e55d04052dd6e50ed1e90676aacc64290d62c0b6" + integrity sha512-F06/6z6/69LbKIK0PYRDTB/teSPUnF7LijHl4JiuYHXn7Y2/iVoLsAMikhT89RVR84orHPGnw16vtCPjSjBDrA== dependencies: "@babel/standalone" "^7.0.0" "@gitlab/vue-toasted" "^1.2.1"