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
Transform user menu into a lateral overlapping menu
Henriette Dargedd7e3086fcbb
diff --git a/app/views/account/_login.html.erb b/app/views/account/_login.html.erbindex 698cd87df3d..693f8dafd5e 100644--- a/app/views/account/_login.html.erb+++ b/app/views/account/_login.html.erb@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.) do %><%= back_url_to_current_page_hidden_field_tag %>- <div class="grid-block">+ <div class="grid-block grid-block_double-column"><div class="form--field -required"><%= styled_label_tag "username-pulldown", User.human_attribute_name(:login) %><div class="form--field-container">@@ -54,7 +54,7 @@ See COPYRIGHT and LICENSE files for more details.<% end %></div></div>-+ <div class="grid-block"><div class="form--field -required"><%= styled_label_tag "password-pulldown", User.human_attribute_name(:password) %><div class="form--field-container">@@ -73,7 +73,9 @@ See COPYRIGHT and LICENSE files for more details.<% end %></div></div>+ </div>+ <div class="grid-block"><div class="form--field"><label class="form--label" for="login-pulldown"> @@ -81,6 +83,7 @@ See COPYRIGHT and LICENSE files for more details.<input type="submit" name="login" id="login-pulldown"value="<%= t(:button_login) %>" class="button -primary button_no-margin" tabindex="1"></div>+ </div></div><%= render partial: "account/auth_providers" %>diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 3aeb47664f4..89b8c5b1de4 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -105,21 +105,27 @@ Redmine::MenuManager.map :account_menu do |menu|menu.push :my_page,:my_page_path,caption: I18n.t("my_page.label"),+ icon: :person,if: ->(_) { User.current.logged? }menu.push :my_profile,{ controller: "/users", action: "show", id: "me" },caption: :label_my_activity,+ icon: :history,if: ->(_) { User.current.logged? }menu.push :my_account,{ controller: "/my", action: "account" },+ icon: :gear,if: ->(_) { User.current.logged? }menu.push :administration,{ controller: "/admin", action: "index" },+ icon: :sliders,if: ->(_) {User.current.allowed_globally?({ controller: "/admin", action: "index" })}menu.push :logout,:signout_path,+ icon: :"sign-out",+ scheme: :danger,if: ->(_) { User.current.logged? },html: {data: {diff --git a/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.html b/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.htmlindex 85bcdb97e18..f36ab01149b 100644--- a/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.html+++ b/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.html@@ -16,5 +16,4 @@>#{{ timer.entity.id }}: {{ timer.entity.name }}</a>- <div class="spot-divider"></div></ng-container>diff --git a/frontend/src/global_styles/common/header/app-menu.sass b/frontend/src/global_styles/common/header/app-menu.sassindex a968333f506..7a8207d0841 100644--- a/frontend/src/global_styles/common/header/app-menu.sass+++ b/frontend/src/global_styles/common/header/app-menu.sass@@ -3,6 +3,7 @@margin: 0&--item+ color: var(--header-item-font-color)display: flex&:hoverdiff --git a/frontend/src/global_styles/content/_accounts.sass b/frontend/src/global_styles/content/_accounts.sassindex 29fb76b7bdd..32f7a1606ef 100644--- a/frontend/src/global_styles/content/_accounts.sass+++ b/frontend/src/global_styles/content/_accounts.sass@@ -46,19 +46,15 @@float: nonedisplay: inline-block-#nav-login-content- padding: 1rem-- .form--text-field- min-width: 170px-#login-pulldownmargin-right: 0// use id selectors to be specific enough to override general content and top-menu definitions+#content .login-auth-providers+ width: 471px+#content .login-auth-providers,#nav-login-content .login-auth-providers- width: 471pxmargin-top: 25pxh3diff --git a/frontend/src/global_styles/primer/_overrides.sass b/frontend/src/global_styles/primer/_overrides.sassindex 719538e12ac..43e9799670f 100644--- a/frontend/src/global_styles/primer/_overrides.sass+++ b/frontend/src/global_styles/primer/_overrides.sass@@ -85,7 +85,7 @@ ul.SegmentedControl,row-gap: 1rem.Button.op-app-header--primer-button,-.Button.op-app-header--primer-button .Button-visual+.Button.op-app-header--primer-button svgalign-self: centercolor: var(--header-item-font-color)diff --git a/lib/redmine/menu_manager/menu_item.rb b/lib/redmine/menu_manager/menu_item.rbindex f5e6afee56f..979e035f858 100644--- a/lib/redmine/menu_manager/menu_item.rb+++ b/lib/redmine/menu_manager/menu_item.rb@@ -37,6 +37,7 @@ class Redmine::MenuManager::MenuItem < Redmine::MenuManager::TreeNode:child_menus,:last,:partial,+ :scheme,:engine,:enterprise_feature@@ -70,6 +71,7 @@ class Redmine::MenuManager::MenuItem < Redmine::MenuManager::TreeNode@child_menus = options[:children]@last = options[:last] || false@partial = options[:partial]+ @scheme = options[:scheme]@badge = options[:badge]@engine = options[:engine]@allow_deeplink = options[:allow_deeplink]diff --git a/lib/redmine/menu_manager/top_menu/user_menu.rb b/lib/redmine/menu_manager/top_menu/user_menu.rbnew file mode 100644index 00000000000..72d72cd7909--- /dev/null+++ b/lib/redmine/menu_manager/top_menu/user_menu.rb@@ -0,0 +1,146 @@+# 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 Redmine::MenuManager::TopMenu::UserMenu+ def render_user_top_menu_node(items = first_level_menu_items_for(:account_menu))+ if omniauth_direct_login?+ render_direct_login+ else+ render_user_drop_down items+ end+ end++ private++ def render_direct_login+ render(Primer::Beta::IconButton.new(icon: "person",+ tag: :a,+ scheme: :invisible,+ href: signin_path,+ classes: "op-app-menu--item op-app-header--primer-button",+ aria: { label: I18n.t(:label_login) }))+ end++ def render_user_drop_down(items)+ avatar = avatar(User.current, class: "op-top-menu-user-avatar", hover_card: { active: false })++ render Primer::Alpha::Dialog.new(title: I18n.t("label_user_menu"),+ visually_hide_title: true,+ position: :right) do |dialog|+ dialog.with_show_button(scheme: :invisible,+ classes: "op-app-header--primer-button op-app-menu--item op-top-menu-user",+ test_selector: "op-app-header--modules-menu-button",+ "aria-label": I18n.t("label_user_menu")) do+ lateral_user_menu_button(avatar)+ end++ dialog.with_header(classes: "op-app-header--modules-menu-header") do+ lateral_user_menu_header(avatar)+ end++ dialog.with_body do+ if User.current.logged?+ lateral_user_menu_body(items)+ else+ render_login_partial+ end+ end+ end+ end++ def lateral_user_menu_button(avatar)+ if User.current.logged? && avatar.present?+ avatar+ else+ render(Primer::Beta::Octicon.new(icon: :person, aria: { label: I18n.t("label_user_menu") }))+ end+ end++ def lateral_user_menu_header(avatar)+ render(Primer::OpenProject::FlexLayout.new(align_items: :center)) do |flex|+ flex.with_column(mr: 2) do+ if User.current.logged? && avatar.present?+ avatar+ else+ render(Primer::Beta::Octicon.new(icon: :person, aria: { label: I18n.t("label_user_menu") }))+ end+ end+ flex.with_column(font_weight: :bold) do+ User.current.logged? ? User.current.name : I18n.t(:label_login)+ end+ end+ end++ def lateral_user_menu_body(items)+ partial_items, link_items = items.partition { |item| item.partial.present? }++ render(Primer::OpenProject::FlexLayout.new) do |flex|+ partial_items.each do |item|+ flex.with_row(mb: 2) do+ render partial: item.partial+ end+ end+ flex.with_row do+ render Primer::Alpha::ActionList.new(+ classes: "op-app-menu--items",+ id: "op-app-header--user-menu-list"+ ) do |list|+ list.with_divider++ add_lateral_user_menu_items link_items+ end+ end+ end+ end++ def add_lateral_user_menu_items(link_items)+ link_items.each do |item|+ list.with_item(+ href: allowed_node_url(item, nil),+ label: item.caption,+ scheme: item.scheme || :default,+ test_selector: "op-menu--item-action"+ ) do |menu_item|+ menu_item.with_leading_visual_icon(icon: item.icon) if item.icon+ end+ end+ end++ def render_login_partial+ partial =+ if OpenProject::Configuration.disable_password_login?+ "account/omniauth_login"+ else+ "account/login"+ end++ render partial:+ end+enddiff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rbindex cd622d49ba4..3cf1388defd 100644--- a/lib/redmine/menu_manager/top_menu_helper.rb+++ b/lib/redmine/menu_manager/top_menu_helper.rb@@ -32,6 +32,7 @@ module Redmine::MenuManager::TopMenuHelperinclude Redmine::MenuManager::TopMenu::HelpMenuinclude Redmine::MenuManager::TopMenu::ProjectsMenuinclude Redmine::MenuManager::TopMenu::QuickAddMenu+ include Redmine::MenuManager::TopMenu::UserMenudef render_top_menu_leftcontent_tag :ul, class: "op-app-menu op-app-menu_drop-left" do@@ -41,8 +42,7 @@ module Redmine::MenuManager::TopMenuHelperdef top_menu_left_menu_items[render_module_top_menu_node,- render_logo,- render_main_top_menu_nodes] # ToDo: Check wether render_main_top_menu_nodes can be removed+ render_logo]enddef render_top_menu_center@@ -101,85 +101,6 @@ module Redmine::MenuManager::TopMenuHelperendend- def render_user_top_menu_node(items = first_level_menu_items_for(:account_menu))- if User.current.logged?- render_user_drop_down items- elsif omniauth_direct_login?- render_direct_login- else- render_login_drop_down- end- end-- def render_login_drop_down- # url = { controller: "/account", action: "login" }- # link = link_to url,- # class: "op-app-menu--item-action",- # title: I18n.t(:label_login) do- # concat content_tag(:span, I18n.t(:label_login), class: "op-app-menu--item-title hidden-for-mobile")- # concat content_tag(:i, "", class: "op-app-menu--item-dropdown-indicator button--dropdown-indicator hidden-for-mobile")- # concat content_tag(:i, "", class: "icon2 icon-user hidden-for-desktop")- # end-- render Primer::Alpha::ActionMenu.new(classes: "op-app-menu--item",- menu_id: "op-app-header--login",- anchor_align: :end) do |menu|- menu.with_show_button(scheme: :invisible,- classes: "op-app-header--primer-button op-top-menu-user",- "aria-label": I18n.t(:label_login)) do- I18n.t(:label_login)- end- end-- # render_menu_dropdown(link, menu_item_class: "") do- # render_login_partial- # end- end-- def render_direct_login- render(Primer::Beta::IconButton.new(icon: "person",- tag: :a,- scheme: :invisible,- href: signin_path,- aria: { label: I18n.t(:label_login) }))- end-- def render_user_drop_down(items)- avatar = avatar(User.current, class: "op-top-menu-user-avatar", hover_card: { active: false })-- render Primer::Alpha::ActionMenu.new(classes: "op-app-menu--item",- menu_id: "op-app-header--user-menu",- anchor_align: :end) do |menu|- menu.with_show_button(scheme: :invisible,- classes: "op-app-header--primer-button op-top-menu-user",- test_selector: "op-app-header--modules-menu-button",- "aria-label": I18n.t("label_user_menu")) do- avatar.presence || render(Primer::Beta::Octicon.new(icon: :person, aria: { label: I18n.t("label_user_menu") }))- end-- items.each do |item|- menu.with_item(- href: allowed_node_url(item, nil),- label: item.caption,- test_selector: "op-menu--item-action"- ) do |menu_item|- menu_item.with_leading_visual_icon(icon: item.icon) if item.icon- end- end- end- end-- def render_login_partial- partial =- if OpenProject::Configuration.disable_password_login?- "account/omniauth_login"- else- "account/login"- end-- render partial:- end-def render_module_top_menu_node(item_groups = module_top_menu_item_groups)unless item_groups.empty?render Primer::Alpha::ActionMenu.new(classes: "op-app-menu--item",@@ -215,17 +136,6 @@ module Redmine::MenuManager::TopMenuHelperendend- def render_main_top_menu_nodes(items = main_top_menu_items)- items.map do |item|- render_menu_node(item)- end.join(" ")- end-- # Menu items for the main top menu- def main_top_menu_items- split_top_menu_into_main_or_more_menus[:base]- end-# Menu items for the modules top menudef more_top_menu_itemssplit_top_menu_into_main_or_more_menus[:modules]