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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Primerize the MySettings form and split it into a separate menu entry
Henriette Dargec52571c10f8d
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rbindex 1b754937f77..e0ee2cf9bca 100644--- a/app/controllers/my_controller.rb+++ b/app/controllers/my_controller.rb@@ -45,6 +45,7 @@ class MyController < ApplicationControllerno_authorization_required! :account,:update_account,:settings,+ :interface,:update_settings,:password,:change_password,@@ -60,6 +61,7 @@ class MyController < ApplicationControllermenu_item :account, only: [:account]menu_item :settings, only: [:settings]+ menu_item :interface, only: [:interface]menu_item :password, only: [:password]menu_item :access_token, only: [:access_token]menu_item :notifications, only: [:notifications]@@ -77,6 +79,8 @@ class MyController < ApplicationControllerwrite_settingsend+ def interface; end+# Manage user's passworddef password@username = @user.logindiff --git a/app/forms/my/alerts_form.rb b/app/forms/my/alerts_form.rbnew file mode 100644index 00000000000..b5297d8a9a3--- /dev/null+++ b/app/forms/my/alerts_form.rb@@ -0,0 +1,41 @@+# frozen_string_literal: true++#-- 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.+#++++class My::AlertsForm < ApplicationForm+ form do |f|+ f.check_box name: :warn_on_leaving_unsaved,+ label: I18n.t("activerecord.attributes.user_preference.warn_on_leaving_unsaved")++ f.check_box name: :auto_hide_popups,+ label: I18n.t("activerecord.attributes.user_preference.auto_hide_popups")++ f.submit(name: :submit, label: I18n.t("activerecord.attributes.user_preference.button_update_alerts"), scheme: :default)+ end+enddiff --git a/app/forms/my/look_and_feel_form.rb b/app/forms/my/look_and_feel_form.rbnew file mode 100644index 00000000000..6fcd045a81c--- /dev/null+++ b/app/forms/my/look_and_feel_form.rb@@ -0,0 +1,69 @@+# frozen_string_literal: true++#-- 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.+#++++class My::LookAndFeelForm < ApplicationForm+ include ApplicationHelper+ form do |f|+ f.select_list(+ name: :theme,+ label: I18n.t("activerecord.attributes.user_preference.theme"),+ caption: I18n.t("activerecord.attributes.user_preference.mode_guideline"),+ required: true,+ include_blank: false,+ input_width: :small+ ) do |select|+ theme_options_for_select.each do |theme|+ select.option(+ value: theme[1],+ label: theme[0]+ )+ end+ end++ f.select_list(+ name: :comments_sorting,+ label: I18n.t("activerecord.attributes.user_preference.comments_sorting"),+ required: true,+ include_blank: false,+ input_width: :small+ ) do |select|+ comment_sort_order_options.each do |theme|+ select.option(+ value: theme[1],+ label: theme[0]+ )+ end+ end++ f.submit(name: :submit,+ label: I18n.t("activerecord.attributes.user_preference.button_update_look_and_feel"),+ scheme: :default)+ end+enddiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 8146e13e3b0..38f86560e68 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -286,12 +286,17 @@ module ApplicationHelperdef theme_options_for_select[- [t("themes.light"), "light"],- [t("themes.light_high_contrast"), "light_high_contrast"],- [t("themes.dark"), "dark"]+ [I18n.t("themes.light"), "light"],+ [I18n.t("themes.light_high_contrast"), "light_high_contrast"],+ [I18n.t("themes.dark"), "dark"]]end+ def comment_sort_order_options+ [[I18n.t("activities.work_packages.activity_tab.label_sort_asc"), "asc"],+ [I18n.t("activities.work_packages.activity_tab.label_sort_desc"), "desc"]]+ end+def body_data_attributes(local_assigns){controller: "application hover-card-trigger",diff --git a/app/views/my/interface.html.erb b/app/views/my/interface.html.erbnew file mode 100644index 00000000000..cb48a7ea917--- /dev/null+++ b/app/views/my/interface.html.erb@@ -0,0 +1,66 @@+<%#-- 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.++++#%>++<% html_title(t(:label_my_account), t(:label_interface)) %>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { t(:label_interface) }+ header.with_breadcrumbs(+ [{ href: my_account_path, text: t(:label_my_account) },+ t(:label_interface)]+ )+ end+%>++<%= error_messages_for "user" %>++<%=+ render(Primer::Beta::Subhead.new) do |component|+ component.with_heading(tag: :h3, size: :medium) { I18n.t("activerecord.attributes.user_preference.header_look_and_feel") }+ end+%>+<%=+ settings_primer_form_with(model: @user.pref, scope: :pref, url: { action: "update_settings" }) do |form|+ render(My::LookAndFeelForm.new(form))+ end+%>++<%=+ render(Primer::Beta::Subhead.new(mt: 3)) do |component|+ component.with_heading(tag: :h3, size: :medium) { I18n.t("activerecord.attributes.user_preference.header_alerts") }+ end+%>+<%=+ settings_primer_form_with(model: @user.pref, scope: :pref, url: { action: "update_settings" }) do |form|+ render(My::AlertsForm.new(form))+ end+%>++<%= call_hook(:view_my_settings, user: @user) %>diff --git a/app/views/my/settings.html.erb b/app/views/my/settings.html.erbindex 4ec9fffcbcb..b8badde19c2 100644--- a/app/views/my/settings.html.erb+++ b/app/views/my/settings.html.erb@@ -44,9 +44,15 @@ See COPYRIGHT and LICENSE files for more details.lang: current_language,html: { id: "my_account_form", class: "form -wide-labels" } do |f| %><fieldset class="form--fieldset">- <div class="form--field"><%= f.select :language, lang_options_for_select, container_class: "-middle" %></div>- <%= render partial: "users/preferences", locals: { input_size: :middle } %>+ <div class="form--field">+ <%= f.select :language, lang_options_for_select, container_class: "-middle" %>+ </div>+ <%= render Settings::TimeZoneSettingComponent.new(+ "time_zone",+ form: f,+ include_blank: false,+ container_class: "-middle"+ ) %></fieldset>- <%= call_hook(:view_my_settings, user: @user, form: f) %><%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %><% end %>diff --git a/app/views/users/_preferences.html.erb b/app/views/users/_preferences.html.erbindex d99ee25d5a1..cdd2bda69d3 100644--- a/app/views/users/_preferences.html.erb+++ b/app/views/users/_preferences.html.erb@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.container_class: defined?(input_size) ? "-#{input_size}" : "-wide") %><div class="form--field">- <%= pref_fields.select :theme, theme_options_for_select, container_class: "-middle" %>+ <%= pref_fields.select :theme, theme_options_for_select, container_class: "-middle" %> <!-- TODO --><div class="form--field-instructions"><%= I18n.t("activerecord.attributes.user_preference.mode_guideline") %></div>diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 17520582cd2..d279530dc75 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -203,6 +203,10 @@ Redmine::MenuManager.map :my_menu do |menu|{ controller: "/my", action: "settings" },caption: :label_setting_plural,icon: "gear"+ menu.push :interface,+ { controller: "/my", action: "interface" },+ caption: :label_interface,+ icon: "device-desktop"menu.push :password,{ controller: "/my", action: "password" },caption: :button_change_password,diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 414e8fdf61d..d535d9c1707 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1170,14 +1170,18 @@ en:password_confirmation: "Confirmation"consented_at: "Consented at"user_preference:- comments_sorting: "Display comments"+ header_look_and_feel: "Look and feel"+ header_alerts: "Alerts"+ button_update_look_and_feel: "Update look and feel"+ button_update_alerts: "Update alerts"+ comments_sorting: "Display work package activity sorted by"dismissed_enterprise_banners: "Hidden enterprise banners"impaired: "Accessibility mode"auto_hide_popups: "Auto-hide success notifications"warn_on_leaving_unsaved: "Warn me when leaving a work package with unsaved changes"- theme: "Mode"+ theme: "Colour mode"time_zone: "Time zone"- mode_guideline: "Some modes will overwrite custom theme colours for accessibility and legibility. For the full custom theme, please select Light mode."+ mode_guideline: "Some modes will overwrite custom theme colours for accessibility and legibility. Please select Light mode for full custom theme support."daily_reminders: "Daily reminders"workdays: "Working days"version:@@ -2870,6 +2874,7 @@ en:label_information_plural: "Information"label_installation_guides: "Installation guides"label_integer: "Integer"+ label_interface: "Interface"label_internal: "Internal"label_introduction_video: "Introduction video"label_invite_user: "Invite user"diff --git a/config/routes.rb b/config/routes.rbindex 29fc8a80261..27592351702 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -838,6 +838,7 @@ Rails.application.routes.draw doget "/my/account", action: "account"get "/my/settings", action: "settings"+ get "/my/interface", action: "interface"get "/my/notifications", action: "notifications"get "/my/reminders", action: "reminders"diff --git a/modules/backlogs/app/forms/my/backlogs_form.rb b/modules/backlogs/app/forms/my/backlogs_form.rbnew file mode 100644index 00000000000..9d3c28280b8--- /dev/null+++ b/modules/backlogs/app/forms/my/backlogs_form.rb@@ -0,0 +1,60 @@+# frozen_string_literal: true++#-- 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.+#++++class My::BacklogsForm < ApplicationForm+ form do |f|+ f.text_field name: :"backlogs[task_color]",+ label: I18n.t("backlogs.task_color"),+ value: @color,+ input_width: :xsmall++ f.check_box name: :"backlogs[versions_default_fold_state]",+ value: DEFAULT_FOLD_STATE,+ checked: default_fold_state_checked?,+ label: I18n.t("backlogs.label_versions_default_fold_state"),+ caption: I18n.t("backlogs.caption_versions_default_fold_state")++ f.submit(name: :submit, label: I18n.t("backlogs.user_preference.button_update_backlogs"), scheme: :default)+ end++ DEFAULT_FOLD_STATE = "closed"++ def initialize(color:, versions_default_fold_state:)+ super()+ @color = color+ @versions_default_fold_state = versions_default_fold_state+ end++ private++ def default_fold_state_checked?+ @versions_default_fold_state == DEFAULT_FOLD_STATE+ end+enddiff --git a/modules/backlogs/app/views/shared/_view_my_settings.html.erb b/modules/backlogs/app/views/shared/_view_my_settings.html.erbindex bead3d8e840..eccefde6806 100644--- a/modules/backlogs/app/views/shared/_view_my_settings.html.erb+++ b/modules/backlogs/app/views/shared/_view_my_settings.html.erb@@ -27,14 +27,13 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%= t(:label_backlogs) %></legend>- <div class="form--field">- <%= styled_label_tag :backlogs_task_color, t(:"backlogs.task_color") %>- <%= styled_text_field_tag :"backlogs[task_color]", color, container_class: "-middle" %>- </div>- <div class="form--field">- <%= styled_label_tag :backlogs_versions_default_fold_state, I18n.t("backlogs.label_versions_default_fold_state") %>- <%= styled_check_box_tag :"backlogs[versions_default_fold_state]", "closed", versions_default_fold_state == "closed" %>- </div>-</fieldset>+<%=+ render(Primer::Beta::Subhead.new(mt: 3)) do |component|+ component.with_heading(tag: :h3, size: :medium) { I18n.t("backlogs.user_preference.header_backlogs") }+ end+%>+<%=+ settings_primer_form_with(model: user.pref, scope: :pref, url: { action: "update_settings" }) do |form|+ render(My::BacklogsForm.new(form, color:, versions_default_fold_state:))+ end+%>diff --git a/modules/backlogs/config/locales/en.yml b/modules/backlogs/config/locales/en.ymlindex 44c6e5af7ae..dd1e4303f5e 100644--- a/modules/backlogs/config/locales/en.yml+++ b/modules/backlogs/config/locales/en.yml@@ -66,6 +66,7 @@ en:hours: "Hours"impediment: "Impediment"label_versions_default_fold_state: "Show versions folded"+ caption_versions_default_fold_state: "Versions will not be expanded by default when viewing backlogs. Each one has to be manually expanded."work_package_is_closed: "Work package is done, when"label_is_done_status: "Status %{status_name} means done"no_burndown_data: "No burndown data available. It is necessary to have the sprint start- and end dates set."@@ -84,6 +85,9 @@ en:task: "Task"task_color: "Task color"unassigned: "Unassigned"+ user_preference:+ header_backlogs: "Backlogs module"+ button_update_backlogs: "Update backlogs module"x_more: "%{count} more..."backlogs_active: "active"diff --git a/spec/routing/my_spec.rb b/spec/routing/my_spec.rbindex 33dce8f9247..e7fcb49661b 100644--- a/spec/routing/my_spec.rb+++ b/spec/routing/my_spec.rb@@ -47,6 +47,10 @@ RSpec.describe "my routes" doexpect(patch("/my/settings")).to route_to("my#update_settings")end+ it "/my/interface GET routes to my#interface" do+ expect(get("/my/interface")).to route_to("my#interface")+ end+it "/my/notifications GET routes to my#notifications" doexpect(get("/my/notifications")).to route_to("my#notifications")end