Commit c5a44926 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch...

Merge branch '324085-move-placement-of-compliance-framework-setting-to-settings-general-after-badges' into 'master'

Move placement of "Compliance Framework" setting to Settings->General after Badges

See merge request gitlab-org/gitlab!66429
parents 62ab718a c6582d8c
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
.settings-content .settings-content
= render 'shared/badges/badge_settings' = render 'shared/badges/badge_settings'
= render_if_exists 'compliance_management/compliance_framework/project_settings', expanded: expanded
= render_if_exists 'projects/settings/default_issue_template' = render_if_exists 'projects/settings/default_issue_template'
= render 'projects/service_desk_settings' = render 'projects/service_desk_settings'
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
= f.text_field :topics, value: @project.topic_list.join(', '), maxlength: 2000, class: "form-control gl-form-input" = f.text_field :topics, value: @project.topic_list.join(', '), maxlength: 2000, class: "form-control gl-form-input"
%p.form-text.text-muted= _('Separate topics with commas.') %p.form-text.text-muted= _('Separate topics with commas.')
= render_if_exists 'compliance_management/compliance_framework/project_settings', f: f
.row .row
.form-group.col-md-9 .form-group.col-md-9
= f.label :description, _('Project description (optional)'), class: 'label-bold' = f.label :description, _('Project description (optional)'), class: 'label-bold'
......
- user_has_edit_permissions = current_user.can?(:admin_compliance_framework, @project) - user_has_edit_permissions = current_user.can?(:admin_compliance_framework, @project)
.row - compliance_framework_doc_link = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('user/project/settings/index.md', anchor: 'compliance-frameworks') }
.form-group.col-md-9.gl-mb-6
- frameworks = @project.namespace.root_ancestor.compliance_management_frameworks %section.settings.compliance-framework.no-animate#js-compliance-framework{ class: ('expanded' if expanded) }
- if user_has_edit_permissions .settings-header
= f.fields_for :compliance_framework_setting, ComplianceManagement::ComplianceFramework::ProjectSettings.new do |cf| %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Compliance framework')
= cf.label :framework, class: 'gl-font-weight-bold' do %button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand')
= _('Compliance framework (optional)') %p= html_escape(_('Select a framework that applies to this project. %{linkStart}How are these added?%{linkEnd}')) % { linkStart: compliance_framework_doc_link, linkEnd: '</a>'.html_safe }
- if frameworks.any?
- selected_default_framework = @project.compliance_framework_setting&.compliance_management_framework&.id .settings-content
= cf.select :framework, options_for_select(frameworks.map { |fw| [fw.name.truncate(88), fw.id] }, selected_default_framework), { selected: '', prompt: _('Choose your framework'), include_blank: _('None') }, { class: 'form-control', disabled: false } = form_for @project, html: { multipart: true, class: "compliance-framework-form" }, authenticity_token: true do |f|
- frameworks = @project.namespace.root_ancestor.compliance_management_frameworks
.form-group
- if user_has_edit_permissions
= f.fields_for :compliance_framework_setting, ComplianceManagement::ComplianceFramework::ProjectSettings.new do |cf|
= cf.label :framework, class: 'gl-font-weight-bold' do
= _('Compliance framework (optional)')
- if frameworks.any?
- selected_default_framework = @project.compliance_framework_setting&.compliance_management_framework&.id
= cf.select :framework, options_for_select(frameworks.map { |fw| [fw.name.truncate(88), fw.id] }, selected_default_framework), { selected: '', prompt: _('Choose your framework'), include_blank: _('None') }, { class: 'form-control', disabled: false }
- else
%p.form-text.text-muted
= _("No compliance frameworks are in use. Create one from the %{link} section in Group Settings.").html_safe % { link: link_to('Compliance frameworks', edit_group_path(@project.namespace.root_ancestor)).html_safe }
- else - else
%p.form-text.text-muted = f.fields_for :compliance_framework_setting, ComplianceManagement::ComplianceFramework::ProjectSettings.new do |cf|
= _("No compliance frameworks are in use. Create one from the %{link} section in Group Settings.").html_safe % { link: link_to('Compliance frameworks', edit_group_path(@project.namespace.root_ancestor)).html_safe } = cf.label :framework, class: 'gl-font-weight-bold' do
- else = _('Compliance framework')
= f.fields_for :compliance_framework_setting, ComplianceManagement::ComplianceFramework::ProjectSettings.new do |cf| - if frameworks.any?
= cf.label :framework, class: 'gl-font-weight-bold' do - selected_framework = @project.compliance_framework_setting&.compliance_management_framework&.name&.truncate(88) || _('None')
= _('Compliance framework') = cf.text_field :framework, value: selected_framework, class: 'form-control read-only', disabled: true
- if frameworks.any? %p.form-text.text-muted
- selected_framework = @project.compliance_framework_setting&.compliance_management_framework&.name&.truncate(88) || _('None') = _("Customizable by owners.")
= cf.text_field :framework, value: selected_framework, class: 'form-control read-only', disabled: true - else
%p.form-text.text-muted %p.form-text.text-muted
= _("Customizable by owners.") = _("No compliance frameworks are in use.")
- else
%p.form-text.text-muted - if user_has_edit_permissions && frameworks.any?
= _("No compliance frameworks are in use.") = f.submit _('Save changes'), class: "btn gl-button btn-confirm"
...@@ -2,38 +2,38 @@ ...@@ -2,38 +2,38 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'projects/edit.html.haml' do RSpec.describe 'compliance_management/compliance_framework/_project_settings.html.haml' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:group_owner) { create(:user) } let_it_be(:group_owner) { create(:user) }
let_it_be(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, namespace: group) }
before do before do
allow(view).to receive(:current_user).and_return(group_owner) allow(view).to receive(:current_user).and_return(group_owner)
allow(view).to receive(:expanded).and_return(true)
allow(group_owner).to receive(:can?).and_return(true) allow(group_owner).to receive(:can?).and_return(true)
assign(:project, project) assign(:project, project)
stub_licensed_features(custom_compliance_frameworks: true) stub_licensed_features(custom_compliance_frameworks: true)
end end
it 'shows the section description' do
render
expect(rendered).to have_text 'Select a framework that applies to this project. How are these added?'
end
context 'group has compliance frameworks' do context 'group has compliance frameworks' do
let_it_be(:framework) { create(:compliance_framework, namespace: group, name: 'Custom framework 23') } let_it_be(:framework) { create(:compliance_framework, namespace: group, name: 'Custom framework 23') }
it 'includes a dropdown including that framework' do it 'includes a dropdown including that framework' do
render render
expect(rendered).to match /Custom framework 23/ expect(rendered).to have_select('project[compliance_framework_setting_attributes][framework]', with_options: ['Custom framework 23'])
end
it 'does not include warning message' do
render
expect(rendered).not_to match /Customizable by owners./
end end
it 'contains the dropdown' do it 'shows the submit button' do
render render
expect(rendered).to have_css('select[id=project_compliance_framework_setting_attributes_framework]') expect(rendered).to have_button('Save changes')
expect(rendered).not_to have_css('select[id=project_compliance_framework_setting_attributes_framework][disabled="disabled"]')
end end
context 'user is group maintainer' do context 'user is group maintainer' do
...@@ -44,10 +44,10 @@ RSpec.describe 'projects/edit.html.haml' do ...@@ -44,10 +44,10 @@ RSpec.describe 'projects/edit.html.haml' do
allow(view).to receive(:current_user).and_return(maintainer) allow(view).to receive(:current_user).and_return(maintainer)
end end
it 'includes warning message' do it 'shows the no permissions text' do
render render
expect(rendered).to match /Customizable by owners./ expect(rendered).to have_text('Customizable by owners.')
end end
it 'disables the dropdown' do it 'disables the dropdown' do
...@@ -55,6 +55,10 @@ RSpec.describe 'projects/edit.html.haml' do ...@@ -55,6 +55,10 @@ RSpec.describe 'projects/edit.html.haml' do
expect(rendered).to have_css('input[id=project_compliance_framework_setting_attributes_framework][disabled="disabled"]') expect(rendered).to have_css('input[id=project_compliance_framework_setting_attributes_framework][disabled="disabled"]')
end end
it 'hides the submit button' do
expect(rendered).not_to have_button('Save changes')
end
end end
end end
...@@ -63,10 +67,33 @@ RSpec.describe 'projects/edit.html.haml' do ...@@ -63,10 +67,33 @@ RSpec.describe 'projects/edit.html.haml' do
group.compliance_management_frameworks.delete_all group.compliance_management_frameworks.delete_all
end end
it 'shows a notification' do it 'shows the empty text' do
render render
expect(rendered).to match /No compliance frameworks are in use. Create one from the .* section in Group Settings./ expect(rendered).to match /No compliance frameworks are in use. Create one from the .* section in Group Settings./
end end
it 'hides the submit button' do
expect(rendered).not_to have_button('Save changes')
end
context 'user is group maintainer' do
let_it_be(:maintainer) { create(:user) }
before do
group.add_maintainer(maintainer)
allow(view).to receive(:current_user).and_return(maintainer)
end
it 'shows the empty text' do
render
expect(rendered).to have_text('No compliance frameworks are in use.')
end
it 'hides the submit button' do
expect(rendered).not_to have_button('Save changes')
end
end
end end
end end
...@@ -29351,6 +29351,9 @@ msgstr "" ...@@ -29351,6 +29351,9 @@ msgstr ""
msgid "Select a file from the left sidebar to begin editing. Afterwards, you'll be able to commit your changes." msgid "Select a file from the left sidebar to begin editing. Afterwards, you'll be able to commit your changes."
msgstr "" msgstr ""
msgid "Select a framework that applies to this project. %{linkStart}How are these added?%{linkEnd}"
msgstr ""
msgid "Select a group to invite" msgid "Select a group to invite"
msgstr "" 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