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

[#47043] Add storage links to the project sidebar menu

Pavel Balashov272b2f58ac46
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 44b48b0250c..d211dd2bbe3 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -65,10 +65,6 @@ class ProjectsController < ApplicationController
end
end
- current_menu_item :index do
- :list_projects
- end
-
def new
render layout: 'no_menu'
end
diff --git a/frontend/src/global_styles/common/menu/menu.sass b/frontend/src/global_styles/common/menu/menu.sass
index c847726d1be..dfb6e7120df 100644
--- a/frontend/src/global_styles/common/menu/menu.sass
+++ b/frontend/src/global_styles/common/menu/menu.sass
@@ -10,6 +10,14 @@
overflow: hidden
text-overflow: ellipsis
+ > .spot-icon
+ width: 1.25rem
+ height: 1.25rem
+ margin-left: 0.25rem
+ margin-right: 0
+ color: var(--primary-color--minor1)
+
+
&-action
display: block
height: 32px
@@ -19,6 +27,13 @@
font-weight: 400
color: var(--context-menu-unselected-font-color)
+ .spot-icon
+ width: 1.25rem
+ height: 1.25rem
+
+ &:first-child
+ margin-right: 0.75rem
+
&:focus
background-color: #f0f0f0
color: var(--context-menu-unselected-font-color)
diff --git a/frontend/src/global_styles/layout/_main_menu.sass b/frontend/src/global_styles/layout/_main_menu.sass
index b1fea06e58a..07c83024fa2 100644
--- a/frontend/src/global_styles/layout/_main_menu.sass
+++ b/frontend/src/global_styles/layout/_main_menu.sass
@@ -226,11 +226,12 @@ a.main-menu--parent-node
display: list-item
.main-menu--children-menu-header
display: none
+
.spot-icon_enterprise-addons
- margin-left: 0.25rem
color: $spot-color-feedback-warning-dark
font-size: 1rem
margin-right: 1px
+
.hidden-navigation
.main-menu
width: var(--main-menu-folded-width)
diff --git a/lib/redmine/menu_manager/menu_helper.rb b/lib/redmine/menu_manager/menu_helper.rb
index 361548eaaab..42c5b10770e 100644
--- a/lib/redmine/menu_manager/menu_helper.rb
+++ b/lib/redmine/menu_manager/menu_helper.rb
@@ -45,6 +45,7 @@ module Redmine::MenuManager::MenuHelper
nil
elsif menu == :project_menu && project && project.persisted?
build_wiki_menus(project)
+ build_storages_menu(project)
render_menu(:project_menu, project)
elsif menu == :wp_query_menu
render_menu(:application_menu, project)
@@ -55,9 +56,8 @@ module Redmine::MenuManager::MenuHelper
def render_menu(menu, project = nil)
links = []
-
+ @menu = menu
menu_items = first_level_menu_items_for(menu, project) do |node|
- @menu = menu
links << render_menu_node(node, project)
end
@@ -164,17 +164,18 @@ module Redmine::MenuManager::MenuHelper
caption, url, selected = extract_node_details(item, project)
link_text = ''.html_safe
- link_text << op_icon(item.icon(project)) if item.icon(project).present?
+ link_text << spot_icon(item.icon) if item.icon(project).present?
link_text << content_tag(:span,
class: "#{menu_class}--item-title #{item.badge(project).present? ? "#{menu_class}--item-title_has-badge" : ''}",
lang: menu_item_locale(item)) do
- title_text = ''.html_safe + caption + badge_for(item)
+ title_text = ''.html_safe + content_tag(:span, caption) + badge_for(item)
if item.enterprise_feature.present? && !EnterpriseToken.allows_to?(item.enterprise_feature)
- title_text << (' '.html_safe + spot_icon('enterprise-addons'))
+ title_text << (''.html_safe + spot_icon('enterprise-addons'))
+ elsif item.icon_after.present?
+ title_text << (''.html_safe + spot_icon(item.icon_after))
end
title_text
end
- link_text << (' '.html_safe + op_icon(item.icon_after)) if item.icon_after.present?
html_options = item.html_options(selected:)
html_options[:title] ||= selected ? t(:description_current_position) + caption : caption
html_options[:class] = "#{html_options[:class]} #{menu_class}--item-action"
@@ -199,6 +200,26 @@ module Redmine::MenuManager::MenuHelper
private
+ def build_storages_menu(project)
+ if project.enabled_module_names.include?('storages') &&
+ current_user.allowed_to?(:view_file_links, project)
+ storages = project.storages
+ Redmine::MenuManager.loose(:project_menu) do |project_menu|
+ storages.each do |s|
+ project_menu.push(
+ :"storage_#{s.id}",
+ s.host,
+ caption: s.name,
+ before: :members,
+ icon: "nextcloud-circle",
+ icon_after: "external-link",
+ external_link: true
+ )
+ end
+ end
+ end
+ end
+
# Returns a list of unattached children menu items
def render_unattached_children_menu(node, project)
return nil unless node.child_menus
@@ -322,7 +343,7 @@ module Redmine::MenuManager::MenuHelper
end
def allowed_project_node?(node, project, user)
- if node_action_allowed?(node, project, user)
+ if node_action_allowed?(node, project, user) || node.external_link?
true
elsif node.allow_deeplink?
node.children.any? do |child|
diff --git a/lib/redmine/menu_manager/menu_item.rb b/lib/redmine/menu_manager/menu_item.rb
index 2294ce59578..e413519ea97 100644
--- a/lib/redmine/menu_manager/menu_item.rb
+++ b/lib/redmine/menu_manager/menu_item.rb
@@ -71,6 +71,7 @@ class Redmine::MenuManager::MenuItem < Redmine::MenuManager::TreeNode
@badge = options[:badge]
@engine = options[:engine]
@allow_deeplink = options[:allow_deeplink]
+ @external_link = !!options[:external_link]
super @name.to_sym
end
@@ -137,6 +138,10 @@ class Redmine::MenuManager::MenuItem < Redmine::MenuManager::TreeNode
@allow_deeplink = allow_deeplink
end
+ def external_link?
+ @external_link
+ end
+
def html_options(options = {})
if options[:selected]
o = @html_options.dup