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
introduce simple emoji reactions
Jonas Jabari53aa61c83828
diff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rbindex a22f51a5f2c..9abed8e499e 100644--- a/app/components/work_packages/activities_tab/index_component.rb+++ b/app/components/work_packages/activities_tab/index_component.rb@@ -53,7 +53,7 @@ module WorkPackages"work-packages--activities-tab--index-update-streams-url-value": update_streams_work_package_activities_url(work_package),"work-packages--activities-tab--index-sorting-value": journal_sorting,"work-packages--activities-tab--index-filter-value": filter,- "work-packages--activities-tab--index-polling-interval-in-ms-value": 60000 # protoypical implementation+ "work-packages--activities-tab--index-polling-interval-in-ms-value": 10000 # protoypical implementation}enddiff --git a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erbnew file mode 100644index 00000000000..4c43bb9eafb--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb@@ -0,0 +1,33 @@+<%=+ component_wrapper do+ if journal.available_untaken_emojis.any?+ render(Primer::Alpha::Overlay.new(+ title: I18n.t("reactions.action_title"),+ padding: :condensed,+ anchor_side: :outside_top,+ visually_hide_title: true+ )) do |d|+ # d.with_header(title: "React")+ d.with_show_button(icon: "smiley", "aria-label": I18n.t("reactions.add_reaction"), title: I18n.t("reactions.add_reaction"))+ d.with_body(pt: 2) do+ flex_layout do |add_reactions_container|+ journal.available_untaken_emojis.each do |emoji|+ add_reactions_container.with_column(mr: 2) do+ render(Primer::Beta::Button.new(+ scheme: :invisible,+ id: "#{journal.id}-#{emoji}",+ tag: :a,+ href: toggle_reaction_work_package_activity_path(journal.journable.id, id: journal.id, emoji: emoji),+ data: { "turbo-stream": true, "turbo-method": :put},+ "aria-label": I18n.t("reactions.react_with", emoji_shortcode: EmojiReaction.shortcode(emoji)),+ )) do+ emoji.html_safe+ end+ end+ end+ end+ end+ end+ end+ end+%>\ No newline at end of filediff --git a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rbnew file mode 100644index 00000000000..07196599919--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb@@ -0,0 +1,53 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 WorkPackages+ module ActivitiesTab+ module Journals+ class ItemComponent::AddReactions < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(journal:)+ super++ @journal = journal+ end++ private++ attr_reader :journal++ def wrapper_uniq_by+ journal.id+ end+ end+ end+ end+enddiff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erbnew file mode 100644index 00000000000..4916837ce60--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb@@ -0,0 +1,21 @@+<%=+ component_wrapper do+ if journal.detailed_grouped_emoji_reactions.any?+ flex_layout do |reactions_container|+ journal.detailed_grouped_emoji_reactions.each do |emoji, data|+ reactions_container.with_column(mr: 2) do+ render(Primer::Beta::Button.new(+ id: "#{journal.id}-#{emoji}",+ tag: :a,+ href: toggle_reaction_work_package_activity_path(journal.journable.id, id: journal.id, emoji: emoji),+ data: { "turbo-stream": true, "turbo-method": :put}+ )) do |button|+ button.with_tooltip(text: tooltip_text(emoji, data[:users]))+ "#{emoji} #{data[:count]}".html_safe+ end+ end+ end+ end+ end+ end+%>\ No newline at end of filediff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/reactions.rbnew file mode 100644index 00000000000..1efdb987733--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.rb@@ -0,0 +1,72 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 WorkPackages+ module ActivitiesTab+ module Journals+ class ItemComponent::Reactions < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(journal:)+ super++ @journal = journal+ end++ private++ attr_reader :journal++ def wrapper_uniq_by+ journal.id+ end++ def tooltip_text(emoji, users)+ max_displayed_users_count = 5++ user_count = users.length+ displayed_users = users.take(max_displayed_users_count).map { |u| u[:name] }++ result = if user_count <= max_displayed_users_count+ displayed_users.join(', ')+ elsif user_count == max_displayed_users_count + 1+ "#{displayed_users.join(', ')} #{I18n.t("reactions.and_n_others_singular", n: 1)}"+ else+ "#{displayed_users.join(', ')} #{I18n.t("reactions.and_n_others_plural", n: user_count - max_displayed_users_count)}"+ end++ result += " "++ result += I18n.t("reactions.reacted_with", emoji_shortcode: EmojiReaction.shortcode(emoji))+ end+ end+ end+ end+enddiff --git a/app/components/work_packages/activities_tab/journals/item_component/show.html.erb b/app/components/work_packages/activities_tab/journals/item_component/show.html.erbindex 797b27b8582..1fa39434802 100644--- a/app/components/work_packages/activities_tab/journals/item_component/show.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/show.html.erb@@ -18,6 +18,14 @@endendend+ journal_container.with_row(mt: 3, flex_layout: true) do |reactions_container|+ reactions_container.with_column do+ render(WorkPackages::ActivitiesTab::Journals::ItemComponent::Reactions.new(journal:))+ end+ reactions_container.with_column do+ render(WorkPackages::ActivitiesTab::Journals::ItemComponent::AddReactions.new(journal:))+ end+ endendendenddiff --git a/app/contracts/emoji_reactions/base_contract.rb b/app/contracts/emoji_reactions/base_contract.rbnew file mode 100644index 00000000000..821f801aa49--- /dev/null+++ b/app/contracts/emoji_reactions/base_contract.rb@@ -0,0 +1,81 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class BaseContract < ::ModelContract+ attribute :emoji+ attribute :user_id+ attribute :reactable_id+ attribute :reactable_type++ validate :manage_emoji_reactions_permission?+ validate :validate_user_exists+ validate :validate_acting_user+ validate :validate_reactable_exists+ validate :validate_emoji_type++ def self.model+ EmojiReaction+ end++ private++ def validate_user_exists+ errors.add :user, :error_not_found unless User.exists?(model.user_id)+ end++ def validate_acting_user+ errors.add :user, :error_unauthorized unless model.user_id == user.id+ end++ def validate_reactable_exists+ errors.add :reactable, :error_not_found unless model.reactable.present?+ end++ def validate_emoji_type+ errors.add :emoji, :inclusion unless EmojiReaction::AVAILABLE_EMOJIS.include?(model.emoji)+ end++ def manage_emoji_reactions_permission?+ unless manage_emoji_reactions?+ errors.add :base, :error_unauthorized+ end+ end++ def manage_emoji_reactions?+ case model.reactable+ when WorkPackage+ user.allowed_in_work_package?(:add_work_package_notes, model.reactable)+ when Journal+ user.allowed_in_work_package?(:add_work_package_notes, model.reactable.journable)+ else+ false+ end+ end+ end+enddiff --git a/app/contracts/emoji_reactions/create_contract.rb b/app/contracts/emoji_reactions/create_contract.rbnew file mode 100644index 00000000000..b3cf59f48a7--- /dev/null+++ b/app/contracts/emoji_reactions/create_contract.rb@@ -0,0 +1,32 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class CreateContract < BaseContract+ end+enddiff --git a/app/contracts/emoji_reactions/delete_contract.rb b/app/contracts/emoji_reactions/delete_contract.rbnew file mode 100644index 00000000000..385fe7bb5b2--- /dev/null+++ b/app/contracts/emoji_reactions/delete_contract.rb@@ -0,0 +1,36 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class DeleteContract < ::DeleteContract+ delete_permission -> {+ # The user can delete the reaction if they created it+ model.user_id == user.id+ }+ end+enddiff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rbindex a8fdc66e115..bf450701616 100644--- a/app/controllers/work_packages/activities_tab_controller.rb+++ b/app/controllers/work_packages/activities_tab_controller.rb@@ -33,7 +33,7 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerbefore_action :find_work_packagebefore_action :find_project- before_action :find_journal, only: %i[edit cancel_edit update]+ before_action :find_journal, only: %i[edit cancel_edit update toggle_reaction]before_action :authorizedef index@@ -66,7 +66,8 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerenddef update_streams- generate_time_based_update_streams(params[:last_update_timestamp], params[:filter])+ generate_time_based_journal_update_streams(params[:last_update_timestamp], params[:filter])+ generate_time_based_reaction_update_streams(params[:last_update_timestamp])respond_with_turbo_streamsend@@ -104,7 +105,8 @@ class WorkPackages::ActivitiesTabController < ApplicationController###if call.success? && call.result- generate_time_based_update_streams(params[:last_update_timestamp], params[:filter])+ generate_time_based_journal_update_streams(params[:last_update_timestamp], params[:filter])+ generate_time_based_reaction_update_streams(params[:last_update_timestamp])endclear_form_via_turbo_stream@@ -156,6 +158,31 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerrespond_with_turbo_streamsend+ def toggle_reaction+ if @journal.emoji_reactions.exists?(user: User.current, emoji: params[:emoji])+ call = EmojiReactions::DeleteService.new(+ user: User.current,+ model: @journal.emoji_reactions.find_by(user: User.current, emoji: params[:emoji])+ ).call+ else+ call = EmojiReactions::CreateService.new(+ user: User.current+ ).call(+ user: User.current,+ reactable: @journal,+ emoji: params[:emoji]+ )+ end++ if call.success?+ update_journal_via_turbo_stream(@journal)+ else+ # TODO: handle errors+ end++ respond_with_turbo_streams+ end+privatedef find_work_package@@ -178,8 +205,8 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerparams.require(:journal).permit(:notes)end- def generate_time_based_update_streams(last_update_timestamp, filter)- # TODO: prototypical implementation+ def generate_time_based_journal_update_streams(last_update_timestamp, filter)+ # TODO: prototypical implementation!journals = @work_package.journalsif filter == "only_comments"@@ -206,6 +233,19 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerendend+ def generate_time_based_reaction_update_streams(last_update_timestamp)+ # Current limitation: Only shows added reactions, not removed ones+ EmojiReaction+ .where(reactable_id: @work_package.journal_ids)+ .where("updated_at > ?", last_update_timestamp).find_each do |reaction|+ update_via_turbo_stream(+ component: WorkPackages::ActivitiesTab::Journals::ItemComponent::Reactions.new(+ journal: reaction.reactable+ )+ )+ end+ end+def append_or_prepend_latest_journal_via_turbo_stream(journal, latest_journal)if latest_journal.created_at.to_date == journal.created_at.to_datetarget_component = WorkPackages::ActivitiesTab::Journals::DayComponent.new(diff --git a/app/models/concerns/reactable.rb b/app/models/concerns/reactable.rbnew file mode 100644index 00000000000..5eb2ad85e71--- /dev/null+++ b/app/models/concerns/reactable.rb@@ -0,0 +1,69 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 Reactable+ extend ActiveSupport::Concern++ included do+ has_many :emoji_reactions, as: :reactable, dependent: :destroy+ end++ def add_reaction(user, emoji)+ emoji_reactions.create(user: user, emoji: emoji)+ end++ def remove_reaction(user, emoji)+ emoji_reactions.find_by(user: user, emoji: emoji)&.destroy+ end++ def grouped_emoji_reactions+ emoji_reactions.group(:emoji).count+ end++ def detailed_grouped_emoji_reactions+ emoji_reactions+ .select('emoji, COUNT(*) as count, ARRAY_AGG(user_id) as user_ids')+ .group(:emoji)+ .map do |result|+ users = User.where(id: result.user_ids).select(:id, :firstname, :lastname)+ {+ emoji: result.emoji,+ count: result.count,+ users: users.map { |u| { id: u.id, name: u.name } }+ }+ end.index_by { |r| r[:emoji] }+ end++ def available_emojis+ EmojiReaction.available_emojis+ end++ def available_untaken_emojis+ EmojiReaction.available_emojis - detailed_grouped_emoji_reactions.keys+ end+enddiff --git a/app/models/emoji_reaction.rb b/app/models/emoji_reaction.rbnew file mode 100644index 00000000000..ef998557ee6--- /dev/null+++ b/app/models/emoji_reaction.rb@@ -0,0 +1,56 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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.+#++++class EmojiReaction < ApplicationRecord+ EMOJI_MAP = {+ thumbs_up: "👍",+ thumbs_down: "👎",+ grinning_face_with_smiling_eyes: "😄",+ confused_face: "😕",+ heart: "❤",+ party_popper: "🎉",+ rocket: "🚀",+ eyes: "👀"+ }.freeze++ AVAILABLE_EMOJIS = EMOJI_MAP.values.freeze++ belongs_to :user+ belongs_to :reactable, polymorphic: true++ validates :emoji, presence: true, inclusion: { in: AVAILABLE_EMOJIS }+ validates :user_id, uniqueness: { scope: [:reactable_type, :reactable_id, :emoji] }++ def self.available_emojis+ AVAILABLE_EMOJIS+ end++ def self.shortcode(html_code)+ EMOJI_MAP.key(html_code)&.to_s&.prepend(':')&.concat(':') || html_code+ end+enddiff --git a/app/models/journal.rb b/app/models/journal.rbindex 1a9229a397a..9a62e756eee 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -34,6 +34,7 @@ class Journal < ApplicationRecordinclude ::JournalFormatterinclude ::Acts::Journalized::FormatHooksinclude Journal::Timestamps+ include Reactableregister_journal_formatter :diff, OpenProject::JournalFormatter::Diffregister_journal_formatter :attachment, OpenProject::JournalFormatter::Attachmentdiff --git a/app/services/emoji_reactions/create_service.rb b/app/services/emoji_reactions/create_service.rbnew file mode 100644index 00000000000..5fd2f0a683b--- /dev/null+++ b/app/services/emoji_reactions/create_service.rb@@ -0,0 +1,32 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class CreateService < ::BaseServices::Create+ end+enddiff --git a/app/services/emoji_reactions/delete_service.rb b/app/services/emoji_reactions/delete_service.rbnew file mode 100644index 00000000000..aa4d5c63fa7--- /dev/null+++ b/app/services/emoji_reactions/delete_service.rb@@ -0,0 +1,32 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class DeleteService < ::BaseServices::Delete+ end+enddiff --git a/app/services/emoji_reactions/set_attributes_service.rb b/app/services/emoji_reactions/set_attributes_service.rbnew file mode 100644index 00000000000..d37f853468e--- /dev/null+++ b/app/services/emoji_reactions/set_attributes_service.rb@@ -0,0 +1,32 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 EmojiReactions+ class SetAttributesService < ::BaseServices::SetAttributes+ end+enddiff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 14ae47ef67d..90996692690 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -206,7 +206,7 @@ Rails.application.reloader.to_prepare dowork_packages_api: [:get],"work_packages/reports": %i[report report_details],"work_packages/activities_tab": %i[index create update_streams edit cancel_edit update- update_sorting update_filter]+ update_sorting update_filter toggle_reaction]},permissible_on: %i[work_package project],contract_actions: { work_packages: %i[read] }diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 501216bef42..738962d4a9f 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -501,6 +501,14 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}Click to assign or change the color of this priority.It can be used for highlighting work packages in the table.+ reactions:+ action_title: "React"+ add_reaction: "Add reaction"+ react_with: "React with %{emoji_shortcode}"+ and_n_others_singular: "and %{n} other"+ and_n_others_plural: "and %{n} others"+ reacted_with: "reacted with %{emoji_shortcode}"+reportings:index:no_results_title_text: There are currently no status reportings.diff --git a/config/routes.rb b/config/routes.rbindex 93b7b01489b..a288cdca504 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -544,6 +544,7 @@ Rails.application.routes.draw doresources :activities, controller: "work_packages/activities_tab", only: %i[index create edit update] domember doget :cancel_edit+ put :toggle_reactionendcollection doget :update_streamsdiff --git a/db/migrate/20240624103354_create_emoji_reactions.rb b/db/migrate/20240624103354_create_emoji_reactions.rbnew file mode 100644index 00000000000..365aa4b7603--- /dev/null+++ b/db/migrate/20240624103354_create_emoji_reactions.rb@@ -0,0 +1,12 @@+class CreateEmojiReactions < ActiveRecord::Migration[7.1]+ def change+ create_table :emoji_reactions do |t|+ t.references :user, null: false, foreign_key: true+ t.references :reactable, polymorphic: true, null: false+ t.string :emoji, null: false+ t.timestamps+ end++ add_index :emoji_reactions, [:user_id, :reactable_type, :reactable_id, :emoji], unique: true, name: 'index_emoji_reactions_uniqueness'+ end+end