Commit 6e0c8d37 authored by peterhegman's avatar peterhegman

Convert dropdowns in Admin / Visiblity and access to radio buttons

Convert the `Default branch protection` and
`Default project creation protection` admin settings from dropdowns
to radio buttons

Changelog: changed
parent ad636465
= form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-visibility-settings'), html: { class: 'fieldset-form', id: 'visibility-settings' } do |f|
= gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-visibility-settings'), html: { class: 'fieldset-form', id: 'visibility-settings' } do |f|
= form_errors(@application_setting)
%fieldset
= render 'shared/default_branch_protection', f: f, selected_level: @application_setting.default_branch_protection
= render 'shared/default_branch_protection', f: f
= render_if_exists 'admin/application_settings/group_owners_can_manage_default_branch_protection_setting', form: f
.form-group
= f.label s_('ProjectCreationLevel|Default project creation protection'), class: 'label-bold'
= f.select :default_project_creation, options_for_select(Gitlab::Access.project_creation_options, @application_setting.default_project_creation), {}, class: 'form-control'
= render 'shared/project_creation_levels', f: f, method: :default_project_creation, legend: s_('ProjectCreationLevel|Default project creation protection')
= render_if_exists 'admin/application_settings/default_project_deletion_protection_setting', form: f
= render_if_exists 'admin/application_settings/default_delayed_project_deletion_setting', form: f
= render_if_exists 'admin/application_settings/default_project_deletion_adjourned_period_setting', form: f
......
.form-group
= f.label :default_branch_protection, class: 'label-bold'
= f.select :default_branch_protection, options_for_select(Gitlab::Access.protection_options, selected_level), {}, class: 'form-control'
%fieldset.form-group
%legend.h5.gl-border-none.gl-mt-0.gl-mb-3= _('Default branch protection')
- Gitlab::Access.protection_options.each do |option|
= f.gitlab_ui_radio_component :default_branch_protection, option[:value], option[:label], help_text: option[:help_text]
- method = local_assigns.fetch(:method, nil)
- legend = local_assigns.fetch(:legend, nil)
%fieldset.form-group
%legend.h5.gl-border-none.gl-mt-0.gl-mb-3= legend
- Gitlab::Access.project_creation_options.each do |label, value|
= f.gitlab_ui_radio_component method, value, label
......@@ -74,16 +74,32 @@ module Gitlab
end
def protection_options
{
"Not protected: Both developers and maintainers can push new commits and force push." => PROTECTION_NONE,
"Protected against pushes: Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch." => PROTECTION_DEV_CAN_MERGE,
"Partially protected: Both developers and maintainers can push new commits, but cannot force push." => PROTECTION_DEV_CAN_PUSH,
"Fully protected: Developers cannot push new commits, but maintainers can. No one can force push." => PROTECTION_FULL
}
[
{
label: s_('DefaultBranchProtection|Not protected'),
help_text: s_('DefaultBranchProtection|Both developers and maintainers can push new commits, force push, or delete the branch.'),
value: PROTECTION_NONE
},
{
label: s_('DefaultBranchProtection|Protected against pushes'),
help_text: s_('DefaultBranchProtection|Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch.'),
value: PROTECTION_DEV_CAN_MERGE
},
{
label: s_('DefaultBranchProtection|Partially protected'),
help_text: s_('DefaultBranchProtection|Both developers and maintainers can push new commits, but cannot force push.'),
value: PROTECTION_DEV_CAN_PUSH
},
{
label: s_('DefaultBranchProtection|Fully protected'),
help_text: s_('DefaultBranchProtection|Developers cannot push new commits, but maintainers can. No one can force push.'),
value: PROTECTION_FULL
}
]
end
def protection_values
protection_options.values
protection_options.map { |option| option[:value] }
end
def human_access(access)
......
......@@ -10861,6 +10861,9 @@ msgstr ""
msgid "Default branch and protected branches"
msgstr ""
msgid "Default branch protection"
msgstr ""
msgid "Default classification label"
msgstr ""
......@@ -10900,6 +10903,30 @@ msgstr ""
msgid "DefaultBranchLabel|default"
msgstr ""
msgid "DefaultBranchProtection|Both developers and maintainers can push new commits, but cannot force push."
msgstr ""
msgid "DefaultBranchProtection|Both developers and maintainers can push new commits, force push, or delete the branch."
msgstr ""
msgid "DefaultBranchProtection|Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch."
msgstr ""
msgid "DefaultBranchProtection|Developers cannot push new commits, but maintainers can. No one can force push."
msgstr ""
msgid "DefaultBranchProtection|Fully protected"
msgstr ""
msgid "DefaultBranchProtection|Not protected"
msgstr ""
msgid "DefaultBranchProtection|Partially protected"
msgstr ""
msgid "DefaultBranchProtection|Protected against pushes"
msgstr ""
msgid "Define a custom deploy freeze pattern with %{cronSyntaxStart}cron syntax%{cronSyntaxEnd}"
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