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
Add my page menu to global and redirect to root
Oliver Günthere3333a96f4c1
diff --git a/app/controllers/concerns/accounts/redirect_after_login.rb b/app/controllers/concerns/accounts/redirect_after_login.rbindex 02a2244903c..6cd5f19f51d 100644--- a/app/controllers/concerns/accounts/redirect_after_login.rb+++ b/app/controllers/concerns/accounts/redirect_after_login.rb@@ -43,15 +43,15 @@ module Accounts::RedirectAfterLoginenddef default_redirect- if (url = OpenProject::Configuration.after_login_default_redirect_url)+ if (url = Setting.after_login_default_redirect_url)redirect_back_or_default urlelse- redirect_back_or_default my_page_path+ redirect_back_or_default home_pathendenddef first_login_redirect- if (url = OpenProject::Configuration.after_first_login_redirect_url)+ if (url = Setting.after_first_login_redirect_url)redirect_back_or_default urlelseredirect_back_or_default home_url(first_time_user: true)diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rbindex a266f667f58..3078b2d7452 100644--- a/config/constants/settings/definition.rb+++ b/config/constants/settings/definition.rb@@ -40,7 +40,7 @@ module Settingsdefault: nil},after_login_default_redirect_url: {- description: "Override URL to which logged in users are redirected instead of the My page",+ description: "Override URL to which logged in users are redirected instead of the Home page",format: :string,default: nil},diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 355c4285192..75f81b84672 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -106,7 +106,7 @@ Redmine::MenuManager.map :account_menu do |menu|partial: "/my/timer/menu"menu.push :my_page,:my_page_path,- caption: I18n.t("js.my_page.label"),+ caption: I18n.t("my_page.label"),if: ->(_) { User.current.logged? }menu.push :my_profile,{ controller: "/users", action: "show", id: "me" },@@ -132,12 +132,17 @@ Redmine::MenuManager.map :global_menu do |menu|icon: "home",first: true+ menu.push :my_page,+ { controller: "/my/page", action: "show" },+ after: :home,+ icon: "person"+# Projectsmenu.push :projects,{ controller: "/projects", project_id: nil, action: "index" },caption: I18n.t("label_projects_menu"),icon: "project",- after: :home,+ after: :my_page,if: ->(_) {User.current.logged? || !Setting.login_required?}diff --git a/docs/installation-and-operations/configuration/README.md b/docs/installation-and-operations/configuration/README.mdindex f75a03f10f2..eaee130bc9e 100644--- a/docs/installation-and-operations/configuration/README.md+++ b/docs/installation-and-operations/configuration/README.md@@ -701,6 +701,18 @@ OPENPROJECT_SECURITY__BADGE__DISPLAYED="false"`rails_asset_host`: A custom host to use to serve static assets such as javascript, CSS, images, etc. (default: `nil`)+### Redirect after login++`after_login_default_redirect_url`: Starting in OpenProject 15.4., users are redirected to the home page after logging in. To customize this behavior (e.g., redirecting them to the My page as before), you can override this with a path.++Example:++```bash+OPENPROJECT_AFTER__LOGIN__DEFAULT__REDIRECT__URL="/my/page"+```+++### Onboarding video url`onboarding_video_url`: An URL for the video displayed on the onboarding modal. This is only shown when the user logs in for the first time.diff --git a/frontend/src/app/features/my-page/my-page.component.ts b/frontend/src/app/features/my-page/my-page.component.tsindex 20ab7115376..a000b05a27a 100644--- a/frontend/src/app/features/my-page/my-page.component.ts+++ b/frontend/src/app/features/my-page/my-page.component.ts@@ -9,6 +9,8 @@ import { GridPageComponent } from 'core-app/shared/components/grids/grid/page/grencapsulation: ViewEncapsulation.None,})export class MyPageComponent extends GridPageComponent {+ showToolbar = false;+protected i18nNamespace():string {return 'my_page';}diff --git a/modules/my_page/app/controllers/my/page_controller.rb b/modules/my_page/app/controllers/my/page_controller.rbnew file mode 100644index 00000000000..ae831523b4e--- /dev/null+++ b/modules/my_page/app/controllers/my/page_controller.rb@@ -0,0 +1,51 @@+# 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 My+ class PageController < ApplicationController+ before_action :require_login+ no_authorization_required! :show++ current_menu_item [:show] do+ :my_page+ end++ def show+ respond_to do |format|+ format.html do+ render locals: { menu_name: :global_menu }+ end+ end+ end++ def default_breadcrumb+ t("js.my_page.label")+ end+ end+enddiff --git a/modules/my_page/app/views/my/page/show.html.erb b/modules/my_page/app/views/my/page/show.html.erbnew file mode 100644index 00000000000..3eb27c87c3d--- /dev/null+++ b/modules/my_page/app/views/my/page/show.html.erb@@ -0,0 +1,15 @@+<% html_title(t("my_page.label")) -%>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { t("my_page.label") }+ header.with_breadcrumbs(+ [+ { href: home_path, text: organization_name },+ t("my_page.label")+ ]+ )+ end+%>++<openproject-base></openproject-base>diff --git a/modules/my_page/config/locales/en.yml b/modules/my_page/config/locales/en.ymlnew file mode 100644index 00000000000..6dd425b098b--- /dev/null+++ b/modules/my_page/config/locales/en.yml@@ -0,0 +1,3 @@+en:+ my_page:+ label: "My page"diff --git a/modules/my_page/config/locales/js-en.yml b/modules/my_page/config/locales/js-en.ymldeleted file mode 100644index 5caa23ecd39..00000000000--- a/modules/my_page/config/locales/js-en.yml+++ /dev/null@@ -1,4 +0,0 @@-en:- js:- my_page:- label: "My page"diff --git a/modules/my_page/config/routes.rb b/modules/my_page/config/routes.rbindex fc4bbb9039b..b1f58c7a575 100644--- a/modules/my_page/config/routes.rb+++ b/modules/my_page/config/routes.rb@@ -27,5 +27,7 @@#++Rails.application.routes.draw do- get "/my/page", to: "angular#empty_layout"+ namespace :my do+ get "/page", to: "page#show"+ endenddiff --git a/modules/my_page/spec/features/my/my_page_navigation_spec.rb b/modules/my_page/spec/features/my/my_page_navigation_spec.rbnew file mode 100644index 00000000000..293d69afa21--- /dev/null+++ b/modules/my_page/spec/features/my/my_page_navigation_spec.rb@@ -0,0 +1,50 @@+# 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 "spec_helper"++require_relative "../../support/pages/my/page"++RSpec.describe "My page navigation" do+ shared_let(:user) { create(:user) }++ before do+ login_as user+ end++ it "navigates from global menu to my page" do+ visit home_path++ find("#main-menu #{test_selector('op-menu--item-action')}", text: "My page").click++ expect(page).to have_current_path "/my/page"+ expect(page).to have_css("h1", text: "My page")+ expect(page).to have_css("#main-menu #{test_selector('op-menu--item-action')}.selected")+ end+enddiff --git a/modules/openid_connect/spec/requests/openid_connect_spec.rb b/modules/openid_connect/spec/requests/openid_connect_spec.rbindex 4d464896378..bace9261cba 100644--- a/modules/openid_connect/spec/requests/openid_connect_spec.rb+++ b/modules/openid_connect/spec/requests/openid_connect_spec.rb@@ -137,7 +137,7 @@ RSpec.describe "OpenID Connect", :skip_2fa_stage, # Prevent redirects to 2FA staredirect_from_provider("keycloak")expect(response).to have_http_status :found- expect(response.location).to match /\/my\/page/+ expect(response.location).to eq "http://#{Setting.host_name}/"endenddiff --git a/modules/two_factor_authentication/spec/features/password_change_spec.rb b/modules/two_factor_authentication/spec/features/password_change_spec.rbindex ab911133082..877fdec02cd 100644--- a/modules/two_factor_authentication/spec/features/password_change_spec.rb+++ b/modules/two_factor_authentication/spec/features/password_change_spec.rb@@ -13,7 +13,7 @@ RSpec.describe "Password change with OTP", :js, with_settings: {password: user_password,password_confirmation: user_password)end- let(:expected_path_after_login) { my_page_path }+ let(:expected_path_after_login) { home_path }def handle_password_change(requires_otp: true)visit signin_pathdiff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rbindex 8cee30868d7..4e0ed73ea87 100644--- a/spec/controllers/account_controller_spec.rb+++ b/spec/controllers/account_controller_spec.rb@@ -80,7 +80,7 @@ RSpec.describe AccountController, :skip_2fa_stage doit "redirects to home" doexpect(response)- .to redirect_to my_page_path+ .to redirect_to home_pathendcontext "and a valid back url is present" do@@ -96,7 +96,7 @@ RSpec.describe AccountController, :skip_2fa_stage dolet(:params) { { back_url: "http://test.foo/work_packages/show/1" } }it "redirects to home" do- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendendend@@ -114,7 +114,7 @@ RSpec.describe AccountController, :skip_2fa_stage doit "allows to post to login" dopost :login, params: { username: admin.login, password: "adminADMIN!" }- expect(response).to redirect_to "/my/page"+ expect(response).to redirect_to home_pathendend@@ -161,8 +161,14 @@ RSpec.describe AccountController, :skip_2fa_stage dopost :login, params: { username: admin.login, password: "adminADMIN!" }end- it "redirect to the my page" do- expect(response).to redirect_to "/my/page"+ it "redirect to the home page" do+ expect(response).to redirect_to home_path+ end++ context "with login redirect set", with_settings: { after_login_default_redirect_url: "/my/page" } do+ it "redirect to the my page" do+ expect(response).to redirect_to my_page_path+ endendit "does not call the user_first_login hook" do@@ -195,7 +201,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "http://test.foo/work_packages/show/1"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "does not redirect to another host with a protocol relative url" do@@ -205,7 +211,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "//test.foo/fake"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "does not redirect to logout" do@@ -215,7 +221,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "/logout"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendcontext "with a relative url root" do@@ -254,7 +260,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "http://test.host/foo/work_packages/show/1"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "does not redirect to another subdirectory with a relative path" do@@ -264,7 +270,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "/foo/work_packages/show/1"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "does not redirect to another subdirectory by going up the path hierarchy" do@@ -274,7 +280,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "http://test.host/openproject/../foo/work_packages/show/1"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "does not redirect to another subdirectory with a protocol relative path" do@@ -284,7 +290,7 @@ RSpec.describe AccountController, :skip_2fa_stage dopassword: "adminADMIN!",back_url: "//test.host/foo/work_packages/show/1"}- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendendend@@ -429,7 +435,7 @@ RSpec.describe AccountController, :skip_2fa_stage doit "allows to login internally still" dopost :login, params: { username: admin.login, password: "adminADMIN!" }- expect(response).to redirect_to "/my/page"+ expect(response).to redirect_to home_pathendendenddiff --git a/spec/controllers/omni_auth_login_controller_spec.rb b/spec/controllers/omni_auth_login_controller_spec.rbindex c894b27c17e..0b070380dc1 100644--- a/spec/controllers/omni_auth_login_controller_spec.rb+++ b/spec/controllers/omni_auth_login_controller_spec.rb@@ -224,7 +224,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage doit "signs in the user after successful external authentication" dopost :callback, params: { provider: :google }- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathendit "logs a successful login" do@@ -252,8 +252,8 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage dopost :callback, params: { provider: :google }end- it "redirects to that url", :aggregate_failures do- expect(response).to redirect_to "/my/page"+ it "redirects to the default one" do+ expect(response).to redirect_to home_pathendend@@ -273,7 +273,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage doexpect { post :callback, params: { provider: :google } }.not_to change { user.reload.firstname }- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathexpect(user.lastname).to eq "newLastname"end@@ -326,7 +326,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage doit "logs in the user" dopost :callback, params: { provider: :google }- expect(response).to redirect_to my_page_path+ expect(response).to redirect_to home_pathexpect(OpenProject::OmniAuth::Authorization).to have_received(:after_login!).with(user, omniauth_hash, any_args)enddiff --git a/spec/features/auth/auth_source_sso_login_spec.rb b/spec/features/auth/auth_source_sso_login_spec.rbindex 88a9a687c7a..9e3e1d5cf51 100644--- a/spec/features/auth/auth_source_sso_login_spec.rb+++ b/spec/features/auth/auth_source_sso_login_spec.rb@@ -56,10 +56,8 @@ RSpec.describe "Login with auth source SSO" dologin_with(user.login, user_password)# on the my page- expect(page)- .to have_current_path my_page_path+ expect(page).to have_current_path home_path- expect(page)- .to have_css("a[title='#{user.name}']")+ expect(page).to have_css("a[title='#{user.name}']")endenddiff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rbindex 605dffdbf66..f83eb7fdfe8 100644--- a/spec/features/auth/auth_stages_spec.rb+++ b/spec/features/auth/auth_stages_spec.rb@@ -139,7 +139,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do# after the stage is finished it must redirect to the complete endpointvisit "/login/dummy_step/success"- expect(current_path).to eql "/my/page" # after which the user will actually be logged in+ expect(page).to have_current_path(home_path) # after which the user will actually be logged invisit "/my/account"@@ -241,7 +241,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do# after the stage is finished it must redirect to the complete endpointvisit "/login/two_step/success"- expect(current_path).to eql "/my/page" # after which the user will actually be logged in+ expect(page).to have_current_path(home_path) # after which the user will actually be logged invisit "/my/account"diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rbindex b61cdb69bbc..5088f6d0e94 100644--- a/spec/features/auth/consent_auth_stage_spec.rb+++ b/spec/features/auth/consent_auth_stage_spec.rb@@ -47,7 +47,7 @@ RSpec.describe "Authentication Stages" do)end- def expect_logged_in(path = my_page_path)+ def expect_logged_in(path = home_path)expect(page).to have_current_path(path)visit my_account_pathwait_for_network_idlediff --git a/spec/features/auth/login_spec.rb b/spec/features/auth/login_spec.rbindex 7cc2e77de8d..02d17ccd71e 100644--- a/spec/features/auth/login_spec.rb+++ b/spec/features/auth/login_spec.rb@@ -70,9 +70,9 @@ RSpec.describe "Login" do# first loginlogin_with(" #{user.login} ", user_password)- # on the my page+ # on the home pathexpect(page)- .to have_current_path my_page_path+ .to have_current_path home_pathendend@@ -126,7 +126,7 @@ RSpec.describe "Login" dologin_with(user.login, user_password)expect(page)- .to have_current_path my_page_path+ .to have_current_path home_pathendcontext "autologin",diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rbindex 0928f5ba77e..8859a07bb01 100644--- a/spec/features/auth/lost_password_spec.rb+++ b/spec/features/auth/lost_password_spec.rb@@ -65,7 +65,7 @@ RSpec.describe "Lost password" dologin_with user.login, new_passwordexpect(page)- .to have_current_path(my_page_path)+ .to have_current_path(home_path)endcontext "when user has an auth source" dodiff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rbindex fff0dc28c5b..c1c43d0e872 100644--- a/spec/features/auth/omniauth_spec.rb+++ b/spec/features/auth/omniauth_spec.rb@@ -73,7 +73,7 @@ RSpec.describe "Omniauth authentication" dofill_in("email", with: user.mail)click_link_or_button "Sign In"- expect(current_url).to eql my_page_url+ expect(current_url).to eql home_urlendit "signs in user" do@@ -128,7 +128,7 @@ RSpec.describe "Omniauth authentication" dofill_in("email", with: user.mail)click_link_or_button "Sign In"- expect(current_url).to eq my_page_url+ expect(current_url).to eq home_urlendend@@ -214,7 +214,7 @@ RSpec.describe "Omniauth authentication" doclick_link_or_button "Sign In"- expect(page).to have_current_path my_page_path+ expect(page).to have_current_path home_pathendenddiff --git a/spec/features/users/brute_force_spec.rb b/spec/features/users/brute_force_spec.rbindex afd897f2bbd..08db3381edf 100644--- a/spec/features/users/brute_force_spec.rb+++ b/spec/features/users/brute_force_spec.rb@@ -89,7 +89,7 @@ RSpec.describe "Loggin (with brute force protection)" donew_login_attempt(login, password)expect(page)- .to have_current_path my_page_path+ .to have_current_path home_path# resets the failed login countexpect(User.where(id: user.id).pluck(:failed_login_count).first)@@ -111,6 +111,6 @@ RSpec.describe "Loggin (with brute force protection)" donew_login_attempt(login, password)expect(page)- .to have_current_path my_page_path+ .to have_current_path home_pathendenddiff --git a/spec/features/work_packages/share/share_account_activation_spec.rb b/spec/features/work_packages/share/share_account_activation_spec.rbindex 33fc571e1bf..72a65169e68 100644--- a/spec/features/work_packages/share/share_account_activation_spec.rb+++ b/spec/features/work_packages/share/share_account_activation_spec.rb@@ -57,7 +57,7 @@ RSpec.describe "Work package sharing invited users",it "allows to invite and activate the account" dologin_with(editor.login, "adminADMIN!")- expect(page).to have_current_path "/my/page"+ expect(page).to have_current_path home_pathwork_package_page.visit!work_package_page.click_share_button