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

show favored project queries in menu

Ivan Kuchin0a6f7cda9c90
diff --git a/app/components/open_project/common/submenu_component.html.erb b/app/components/open_project/common/submenu_component.html.erb
index 5b38527ce18..ba0b2953121 100644
--- a/app/components/open_project/common/submenu_component.html.erb
+++ b/app/components/open_project/common/submenu_component.html.erb
@@ -62,6 +62,9 @@
<% selected = child_item.selected ? 'selected' : '' %>
<a class="op-sidemenu--item-action <%= selected %>" href="<%= child_item.href %>" data-test-selector="op-sidemenu--item-action">
<span class="op-sidemenu--item-title"><%= child_item.title %></span>
+ <% if child_item.favored %>
+ <%= render Primer::Beta::Octicon.new(icon: "star-fill", "aria-label": I18n.t(:label_favorite), classes: %w[op-sidemenu--item-mark op-primer--star-icon]) %>
+ <% end %>
</a>
</li>
<% end %>
diff --git a/app/menus/projects/menu.rb b/app/menus/projects/menu.rb
index 1726f9e8e01..96fb25144cb 100644
--- a/app/menus/projects/menu.rb
+++ b/app/menus/projects/menu.rb
@@ -67,6 +67,10 @@ module Projects
end
end
+ def favored?(query_params)
+ query_params[:query_id].in?(favored_ids)
+ end
+
def query_path(query_params)
projects_path(query_params)
end
@@ -117,6 +121,11 @@ module Projects
def persisted_filters
@persisted_filters = ::ProjectQuery.visible(current_user).order(:name)
+ .sort_by.with_index { |query, i| [query.id.in?(favored_ids) ? 0 : 1, i] }
+ end
+
+ def favored_ids
+ @favored_ids = ::ProjectQuery.favored_by(current_user).pluck(:id).to_set
end
def modification_params?
diff --git a/app/menus/submenu.rb b/app/menus/submenu.rb
index 0cdbcbbb861..3028e3fbd63 100644
--- a/app/menus/submenu.rb
+++ b/app/menus/submenu.rb
@@ -92,7 +92,8 @@ class Submenu
def menu_item(name, query_params)
OpenProject::Menu::MenuItem.new(title: name,
href: query_path(query_params),
- selected: selected?(query_params))
+ selected: selected?(query_params),
+ favored: favored?(query_params))
end
def selected?(query_params)
@@ -109,6 +110,10 @@ class Submenu
true
end
+ def favored?(_query_params)
+ false
+ end
+
def query_path(query_params)
raise NotImplementedError
end
diff --git a/frontend/src/global_styles/content/_sidemenu.sass b/frontend/src/global_styles/content/_sidemenu.sass
index 059ab00bf74..019ef72b898 100644
--- a/frontend/src/global_styles/content/_sidemenu.sass
+++ b/frontend/src/global_styles/content/_sidemenu.sass
@@ -46,15 +46,16 @@
padding-left: 12px
&--item-title
- display: flex
- margin-right: auto
+ display: inline-block
overflow: hidden
text-overflow: ellipsis
white-space: nowrap
line-height: 30px
text-decoration: none
- width: 100%
&--item-icon
font-size: 24px
margin-right: 8px
+
+ &--item-mark
+ margin-left: 8px
diff --git a/lib/open_project/menu.rb b/lib/open_project/menu.rb
index 693e4517b87..0c2458efa59 100644
--- a/lib/open_project/menu.rb
+++ b/lib/open_project/menu.rb
@@ -31,6 +31,6 @@
module OpenProject
module Menu
MenuGroup = Data.define(:header, :children)
- MenuItem = Data.define(:title, :href, :selected)
+ MenuItem = Data.define(:title, :href, :selected, :favored)
end
end