Skip to content
代码片段 群组 项目
未验证 提交 41a37f37 编辑于 作者: Nataliia Radina's avatar Nataliia Radina 提交者: GitLab
浏览文件

Fix length, logic and text for project badges

Changelog: fixed

EE: true
上级 1176c85d
No related branches found
No related tags found
无相关合并请求
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
- is_maintainer = can?(current_user, :maintainer_access, project.root_ancestor) - is_admin = can?(current_user, :admin_compliance_framework, project.root_ancestor)
- title = s_('ComplianceFrameworks|This project is covered by the rules defined in the compliance framework. Only group owners and maintainers can view details of the compliance framework.') if !is_maintainer - title = s_('ComplianceFrameworks|This project is covered by the rules defined in the compliance framework. Only admins of the parent group can edit the compliance framework.') if !is_admin
- href = compliance_center_path(project) if is_maintainer - href = compliance_center_path(project) if is_admin
- if show_compliance_frameworks_info?(@project) - if show_compliance_frameworks_info?(@project)
.project-page-sidebar-block.gl-py-4.gl-border-b.gl-border-gray-50 .project-page-sidebar-block.gl-py-4.gl-border-b.gl-border-gray-50
%p.gl-font-bold.gl-text-gray-900.gl-m-0= s_('ComplianceFrameworks|Compliance frameworks applied') %p.gl-font-bold.gl-text-gray-900.gl-mb-2= s_('ComplianceFrameworks|Compliance frameworks applied')
.gl-mb-4 .gl-mb-4
- project.compliance_framework_settings.each do |setting| - project.compliance_framework_settings.each do |setting|
= gl_badge_tag(nil, { href: href, class: ["gl-display-inline-block gl-mr-1 gl-mt-3", ('has-tooltip' if !is_maintainer)], style: "background-color: #{setting.compliance_management_framework.color}; color: #{text_color_for_bg(setting.compliance_management_framework.color)}", data: { container: 'body', testid: 'compliance-frameworks-info' }, title: title }) do = gl_badge_tag(nil, { href: href, class: ["gl-inline-block gl-mr-1 gl-mt-2", ('has-tooltip' if !is_admin)], style: "background-color: #{setting.compliance_management_framework.color}; color: #{text_color_for_bg(setting.compliance_management_framework.color)}", data: { container: 'body', testid: 'compliance-frameworks-info' }, title: title }) do
= setting.compliance_management_framework.name = truncate(setting.compliance_management_framework.name, length: 30)
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'compliance_management/compliance_framework/_compliance_framework_info.html.haml' do RSpec.describe 'compliance_management/compliance_framework/_compliance_framework_info.html.haml', feature_category: :compliance_management do
let(:group) { build_stubbed(:group) } let(:group) { build_stubbed(:group) }
let(:framework1) { build_stubbed(:compliance_framework) } let(:framework1) { build_stubbed(:compliance_framework) }
let(:project) do let(:project) do
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
before do before do
allow(view).to receive(:show_compliance_frameworks_info?).and_return(true) allow(view).to receive(:show_compliance_frameworks_info?).and_return(true)
allow(view).to receive(:can?).with(anything, :maintainer_access, project.root_ancestor).and_return(false) allow(view).to receive(:can?).with(anything, :admin_compliance_framework, project.root_ancestor).and_return(false)
end end
it 'renders compliance framework badges' do it 'renders compliance framework badges' do
...@@ -22,17 +22,17 @@ ...@@ -22,17 +22,17 @@
expect(rendered).to have_content(framework1.name) expect(rendered).to have_content(framework1.name)
end end
context 'when user is not a group maintainer' do context 'when user is not a group owner' do
it 'renders tooltip for badges' do it 'renders tooltip for badges' do
render('compliance_management/compliance_framework/compliance_frameworks_info', project: project) render('compliance_management/compliance_framework/compliance_frameworks_info', project: project)
expect(rendered).to have_css('.has-tooltip') expect(rendered).to have_css('.has-tooltip')
end end
end end
context 'when user is a group maintainer' do context 'when user is a group owner' do
before do before do
allow(view).to receive(:show_compliance_frameworks_info?).and_return(true) allow(view).to receive(:show_compliance_frameworks_info?).and_return(true)
allow(view).to receive(:can?).with(anything, :maintainer_access, project.root_ancestor).and_return(true) allow(view).to receive(:can?).with(anything, :admin_compliance_framework, project.root_ancestor).and_return(true)
end end
it 'does not render tooltip for badges' do it 'does not render tooltip for badges' do
......
...@@ -13563,7 +13563,7 @@ msgstr "" ...@@ -13563,7 +13563,7 @@ msgstr ""
msgid "ComplianceFrameworks|There can be only one default framework." msgid "ComplianceFrameworks|There can be only one default framework."
msgstr "" msgstr ""
   
msgid "ComplianceFrameworks|This project is covered by the rules defined in the compliance framework. Only group owners and maintainers can view details of the compliance framework." msgid "ComplianceFrameworks|This project is covered by the rules defined in the compliance framework. Only admins of the parent group can edit the compliance framework."
msgstr "" msgstr ""
   
msgid "ComplianceFrameworks|To link this policy and framework, edit the policy's scope." msgid "ComplianceFrameworks|To link this policy and framework, edit the policy's scope."
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册