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

Set activity timestamp to anchor

Kabiru Mwenja9b6c45f4d063
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 2a0c5aa86ca..5546b1e25ac 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
@@ -45,7 +45,11 @@
end
end
header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ if OpenProject::FeatureDecisions.work_package_comment_id_url_active?
+ activity_anchor_link(journal) { journal_updated_at_formatted_time(journal) }
+ else
+ journal_updated_at_formatted_time(journal)
+ end
end
end
header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
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
index 2cbcb6b3688..42c9fc3156f 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.rb
@@ -160,13 +160,21 @@ module WorkPackages
def render_mobile_updated_time(container)
container.with_column do
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ if OpenProject::FeatureDecisions.work_package_comment_id_url_active?
+ activity_anchor_link(journal) { journal_updated_at_formatted_time(journal) }
+ else
+ journal_updated_at_formatted_time(journal)
+ end
end
end
def render_updated_time(container)
container.with_column(mr: 1, classes: "hidden-for-mobile") do
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ if OpenProject::FeatureDecisions.work_package_comment_id_url_active?
+ activity_anchor_link(journal) { journal_updated_at_formatted_time(journal) }
+ else
+ journal_updated_at_formatted_time(journal)
+ end
end
end
@@ -189,6 +197,8 @@ module WorkPackages
end
def render_activity_link(container)
+ return if OpenProject::FeatureDecisions.work_package_comment_id_url_active?
+
container.with_column(
pr: 3,
classes: "work-packages-activities-tab-journals-item-component-details--activity-link-container"
diff --git a/app/components/work_packages/activities_tab/shared_helpers.rb b/app/components/work_packages/activities_tab/shared_helpers.rb
index 4615eaf3525..99bcf81c035 100644
--- a/app/components/work_packages/activities_tab/shared_helpers.rb
+++ b/app/components/work_packages/activities_tab/shared_helpers.rb
@@ -57,7 +57,13 @@ module WorkPackages
"work-packages--activities-tab--index-anchor-name-param": activity_anchor_name
}
)) do
- "##{journal_activity_id(journal)}"
+ block_given? ? yield : "##{journal_activity_id(journal)}"
+ end
+ end
+
+ def journal_updated_at_formatted_time(journal)
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) do
+ format_time(journal.updated_at)
end
end
diff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rb
index d3663823a85..db679e81024 100644
--- a/spec/features/activities/work_package/activities_spec.rb
+++ b/spec/features/activities/work_package/activities_spec.rb
@@ -883,6 +883,8 @@ RSpec.describe "Work package activity", :js, with_flag: { primerized_work_packag
end
describe "scrolls to comment specified in the URL" do
+ include Redmine::I18n
+
context "when sorting set to asc" do
let!(:admin_preferences) { create(:user_preference, user: admin, others: { comments_sorting: :asc }) }
@@ -903,7 +905,7 @@ RSpec.describe "Work package activity", :js, with_flag: { primerized_work_packag
context "with #comment- anchor",
with_flag: { primerized_work_package_activities: true, work_package_comment_id_url: true } do
before do
- visit project_work_package_path(project, work_package.id, "activity", anchor: "comment-1")
+ visit project_work_package_path(project, work_package.id, "activity", anchor: "comment-#{comment_1.id}")
wp_page.wait_for_activity_tab
end
@@ -911,7 +913,7 @@ RSpec.describe "Work package activity", :js, with_flag: { primerized_work_packag
wait_for_auto_scrolling_to_finish
activity_tab.expect_journal_container_at_position(50) # would be at the bottom if no anchor would be provided
- # activity_tab.expect_no_activity_anchor_link TODO: Enable once timestamps converted to anchors
+ activity_tab.expect_activity_anchor_link(text: format_time(comment_1.updated_at))
end
end
end
@@ -944,7 +946,7 @@ RSpec.describe "Work package activity", :js, with_flag: { primerized_work_packag
wait_for_auto_scrolling_to_finish
activity_tab.expect_journal_container_at_bottom # would be at the top if no anchor would be provided
- # activity_tab.expect_no_activity_anchor_link TODO: Enable once timestamps converted to anchors
+ activity_tab.expect_activity_anchor_link(text: format_time(comment_1.updated_at))
end
end
end
diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rb
index 926ee0a82fe..80b25b25a00 100644
--- a/spec/support/components/work_packages/activities.rb
+++ b/spec/support/components/work_packages/activities.rb
@@ -159,10 +159,6 @@ module Components
expect(page).to have_test_selector("activity-anchor-link", text:)
end
- def expect_no_activity_anchor_link
- expect(page).not_to have_test_selector("activity-anchor-link")
- end
-
def add_comment(text: nil, save: true)
if page.find_test_selector("op-open-work-package-journal-form-trigger")
open_new_comment_editor