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

implemented github PR style

Jonas Jabari66bab815e42b
diff --git a/app/components/_index.sass b/app/components/_index.sass
index 0c708e0fab3..887a4542f48 100644
--- a/app/components/_index.sass
+++ b/app/components/_index.sass
@@ -1,6 +1,7 @@
@import "work_packages/activities_tab/index_component"
@import "work_packages/activities_tab/journals/new_component"
@import "work_packages/activities_tab/journals/item_component/edit"
+@import "work_packages/activities_tab/journals/item_component/details"
@import "shares/modal_body_component"
@import "shares/invite_user_form_component"
@import "work_packages/progress/modal_body_component"
diff --git a/app/components/work_packages/activities_tab/index_component.html.erb b/app/components/work_packages/activities_tab/index_component.html.erb
index 811b7cc4aa0..10af70e19db 100644
--- a/app/components/work_packages/activities_tab/index_component.html.erb
+++ b/app/components/work_packages/activities_tab/index_component.html.erb
@@ -10,7 +10,7 @@
)
)
end
- activties_tab_container.with_row(flex_layout: true) do |journals_wrapper_container|
+ activties_tab_container.with_row(flex_layout: true, mt: 3) do |journals_wrapper_container|
journals_wrapper_container.with_row(
id: "journals-container",
classes: "with-initial-input-compensation",
diff --git a/app/components/work_packages/activities_tab/journals/day_component.html.erb b/app/components/work_packages/activities_tab/journals/day_component.html.erb
index b0e44ce2c33..3b547089447 100644
--- a/app/components/work_packages/activities_tab/journals/day_component.html.erb
+++ b/app/components/work_packages/activities_tab/journals/day_component.html.erb
@@ -1,9 +1,9 @@
<%=
- component_wrapper do
+ component_wrapper(class: "work-packages-activities-tab-journals-day-component") do
flex_layout do |day_container|
- day_container.with_row(my:2) do
- render(Primer::Beta::Text.new(color: :muted)) { format_activity_day(day_as_date) }
- end
+ # day_container.with_row(my:2) do
+ # render(Primer::Beta::Text.new(color: :muted)) { format_activity_day(day_as_date) }
+ # end
day_container.with_row do
flex_layout(id: insert_target_modifier_id) do |journals_of_day_container|
journals.each do |journal|
diff --git a/app/components/work_packages/activities_tab/journals/item_component.html.erb b/app/components/work_packages/activities_tab/journals/item_component.html.erb
index 7b92abdd9a4..0a8d45e5a9d 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component.html.erb
@@ -1,72 +1,79 @@
<%=
- component_wrapper(data: wrapper_data_attributes) do
- render(Primer::Box.new(id: "activity-#{journal.version}", border: true, border_radius: 2, p: 3, my: 2)) do
- flex_layout do |journal_container|
- journal_container.with_row(flex_layout: true, align_items: :center, justify_content: :space_between) do |header_container|
- header_container.with_column(flex_layout: true) do |header_start_container|
- header_start_container.with_column(mr: 2) do
- render Users::AvatarComponent.new(user: journal.user, show_name: false)
- end
- header_start_container.with_column(flex_layout: true) do |header_text_container|
- header_text_container.with_row do
- render(Primer::Beta::Link.new(
- href: user_url(journal.user),
- target: "_blank",
- scheme: :primary,
- underline: false,
- font_weight: :bold
- )) do
- journal.user.name
- end
- end
- header_text_container.with_row(flex_layout: true) do |header_text_timestamp_container|
- header_text_timestamp_container.with_column(mr: 1) do
- render(Primer::Beta::Text.new(color: :subtle, mt: 1, font_size: :small)) do
- if updated?
- I18n.t("attributes.updated_at")
+ component_wrapper(data: wrapper_data_attributes, class: "work-packages-activities-tab-journals-item-component") do
+ flex_layout do |journal_container|
+ if journal.notes.present?
+ journal_container.with_row do
+ render(border_box_container(id: "activity-#{journal.version}", padding: :condensed)) do |border_box_component|
+ border_box_component.with_header(px: 2, py: 0) do
+ flex_layout(align_items: :center, justify_content: :space_between) do |header_container|
+ header_container.with_column(flex_layout: true) do |header_start_container|
+ header_start_container.with_column(mr: 2) do
+ render Users::AvatarComponent.new(user: journal.user, show_name: false, size: :mini)
+ end
+ header_start_container.with_column(mr: 1) do
+ render(Primer::Beta::Link.new(
+ href: user_url(journal.user),
+ target: "_blank",
+ scheme: :primary,
+ underline: false,
+ font_weight: :bold
+ )) do
+ journal.user.name
+ end
+ end
+ header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
+ if journal.initial?
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ t("activities.work_packages.activity_tab.created_on")
+ end
else
- I18n.t("attributes.created_at")
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ t("activities.work_packages.activity_tab.commented_on")
+ end
end
end
+ header_start_container.with_column(mr: 1) do
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ end
end
- header_text_timestamp_container.with_column do
- render(Primer::Beta::Text.new(color: :subtle, mt: 1, font_size: :small)) { format_time(journal.updated_at) }
+ header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
+ if has_unread_notifications?
+ header_end_container.with_column(mr: 2, pt: 1) do
+ bubble_html
+ end
+ end
+ header_end_container.with_column do
+ render(Primer::Beta::Link.new(
+ href: activity_anchor,
+ scheme: :secondary,
+ underline: false,
+ font_size: :small,
+ data: { turbo: false }
+ )) do
+ "##{journal.version}"
+ end
+ end
+ header_end_container.with_column(ml: 2) do
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal",
+ 'aria-label': I18n.t(:button_actions),
+ scheme: :invisible)
+ copy_url_action_item(menu)
+ edit_action_item(menu) if editable?
+ quote_action_item(menu) if journal.notes.present?
+ end
+ end
end
end
end
- end
- header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
- if has_unread_notifications?
- header_end_container.with_column(mr: 2, pt: 1) do
- bubble_html
- end
- end
- header_end_container.with_column do
- render(Primer::Beta::Link.new(
- href: activity_anchor,
- scheme: :secondary,
- underline: false,
- font_size: :small,
- data: { turbo: false }
- )) do
- "##{journal.version}"
- end
- end
- header_end_container.with_column(ml: 2) do
- render(Primer::Alpha::ActionMenu.new) do |menu|
- menu.with_show_button(icon: "kebab-horizontal",
- 'aria-label': I18n.t(:button_actions),
- scheme: :invisible)
- copy_url_action_item(menu)
- edit_action_item(menu) if editable?
- quote_action_item(menu) if journal.notes.present?
- end
+ border_box_component.with_body do
+ content
end
end
end
- journal_container.with_row do
- content
- end
+ end
+ journal_container.with_row do
+ render(WorkPackages::ActivitiesTab::Journals::ItemComponent::Details.new(journal:, has_unread_notifications: notification_on_details?))
end
end
end
diff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rb
index 94dc2dacc63..7b7042b8231 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component.rb
@@ -92,6 +92,10 @@ module WorkPackages
journal.notifications.where(read_ian: false, recipient_id: User.current.id).any?
end
+ def notification_on_details?
+ has_unread_notifications? && journal.notes.blank?
+ end
+
def copy_url_action_item(menu)
menu.with_item(label: t("button_copy_link_to_clipboard"),
tag: :button,
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
new file mode 100644
index 00000000000..384c3c0a532
--- /dev/null
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
@@ -0,0 +1,19 @@
+<%=
+ component_wrapper(class: "work-packages-activities-tab-journals-item-component-details") do
+ if journal.details.any?
+ flex_layout(my: 0, border: :left, classes: "details-container") do |details_container|
+ if journal.notes.present?
+ render_details(details_container)
+ else
+ render_details_header(details_container)
+ render_details(details_container)
+ end
+ end
+ else
+ flex_layout(my: 0, border: :left, classes: "details-container details-container--empty--#{journal_sorting}") do |details_container|
+ # empty row to render the flex layout with its minimal height
+ render_empty_line(details_container)
+ end
+ end
+ end
+%>
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.rb b/app/components/work_packages/activities_tab/journals/item_component/details.rb
new file mode 100644
index 00000000000..776d8db809e
--- /dev/null
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.rb
@@ -0,0 +1,157 @@
+#-- 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::Details < ApplicationComponent
+ include ApplicationHelper
+ include AvatarHelper
+ include JournalFormatter
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ def initialize(journal:, has_unread_notifications: false)
+ super
+
+ @journal = journal
+ @has_unread_notifications = has_unread_notifications
+ end
+
+ private
+
+ attr_reader :journal, :has_unread_notifications
+
+ def wrapper_uniq_by
+ journal.id
+ end
+
+ def render_details_header(details_container)
+ details_container.with_row(flex_layout: true, align_items: :center,
+ justify_content: :space_between, classes: "details-header-container") do |header_container|
+ header_container.with_column(flex_layout: true, align_items: :center) do |header_start_container|
+ header_start_container.with_column(mr: 2, classes: "timeline-icon") do
+ if journal.initial?
+ render Primer::Beta::Octicon.new(icon: "diff-added", size: :small, "aria-label": "Add", color: :subtle)
+ else
+ render Primer::Beta::Octicon.new(icon: "diff-modified", size: :small, "aria-label": "Change", color: :subtle)
+ end
+ end
+ header_start_container.with_column(mr: 2) do
+ render Users::AvatarComponent.new(user: journal.user, show_name: false, size: :mini)
+ end
+ header_start_container.with_column(mr: 1) do
+ render(Primer::Beta::Link.new(
+ href: user_url(journal.user),
+ target: "_blank",
+ scheme: :primary,
+ underline: false,
+ font_weight: :bold
+ )) do
+ journal.user.name
+ end
+ end
+ header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
+ if journal.initial?
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ t("activities.work_packages.activity_tab.created_on")
+ end
+ else
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ t("activities.work_packages.activity_tab.changed_on")
+ end
+ end
+ end
+ header_start_container.with_column(mr: 1) do
+ render(Primer::Beta::Text.new(color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ end
+ end
+ header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
+ if has_unread_notifications
+ header_end_container.with_column(mr: 2, pt: 1) do
+ bubble_html
+ end
+ end
+ header_end_container.with_column(pr: 3) do
+ render(Primer::Beta::Link.new(
+ href: activity_anchor,
+ scheme: :secondary,
+ underline: false,
+ font_size: :small,
+ data: { turbo: false }
+ )) do
+ "##{journal.version}"
+ end
+ end
+ end
+ end
+ end
+
+ def render_details(details_container)
+ return if journal.initial? && journal_sorting == "desc"
+
+ details_container.with_row(flex_layout: true, pt: 1, pb: 3) do |details_container_inner|
+ if journal.initial?
+ render_empty_line(details_container_inner)
+ else
+ journal.details.each do |detail|
+ details_container_inner.with_row(flex_layout: true, my: 1, align_items: :flex_start) do |detail_container|
+ detail_container.with_column(classes: "detail-stem-line")
+ detail_container.with_column(pl: 1, font_size: :small) do
+ render(Primer::Beta::Text.new) { journal.render_detail(detail) }
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def render_empty_line(details_container)
+ details_container.with_row(my: 1, font_size: :small, classes: "empty-line")
+ end
+
+ def bubble_html
+ "
+ <span
+ class=\"comments-number--bubble op-bubble op-bubble_mini\"
+ data-test-selector=\"user-activity-bubble\"
+ ></span>
+ ".html_safe
+ end
+
+ def activity_anchor
+ "#activity-#{journal.version}"
+ end
+
+ def journal_sorting
+ User.current.preference&.comments_sorting || "desc"
+ end
+ end
+ end
+ end
+end
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.sass b/app/components/work_packages/activities_tab/journals/item_component/details.sass
new file mode 100644
index 00000000000..8e838bfd807
--- /dev/null
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.sass
@@ -0,0 +1,30 @@
+.work-packages-activities-tab-journals-item-component-details
+ .details-container
+ margin-left: 19px
+ min-height: 20px
+ .details-container--empty--last--asc
+ display: none!important
+ .details-header-container
+ margin-left: -14px
+ .timeline-icon
+ background-color: var(--bgColor-muted)
+ border-radius: 50%
+ width: 28px
+ height: 28px
+ text-align: center
+ padding-top: 3px
+ .empty-line
+ margin-top: 0px!important
+ margin-bottom: 0px!important
+ .detail-stem-line
+ position: relative
+ width: 20px
+ .detail-stem-line::before
+ content: ""
+ position: absolute
+ top: 10px
+ left: 0
+ width: 100%
+ height: var(--borderWidth-thin, 1px)
+ background-color: var(--borderColor-default)
+ transform: translateY(-50%)
\ No newline at end of file
diff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb
index 3fae4360c28..47bbd8e0bf8 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb
@@ -1,6 +1,6 @@
<%=
component_wrapper(class: "work-packages-activities-tab-journals-item-component-edit") do
- render(Primer::Box.new(mt: 3)) do
+ render(Primer::Box.new(my: 3)) do
primer_form_with(
id: "work-package-journal-form",
model: journal,
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..e633da63840 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
@@ -3,21 +3,12 @@
if journal.notes.present? || (journal.details.any? && !journal.initial?)
flex_layout do |journal_container|
if journal.notes.present?
- journal_container.with_row(mt: 3) do
+ journal_container.with_row do
render(Primer::Box.new(mt: 1)) do
format_text(journal, :notes)
end
end
end
- if journal.details.any? && !journal.initial?
- journal_container.with_row(flex_layout: true, border_radius: 2, p: 3, my: 3, bg: :subtle) do |details_container|
- journal.details.each do |detail|
- details_container.with_row(mt: 1, font_size: :small) do
- render(Primer::Beta::Text.new) { journal.render_detail(detail) }
- end
- end
- end
- end
end
end
end
diff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rb
index 307d1ab2f39..1f750a604bd 100644
--- a/app/controllers/work_packages/activities_tab_controller.rb
+++ b/app/controllers/work_packages/activities_tab_controller.rb
@@ -104,6 +104,17 @@ class WorkPackages::ActivitiesTabController < ApplicationController
###
if call.success? && call.result
+ if call.result.initial?
+ # we need to update the whole item component for an initial journal entry
+ # and not just the show part as happens in the time based update
+ # as this part is not rendered for initial journal
+ update_via_turbo_stream(
+ component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(
+ journal: call.result,
+ state: :show
+ )
+ )
+ end
generate_time_based_update_streams(params[:last_update_timestamp], params[:filter])
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 881420c0bb7..40672ae75b2 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -43,6 +43,9 @@ en:
label_sort_desc: "Newest on top"
label_type_to_comment: "Type here to comment"
label_submit_comment: "Submit comment"
+ commented_on: "commented on"
+ changed_on: "made changes on"
+ created_on: "created on"
admin:
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index 014769294a0..097eb712e87 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -36,6 +36,7 @@ export default class IndexController extends Controller {
connect() {
this.setLocalStorageKey();
this.setLastUpdateTimestamp();
+ this.hideLastPartOfTimeLineStem();
this.setupEventListeners();
this.handleInitialScroll();
this.startPolling();
@@ -109,6 +110,7 @@ export default class IndexController extends Controller {
const text = await response.text();
Turbo.renderStreamMessage(text);
this.setLastUpdateTimestamp();
+ this.hideLastPartOfTimeLineStem();
}
}
@@ -319,6 +321,7 @@ export default class IndexController extends Controller {
this.journalsContainerTarget,
this.sortingValue === 'asc',
);
+ this.hideLastPartOfTimeLineStem();
}, 100);
}
}
@@ -339,4 +342,17 @@ export default class IndexController extends Controller {
setLastUpdateTimestamp() {
this.lastUpdateTimestamp = new Date().toISOString();
}
+
+ hideLastPartOfTimeLineStem() {
+ // TODO: I wasn't able to find a pure CSS solution
+ // Didn't want to identify on server-side which element is last in the list in order to avoid n+1 queries
+ // happy to get rid of this hacky JS solution!
+ this.element.querySelectorAll('.details-container--empty--last--asc').forEach((container) => container.classList.remove('details-container--empty--last--asc'));
+
+ const containers = this.element.querySelectorAll('.details-container--empty--asc');
+ if (containers.length > 0) {
+ const lastContainer = containers[containers.length - 1] as HTMLElement;
+ lastContainer.classList.add('details-container--empty--last--asc');
+ }
+ }
}