From 46ddc601b8ca81144217747e970b82782612ce83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 14 Jan 2025 14:25:16 +0100 Subject: [PATCH] Defauls settings' values --- app/views/settings/_oauth_settings.html.erb | 86 ++++++++++----------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/app/views/settings/_oauth_settings.html.erb b/app/views/settings/_oauth_settings.html.erb index 28d391b..56bdcb0 100644 --- a/app/views/settings/_oauth_settings.html.erb +++ b/app/views/settings/_oauth_settings.html.erb @@ -32,14 +32,14 @@ %w(Okta Okta), %w(Custom), [" ".html_safe, 'none'] - ], @settings[:oauth_name]), onchange: 'oauth_settings_visibility()' %> + ], RedmineOauth.oauth_name), onchange: 'oauth_settings_visibility()' %> <%= l(:oauth_provider_info) %>

-
+

- <% icons = %w(far\ fa-address-book far\ fa-address-card far\ fa-angry far\ fa-arrow-alt-circle-down far\ fa-arrow-alt-circle-left far\ fa-arrow-alt-circle-right far\ fa-arrow-alt-circle-up far\ fa-bell far\ fa-bell-slash far\ fa-bookmark far\ fa-building far\ fa-calendar far\ fa-calendar-alt far\ fa-calendar-check far\ fa-calendar-minus far\ fa-calendar-plus far\ fa-calendar-times far\ fa-caret-square-down far\ fa-caret-square-left far\ fa-caret-square-right far\ fa-caret-square-up far\ fa-chart-bar far\ fa-check-circle far\ fa-check-square far\ fa-circle far\ fa-clipboard far\ fa-clock far\ fa-clone far\ fa-closed-captioning far\ fa-comment far\ fa-comment-alt far\ fa-comment-dots far\ fa-comments far\ fa-compass far\ fa-copy far\ fa-copyright far\ fa-credit-card far\ fa-dizzy far\ fa-dot-circle far\ fa-edit far\ fa-envelope far\ fa-envelope-open far\ fa-eye far\ fa-eye-slash far\ fa-file far\ fa-file-alt far\ fa-file-archive far\ fa-file-audio far\ fa-file-code far\ fa-file-excel far\ fa-file-image far\ fa-file-pdf far\ fa-file-powerpoint far\ fa-file-video far\ fa-file-word far\ fa-flag far\ fa-flushed far\ fa-folder far\ fa-folder-open far\ fa-frown far\ fa-frown-open far\ fa-futbol far\ fa-gem far\ fa-grimace far\ fa-grin far\ fa-grin-alt far\ fa-grin-beam far\ fa-grin-beam-sweat far\ fa-grin-hearts far\ fa-grin-squint far\ fa-grin-squint-tears far\ fa-grin-stars far\ fa-grin-tears far\ fa-grin-tongue far\ fa-grin-tongue-squint far\ fa-grin-tongue-wink far\ fa-grin-wink far\ fa-hand-lizard far\ fa-hand-paper far\ fa-hand-peace far\ fa-hand-point-down far\ fa-hand-point-left far\ fa-hand-point-right far\ fa-hand-point-up far\ fa-hand-pointer far\ fa-hand-rock far\ fa-hand-scissors far\ fa-hand-spock far\ fa-handshake far\ fa-hdd far\ fa-heart far\ fa-hospital far\ fa-hourglass far\ fa-id-badge far\ fa-id-card far\ fa-image far\ fa-images far\ fa-keyboard far\ fa-kiss far\ fa-kiss-beam far\ fa-kiss-wink-heart far\ fa-laugh far\ fa-laugh-beam far\ fa-laugh-squint far\ fa-laugh-wink far\ fa-lemon far\ fa-life-ring far\ fa-lightbulb far\ fa-list-alt far\ fa-map far\ fa-meh far\ fa-meh-blank far\ fa-meh-rolling-eyes far\ fa-minus-square far\ fa-money-bill-alt far\ fa-moon far\ fa-newspaper far\ fa-object-group far\ fa-object-ungroup far\ fa-paper-plane far\ fa-pause-circle far\ fa-play-circle far\ fa-plus-square far\ fa-question-circle far\ fa-registered far\ fa-sad-cry far\ fa-sad-tear far\ fa-save far\ fa-share-square far\ fa-smile far\ fa-smile-beam far\ fa-smile-wink far\ fa-snowflake far\ fa-square far\ fa-star far\ fa-star-half far\ fa-sticky-note far\ fa-stop-circle far\ fa-sun far\ fa-surprise far\ fa-thumbs-down far\ fa-thumbs-up far\ fa-times-circle far\ fa-tired far\ fa-trash-alt far\ fa-user far\ fa-user-circle far\ fa-window-close far\ fa-window-maximize far\ fa-window-minimize far\ fa-window-restore @@ -48,75 +48,73 @@ icons.map!{ |icon| Array.new(2, icon) } icons.insert(0, [" ".html_safe, 'none']) %> - <%= select_tag 'settings[button_icon]', options_for_select(icons, @settings[:button_icon]), + <%= select_tag 'settings[button_icon]', options_for_select(icons, RedmineOauth.button_icon), onchange: "oauth_set_icon();" %> - <% style = "background: #{@settings[:button_color]};" %> - <% if @settings[:button_icon] == 'none' %> + <% style = "background: #{RedmineOauth.button_color};" %> + <% if RedmineOauth.button_icon == 'none' %> <% style << 'display: none;'%> <% end %> <%= button_tag(name: 'login-oauth', id: 'login-oauth-button', title: l(:oauth_login_with), style: style, disabled: true) do %> - - <%= l(:oauth_login_via, oauth: !@settings[:custom_name].nil? && !@settings[:custom_name].empty? ? @settings[:custom_name] : @settings[:oauth_name]).html_safe %> + + <%= l(:oauth_login_via, oauth: RedmineOauth.custom_name.present? ? RedmineOauth.custom_name : RedmineOauth.oauth_name) %> <% end %> <%= l(:oauth_button_info) %>

- <% if %w(Custom).include?(@settings[:oauth_name]) %> + <% if %w(Custom).include?(RedmineOauth.oauth_name) %>

<% end %> - <%= text_field_tag 'settings[site]', @settings[:site], size: 40 %> + <%= text_field_tag 'settings[site]', RedmineOauth.site, size: 40 %> <%= l(:oauth_site_info) %>

- <% if %w(Azure\ AD).include?(@settings[:oauth_name]) %> + <% if %w(Azure\ AD).include?(RedmineOauth.oauth_name) %>

<% else %>

- <%= text_field_tag 'settings[client_id]', @settings[:client_id], size: 40 %> + <%= text_field_tag 'settings[client_id]', RedmineOauth.client_id, size: 40 %> <%= l(:oauth_client_id_info) %>

- <%= text_field_tag 'settings[client_secret]', Redmine::Ciphering.decrypt_text(@settings[:client_secret]), + <%= text_field_tag 'settings[client_secret]', Redmine::Ciphering.decrypt_text(RedmineOauth.client_secret), size: 40 %> <%= l(:oauth_client_secret_info) %>

- <% if %w(GitLab Google Custom).include?(@settings[:oauth_name]) %> + <% if %w(GitLab Google Custom).include?(RedmineOauth.oauth_name) %>

<% end %> - <%= text_field_tag 'settings[tenant_id]', @settings[:tenant_id], size: 40 %> + <%= text_field_tag 'settings[tenant_id]', RedmineOauth.tenant_id, size: 40 %> <%= l(:oauth_tenant_id_info) %>

<%= select_tag 'settings[self_registration]', options_for_select([ - [l(:label_disabled), "0"], - [l(:label_registration_activation_by_email), "1"], - [l(:label_registration_manual_activation), "2"], - [l(:label_registration_automatic_activation), "3"] - ], @settings[:self_registration]), onchange: 'oauth_self_registration_changed();' %> + [l(:label_disabled), '0'], + [l(:label_registration_activation_by_email), '1'], + [l(:label_registration_manual_activation), '2'], + [l(:label_registration_automatic_activation), '3'] + ], RedmineOauth.self_registration), onchange: 'oauth_self_registration_changed();' %> <%= l(:label_default)%>: <%= l(:label_disabled) %>

- <% style = if @settings[:self_registration].present? && (@settings[:self_registration] != '0') + <% style = if RedmineOauth.self_registration != '0' 'display: block' else 'display: none' @@ -124,28 +122,28 @@

- <%= text_field_tag 'settings[custom_firstname_field]', @settings[:custom_firstname_field] %> + <%= text_field_tag 'settings[custom_firstname_field]', RedmineOauth.custom_firstname_field %> <%= l(:label_default) %>: given_name

- <%= text_field_tag 'settings[custom_lastname_field]', @settings[:custom_lastname_field] %> + <%= text_field_tag 'settings[custom_lastname_field]', RedmineOauth.custom_lastname_field %> <%= l(:label_default) %>: family_name

- <%= text_field_tag 'settings[validate_user_roles]', @settings[:validate_user_roles], size: 40 %> + <%= text_field_tag 'settings[validate_user_roles]', RedmineOauth.validate_user_roles, size: 40 %> <%= l(:oauth_validate_user_roles_info) %>

- <%= check_box_tag 'settings[hide_login_form]', true, @settings[:hide_login_form] %> + <%= check_box_tag 'settings[hide_login_form]', '1', RedmineOauth.hide_login_form? %> <%= l(:label_default)%>: <%= l(:general_text_No) %>

- <%= check_box_tag 'settings[update_login]', true, @settings[:update_login] %> + <%= check_box_tag 'settings[update_login]', '1', RedmineOauth.update_login? %> <%= l(:oauth_update_login_info) %>
@@ -154,63 +152,61 @@

- <%= check_box_tag 'settings[oauth_logout]', true, @settings[:oauth_logout] %> + <%= check_box_tag 'settings[oauth_logout]', '1', RedmineOauth.oauth_logout? %> - <%= l(:oauth_logout_info) %> -
+ <%= l(:oauth_logout_info) %>
<%= l(:label_default) %>: <%= l(:general_text_No) %>

- <%= check_box_tag 'settings[oauth_login]', true, @settings[:oauth_login] %> + <%= check_box_tag 'settings[oauth_login]', '1', RedmineOauth.oauth_login? %> - <%= l(:oauth_login_info) %> -
+ <%= l(:oauth_login_info) %>
<%= l(:label_default) %>: <%= l(:general_text_No) %>

- <% style = %w(Custom).exclude?(@settings[:oauth_name]) ? 'display: none' : 'display: block' %> + <% style = %w(Custom).exclude?(RedmineOauth.oauth_name) ? 'display: none' : 'display: block' %>

- <%= l(:oauth_custom_name_info) %>

- <%= text_field_tag 'settings[custom_auth_endpoint]', @settings[:custom_auth_endpoint], size: 80 %> + <%= text_field_tag 'settings[custom_auth_endpoint]', RedmineOauth.custom_auth_endpoint, size: 80 %> <%= l(:oauth_custom_auth_endpoint_info) %>

- <%= text_field_tag 'settings[custom_token_endpoint]', @settings[:custom_token_endpoint], size: 80 %> + <%= text_field_tag 'settings[custom_token_endpoint]', RedmineOauth.custom_token_endpoint, size: 80 %> <%= l(:oauth_custom_token_endpoint_info) %>

- <%= text_field_tag 'settings[custom_profile_endpoint]', @settings[:custom_profile_endpoint], size: 80 %> + <%= text_field_tag 'settings[custom_profile_endpoint]', RedmineOauth.custom_profile_endpoint, size: 80 %> <%= l(:oauth_custom_profile_endpoint_info) %>

- <%= text_field_tag 'settings[custom_logout_endpoint]', @settings[:custom_logout_endpoint], size: 80 %> + <%= text_field_tag 'settings[custom_logout_endpoint]', RedmineOauth.custom_logout_endpoint, size: 80 %> <%= l(:oauth_custom_logout_endpoint_info) %>

- <%= text_field_tag 'settings[custom_scope]', @settings[:custom_scope], size: 40 %> + <%= text_field_tag 'settings[custom_scope]',RedmineOauth.custom_scope, size: 40 %> <%= l(:oauth_custom_scope_info) %>

- <%= text_field_tag 'settings[custom_uid_field]', @settings[:custom_uid_field], size: 40 %> + <%= text_field_tag 'settings[custom_uid_field]', RedmineOauth.custom_uid_field, size: 40 %> <%= l(:oauth_custom_uid_field_info) %>

- <%= text_field_tag 'settings[custom_email_field]', @settings[:custom_email_field], size: 40 %> + <%= text_field_tag 'settings[custom_email_field]', RedmineOauth.custom_email_field, size: 40 %> <%= l(:oauth_custom_email_field_info) %>