2015-01-08 03:22:50 -05:00
|
|
|
module ApplicationSettingsHelper
|
2017-02-22 12:51:46 -05:00
|
|
|
delegate :gravatar_enabled?,
|
|
|
|
:signup_enabled?,
|
|
|
|
:signin_enabled?,
|
|
|
|
:akismet_enabled?,
|
|
|
|
:koding_enabled?,
|
|
|
|
to: :current_application_settings
|
2015-01-08 12:53:35 -05:00
|
|
|
|
2015-05-29 07:29:16 -04:00
|
|
|
def user_oauth_applications?
|
|
|
|
current_application_settings.user_oauth_applications
|
|
|
|
end
|
|
|
|
|
2016-06-15 18:30:55 -04:00
|
|
|
def allowed_protocols_present?
|
2016-06-29 15:30:27 -04:00
|
|
|
current_application_settings.enabled_git_access_protocol.present?
|
2016-06-15 18:30:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def enabled_protocol
|
2016-06-29 15:30:27 -04:00
|
|
|
case current_application_settings.enabled_git_access_protocol
|
2016-06-15 18:30:55 -04:00
|
|
|
when 'http'
|
|
|
|
gitlab_config.protocol
|
|
|
|
when 'ssh'
|
|
|
|
'ssh'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-29 16:25:04 -04:00
|
|
|
def enabled_project_button(project, protocol)
|
2016-06-15 18:30:55 -04:00
|
|
|
case protocol
|
|
|
|
when 'ssh'
|
2016-07-05 17:48:48 -04:00
|
|
|
ssh_clone_button(project, 'bottom', append_link: false)
|
2016-06-15 18:30:55 -04:00
|
|
|
else
|
2016-07-05 17:48:48 -04:00
|
|
|
http_clone_button(project, 'bottom', append_link: false)
|
2016-06-15 18:30:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-01 10:06:46 -05:00
|
|
|
# Return a group of checkboxes that use Bootstrap's button plugin for a
|
|
|
|
# toggle button effect.
|
|
|
|
def restricted_level_checkboxes(help_block_id)
|
|
|
|
Gitlab::VisibilityLevel.options.map do |name, level|
|
|
|
|
checked = restricted_visibility_levels(true).include?(level)
|
2016-11-14 14:26:37 -05:00
|
|
|
css_class = checked ? 'active' : ''
|
|
|
|
checkbox_name = "application_setting[restricted_visibility_levels][]"
|
2015-03-01 10:06:46 -05:00
|
|
|
|
2016-11-14 14:26:37 -05:00
|
|
|
label_tag(name, class: css_class) do
|
2015-03-10 20:21:09 -04:00
|
|
|
check_box_tag(checkbox_name, level, checked,
|
|
|
|
autocomplete: 'off',
|
2016-11-14 14:26:37 -05:00
|
|
|
'aria-describedby' => help_block_id,
|
|
|
|
id: name) + visibility_level_icon(level) + name
|
2015-03-01 10:06:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-12 02:13:20 -04:00
|
|
|
|
|
|
|
# Return a group of checkboxes that use Bootstrap's button plugin for a
|
|
|
|
# toggle button effect.
|
|
|
|
def import_sources_checkboxes(help_block_id)
|
|
|
|
Gitlab::ImportSources.options.map do |name, source|
|
|
|
|
checked = current_application_settings.import_sources.include?(source)
|
2016-11-19 09:44:06 -05:00
|
|
|
css_class = checked ? 'active' : ''
|
2015-08-12 02:13:20 -04:00
|
|
|
checkbox_name = 'application_setting[import_sources][]'
|
|
|
|
|
2016-11-19 09:44:06 -05:00
|
|
|
label_tag(name, class: css_class) do
|
2015-08-12 02:13:20 -04:00
|
|
|
check_box_tag(checkbox_name, source, checked,
|
|
|
|
autocomplete: 'off',
|
2016-11-19 09:44:06 -05:00
|
|
|
'aria-describedby' => help_block_id,
|
|
|
|
id: name.tr(' ', '_')) + name
|
2015-08-12 02:13:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-05-04 06:33:33 -04:00
|
|
|
|
2016-05-12 06:43:12 -04:00
|
|
|
def oauth_providers_checkboxes
|
2016-05-04 06:33:33 -04:00
|
|
|
button_based_providers.map do |source|
|
2016-05-10 04:29:19 -04:00
|
|
|
disabled = current_application_settings.disabled_oauth_sign_in_sources.include?(source.to_s)
|
2016-05-04 06:33:33 -04:00
|
|
|
css_class = 'btn'
|
2016-05-10 11:50:03 -04:00
|
|
|
css_class << ' active' unless disabled
|
2016-05-10 04:29:19 -04:00
|
|
|
checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
|
2016-05-04 06:33:33 -04:00
|
|
|
|
|
|
|
label_tag(checkbox_name, class: css_class) do
|
2016-05-10 04:29:19 -04:00
|
|
|
check_box_tag(checkbox_name, source, !disabled,
|
2016-05-12 06:43:12 -04:00
|
|
|
autocomplete: 'off') + Gitlab::OAuth::Provider.label_for(source)
|
2016-05-04 06:33:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-29 23:35:00 -04:00
|
|
|
|
2016-11-03 10:12:20 -04:00
|
|
|
def repository_storages_options_for_select
|
2016-06-29 23:35:00 -04:00
|
|
|
options = Gitlab.config.repositories.storages.map do |name, path|
|
|
|
|
["#{name} - #{path}", name]
|
|
|
|
end
|
|
|
|
|
2016-11-03 10:12:20 -04:00
|
|
|
options_for_select(options, @application_setting.repository_storages)
|
2016-06-29 23:35:00 -04:00
|
|
|
end
|
2016-11-04 18:54:24 -04:00
|
|
|
|
|
|
|
def sidekiq_queue_options_for_select
|
|
|
|
options_for_select(Sidekiq::Queue.all.map(&:name), @application_setting.sidekiq_throttling_queues)
|
|
|
|
end
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|