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

Merge branch 'feature/54733-primerise-the-activity-panel' into feature/40437-emoji-reactions-to-work-package-comments

jjabari-ope86f322ea4a4
diff --cc app/controllers/work_packages/activities_tab_controller.rb
index 0958ce69439,6aec4724d5f..f285b3b5b02
--- a/app/controllers/work_packages/activities_tab_controller.rb
+++ b/app/controllers/work_packages/activities_tab_controller.rb
@@@ -33,7 -33,7 +33,7 @@@ class WorkPackages::ActivitiesTabContro
before_action :find_work_package
before_action :find_project
- before_action :find_journal, only: %i[edit cancel_edit update toggle_reaction toggle_notification_read_status]
- before_action :find_journal, only: %i[edit cancel_edit update]
++ before_action :find_journal, only: %i[edit cancel_edit update toggle_reaction]
before_action :set_filter
before_action :authorize
@@@ -154,53 -153,6 +154,36 @@@
respond_with_turbo_streams
end
+ def toggle_reaction
+ call = if @journal.emoji_reactions.exists?(user: User.current, emoji: params[:emoji])
+ EmojiReactions::DeleteService.new(
+ user: User.current,
+ model: @journal.emoji_reactions.find_by(user: User.current, emoji: params[:emoji])
+ ).call
+ else
+ EmojiReactions::CreateService.new(
+ user: User.current
+ ).call(
+ user: User.current,
+ reactable: @journal,
+ emoji: params[:emoji]
+ )
+ end
+
+ if call.success?
+ update_via_turbo_stream(
+ component: WorkPackages::ActivitiesTab::Journals::ItemComponent::Show.new(
+ journal: @journal,
+ filter: params[:filter]&.to_sym || :all
+ )
+ )
+ else
+ # TODO: handle errors
+ end
+
+ respond_with_turbo_streams
+ end
+
- def toggle_notification_read_status
- notification = Notification.find_by(recipient: User.current, journal: @journal)
-
- call = Notifications::UpdateService.new(model: notification, user: User.current).call(
- read_ian: !notification.read_ian
- )
-
- if call.success?
- update_item_component(@journal.reload, state: :show)
- update_activity_counter
- else
- handle_failed_update_call(call)
- end
-
- respond_with_turbo_streams
- end
-
private
def respond_with_error(error_message)
@@@ -348,48 -300,17 +332,43 @@@
journals = journals.where.not(notes: "")
end
+ rerender_updated_journals(journals, last_update_timestamp)
+
+ rerender_journals_with_updated_notification(journals, last_update_timestamp)
+
+ append_or_prepend_new_journals(journals, last_update_timestamp)
+
+ if journals.any?
+ remove_potential_empty_state
+ update_activity_counter
+ 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 rerender_updated_journals(journals, last_update_timestamp)
journals.where("updated_at > ?", last_update_timestamp).find_each do |journal|
- # we need to update the whole component as the show part is not rendered for journals which originally have no notes
- update_journal_item(journal:)
- end
- end
-
- def rerender_journals_with_updated_notification(journals, last_update_timestamp)
- journals
- .joins(:notifications)
- .where("notifications.updated_at > ?", last_update_timestamp)
- .find_each do |journal|
- update_journal_item(journal:)
+ update_via_turbo_stream(
+ # we need to update the whole component as the show part is not rendered for journals which originally have no notes
+ component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(
+ journal:,
+ filter: @filter
+ )
+ )
+ # TODO: is it possible to loose an edit state this way?
end
- end
- def append_or_prepend_new_journals(journals, last_update_timestamp)
journals.where("created_at > ?", last_update_timestamp).find_each do |journal|
append_or_prepend_latest_journal_via_turbo_stream(journal)
end
diff --cc config/routes.rb
index d28f8173ea2,4f79c4033b3..1a048571bb8
--- a/config/routes.rb
+++ b/config/routes.rb
@@@ -577,12 -580,9 +580,10 @@@ Rails.application.routes.draw d
# states managed by client-side routing on work_package#index
get "details/*state" => "work_packages#index", on: :collection, as: :details
- resources :activities, controller: "work_packages/activities_tab",
- only: %i[index create edit update] do
+ resources :activities, controller: "work_packages/activities_tab", only: %i[index create edit update] do
member do
get :cancel_edit
+ put :toggle_reaction
- put :toggle_notification_read_status
end
collection do
get :update_streams