Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] dev from opf:dev #222

Merged
merged 30 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dfd664b
[#59280] Ensure that the new Activity tab renders quickly also for wo…
jjabari-op Nov 18, 2024
bb8f133
refactored stem rendering for better rendering performance
jjabari-op Nov 18, 2024
8b06a06
introduce deffered loading for older journals
jjabari-op Nov 18, 2024
c6f5f47
simple waiting mechanism in order to wait for anchor to be rendered i…
jjabari-op Nov 18, 2024
ecfb393
build(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /frontend
dependabot[bot] Nov 19, 2024
4f47e3f
[#59391] rework file links to paginated collection
Kharonus Nov 19, 2024
e86d5bd
[#59391] updated API specs for new pagination in file links
Kharonus Nov 19, 2024
6e09479
[#59391] applied PR comments
Kharonus Nov 20, 2024
6c6e7ca
enhanced and used eager loading wrapper in order to avoid n+1, added …
jjabari-op Nov 20, 2024
56ce2ff
limit scope of notification update streams
jjabari-op Nov 20, 2024
17f92db
Merge branch 'release/15.0' into code-maintenance/59280-ensure-that-t…
jjabari-op Nov 20, 2024
7d0b69a
quickly disable the journals API call, which is not required anymore,…
jjabari-op Nov 20, 2024
d2c72d6
Merge branch 'release/15.0' into code-maintenance/59280-ensure-that-t…
jjabari-op Nov 21, 2024
5ca7abe
Update app/controllers/work_packages/activities_tab_controller.rb
jjabari-op Nov 21, 2024
fbb39b4
revert angular based comment loading removal, breaks specs, needs to …
jjabari-op Nov 21, 2024
2ba1b5e
tests[Op#59280]: add unit tests for eager loading wrapper
akabiru Nov 21, 2024
292a116
resolve Performance/CollectionLiteralInLoop
akabiru Nov 21, 2024
8ecfc43
Merge pull request #17230 from opf/bug/59391-files-count-badge-missin…
Kharonus Nov 21, 2024
d9c81b9
Accept fingerprint as present
oliverguenther Nov 20, 2024
d61ab2e
Merge pull request #17224 from opf/code-maintenance/59280-ensure-that…
jjabari-op Nov 21, 2024
92da8d9
update locales from crowdin [ci skip]
openprojectci Nov 22, 2024
424d325
build(deps-dev): bump rubocop-performance from 1.22.1 to 1.23.0
dependabot[bot] Nov 22, 2024
782c740
build(deps): bump aws-sdk-s3 from 1.170.1 to 1.173.0
dependabot[bot] Nov 22, 2024
ea386ef
build(deps): bump spreadsheet from 1.3.1 to 1.3.3
dependabot[bot] Nov 22, 2024
a5c6126
Merge pull request #17254 from opf/dependabot/bundler/dev/spreadsheet…
ulferts Nov 22, 2024
9c21616
Merge pull request #17253 from opf/dependabot/bundler/dev/aws-sdk-s3-…
ulferts Nov 22, 2024
1381cb0
adapt spec expectation to bumped json version
ulferts Nov 22, 2024
91509bb
Merge remote-tracking branch 'origin/merge-release/15.0-2024112203412…
ulferts Nov 22, 2024
7a29d8d
Merge pull request #17226 from opf/dependabot/npm_and_yarn/frontend/c…
ulferts Nov 22, 2024
8aaadc4
Merge pull request #17252 from opf/dependabot/bundler/dev/rubocop-per…
ulferts Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,16 @@ GEM
awesome_nested_set (3.7.0)
activerecord (>= 4.0.0, < 8.0)
aws-eventstream (1.3.0)
aws-partitions (1.1005.0)
aws-partitions (1.1012.0)
aws-sdk-core (3.212.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.95.0)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.170.1)
aws-sdk-s3 (1.173.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -689,7 +689,7 @@ GEM
reline (>= 0.4.2)
iso8601 (0.13.0)
jmespath (1.6.2)
json (2.8.1)
json (2.8.2)
json-jwt (1.16.7)
activesupport (>= 4.2)
aes_key_wrap
Expand Down Expand Up @@ -1028,15 +1028,15 @@ GEM
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.35.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-openproject (0.2.0)
rubocop
rubocop-performance (1.22.1)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.27.0)
Expand Down Expand Up @@ -1090,7 +1090,7 @@ GEM
multi_json (~> 1.10)
simpleidn (0.2.3)
smart_properties (1.17.0)
spreadsheet (1.3.1)
spreadsheet (1.3.3)
bigdecimal
ruby-ole
spring (4.2.1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
<%=
content_tag("turbo-frame", id: "work-package-activities-tab-content") do
flex_layout(classes: "work-packages-activities-tab-index-component", mb: [5, 5, 5, 5, 0]) do |activties_tab_wrapper_container|
activties_tab_wrapper_container.with_row(classes: "work-packages-activities-tab-index-component--errors") do
render(
WorkPackages::ActivitiesTab::ErrorStreamComponent.new
)
end
activties_tab_wrapper_container.with_row do
component_wrapper(data: wrapper_data_attributes) do
flex_layout do |activties_tab_container|
activties_tab_container.with_row(mb: 2) do
render(
WorkPackages::ActivitiesTab::Journals::FilterAndSortingComponent.new(
work_package:,
filter:
)
)
end
activties_tab_container.with_row(flex_layout: true, mt: 3) do |journals_wrapper_container|
journals_wrapper_container.with_row(
classes: "work-packages-activities-tab-index-component--journals-container work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation",
data: { "work-packages--activities-tab--index-target": "journalsContainer" }
) do
unless deferred
content_tag("turbo-frame", id: "work-package-activities-tab-content") do
flex_layout(classes: "work-packages-activities-tab-index-component", mb: [5, 5, 5, 5, 0]) do |activties_tab_wrapper_container|
activties_tab_wrapper_container.with_row(classes: "work-packages-activities-tab-index-component--errors") do
render(
WorkPackages::ActivitiesTab::ErrorStreamComponent.new
)
end
activties_tab_wrapper_container.with_row do
component_wrapper(data: wrapper_data_attributes) do
flex_layout do |activties_tab_container|
activties_tab_container.with_row(mb: 2) do
render(
WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package:, filter:)
WorkPackages::ActivitiesTab::Journals::FilterAndSortingComponent.new(
work_package:,
filter:
)
)
end
if adding_comment_allowed?
activties_tab_container.with_row(flex_layout: true, mt: 3) do |journals_wrapper_container|
journals_wrapper_container.with_row(
classes: "work-packages-activities-tab-index-component--input-container work-packages-activities-tab-index-component--input-container_sort-#{journal_sorting}",
mt: 3,
mb: [3, nil, nil, nil, 0],
pt: 2,
pb: 2,
pl: 3,
pr: [3, nil, nil, nil, 2],
border: [nil, nil, nil, nil, :top],
border_radius: [2, nil, nil, nil, 0],
bg: :subtle
classes: "work-packages-activities-tab-index-component--journals-container work-packages-activities-tab-index-component--journals-container_with-initial-input-compensation",
data: { "work-packages--activities-tab--index-target": "journalsContainer" }
) do
render(
WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)
WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package:, filter:)
)
end
if adding_comment_allowed?
journals_wrapper_container.with_row(
classes: "work-packages-activities-tab-index-component--input-container work-packages-activities-tab-index-component--input-container_sort-#{journal_sorting}",
mt: 3,
mb: [3, nil, nil, nil, 0],
pt: 2,
pb: 2,
pl: 3,
pr: [3, nil, nil, nil, 2],
border: [nil, nil, nil, nil, :top],
border_radius: [2, nil, nil, nil, 0],
bg: :subtle
) do
render(
WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)
)
end
end
end
end
end
end
end
end
else
render(
WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package:, filter:, deferred:)
)
end
%>
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ class IndexComponent < ApplicationComponent
include OpTurbo::Streamable
include WorkPackages::ActivitiesTab::SharedHelpers

def initialize(work_package:, last_server_timestamp:, filter: :all)
def initialize(work_package:, last_server_timestamp:, filter: :all, deferred: false)
super

@work_package = work_package
@filter = filter
@last_server_timestamp = last_server_timestamp
@deferred = deferred
end

private

attr_reader :work_package, :filter, :last_server_timestamp
attr_reader :work_package, :filter, :last_server_timestamp, :deferred

def wrapper_data_attributes
stimulus_controller = "work-packages--activities-tab--index"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
<%=
component_wrapper(class: "work-packages-activities-tab-journals-index-component") do
flex_layout(data: { test_selector: "op-wp-journals-#{filter}-#{journal_sorting}" }) 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|
if empty_state?
journals_index_container.with_row(mt: 2, mb: 3) do
render(
WorkPackages::ActivitiesTab::Journals::EmptyComponent.new
)
unless deferred
component_wrapper(class: "work-packages-activities-tab-journals-index-component") do
flex_layout(data: { test_selector: "op-wp-journals-#{filter}-#{journal_sorting}" }) 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|
if empty_state?
journals_index_container.with_row(mt: 2, mb: 3) do
render(
WorkPackages::ActivitiesTab::Journals::EmptyComponent.new
)
end
end

if !journal_sorting_desc? && journals.count > MAX_RECENT_JOURNALS
journals_index_container.with_row do
helpers.turbo_frame_tag("work-package-activities-tab-content-older-journals", src: work_package_activities_path(work_package, filter:, deferred: true))
end
end
end

journals.each do |journal|
journals_index_container.with_row do
render(WorkPackages::ActivitiesTab::Journals::ItemComponent.new(
journal:, filter:,
grouped_emoji_reactions: wp_journals_grouped_emoji_reactions[journal.id]
))
recent_journals.each do |journal|
journals_index_container.with_row do
render(WorkPackages::ActivitiesTab::Journals::ItemComponent.new(
journal:, filter:,
grouped_emoji_reactions: wp_journals_grouped_emoji_reactions[journal.id]
))
end
end

if journal_sorting_desc? && journals.count > MAX_RECENT_JOURNALS
journals_index_container.with_row do
helpers.turbo_frame_tag("work-package-activities-tab-content-older-journals", src: work_package_activities_path(work_package, filter:, deferred: true))
end
end
end
end
end

unless empty_state? || journal_sorting_desc?
journals_index_wrapper_container
.with_row(classes: "work-packages-activities-tab-journals-index-component--stem-connection")
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
else
helpers.turbo_frame_tag("work-package-activities-tab-content-older-journals") do
flex_layout do |older_journals_container|
older_journals.each do |journal|
older_journals_container.with_row do
render(WorkPackages::ActivitiesTab::Journals::ItemComponent.new(
journal:, filter:,
grouped_emoji_reactions: wp_journals_grouped_emoji_reactions[journal.id]
))
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ module WorkPackages
module ActivitiesTab
module Journals
class IndexComponent < ApplicationComponent
MAX_RECENT_JOURNALS = 30

include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
include WorkPackages::ActivitiesTab::SharedHelpers

def initialize(work_package:, filter: :all)
def initialize(work_package:, filter: :all, deferred: false)
super

@work_package = work_package
@filter = filter
@deferred = deferred
end

private

attr_reader :work_package, :filter
attr_reader :work_package, :filter, :deferred

def insert_target_modified?
true
Expand All @@ -60,16 +63,48 @@ def journal_sorting_desc?
journal_sorting == "desc"
end

def journals
def base_journals
work_package
.journals
.includes(:user, :notifications)
.includes(
:user,
:customizable_journals,
:attachable_journals,
:storable_journals,
:notifications
)
.reorder(version: journal_sorting)
.with_sequence_version
end

def journals
API::V3::Activities::ActivityEagerLoadingWrapper.wrap(base_journals)
end

def recent_journals
recent_ones = if journal_sorting_desc?
base_journals.first(MAX_RECENT_JOURNALS)
else
base_journals.last(MAX_RECENT_JOURNALS)
end

API::V3::Activities::ActivityEagerLoadingWrapper.wrap(recent_ones)
end

def older_journals
older_ones = if journal_sorting_desc?
base_journals.offset(MAX_RECENT_JOURNALS)
else
total = base_journals.count
limit = [total - MAX_RECENT_JOURNALS, 0].max
base_journals.limit(limit)
end

API::V3::Activities::ActivityEagerLoadingWrapper.wrap(older_ones)
end

def journal_with_notes
journals.where.not(notes: "")
base_journals.where.not(notes: "")
end

def wp_journals_grouped_emoji_reactions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def updated?
end

def has_unread_notifications?
journal.notifications.where(read_ian: false, recipient_id: User.current.id).any?
journal.has_unread_notifications_for_user?(User.current)
end

def notification_on_details?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
when :only_comments
render_empty_line(details_container) unless journal.notes.blank? && !journal.noop?
when :only_changes
if journal.details.any?
if has_details?
render_details_header(details_container)
render_details(details_container)
end
else
if journal.details.any?
if has_details?
if journal.notes.present?
render_details(details_container)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def wrapper_uniq_by
journal.id
end

def journal_details
@journal_details ||= journal.details
end

def has_details?
@has_details ||= journal_details.any?
end

def render_details_header(details_container)
details_container.with_row(
flex_layout: true,
Expand Down Expand Up @@ -223,7 +231,7 @@ def skip_rendering_details?
end

def render_journal_details(details_container_inner)
journal.details.each do |detail|
journal_details.each do |detail|
rendered_detail = journal.render_detail(detail)
render_single_detail(details_container_inner, rendered_detail) if rendered_detail.present?
end
Expand Down
Loading
Loading