Commit 960243b9 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '358319-replace-generic-checkbox-with-gitlab-ui-styled-checkbox-in-app-views-admin' into 'master'

Replace generic checkbox with GitLab UI styled checkbox in app/views/admin/application_settings/_visibility_and_access.html.haml

See merge request gitlab-org/gitlab!84745
parents 0e46f8b4 8a3d9b73
......@@ -69,39 +69,31 @@ module ApplicationSettingsHelper
end
end
# Return a group of checkboxes that use Bootstrap's button plugin for a
# toggle button effect.
def restricted_level_checkboxes(help_block_id, checkbox_name, options = {})
def restricted_level_checkboxes(form)
Gitlab::VisibilityLevel.values.map do |level|
checked = restricted_visibility_levels(true).include?(level)
css_class = checked ? 'active' : ''
tag_name = "application_setting_visibility_level_#{level}"
label_tag(tag_name, class: css_class) do
check_box_tag(checkbox_name, level, checked,
autocomplete: 'off',
'aria-describedby' => help_block_id,
'class' => options[:class],
id: tag_name) + visibility_level_icon(level) + visibility_level_label(level)
end
form.gitlab_ui_checkbox_component(
:restricted_visibility_levels,
"#{visibility_level_icon(level)} #{visibility_level_label(level)}".html_safe,
checkbox_options: { checked: checked, multiple: true, autocomplete: 'off' },
checked_value: level,
unchecked_value: nil
)
end
end
# Return a group of checkboxes that use Bootstrap's button plugin for a
# toggle button effect.
def import_sources_checkboxes(help_block_id, options = {})
def import_sources_checkboxes(form)
Gitlab::ImportSources.options.map do |name, source|
checked = @application_setting.import_sources.include?(source)
css_class = checked ? 'active' : ''
checkbox_name = 'application_setting[import_sources][]'
label_tag(name, class: css_class) do
check_box_tag(checkbox_name, source, checked,
autocomplete: 'off',
'aria-describedby' => help_block_id,
'class' => options[:class],
id: name.tr(' ', '_')) + name
end
form.gitlab_ui_checkbox_component(
:import_sources,
name,
checkbox_options: { checked: checked, multiple: true, autocomplete: 'off' },
checked_value: source,
unchecked_value: nil
)
end
end
......
......@@ -17,18 +17,16 @@
= render('shared/visibility_radios', model_method: :default_group_visibility, form: f, selected_level: @application_setting.default_group_visibility, form_model: Group.new)
.form-group
= f.label :restricted_visibility_levels, class: 'label-bold'
- checkbox_name = 'application_setting[restricted_visibility_levels][]'
= hidden_field_tag(checkbox_name)
- restricted_level_checkboxes('restricted-visibility-help', checkbox_name, class: 'form-check-input').each do |level|
.form-check
= level
= hidden_field_tag 'application_setting[restricted_visibility_levels][]'
- restricted_level_checkboxes(f).each do |level|
= level
%span.form-text.text-muted#restricted-visibility-help
= _('Selected levels cannot be used by non-admin users for groups, projects or snippets. If the public level is restricted, user profiles are only visible to logged in users.')
.form-group
= f.label :import_sources, class: 'label-bold'
= hidden_field_tag 'application_setting[import_sources][]'
- import_sources_checkboxes('import-sources-help', class: 'form-check-input').each do |source|
.form-check= source
- import_sources_checkboxes(f).each do |source|
= source
%span.form-text.text-muted#import-sources-help
= _('Enabled sources for code import during project creation. OmniAuth must be configured for GitHub')
= link_to sprite_icon('question-o'), help_page_path("integration/github")
......@@ -40,10 +38,7 @@
= render_if_exists 'admin/application_settings/ldap_access_setting', form: f
.form-group
.form-check
= f.check_box :project_export_enabled, class: 'form-check-input'
= f.label :project_export_enabled, class: 'form-check-label' do
= _('Project export enabled')
= f.gitlab_ui_checkbox_component :project_export_enabled, s_('AdminSettings|Project export enabled')
.form-group
%label.label-bold= _('Enabled Git access protocols')
......@@ -65,9 +60,6 @@
.form-group
%label.label-bold= s_('AdminSettings|Feed token')
.form-check
= f.check_box :disable_feed_token, class: 'form-check-input'
= f.label :disable_feed_token, class: 'form-check-label' do
= s_('AdminSettings|Disable feed token')
= f.gitlab_ui_checkbox_component :disable_feed_token, s_('AdminSettings|Disable feed token')
= f.submit _('Save changes'), class: "gl-button btn btn-confirm"
......@@ -4,8 +4,6 @@
.form-group
= f.label _('Default delayed project deletion'), class: 'label-bold'
.form-check
= f.check_box :delayed_project_deletion, class: 'form-check-input'
= f.label :delayed_project_deletion, class: 'form-check-label' do
= _('Enable delayed project deletion by default for newly-created groups.')
= _('Does not apply to projects in personal namespaces, which are deleted immediately on request.')
= f.gitlab_ui_checkbox_component :delayed_project_deletion,
_('Enable delayed project deletion by default for newly-created groups.'),
help_text: _('Does not apply to projects in personal namespaces, which are deleted immediately on request.')
......@@ -4,7 +4,4 @@
.form-group
= f.label _('Default project deletion protection'), class: 'label-bold'
.form-check
= f.check_box :default_project_deletion_protection, class: 'form-check-input'
= f.label :default_project_deletion_protection, class: 'form-check-label' do
= _('Only admins can delete project')
= f.gitlab_ui_checkbox_component :default_project_deletion_protection, _('Only admins can delete project')
......@@ -2700,6 +2700,9 @@ msgstr ""
msgid "AdminSettings|Preview payload"
msgstr ""
msgid "AdminSettings|Project export enabled"
msgstr ""
msgid "AdminSettings|Protect CI/CD variables by default"
msgstr ""
......@@ -29143,9 +29146,6 @@ msgstr ""
msgid "Project export download requests"
msgstr ""
msgid "Project export enabled"
msgstr ""
msgid "Project export has been deleted."
msgstr ""
......
......@@ -34,16 +34,16 @@ RSpec.describe 'Admin updates settings' do
it 'uncheck all restricted visibility levels' do
page.within('.as-visibility-access') do
find('#application_setting_visibility_level_0').set(false)
find('#application_setting_visibility_level_10').set(false)
find('#application_setting_visibility_level_20').set(false)
find('#application_setting_restricted_visibility_levels_0').set(false)
find('#application_setting_restricted_visibility_levels_10').set(false)
find('#application_setting_restricted_visibility_levels_20').set(false)
click_button 'Save changes'
end
expect(page).to have_content "Application settings saved successfully"
expect(find('#application_setting_visibility_level_0')).not_to be_checked
expect(find('#application_setting_visibility_level_10')).not_to be_checked
expect(find('#application_setting_visibility_level_20')).not_to be_checked
expect(find('#application_setting_restricted_visibility_levels_0')).not_to be_checked
expect(find('#application_setting_restricted_visibility_levels_10')).not_to be_checked
expect(find('#application_setting_restricted_visibility_levels_20')).not_to be_checked
end
it 'modify import sources' do
......
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