From 038bc26571d85562904c9d4345f3872068a7e28f Mon Sep 17 00:00:00 2001 From: Mir Bhatia Date: Tue, 17 Feb 2026 12:25:52 +0100 Subject: [PATCH 1/2] Add dev env user switcher --- .../user_switcher_component.html.erb | 65 +++++++++++++++++++ .../development/user_switcher_component.rb | 56 ++++++++++++++++ .../development/user_switcher_controller.rb | 63 ++++++++++++++++++ config/locales/en/development.yml | 9 +++ config/routes.rb | 7 ++ lib/redmine/menu_manager/top_menu_helper.rb | 7 ++ 6 files changed, 207 insertions(+) create mode 100644 app/components/development/user_switcher_component.html.erb create mode 100644 app/components/development/user_switcher_component.rb create mode 100644 app/controllers/development/user_switcher_controller.rb create mode 100644 config/locales/en/development.yml diff --git a/app/components/development/user_switcher_component.html.erb b/app/components/development/user_switcher_component.html.erb new file mode 100644 index 000000000000..98aa7beef356 --- /dev/null +++ b/app/components/development/user_switcher_component.html.erb @@ -0,0 +1,65 @@ +<%#-- 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. + +++#%> + +<%= + render( + Primer::Alpha::ActionMenu.new( + classes: "op-app-menu--item", + menu_id: "op-dev-user-switcher-menu", + anchor_align: :end + ) + ) do |menu| + menu.with_show_button( + scheme: :invisible, + classes: "op-app-header--primer-button", + test_selector: "op-dev-user-switcher-button", + px: 1 + ) do |button| + button.with_leading_visual_icon(icon: :"person-add") + button.with_tooltip(text: I18n.t("development.user_switcher.tooltip")) + concat content_tag(:span, "DEV", style: "color: #ff6b00; font-weight: bold; margin-right: 4px; font-size: 10px;") + content_tag(:span, current_user_name, class: "hidden-for-mobile") + end + + menu.with_group do |group| + group.with_heading(title: I18n.t("development.user_switcher.active_users")) + + users.each do |user| + group.with_item( + href: development_switch_user_path(user_id: user.id), + label: user.name, + description_scheme: :block, + description: "#{user.login} (#{user.mail})", + active: user.id == User.current.id, + content_arguments: { data: { "turbo-method": "post" } } + ) + end + end + end +%> diff --git a/app/components/development/user_switcher_component.rb b/app/components/development/user_switcher_component.rb new file mode 100644 index 000000000000..c3837d9feb2e --- /dev/null +++ b/app/components/development/user_switcher_component.rb @@ -0,0 +1,56 @@ +# 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. +#++ + +module Development + class UserSwitcherComponent < ApplicationComponent + def render? + Rails.env.development? + end + + def users + return [] unless development_environment? + + @users ||= User.active + .not_builtin + .order(:lastname, :firstname) + .limit(100) + end + + def current_user_name + User.current.logged? ? User.current.name : "Anonymous" + end + + private + + def development_environment? + Rails.env.development? + end + end +end diff --git a/app/controllers/development/user_switcher_controller.rb b/app/controllers/development/user_switcher_controller.rb new file mode 100644 index 000000000000..c22b34e3b6ce --- /dev/null +++ b/app/controllers/development/user_switcher_controller.rb @@ -0,0 +1,63 @@ +# 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. +#++ + +module Development + class UserSwitcherController < ApplicationController + # We need to allow non-admin users to switch back to admin + no_authorization_required! :switch + + before_action :verify_development_mode + + def switch + user = User.find_by(id: params[:user_id]) + + if user&.active? + login_user(user) + flash[:notice] = I18n.t("development.user_switcher.switched", name: user.name) + else + flash[:error] = I18n.t("development.user_switcher.user_not_found") + end + + redirect_back_or_to root_path + end + + private + + def development_mode_enabled? + Rails.env.development? + end + + def verify_development_mode + return if development_mode_enabled? + + render plain: "Development environment required", status: :forbidden + end + end +end diff --git a/config/locales/en/development.yml b/config/locales/en/development.yml new file mode 100644 index 000000000000..af22c4def3d0 --- /dev/null +++ b/config/locales/en/development.yml @@ -0,0 +1,9 @@ +en: + development: + user_switcher: + switched: "Switched to user: %{name}" + user_not_found: "User not found or inactive" + title: "Switch User (Dev)" + tooltip: "Switch User (Dev Only)" + heading: "Switch User (Development)" + active_users: "Active Users" diff --git a/config/routes.rb b/config/routes.rb index 5373a93f1f3a..1cca6decd325 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,6 +47,13 @@ mount API::Mcp => "/mcp" + # Development-only routes - blocked at routing level if not in dev environment + constraints(->(_request) { Rails.env.development? }) do + namespace :development do + match "switch_user", to: "user_switcher#switch", via: %i[get post] + end + end + # Redirect deprecated issue links to new work packages uris get "/issues(/)" => redirect("#{rails_relative_url_root}/work_packages") # The URI.escape doesn't escape / unless you ask it to. diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb index 17a4181c38a2..2a52afc49ec7 100644 --- a/lib/redmine/menu_manager/top_menu_helper.rb +++ b/lib/redmine/menu_manager/top_menu_helper.rb @@ -113,6 +113,7 @@ def render_global_search_input def render_top_menu_right capture do concat render_top_menu_teaser + concat render_dev_user_switcher concat render_quick_add_menu concat render_notification_top_menu_node concat render_help_top_menu_node @@ -120,6 +121,12 @@ def render_top_menu_right end end + def render_dev_user_switcher + return "".html_safe unless Rails.env.development? + + render(Development::UserSwitcherComponent.new) + end + private def render_notification_top_menu_node From 00790702cec93540d23a98b1e7da7abe9508d864 Mon Sep 17 00:00:00 2001 From: Mir Bhatia Date: Fri, 27 Feb 2026 18:06:22 +0100 Subject: [PATCH 2/2] Separate out into new module --- Gemfile.lock | 7 ++ Gemfile.modules | 4 ++ config/routes.rb | 7 -- lib/redmine/menu_manager/top_menu_helper.rb | 7 -- .../component.html.erb | 17 ++--- .../dev_tools_user_switcher/component.rb | 17 ++--- .../dev_tools}/user_switcher_controller.rb | 23 ++----- .../dev_tools/config/locales/en.yml | 6 +- modules/dev_tools/config/routes.rb | 35 ++++++++++ modules/dev_tools/dev_tools.gemspec | 42 ++++++++++++ .../dev_tools/lib/open_project/dev_tools.rb | 64 +++++++++++++++++++ .../lib/open_project/dev_tools/engine.rb | 48 ++++++++++++++ .../dev_tools/hooks/layout_hook.rb | 45 +++++++++++++ .../dev_tools/lib/openproject-dev_tools.rb | 31 +++++++++ 14 files changed, 294 insertions(+), 59 deletions(-) rename app/components/development/user_switcher_component.html.erb => modules/dev_tools/app/components/dev_tools_user_switcher/component.html.erb (71%) rename app/components/development/user_switcher_component.rb => modules/dev_tools/app/components/dev_tools_user_switcher/component.rb (81%) rename {app/controllers/development => modules/dev_tools/app/controllers/dev_tools}/user_switcher_controller.rb (74%) rename config/locales/en/development.yml => modules/dev_tools/config/locales/en.yml (67%) create mode 100644 modules/dev_tools/config/routes.rb create mode 100644 modules/dev_tools/dev_tools.gemspec create mode 100644 modules/dev_tools/lib/open_project/dev_tools.rb create mode 100644 modules/dev_tools/lib/open_project/dev_tools/engine.rb create mode 100644 modules/dev_tools/lib/open_project/dev_tools/hooks/layout_hook.rb create mode 100644 modules/dev_tools/lib/openproject-dev_tools.rb diff --git a/Gemfile.lock b/Gemfile.lock index 54235568b402..417c921e67aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,6 +114,11 @@ PATH specs: costs (1.0.0) +PATH + remote: modules/dev_tools + specs: + openproject-dev_tools (1.0.0) + PATH remote: modules/documents specs: @@ -1653,6 +1658,7 @@ DEPENDENCIES openproject-bim! openproject-boards! openproject-calendar! + openproject-dev_tools! openproject-documents! openproject-gantt! openproject-github_integration! @@ -2031,6 +2037,7 @@ CHECKSUMS openproject-bim (1.0.0) openproject-boards (1.0.0) openproject-calendar (1.0.0) + openproject-dev_tools (1.0.0) openproject-documents (1.0.0) openproject-gantt (1.0.0) openproject-github_integration (1.0.0) diff --git a/Gemfile.modules b/Gemfile.modules index bf1f2f7b5b93..7a8daa7c86c0 100644 --- a/Gemfile.modules +++ b/Gemfile.modules @@ -2,6 +2,10 @@ group :development, :test do gem 'ladle' end +group :development do + gem 'openproject-dev_tools', path: 'modules/dev_tools' +end + gem 'omniauth-openid_connect-providers', git: 'https://github.com/opf/omniauth-openid_connect-providers.git', ref: 'c7e2498a8b093cfc5693d4960cae2e903a5e10cd' diff --git a/config/routes.rb b/config/routes.rb index 1cca6decd325..5373a93f1f3a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,13 +47,6 @@ mount API::Mcp => "/mcp" - # Development-only routes - blocked at routing level if not in dev environment - constraints(->(_request) { Rails.env.development? }) do - namespace :development do - match "switch_user", to: "user_switcher#switch", via: %i[get post] - end - end - # Redirect deprecated issue links to new work packages uris get "/issues(/)" => redirect("#{rails_relative_url_root}/work_packages") # The URI.escape doesn't escape / unless you ask it to. diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb index 2a52afc49ec7..17a4181c38a2 100644 --- a/lib/redmine/menu_manager/top_menu_helper.rb +++ b/lib/redmine/menu_manager/top_menu_helper.rb @@ -113,7 +113,6 @@ def render_global_search_input def render_top_menu_right capture do concat render_top_menu_teaser - concat render_dev_user_switcher concat render_quick_add_menu concat render_notification_top_menu_node concat render_help_top_menu_node @@ -121,12 +120,6 @@ def render_top_menu_right end end - def render_dev_user_switcher - return "".html_safe unless Rails.env.development? - - render(Development::UserSwitcherComponent.new) - end - private def render_notification_top_menu_node diff --git a/app/components/development/user_switcher_component.html.erb b/modules/dev_tools/app/components/dev_tools_user_switcher/component.html.erb similarity index 71% rename from app/components/development/user_switcher_component.html.erb rename to modules/dev_tools/app/components/dev_tools_user_switcher/component.html.erb index 98aa7beef356..bd63271cf33e 100644 --- a/app/components/development/user_switcher_component.html.erb +++ b/modules/dev_tools/app/components/dev_tools_user_switcher/component.html.erb @@ -37,26 +37,21 @@ See COPYRIGHT and LICENSE files for more details. ) do |menu| menu.with_show_button( scheme: :invisible, - classes: "op-app-header--primer-button", - test_selector: "op-dev-user-switcher-button", - px: 1 + classes: "op-app-header--primer-button" ) do |button| button.with_leading_visual_icon(icon: :"person-add") - button.with_tooltip(text: I18n.t("development.user_switcher.tooltip")) - concat content_tag(:span, "DEV", style: "color: #ff6b00; font-weight: bold; margin-right: 4px; font-size: 10px;") - content_tag(:span, current_user_name, class: "hidden-for-mobile") + button.with_tooltip(text: I18n.t("dev_tools.user_switcher.tooltip")) + + current_user_name end menu.with_group do |group| - group.with_heading(title: I18n.t("development.user_switcher.active_users")) + group.with_heading(title: I18n.t("dev_tools.user_switcher.active_users")) users.each do |user| group.with_item( - href: development_switch_user_path(user_id: user.id), + href: dev_tools_switch_user_path(user_id: user.id), label: user.name, - description_scheme: :block, - description: "#{user.login} (#{user.mail})", - active: user.id == User.current.id, content_arguments: { data: { "turbo-method": "post" } } ) end diff --git a/app/components/development/user_switcher_component.rb b/modules/dev_tools/app/components/dev_tools_user_switcher/component.rb similarity index 81% rename from app/components/development/user_switcher_component.rb rename to modules/dev_tools/app/components/dev_tools_user_switcher/component.rb index c3837d9feb2e..38030b1fe510 100644 --- a/app/components/development/user_switcher_component.rb +++ b/modules/dev_tools/app/components/dev_tools_user_switcher/component.rb @@ -28,29 +28,20 @@ # See COPYRIGHT and LICENSE files for more details. #++ -module Development - class UserSwitcherComponent < ApplicationComponent +module DevToolsUserSwitcher + class Component < ApplicationComponent def render? - Rails.env.development? + User.current.logged? end def users - return [] unless development_environment? - @users ||= User.active .not_builtin .order(:lastname, :firstname) - .limit(100) end def current_user_name - User.current.logged? ? User.current.name : "Anonymous" - end - - private - - def development_environment? - Rails.env.development? + User.current.name end end end diff --git a/app/controllers/development/user_switcher_controller.rb b/modules/dev_tools/app/controllers/dev_tools/user_switcher_controller.rb similarity index 74% rename from app/controllers/development/user_switcher_controller.rb rename to modules/dev_tools/app/controllers/dev_tools/user_switcher_controller.rb index c22b34e3b6ce..ae1aaf57d23c 100644 --- a/app/controllers/development/user_switcher_controller.rb +++ b/modules/dev_tools/app/controllers/dev_tools/user_switcher_controller.rb @@ -28,36 +28,23 @@ # See COPYRIGHT and LICENSE files for more details. #++ -module Development +module DevTools class UserSwitcherController < ApplicationController - # We need to allow non-admin users to switch back to admin + # No authorization required - this module only loads in development + # Non-admin users need to be able to switch back to admin no_authorization_required! :switch - before_action :verify_development_mode - def switch user = User.find_by(id: params[:user_id]) if user&.active? login_user(user) - flash[:notice] = I18n.t("development.user_switcher.switched", name: user.name) + flash[:notice] = I18n.t("dev_tools.user_switcher.switched", name: user.name) else - flash[:error] = I18n.t("development.user_switcher.user_not_found") + flash[:error] = I18n.t("dev_tools.user_switcher.user_not_found") end redirect_back_or_to root_path end - - private - - def development_mode_enabled? - Rails.env.development? - end - - def verify_development_mode - return if development_mode_enabled? - - render plain: "Development environment required", status: :forbidden - end end end diff --git a/config/locales/en/development.yml b/modules/dev_tools/config/locales/en.yml similarity index 67% rename from config/locales/en/development.yml rename to modules/dev_tools/config/locales/en.yml index af22c4def3d0..8863a8dff74b 100644 --- a/config/locales/en/development.yml +++ b/modules/dev_tools/config/locales/en.yml @@ -1,9 +1,9 @@ en: - development: + dev_tools: user_switcher: switched: "Switched to user: %{name}" user_not_found: "User not found or inactive" - title: "Switch User (Dev)" + title: "Switch User (Dev Only)" tooltip: "Switch User (Dev Only)" - heading: "Switch User (Development)" + heading: "Switch User (Dev Only)" active_users: "Active Users" diff --git a/modules/dev_tools/config/routes.rb b/modules/dev_tools/config/routes.rb new file mode 100644 index 000000000000..8403a8519642 --- /dev/null +++ b/modules/dev_tools/config/routes.rb @@ -0,0 +1,35 @@ +# 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. +#++ + +OpenProject::Application.routes.draw do + scope module: :dev_tools, path: "dev_tools", as: :dev_tools do + match "switch_user", to: "user_switcher#switch", via: %i[get post] + end +end diff --git a/modules/dev_tools/dev_tools.gemspec b/modules/dev_tools/dev_tools.gemspec new file mode 100644 index 000000000000..b3cb51c65584 --- /dev/null +++ b/modules/dev_tools/dev_tools.gemspec @@ -0,0 +1,42 @@ +# 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. +#++ + +Gem::Specification.new do |s| + s.name = "openproject-dev_tools" + s.version = "1.0.0" + s.authors = "OpenProject GmbH" + s.email = "info@openproject.com" + s.summary = "OpenProject Development Tools" + s.description = "Development only tools for OpenProject (user switcher, custom styles, etc.)" + s.license = "GPL-3.0" + + s.files = Dir["{app,config,lib}/**/*"] + s.metadata["rubygems_mfa_required"] = "true" +end diff --git a/modules/dev_tools/lib/open_project/dev_tools.rb b/modules/dev_tools/lib/open_project/dev_tools.rb new file mode 100644 index 000000000000..a8f896cd8fa0 --- /dev/null +++ b/modules/dev_tools/lib/open_project/dev_tools.rb @@ -0,0 +1,64 @@ +# 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. +#++# 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. +# #++ + +require "open_project/dev_tools/engine" + +module OpenProject + module DevTools + end +end diff --git a/modules/dev_tools/lib/open_project/dev_tools/engine.rb b/modules/dev_tools/lib/open_project/dev_tools/engine.rb new file mode 100644 index 000000000000..5e7d09d6a0fa --- /dev/null +++ b/modules/dev_tools/lib/open_project/dev_tools/engine.rb @@ -0,0 +1,48 @@ +# 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. +#++ + +module OpenProject + module DevTools + class Engine < ::Rails::Engine + engine_name :openproject_dev_tools + + include OpenProject::Plugins::ActsAsOpEngine + + register "openproject-dev_tools", + author_url: "https://www.openproject.org", + bundled: true, + name: "OpenProject Dev Tools" + + config.to_prepare do + OpenProject::DevTools::Hooks::LayoutHook + end + end + end +end diff --git a/modules/dev_tools/lib/open_project/dev_tools/hooks/layout_hook.rb b/modules/dev_tools/lib/open_project/dev_tools/hooks/layout_hook.rb new file mode 100644 index 000000000000..e12900c5cd80 --- /dev/null +++ b/modules/dev_tools/lib/open_project/dev_tools/hooks/layout_hook.rb @@ -0,0 +1,45 @@ +# 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. +#++ + +module OpenProject + module DevTools + module Hooks + class LayoutHook < OpenProject::Hook::ViewListener + def view_layouts_base_top_menu(context = {}) + context[:controller].send( + :render_to_string, + DevToolsUserSwitcher::Component.new, + layout: false + ) + end + end + end + end +end diff --git a/modules/dev_tools/lib/openproject-dev_tools.rb b/modules/dev_tools/lib/openproject-dev_tools.rb new file mode 100644 index 000000000000..71b7c9e2732c --- /dev/null +++ b/modules/dev_tools/lib/openproject-dev_tools.rb @@ -0,0 +1,31 @@ +# 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. +#++ + +require "open_project/dev_tools"