Commit 4fbf0dee authored by Phil Hughes's avatar Phil Hughes

Merge branch 'jlouw-improve-compliance-framework-tooptips' into 'master'

Improve tooltips for compliance framework badges

Closes #214628

See merge request gitlab-org/gitlab!31883
parents e4d0c250 782cd3bc
......@@ -20,6 +20,10 @@ module ComplianceManagement
compliance_framework_color_values.fetch(framework.to_sym)
end
def compliance_framework_tooltip(framework)
compliance_framework_tooltip_values.fetch(framework.to_sym)
end
private
def compliance_framework_option_values
......@@ -51,6 +55,15 @@ module ComplianceManagement
sox: 'gl-bg-orange-500'
}.freeze
end
def compliance_framework_tooltip_values
@compliance_framework_tooltip_values ||=
compliance_framework_title_values.map { |k, v| [k, get_compliance_framework_tooltip(v)] }.to_h
end
def get_compliance_framework_tooltip(framework)
s_("ComplianceFramework|This project is regulated by %{framework}." % { framework: framework })
end
end
end
end
......@@ -4,7 +4,7 @@
- framework = project.compliance_framework_setting.framework
- color = compliance_framework_color(framework)
- title = compliance_framework_title(framework)
- description = compliance_framework_description(framework)
- tooltip = compliance_framework_tooltip(framework)
%span.badge.compliance-framework-pill.ml-2.has-tooltip{ class: color, data: { container: 'body' }, title: description }
%span.badge.compliance-framework-pill.ml-2.has-tooltip{ class: color, data: { container: 'body' }, title: tooltip }
= title
---
title: Improve tooltips for compliance framework badges
merge_request: 31883
author:
type: changed
......@@ -62,4 +62,20 @@ describe ComplianceManagement::ComplianceFramework::ProjectSettingsHelper do
it { expect(helper.compliance_framework_color(framework)).to eq(color) }
end
end
describe '#compliance_framework_tooltip' do
using RSpec::Parameterized::TableSyntax
where(:framework, :tooltip) do
:gdpr | 'This project is regulated by GDPR.'
:hipaa | 'This project is regulated by HIPAA.'
:pci_dss | 'This project is regulated by PCI-DSS.'
:soc_2 | 'This project is regulated by SOC 2.'
:sox | 'This project is regulated by SOX.'
end
with_them do
it { expect(helper.compliance_framework_tooltip(framework)).to eq(tooltip) }
end
end
end
......@@ -5602,6 +5602,9 @@ msgstr ""
msgid "ComplianceFramework|SOX - Sarbanes-Oxley"
msgstr ""
msgid "ComplianceFramework|This project is regulated by %{framework}."
msgstr ""
msgid "Confidence: %{confidence}"
msgstr ""
......
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