-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16020 from opf/feature/40437-emoji-reactions-to-w…
…ork-package-comments Feature/40437 emoji reactions to work package comments
- Loading branch information
Showing
37 changed files
with
1,783 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 17 additions & 7 deletions
24
app/components/work_packages/activities_tab/journals/index_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
<%= | ||
component_wrapper(class: "work-packages-activities-tab-journals-index-component") do | ||
flex_layout do |journals_index_wrapper_container| | ||
journals_index_wrapper_container.with_row(classes: "work-packages-activities-tab-journals-index-component--journals-inner-container", mb: inner_container_margin_bottom) do | ||
flex_layout(id: insert_target_modifier_id, data: { "test_selector": "op-wp-journals-container" }) do |journals_index_container| | ||
journals_index_wrapper_container.with_row( | ||
classes: "work-packages-activities-tab-journals-index-component--journals-inner-container", | ||
mb: inner_container_margin_bottom | ||
) do | ||
flex_layout(id: insert_target_modifier_id, | ||
data: { test_selector: "op-wp-journals-container" }) do |journals_index_container| | ||
if empty_state? | ||
journals_index_container.with_row(mt: 2, mb: 3) do | ||
render( | ||
WorkPackages::ActivitiesTab::Journals::EmptyComponent.new() | ||
WorkPackages::ActivitiesTab::Journals::EmptyComponent.new | ||
) | ||
end | ||
end | ||
|
||
journals.each do |journal| | ||
journals_index_container.with_row do | ||
render( | ||
WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal:, filter:) | ||
) | ||
render(WorkPackages::ActivitiesTab::Journals::ItemComponent.new( | ||
journal:, filter:, | ||
grouped_emoji_reactions: wp_journals_grouped_emoji_reactions[journal.id] | ||
)) | ||
end | ||
end | ||
end | ||
end | ||
journals_index_wrapper_container.with_row(classes: "work-packages-activities-tab-journals-index-component--stem-connection") unless empty_state? || journal_sorting == "desc" | ||
|
||
unless empty_state? || journal_sorting_desc? | ||
journals_index_wrapper_container | ||
.with_row(classes: "work-packages-activities-tab-journals-index-component--stem-connection") | ||
end | ||
end | ||
end | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<%= | ||
component_wrapper do | ||
if journal.available_emoji_reactions.any? | ||
render(Primer::Alpha::Overlay.new( | ||
title: I18n.t("reactions.action_title"), | ||
padding: :condensed, | ||
anchor_side: :outside_top, | ||
visually_hide_title: true | ||
)) do |overlay| | ||
overlay.with_show_button( | ||
icon: "smiley", | ||
"aria-label": I18n.t("reactions.add_reaction"), | ||
title: I18n.t("reactions.add_reaction"), | ||
mr: 2, | ||
test_selector: "add-reactions-button" | ||
) | ||
|
||
overlay.with_body(pt: 2) do | ||
flex_layout do |add_reactions_container| | ||
journal.available_emoji_reactions.each do |emoji, reaction| | ||
add_reactions_container.with_column(mr: 2) do | ||
render(Primer::Beta::Button.new( | ||
scheme: :invisible, | ||
id: "#{journal.id}-#{reaction}", | ||
tag: :a, | ||
href: toggle_reaction_work_package_activity_path(journal.journable.id, id: journal.id, reaction:), | ||
data: { "turbo-stream": true, "turbo-method": :put }, | ||
"aria-label": I18n.t("reactions.react_with", reaction: reaction.to_s.humanize(capitalize: false)) | ||
)) do | ||
emoji | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
%> |
56 changes: 56 additions & 0 deletions
56
app/components/work_packages/activities_tab/journals/item_component/add_reactions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#-- 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 | ||
|
||
def render? | ||
User.current.allowed_in_work_package?(:add_work_package_notes, work_package) | ||
end | ||
|
||
private | ||
|
||
attr_reader :journal | ||
|
||
def work_package = journal.journable | ||
def wrapper_uniq_by = journal.id | ||
end | ||
end | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<%= | ||
component_wrapper do | ||
if grouped_emoji_reactions.present? | ||
flex_layout(test_selector: "emoji-reactions") do |reactions_container| | ||
grouped_emoji_reactions.each do |reaction, data| | ||
reactions_container.with_column(mr: 2) do | ||
render(Primer::Beta::Button.new( | ||
scheme: button_scheme(data[:users]), | ||
color: :default, | ||
bg: counter_color(data[:users]), | ||
id: "#{journal.id}-#{reaction}", | ||
test_selector: "reaction-#{reaction}", | ||
tag: :a, | ||
href: href(reaction:), | ||
data: { turbo_stream: true, turbo_method: :put }, | ||
aria: { label: aria_label_text(reaction, data[:users]) }, | ||
disabled: current_user_cannot_react?, | ||
classes: "op-reactions-button" | ||
)) do |button| | ||
button.with_tooltip(text: number_of_user_reactions_text(data[:users]), | ||
test_selector: "reaction-tooltip-#{reaction}") do | ||
button.with_icon(EmojiReactions.emoji(reaction), size: :small) | ||
end | ||
"#{EmojiReaction.emoji(reaction)} #{data[:count]}" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
%> |
Oops, something went wrong.