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

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.rb
index 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::RedirectAfterLogin
end
def default_redirect
- if (url = OpenProject::Configuration.after_login_default_redirect_url)
+ if (url = Setting.after_login_default_redirect_url)
redirect_back_or_default url
else
- redirect_back_or_default my_page_path
+ redirect_back_or_default home_path
end
end
def first_login_redirect
- if (url = OpenProject::Configuration.after_first_login_redirect_url)
+ if (url = Setting.after_first_login_redirect_url)
redirect_back_or_default url
else
redirect_back_or_default home_url(first_time_user: true)
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb
index a266f667f58..3078b2d7452 100644
--- a/config/constants/settings/definition.rb
+++ b/config/constants/settings/definition.rb
@@ -40,7 +40,7 @@ module Settings
default: 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.rb
index 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"
+
# Projects
menu.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.md
index 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.ts
index 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/gr
encapsulation: 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.rb
new file mode 100644
index 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
+end
diff --git a/modules/my_page/app/views/my/page/show.html.erb b/modules/my_page/app/views/my/page/show.html.erb
new file mode 100644
index 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.yml
new file mode 100644
index 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.yml
deleted file mode 100644
index 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.rb
index 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"
+ end
end
diff --git a/modules/my_page/spec/features/my/my_page_navigation_spec.rb b/modules/my_page/spec/features/my/my_page_navigation_spec.rb
new file mode 100644
index 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
+end
diff --git a/modules/openid_connect/spec/requests/openid_connect_spec.rb b/modules/openid_connect/spec/requests/openid_connect_spec.rb
index 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 sta
redirect_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}/"
end
end
diff --git a/modules/two_factor_authentication/spec/features/password_change_spec.rb b/modules/two_factor_authentication/spec/features/password_change_spec.rb
index 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_path
diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb
index 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 do
it "redirects to home" do
expect(response)
- .to redirect_to my_page_path
+ .to redirect_to home_path
end
context "and a valid back url is present" do
@@ -96,7 +96,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
let(: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_path
end
end
end
@@ -114,7 +114,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
it "allows to post to login" do
post :login, params: { username: admin.login, password: "adminADMIN!" }
- expect(response).to redirect_to "/my/page"
+ expect(response).to redirect_to home_path
end
end
@@ -161,8 +161,14 @@ RSpec.describe AccountController, :skip_2fa_stage do
post :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
+ end
end
it "does not call the user_first_login hook" do
@@ -195,7 +201,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "adminADMIN!",
back_url: "http://test.foo/work_packages/show/1"
}
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
it "does not redirect to another host with a protocol relative url" do
@@ -205,7 +211,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "adminADMIN!",
back_url: "//test.foo/fake"
}
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
it "does not redirect to logout" do
@@ -215,7 +221,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "adminADMIN!",
back_url: "/logout"
}
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
context "with a relative url root" do
@@ -254,7 +260,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "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_path
end
it "does not redirect to another subdirectory with a relative path" do
@@ -264,7 +270,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "adminADMIN!",
back_url: "/foo/work_packages/show/1"
}
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
it "does not redirect to another subdirectory by going up the path hierarchy" do
@@ -274,7 +280,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "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_path
end
it "does not redirect to another subdirectory with a protocol relative path" do
@@ -284,7 +290,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
password: "adminADMIN!",
back_url: "//test.host/foo/work_packages/show/1"
}
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
end
end
@@ -429,7 +435,7 @@ RSpec.describe AccountController, :skip_2fa_stage do
it "allows to login internally still" do
post :login, params: { username: admin.login, password: "adminADMIN!" }
- expect(response).to redirect_to "/my/page"
+ expect(response).to redirect_to home_path
end
end
end
diff --git a/spec/controllers/omni_auth_login_controller_spec.rb b/spec/controllers/omni_auth_login_controller_spec.rb
index 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 do
it "signs in the user after successful external authentication" do
post :callback, params: { provider: :google }
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
end
it "logs a successful login" do
@@ -252,8 +252,8 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do
post :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_path
end
end
@@ -273,7 +273,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do
expect { 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_path
expect(user.lastname).to eq "newLastname"
end
@@ -326,7 +326,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do
it "logs in the user" do
post :callback, params: { provider: :google }
- expect(response).to redirect_to my_page_path
+ expect(response).to redirect_to home_path
expect(OpenProject::OmniAuth::Authorization)
.to have_received(:after_login!).with(user, omniauth_hash, any_args)
end
diff --git a/spec/features/auth/auth_source_sso_login_spec.rb b/spec/features/auth/auth_source_sso_login_spec.rb
index 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" do
login_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}']")
end
end
diff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rb
index 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 endpoint
visit "/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 in
visit "/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 endpoint
visit "/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 in
visit "/my/account"
diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb
index 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_path
wait_for_network_idle
diff --git a/spec/features/auth/login_spec.rb b/spec/features/auth/login_spec.rb
index 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 login
login_with(" #{user.login} ", user_password)
- # on the my page
+ # on the home path
expect(page)
- .to have_current_path my_page_path
+ .to have_current_path home_path
end
end
@@ -126,7 +126,7 @@ RSpec.describe "Login" do
login_with(user.login, user_password)
expect(page)
- .to have_current_path my_page_path
+ .to have_current_path home_path
end
context "autologin",
diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rb
index 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" do
login_with user.login, new_password
expect(page)
- .to have_current_path(my_page_path)
+ .to have_current_path(home_path)
end
context "when user has an auth source" do
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index 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" do
fill_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_url
end
it "signs in user" do
@@ -128,7 +128,7 @@ RSpec.describe "Omniauth authentication" do
fill_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_url
end
end
@@ -214,7 +214,7 @@ RSpec.describe "Omniauth authentication" do
click_link_or_button "Sign In"
- expect(page).to have_current_path my_page_path
+ expect(page).to have_current_path home_path
end
end
diff --git a/spec/features/users/brute_force_spec.rb b/spec/features/users/brute_force_spec.rb
index 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)" do
new_login_attempt(login, password)
expect(page)
- .to have_current_path my_page_path
+ .to have_current_path home_path
# resets the failed login count
expect(User.where(id: user.id).pluck(:failed_login_count).first)
@@ -111,6 +111,6 @@ RSpec.describe "Loggin (with brute force protection)" do
new_login_attempt(login, password)
expect(page)
- .to have_current_path my_page_path
+ .to have_current_path home_path
end
end
diff --git a/spec/features/work_packages/share/share_account_activation_spec.rb b/spec/features/work_packages/share/share_account_activation_spec.rb
index 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" do
login_with(editor.login, "adminADMIN!")
- expect(page).to have_current_path "/my/page"
+ expect(page).to have_current_path home_path
work_package_page.visit!
work_package_page.click_share_button