-
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 #17594 from opf/bug/59374-regression-missing-commi…
…t-message-comments-in-work-packages-after-upgrade-to-1501 Bug/59374 regression missing commit message comments in work packages after upgrade to 1501
- Loading branch information
Showing
8 changed files
with
484 additions
and
40 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
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
81 changes: 81 additions & 0 deletions
81
app/components/work_packages/activities_tab/journals/revision_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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<%= | ||
component_wrapper(class: "work-packages-activities-tab-journals-item-component") do | ||
flex_layout(data: { | ||
test_selector: "op-wp-revision-entry-#{changeset.id}" | ||
}) do |revision_container| | ||
revision_container.with_row do | ||
render(border_box_container( | ||
id: "activity-anchor-r#{changeset.revision}", | ||
padding: :condensed, | ||
"aria-label": I18n.t("activities.work_packages.activity_tab.commented") | ||
)) do |border_box_component| | ||
border_box_component.with_header(px: 2, py: 1, data: { test_selector: "op-revision-header" }) do | ||
flex_layout(align_items: :center, justify_content: :space_between, classes: "work-packages-activities-tab-revision-component--header") do |header_container| | ||
header_container.with_column(flex_layout: true, | ||
classes: "work-packages-activities-tab-journals-item-component--header-start-container ellipsis") do |header_start_container| | ||
header_start_container.with_column(mr: 2) do | ||
if changeset.user | ||
render(Users::AvatarComponent.new(user: changeset.user, show_name: false, size: :mini)) | ||
end | ||
end | ||
header_start_container.with_column(mr: 1, flex_layout: true, | ||
classes: "work-packages-activities-tab-journals-item-component--user-name-container hidden-for-desktop") do |user_name_container| | ||
user_name_container.with_row(classes: "work-packages-activities-tab-journals-item-component--user-name ellipsis") do | ||
render_user_name | ||
end | ||
user_name_container.with_row do | ||
render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mr: 1)) do | ||
committed_text = render(Primer::Beta::Link.new( | ||
href: revision_url, | ||
scheme: :secondary, | ||
underline: false, | ||
font_size: :small, | ||
target: "_blank" | ||
)) do | ||
I18n.t("js.label_committed_link", revision_identifier: short_revision) | ||
end | ||
I18n.t("js.label_committed_at", | ||
committed_revision_link: committed_text.html_safe, | ||
date: format_time(changeset.committed_on)).html_safe | ||
end | ||
end | ||
end | ||
header_start_container.with_column(mr: 1, | ||
classes: "work-packages-activities-tab-journals-item-component--user-name ellipsis hidden-for-mobile") do | ||
render_user_name | ||
end | ||
header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do | ||
render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mr: 1)) do | ||
committed_text = render(Primer::Beta::Link.new( | ||
href: revision_url, | ||
scheme: :secondary, | ||
underline: false, | ||
font_size: :small, | ||
target: "_blank" | ||
)) do | ||
I18n.t("js.label_committed_link", revision_identifier: short_revision) | ||
end | ||
I18n.t("js.label_committed_at", | ||
committed_revision_link: committed_text.html_safe, | ||
date: format_time(changeset.committed_on)).html_safe | ||
end | ||
end | ||
end | ||
end | ||
end | ||
border_box_component.with_body( | ||
classes: "work-packages-activities-tab-journals-item-component--journal-notes-body", | ||
data: { test_selector: "op-revision-notes-body" } | ||
) do | ||
render(Primer::Box.new(mt: 1, classes: "op-uc-container")) do | ||
format_text(changeset, :comments) | ||
end | ||
end | ||
end | ||
end | ||
revision_container.with_row(flex_layout: true, classes: "work-packages-activities-tab-revision-component--stem-line-container") do |stem_line_container| | ||
stem_line_container.with_column(border: :left, classes: "work-packages-activities-tab-revision-component--stem-line") | ||
end | ||
end | ||
end | ||
%> |
127 changes: 127 additions & 0 deletions
127
app/components/work_packages/activities_tab/journals/revision_component.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,127 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 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. | ||
# ++ | ||
|
||
require "sanitize" | ||
|
||
module WorkPackages | ||
module ActivitiesTab | ||
module Journals | ||
class RevisionComponent < ApplicationComponent | ||
include ApplicationHelper | ||
include OpPrimer::ComponentHelpers | ||
include OpTurbo::Streamable | ||
|
||
def initialize(changeset:, filter:) | ||
super | ||
|
||
@changeset = changeset | ||
@filter = filter | ||
end | ||
|
||
def render_committer_name(committer) | ||
render(Primer::Beta::Text.new(font_weight: :bold, mr: 1)) do | ||
remove_email_addresses(committer) | ||
end | ||
end | ||
|
||
def remove_email_addresses(committer) | ||
return "" if committer.blank? | ||
|
||
ERB::Util.html_escape( | ||
Sanitize.fragment( | ||
committer.gsub(%r{<[^>]+@[^>]+>}, ""), | ||
Sanitize::Config::RESTRICTED | ||
).strip | ||
) | ||
end | ||
|
||
private | ||
|
||
attr_reader :changeset, :filter | ||
|
||
def render? | ||
filter != :only_comments | ||
end | ||
|
||
def user_name | ||
if changeset.user | ||
changeset.user.name | ||
else | ||
# Extract name from committer string (format: "name <email>") | ||
changeset.committer.split("<").first.strip | ||
end | ||
end | ||
|
||
def revision_url | ||
repository = changeset.repository | ||
project = repository.project | ||
|
||
show_revision_project_repository_path(project_id: project.id, rev: changeset.revision) | ||
end | ||
|
||
def short_revision | ||
changeset.revision[0..7] | ||
end | ||
|
||
def copy_url_action_item(menu) | ||
menu.with_item(label: t("button_copy_link_to_clipboard"), | ||
tag: :button, | ||
content_arguments: { | ||
data: { | ||
action: "click->work-packages--activities-tab--item#copyActivityUrlToClipboard" | ||
} | ||
}) do |item| | ||
item.with_leading_visual_icon(icon: :copy) | ||
end | ||
end | ||
|
||
def render_user_name | ||
if changeset.user | ||
render_user_link(changeset.user) | ||
else | ||
render_committer_name(changeset.committer) | ||
end | ||
end | ||
|
||
def render_user_link(user) | ||
render(Primer::Beta::Link.new( | ||
href: user_url(user), | ||
target: "_blank", | ||
scheme: :primary, | ||
underline: false, | ||
font_weight: :bold | ||
)) do | ||
changeset.user.name | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
app/components/work_packages/activities_tab/journals/revision_component.sass
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,7 @@ | ||
.work-packages-activities-tab-revision-component | ||
&--header | ||
min-height: 32px | ||
&--stem-line-container | ||
min-height: 20px | ||
&--stem-line | ||
margin-left: 19px |
Oops, something went wrong.