Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Primerize setings

Oliver Günther985b07d1fdb0
diff --git a/app/components/types/edit_page_header_component.html.erb b/app/components/types/edit_page_header_component.html.erb
index 6d26386c3b0..114769838ec 100644
--- a/app/components/types/edit_page_header_component.html.erb
+++ b/app/components/types/edit_page_header_component.html.erb
@@ -33,18 +33,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(breadcrumb_items)
if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @tabs.each do |tab|
- tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|
- feature = tab[:enterprise_feature]
-
- if feature && !EnterpriseToken.allows_to?(feature)
- t.with_icon(icon: :"op-enterprise-addons", classes: "upsell-colored")
- end
- t.with_text { I18n.t(tab[:label]) }
- end
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
end
%>
diff --git a/app/forms/application_form.rb b/app/forms/application_form.rb
index 2fe86546d08..87a6882aa5e 100644
--- a/app/forms/application_form.rb
+++ b/app/forms/application_form.rb
@@ -31,7 +31,7 @@
class ApplicationForm < Primer::Forms::Base
def self.settings_form
form do |f|
- f = SettingsFormDecorator.new(f)
+ f = Settings::FormDecorator.new(f)
yield f
end
end
diff --git a/app/models/setting/self_registration.rb b/app/models/setting/self_registration.rb
index cfe39da6295..092078c7cb0 100644
--- a/app/models/setting/self_registration.rb
+++ b/app/models/setting/self_registration.rb
@@ -54,8 +54,12 @@ class Setting
value key: :disabled
end
+ def self.selected?(val)
+ key(value: Setting.self_registration) == val.to_sym
+ end
+
def self.disabled?
- key(value: Setting.self_registration) == :disabled
+ selected?(:disabled)
end
def self.enabled?
@@ -67,7 +71,7 @@ class Setting
end
def self.by_email?
- key(value: Setting.self_registration) == :activation_by_email
+ selected?(:activation_by_email)
end
def self.manual
@@ -75,7 +79,7 @@ class Setting
end
def self.manual?
- key(value: Setting.self_registration) == :manual_activation
+ selected?(:manual_activation)
end
def self.automatic
@@ -83,7 +87,7 @@ class Setting
end
def self.automatic?
- key(value: Setting.self_registration) == :automatic_activation
+ selected?(:automatic_activation)
end
def self.unsupervised_registration?
diff --git a/app/views/admin/settings/authentication_settings/_login.html.erb b/app/views/admin/settings/authentication_settings/_login.html.erb
new file mode 100644
index 00000000000..78bd29a2f9b
--- /dev/null
+++ b/app/views/admin/settings/authentication_settings/_login.html.erb
@@ -0,0 +1,102 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%=
+ admin_settings_primer_form_with(scope: :settings,
+ url: admin_settings_authentication_path(tab: params[:tab]),
+ method: :patch) do |f|
+ render_inline_settings_form(f) do |form|
+ form.select_list(
+ name: :omniauth_direct_login_provider,
+ input_width: :medium,
+ label: I18n.t(:setting_omniauth_direct_login_provider),
+ caption: I18n.t(
+ "settings.authentication.omniauth_direct_login_hint_html",
+ internal_path: internal_signin_url
+ ).html_safe,
+ include_blank: I18n.t(:label_none_parentheses)
+ ) do |select|
+ AuthProvider
+ .where(available: true)
+ .order("lower(display_name) ASC")
+ .select(:type, :display_name, :slug)
+ .to_a
+ .each do |provider|
+ select.option(
+ value: provider.slug,
+ label: "#{provider.display_name} (#{provider.human_type})",
+ selected: Setting.omniauth_direct_login_provider == provider.slug
+ )
+ end
+ end
+
+ form.select_list(
+ name: :autologin,
+ input_width: :medium,
+ label: I18n.t(:setting_autologin),
+ ) do |select|
+ select.option(
+ value: 0,
+ label: I18n.t(:label_disabled),
+ selected: Setting.autologin == 0
+ )
+
+ Settings::Definition[:autologin].allowed.each do |days|
+ select.option(
+ value: days,
+ label: I18n.t("datetime.distance_in_words.x_days", count: days),
+ selected: Setting.autologin == days
+ )
+ end
+ end
+
+ form.check_box(name: :session_ttl_enabled)
+
+ form.text_field(name: :session_ttl,
+ type: :number,
+ size: 6,
+ min: 0,
+ caption: I18n.t("setting_session_ttl_hint"),
+ trailing_visual: { text: { text: I18n.t(:label_minute_plural) } },
+ input_width: :small)
+
+ form.check_box(name: :log_requesting_user)
+
+ form.text_field(name: :after_first_login_redirect_url,
+ caption: I18n.t(:setting_after_first_login_redirect_url_text_html).html_safe,
+ input_width: :large)
+
+ form.text_field(name: :after_login_default_redirect_url,
+ caption: I18n.t(:setting_after_login_default_redirect_url_text_html).html_safe,
+ input_width: :large)
+
+ form.submit
+ end
+ end
+%>
diff --git a/app/views/admin/settings/authentication_settings/_passwords.html.erb b/app/views/admin/settings/authentication_settings/_passwords.html.erb
new file mode 100644
index 00000000000..dae58d29346
--- /dev/null
+++ b/app/views/admin/settings/authentication_settings/_passwords.html.erb
@@ -0,0 +1,109 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%=
+ admin_settings_primer_form_with(scope: :settings,
+ url: admin_settings_authentication_path(tab: params[:tab]),
+ data: { turbo_method: :patch },
+ method: :patch) do |f|
+ render_inline_settings_form(f) do |form|
+ disabled = OpenProject::Configuration.disable_password_login?
+
+ if disabled
+ form.html_content do
+ render Primer::Alpha::Banner.new(
+ scheme: :default,
+ icon: :info,
+ my: 2
+ ) do
+ I18n.t(
+ :note_password_login_disabled,
+ configuration: static_link_to(:disable_password_login, label: I18n.t('label_configuration'))
+ ).html_safe
+ end
+ end
+ end
+
+ form.text_field name: :password_min_length,
+ disabled:,
+ type: :number,
+ size: 6,
+ min: 1,
+ input_width: :small
+
+ form.check_box_group(disabled:, label: I18n.t(:setting_password_active_rules)) do |group|
+ OpenProject::Passwords::Evaluator.known_rules.each do |rule|
+ group.check_box(name: "password_active_rule[]", label: I18n.t("label_password_rule_#{rule}"))
+ end
+ end
+
+ form.text_field(name: :password_min_adhered_rules,
+ type: :number,
+ disabled:,
+ size: 6,
+ min: 0,
+ input_width: :small)
+
+ form.text_field(name: :password_days_valid,
+ type: :number,
+ disabled:,
+ size: 6,
+ min: 0,
+ caption: I18n.t(:text_hint_disable_with_0),
+ input_width: :small)
+
+ form.text_field(name: :password_count_former_banned,
+ type: :number,
+ disabled:,
+ size: 6,
+ min: 0,
+ input_width: :small)
+
+ form.check_box(name: :lost_password,
+ disabled:)
+
+ form.text_field(name: :brute_force_block_after_failed_logins,
+ type: :number,
+ disabled:,
+ size: 6,
+ min: 0,
+ caption: I18n.t(:text_hint_disable_with_0),
+ input_width: :small)
+
+ form.text_field(name: :brute_force_block_minutes,
+ type: :number,
+ disabled:,
+ size: 6,
+ min: 0,
+ caption: I18n.t(:text_hint_disable_with_0),
+ trailing_visual: { text: { text: I18n.t(:label_minute_plural) } },
+ input_width: :small)
+ end
+ end
+%>
diff --git a/app/views/admin/settings/authentication_settings/_registration.html.erb b/app/views/admin/settings/authentication_settings/_registration.html.erb
new file mode 100644
index 00000000000..267dee4f2af
--- /dev/null
+++ b/app/views/admin/settings/authentication_settings/_registration.html.erb
@@ -0,0 +1,84 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%=
+ admin_settings_primer_form_with(scope: :settings,
+ url: admin_settings_authentication_path(tab: params[:tab]),
+ data: { turbo_method: :patch },
+ method: :patch) do |f|
+ render_inline_settings_form(f) do |form|
+ form.check_box(
+ name: :login_required,
+ caption: I18n.t(:setting_login_required_caption),
+ )
+
+ form.select_list(
+ name: :self_registration,
+ input_width: :medium,
+ label: I18n.t(:setting_self_registration),
+ include_blank: false
+ ) do |select|
+ Setting::SelfRegistration::VALUES.each do |key, value|
+ label = key == :disabled ? I18n.t(:label_disabled) : I18n.t("label_registration_#{key}")
+ select.option(
+ value:,
+ label:,
+ selected: Setting.self_registration == value
+ )
+ end
+ end
+
+ if Setting::SelfRegistration.unsupervised_registration?
+ form.html_content do
+ render Primer::Alpha::Banner.new(
+ scheme: :warning,
+ icon: :alert,
+ my: 2
+ ) do
+ I18n.t(:setting_self_registration_warning)
+ end
+ end
+ end
+
+ form.text_field(
+ type: :number,
+ min: 0,
+ max: 100,
+ input_width: :small,
+ trailing_visual: { text: { text: I18n.t("datetime.units.day.other") } },
+ name: :invitation_expiration_days,
+ caption: I18n.t(:setting_invitation_expiration_days_caption),
+ )
+
+ form.multi_language_text_select(name: :registration_footer)
+
+ form.submit
+ end
+ end
+%>
diff --git a/app/views/admin/settings/authentication_settings/show.html.erb b/app/views/admin/settings/authentication_settings/show.html.erb
index 2b4ba182dc7..c4659022926 100644
--- a/app/views/admin/settings/authentication_settings/show.html.erb
+++ b/app/views/admin/settings/authentication_settings/show.html.erb
@@ -28,6 +28,28 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% html_title t(:label_administration), t(:label_authentication) -%>
+<% tabs = [
+ {
+ name: :login,
+ path: admin_settings_authentication_path(tab: :login),
+ label: :"settings.authentication.login_and_sso",
+ partial: "admin/settings/authentication_settings/login"
+ },
+ {
+ name: :registration,
+ path: admin_settings_authentication_path(tab: :registration),
+ label: :"settings.authentication.registration",
+ partial: "admin/settings/authentication_settings/registration"
+ },
+ {
+ name: :passwords,
+ path: admin_settings_authentication_path(tab: :passwords),
+ label: :"settings.passwords",
+ partial: "admin/settings/authentication_settings/passwords"
+ }
+]
+%>
+
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:label_authentication_settings) }
@@ -36,159 +58,11 @@ See COPYRIGHT and LICENSE files for more details.
{ href: admin_settings_authentication_path, text: t(:label_authentication) },
t(:label_authentication_settings)]
)
+ render_tab_header_nav(header, tabs)
end
%>
-<%= styled_form_tag(admin_settings_authentication_path, method: :patch) do %>
- <section class="form--section">
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t("settings.general") %></legend>
- <div class="form--field"><%= setting_check_box :login_required %></div>
-
- <div class="form--field">
- <%= setting_select :self_registration, [[t(:label_disabled), Setting::SelfRegistration.disabled.to_s],
- [t(:label_registration_activation_by_email), Setting::SelfRegistration.by_email.to_s],
- [t(:label_registration_manual_activation), Setting::SelfRegistration.manual.to_s],
- [t(:label_registration_automatic_activation), Setting::SelfRegistration.automatic.to_s]],
- container_class: "-middle" %>
- <div class="form--field-instructions">
- <% if Setting::SelfRegistration.unsupervised_registration? %>
- <%=
- render Primer::Alpha::Banner.new(
- scheme: :warning,
- icon: :alert,
- my: 2
- ) do
- I18n.t(:setting_self_registration_warning)
- end
- %>
- <% end %>
- </div>
- </div>
-
-
- <div class="form--field">
- <%= setting_check_box :email_login, title: I18n.t("tooltip.setting_email_login") %>
- </div>
-
- <%= render Settings::NumericSettingComponent.new("invitation_expiration_days", unit: "days") %>
- </fieldset>
-
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:"settings.authentication.single_sign_on") %></legend>
- <div class="form--field">
- <% providers = AuthProvider
- .where(available: true)
- .order("lower(display_name) ASC")
- .select(:type, :display_name, :slug)
- .to_a
- .map { |p| ["#{p.display_name} (#{p.human_type})", p.slug] } %>
- <%= setting_select :omniauth_direct_login_provider,
- [[t(:label_disabled), ""]] + providers,
- container_class: "-middle" %>
- <span class="form--field-instructions">
- <%= t(
- "settings.authentication.omniauth_direct_login_hint_html",
- internal_path: internal_signin_url
- ) %>
- </span>
- </div>
- </fieldset>
-
- <fieldset class="form--fieldset">
- <fieldset id="registration_footer" class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:setting_registration_footer) %></legend>
- <%= render Settings::TextSettingComponent.new(I18n.locale, name: "registration_footer") %>
- </fieldset>
- </fieldset>
-
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t("settings.passwords") %></legend>
- <% if !OpenProject::Configuration.disable_password_login? %>
- <div class="form--field -wide-label"><%= setting_text_field :password_min_length, size: 6, container_class: "-xslim" %></div>
- <div class="form--field -wide-label">
- <% rules = OpenProject::Passwords::Evaluator.known_rules.map do |rule|
- [t("label_password_rule_#{rule}"), rule]
- end %>
- <%= setting_multiselect :password_active_rules, rules %>
- </div>
- <div class="form--field -wide-label"><%= setting_text_field :password_min_adhered_rules, size: 6, container_class: "-xslim" %></div>
- <div class="form--field -wide-label"><%= setting_text_field :password_days_valid, size: 6, container_class: "-xslim" %>
- <span class="form--field-instructions">
- <%= t(:text_hint_disable_with_0) %>
- </span>
- </div>
- <div class="form--field -wide-label"><%= setting_text_field :password_count_former_banned, size: 6, container_class: "-xslim" %></div>
- <div class="form--field -wide-label"><%= setting_check_box :lost_password, label: :label_password_lost %></div>
- <% else %>
- <div class="form--field -wide-label">
- <label><b><%= I18n.t :note %>: </b>
- <%=
- url = "https://www.openproject.org/docs/installation-and-operations/configuration/#disable-password-login"
-
- explanation = I18n.t :note_password_login_disabled,
- configuration: "<a target=\"_blank\" href=\"#{url}\"> #{I18n.t('label_configuration')}</a>"
-
- explanation.html_safe
- %>
- </label>
- </div>
- <% end %>
- </fieldset>
-
- <% unless OpenProject::Configuration.disable_password_login? %>
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t("settings.brute_force_prevention") %></legend>
- <div class="form--field -wide-label"><%= setting_text_field :brute_force_block_after_failed_logins, container_class: "-xslim" %>
- <span class="form--field-instructions">
- <%= t(:text_hint_disable_with_0) %>
- </span>
- </div>
- <div class="form--field -wide-label"><%= setting_text_field :brute_force_block_minutes, unit: t(:label_minute_plural), container_class: "-xslim" %></div>
- </fieldset>
- <% end %>
-
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t("settings.session") %></legend>
- <div class="form--field -wide-label"><%= setting_select :autologin,
- ([[t(:label_disabled), 0]] +
- Settings::Definition[:autologin].allowed.collect do |days|
- [t("datetime.distance_in_words.x_days", count: days),
- days.to_s]
- end),
- container_class: "-xslim" %>
- </div>
- <div class="form--field -wide-label"><%= setting_check_box :session_ttl_enabled %></div>
- <div class="form--field -wide-label" id="settings_session_ttl_container" style="display:none;">
- <%= setting_text_field :session_ttl, unit: t(:label_minute_plural), container_class: "-xslim" %>
- <span class="form--field-instructions">
- <%= I18n.t("setting_session_ttl_hint") %>
- </span>
- </div>
- </fieldset>
-
- <fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t("settings.other") %></legend>
- <div class="form--field -wide-label"><%= setting_check_box :log_requesting_user %></div>
-
- <div class="form--field -wide-label">
- <%= setting_text_field :after_first_login_redirect_url, container_class: "-middle" %>
- <span class="form--field-instructions">
- <%= t(:setting_after_first_login_redirect_url_text_html) %>
- </span>
- </div>
- <div class="form--field -wide-label">
- <%= setting_text_field :after_login_default_redirect_url, container_class: "-middle" %>
- <span class="form--field-instructions">
- <%= t(:setting_after_login_default_redirect_url_text_html) %>
- </span>
- </div>
- </fieldset>
- </section>
- <% unless OpenProject::Configuration.disable_password_login? %>
- <div style="float:right;">
- <%= link_to t(:label_ldap_authentication), { controller: "/ldap_auth_sources", action: "index" }, class: "icon icon-server-key" %>
- </div>
- <% end %>
- <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
-<% end %>
+<%=
+ selected_tab = selected_tab(tabs)
+ render partial: "common/tabs", locals: { tabs:, selected_tab:, with_tab_nav: false }
+%>
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb
index 03f3e58d4a4..e1241b4d3ca 100644
--- a/config/constants/settings/definition.rb
+++ b/config/constants/settings/definition.rb
@@ -979,7 +979,8 @@ module Settings
default: nil
},
self_registration: {
- default: 2
+ default: 2,
+ format: :integer
},
sendmail_arguments: {
description: "Arguments to call sendmail with in case it is configured as outgoing email setup",
diff --git a/config/locales/en.yml b/config/locales/en.yml
index e029cc1c5f4..22b2e6d980f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3864,6 +3864,7 @@ en:
This defines what is considered a "day" when displaying duration in days and hours
(for example, if a day is 8 hours, 32 hours would be 4 days).
setting_invitation_expiration_days: "Activation email expires after"
+ setting_invitation_expiration_days_caption: "Number of days after which the activation email expires."
setting_work_package_done_ratio: "Progress calculation mode"
setting_work_package_done_ratio_field: "Work-based"
setting_work_package_done_ratio_field_caption_html: >-
@@ -3883,6 +3884,9 @@ en:
setting_journal_aggregation_time_minutes: "User actions aggregated within"
setting_log_requesting_user: "Log user login, name, and mail address for all requests"
setting_login_required: "Authentication required"
+ setting_login_required_caption: "When checked, all requests to the application have to be authenticated."
+ setting_lost_password: "Enable password reset"
+ setting_lost_password_caption: "When checked, allow users to reset their own passwords."
setting_mail_from: "Emission email address"
setting_mail_handler_api_key: "API key"
setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
@@ -3908,6 +3912,7 @@ en:
setting_project_gantt_query_text: "You can modify the query that is used to display Gantt chart from the project overview page."
setting_security_badge_displayed: "Display security badge"
setting_registration_footer: "Registration footer"
+ setting_registration_footer_caption: "This text is displayed in the footer of the registration page. Use the HTML editor to format the text for each selected language."
setting_repositories_automatic_managed_vendor: "Automatic repository vendor type"
setting_repositories_encodings: "Repositories encodings"
setting_repository_storage_cache_minutes: "Repository disk size cache"
@@ -3951,6 +3956,8 @@ en:
settings:
authentication:
+ login_and_sso: "Login and SSO"
+ registration: "Registration"
single_sign_on: "Single Sign-On"
omniauth_direct_login_hint_html: >
If this option is active, login requests will redirect to the configured omniauth provider.
diff --git a/config/static_links.yml b/config/static_links.yml
index 3b398f6891e..43a91cd09dd 100644
--- a/config/static_links.yml
+++ b/config/static_links.yml
@@ -185,3 +185,5 @@ ical_docs:
href: https://www.openproject.org/docs/user-guide/calendar/#subscribe-to-a-calendar
integrations:
href: https://www.openproject.org/docs/system-admin-guide/integrations/
+disable_password_login:
+ href: https://www.openproject.org/docs/installation-and-operations/configuration/#disable-password-login
diff --git a/frontend/src/app/core/setup/globals/global-listeners/settings.ts b/frontend/src/app/core/setup/globals/global-listeners/settings.ts
index 0c01896dc86..4dac33b2ce0 100644
--- a/frontend/src/app/core/setup/globals/global-listeners/settings.ts
+++ b/frontend/src/app/core/setup/globals/global-listeners/settings.ts
@@ -32,9 +32,10 @@ export function listenToSettingChanges() {
const id:string = self.attr('id') || '';
const settingName = id.replace('lang-for-', '');
const newLang = self.val() as string;
- const textArea = jQuery(`#settings-${settingName}`);
+ const textAreaId = `#settings-${settingName}`;
+ const textArea = jQuery(textAreaId);
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
- const editor = textArea.siblings('opce-ckeditor-augmented-textarea').data('editor');
+ const editor = jQuery(`opce-ckeditor-augmented-textarea[data-textarea-selector='"${textAreaId}"'`).data('editor');
return {
id, settingName, newLang, textArea, editor,
diff --git a/lib/primer/open_project/forms/rich_text_area.html.erb b/lib/primer/open_project/forms/rich_text_area.html.erb
index 385569de4c3..56122d61027 100644
--- a/lib/primer/open_project/forms/rich_text_area.html.erb
+++ b/lib/primer/open_project/forms/rich_text_area.html.erb
@@ -1,11 +1,11 @@
<%= render(FormControl.new(input: @input)) do %>
<%= content_tag(:div, hidden: true) do %>
- <%= builder.text_area(@input.name, **@input.input_arguments) %>
+ <%= builder.text_area(@input.name, **@input.input_arguments, id: @text_area_id) %>
<% end %>
<%= angular_component_tag "opce-ckeditor-augmented-textarea",
inputs: @rich_text_options.reverse_merge(
{
- textareaSelector: "##{builder.field_id(@input.name)}",
+ textareaSelector: "##{@text_area_id}",
macros: false,
turboMode: true
}
diff --git a/lib/primer/open_project/forms/rich_text_area.rb b/lib/primer/open_project/forms/rich_text_area.rb
index 1008a5d1f82..d5f984d7800 100644
--- a/lib/primer/open_project/forms/rich_text_area.rb
+++ b/lib/primer/open_project/forms/rich_text_area.rb
@@ -14,6 +14,7 @@ module Primer
@input = input
@rich_text_data = rich_text_options.delete(:data) { {} }
@rich_text_options = rich_text_options
+ @text_area_id = rich_text_options[:text_area_id] || SecureRandom.alphanumeric(16)
end
end
end
diff --git a/lookbook/docs/patterns/02-forms.md.erb b/lookbook/docs/patterns/02-forms.md.erb
index 42d5f7604d5..15c51564e54 100644
--- a/lookbook/docs/patterns/02-forms.md.erb
+++ b/lookbook/docs/patterns/02-forms.md.erb
@@ -507,7 +507,7 @@ end
It is easier to write and read.
-Under the hood, the form object is decorated with `SettingsFormDecorator`.
+Under the hood, the form object is decorated with `Settings::FormDecorator`.
That's where all the helper methods are defined. There aren't many for now, but
this is intended to grow to support more advanced form features for
administration pages.