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

change watcher helper that can be used in page header action buttons

Behrokh Satarnejad21178a2c0120
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 42c2cabf298..4b9aa499533 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -42,7 +42,7 @@ module WatchersHelper
path = send(:"#{(watched ? 'unwatch' : 'watch')}_path", object_type: object.class.to_s.underscore.pluralize,
object_id: object.id,
replace: options.delete("replace"))
- html_options[:class] = "#{html_options[:class]} Button--secondary Button"
+ html_options[:class] = "#{html_options[:class]} button"
method = watched ? :delete : :post
@@ -52,3 +52,28 @@ module WatchersHelper
content_tag(:span, label, class: "button--text"), path, html_options.merge(method:))
end
end
+
+def watcher_button_arguments(object, user)
+ return nil unless user&.logged? && object.respond_to?(:watched_by?)
+
+ watched = object.watched_by?(user)
+
+ path = send(:"#{(watched ? 'unwatch' : 'watch')}_path", object_type: object.class.to_s.underscore.pluralize,
+ object_id: object.id)
+
+ method = watched ? :delete : :post
+
+ label = watched ? I18n.t(:button_unwatch) : I18n.t(:button_watch)
+
+ {
+ tag: :a,
+ href: path,
+ scheme: :default,
+ aria: { label: label },
+ data: {
+ method:
+ },
+ mobile_icon: watched ? "eye-closed" : "eye",
+ mobile_label: label
+ }
+end