Commit 782cd3bc authored by Jiaan Louw's avatar Jiaan Louw Committed by Phil Hughes

Improve tooltips for compliance framework badges

Adds more context to the compliance framework badge tooltips.
parent 41f6db67
......@@ -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
......@@ -5593,6 +5593,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