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

project query favoring interface

Ivan Kuchine3f93211810c
diff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erb
index 417c8e08fab..ec36b2c0b4c 100644
--- a/app/components/projects/index_page_header_component.html.erb
+++ b/app/components/projects/index_page_header_component.html.erb
@@ -21,6 +21,29 @@
)
end
+ if can_toggle_favor?
+ if currently_favored?
+ header.with_action_icon_button(
+ icon: "star-fill",
+ mobile_icon: "star-fill",
+ label: t(:button_unfavorite),
+ classes: "op-primer--star-icon",
+ tag: :a,
+ href: helpers.build_favorite_path(query, format: :html),
+ data: { method: :delete },
+ )
+ else
+ header.with_action_icon_button(
+ icon: "star",
+ mobile_icon: "star",
+ label: t(:button_favorite),
+ tag: :a,
+ href: helpers.build_favorite_path(query, format: :html),
+ data: { method: :post },
+ )
+ end
+ end
+
header.with_action_menu(
menu_arguments: {
anchor_align: :end
diff --git a/app/components/projects/index_page_header_component.rb b/app/components/projects/index_page_header_component.rb
index 5e3fd994a12..fadd93b97d9 100644
--- a/app/components/projects/index_page_header_component.rb
+++ b/app/components/projects/index_page_header_component.rb
@@ -106,6 +106,10 @@ class Projects::IndexPageHeaderComponent < ApplicationComponent
state == :show
end
+ def can_toggle_favor? = query.persisted?
+
+ def currently_favored? = query.favored_by?(current_user)
+
def breadcrumb_items
[
{ href: projects_path, text: t(:label_project_plural) },