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

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.rb
index 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
}
end
diff --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.erb
new file mode 100644
index 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 file
diff --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.rb
new file mode 100644
index 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
+end
diff --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.erb
new file mode 100644
index 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 file
diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.rb b/app/components/work_packages/activities_tab/journals/item_component/reactions.rb
new file mode 100644
index 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
+end
diff --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.erb
index 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 @@
end
end
end
+ 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
+ end
end
end
end
diff --git a/app/contracts/emoji_reactions/base_contract.rb b/app/contracts/emoji_reactions/base_contract.rb
new file mode 100644
index 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
+end
diff --git a/app/contracts/emoji_reactions/create_contract.rb b/app/contracts/emoji_reactions/create_contract.rb
new file mode 100644
index 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
+end
diff --git a/app/contracts/emoji_reactions/delete_contract.rb b/app/contracts/emoji_reactions/delete_contract.rb
new file mode 100644
index 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
+end
diff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rb
index 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 < ApplicationController
before_action :find_work_package
before_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 :authorize
def index
@@ -66,7 +66,8 @@ class WorkPackages::ActivitiesTabController < ApplicationController
end
def 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_streams
end
@@ -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])
end
clear_form_via_turbo_stream
@@ -156,6 +158,31 @@ class WorkPackages::ActivitiesTabController < ApplicationController
respond_with_turbo_streams
end
+ 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
+
private
def find_work_package
@@ -178,8 +205,8 @@ class WorkPackages::ActivitiesTabController < ApplicationController
params.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.journals
if filter == "only_comments"
@@ -206,6 +233,19 @@ class WorkPackages::ActivitiesTabController < ApplicationController
end
end
+ 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_date
target_component = WorkPackages::ActivitiesTab::Journals::DayComponent.new(
diff --git a/app/models/concerns/reactable.rb b/app/models/concerns/reactable.rb
new file mode 100644
index 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
+end
diff --git a/app/models/emoji_reaction.rb b/app/models/emoji_reaction.rb
new file mode 100644
index 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: "&#x1F44D;",
+ thumbs_down: "&#x1F44E;",
+ grinning_face_with_smiling_eyes: "&#x1F604;",
+ confused_face: "&#x1F615;",
+ heart: "&#x2764;",
+ party_popper: "&#x1F389;",
+ rocket: "&#x1F680;",
+ eyes: "&#x1F440;"
+ }.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
+end
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 1a9229a397a..9a62e756eee 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -34,6 +34,7 @@ class Journal < ApplicationRecord
include ::JournalFormatter
include ::Acts::Journalized::FormatHooks
include Journal::Timestamps
+ include Reactable
register_journal_formatter :diff, OpenProject::JournalFormatter::Diff
register_journal_formatter :attachment, OpenProject::JournalFormatter::Attachment
diff --git a/app/services/emoji_reactions/create_service.rb b/app/services/emoji_reactions/create_service.rb
new file mode 100644
index 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
+end
diff --git a/app/services/emoji_reactions/delete_service.rb b/app/services/emoji_reactions/delete_service.rb
new file mode 100644
index 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
+end
diff --git a/app/services/emoji_reactions/set_attributes_service.rb b/app/services/emoji_reactions/set_attributes_service.rb
new file mode 100644
index 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
+end
diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb
index 14ae47ef67d..90996692690 100644
--- a/config/initializers/permissions.rb
+++ b/config/initializers/permissions.rb
@@ -206,7 +206,7 @@ Rails.application.reloader.to_prepare do
work_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.yml
index 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.rb
index 93b7b01489b..a288cdca504 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -544,6 +544,7 @@ Rails.application.routes.draw do
resources :activities, controller: "work_packages/activities_tab", only: %i[index create edit update] do
member do
get :cancel_edit
+ put :toggle_reaction
end
collection do
get :update_streams
diff --git a/db/migrate/20240624103354_create_emoji_reactions.rb b/db/migrate/20240624103354_create_emoji_reactions.rb
new file mode 100644
index 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