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 the `home` item to the global menu

Aaron Contreras413dc94f30eb
diff --git a/app/controllers/homescreen_controller.rb b/app/controllers/homescreen_controller.rb
index 97803cae467..4ddfe4ecdf1 100644
--- a/app/controllers/homescreen_controller.rb
+++ b/app/controllers/homescreen_controller.rb
@@ -29,7 +29,7 @@
class HomescreenController < ApplicationController
skip_before_action :check_if_login_required, only: [:robots]
- layout 'no_menu'
+ layout 'global'
def index
@newest_projects = Project.visible.newest.take(3)
@@ -40,6 +40,10 @@ class HomescreenController < ApplicationController
@homescreen = OpenProject::Static::Homescreen
end
+ current_menu_item [:index] do
+ :home
+ end
+
def robots
if Setting.login_required?
render template: 'homescreen/robots-login-required', format: :text
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index e27f3b10260..b48987afc67 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -121,7 +121,12 @@ Redmine::MenuManager.map :account_menu do |menu|
if: Proc.new { User.current.logged? }
end
-Redmine::MenuManager.map :global_menu
+Redmine::MenuManager.map :global_menu do |menu|
+ # Homescreen
+ menu.push :home,
+ { controller: '/homescreen', action: 'index' },
+ icon: 'home'
+end
Redmine::MenuManager.map :global_work_packages_menu do |menu|
menu.push :work_packages_query_select,
diff --git a/spec/features/homescreen/index_spec.rb b/spec/features/homescreen/index_spec.rb
index d54298a1d2f..23950ee4b0a 100644
--- a/spec/features/homescreen/index_spec.rb
+++ b/spec/features/homescreen/index_spec.rb
@@ -28,12 +28,23 @@
require 'spec_helper'
-RSpec.describe 'Homescreen index' do
+RSpec.describe 'Homescreen', 'index', :with_cuprite do
let(:admin) { create(:admin) }
let(:user) { build_stubbed(:user) }
let!(:project) { create(:public_project, identifier: 'public-project') }
let(:general_settings_page) { Pages::Admin::SystemSettings::General.new }
+ it 'is reachable by the global menu' do
+ login_as user
+ visit root_url
+
+ within '#main-menu' do
+ click_on 'Home'
+ end
+
+ expect(page).to have_current_path(home_path)
+ end
+
context 'with a dynamic URL in the welcome text' do
before do
Setting.welcome_text = "With [a link to the public project]({{opSetting:base_url}}/projects/public-project)"
@@ -50,7 +61,7 @@ RSpec.describe 'Homescreen index' do
expect(page).to have_current_path project_path(project)
end
- it 'can change the welcome text and still have a valid link', js: true, with_cuprite: true do
+ it 'can change the welcome text and still have a valid link', js: true do
login_as admin
general_settings_page.visit!
diff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rb
index 6f9198c8b0b..0912e45736f 100644
--- a/spec/lib/redmine/menu_manager_spec.rb
+++ b/spec/lib/redmine/menu_manager_spec.rb
@@ -51,7 +51,6 @@ RSpec.describe Redmine::MenuManager do
context 'for the global_menu' do
it 'includes the expected items' do
- pending ':home menu item missing in the menu'
expect(described_class.items(:global_menu).map(&:name))
.to include(:home)
end