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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#54015] Update agenda item work package history subtitles (#15196)
Mir Bhatia863ef4ee6efc
diff --git a/app/components/activities/item_component.html.erb b/app/components/activities/item_component.html.erbindex c0d5c6f5dce..79292a100db 100644--- a/app/components/activities/item_component.html.erb+++ b/app/components/activities/item_component.html.erb@@ -42,6 +42,7 @@ See COPYRIGHT and LICENSE files for more details.datetime: @event.event_datetime,is_creation: initial?,is_deletion: deletion?,+ is_work_package: work_package?,journable_type: @event.journal.journable_type))%>diff --git a/app/components/activities/item_component.rb b/app/components/activities/item_component.rbindex e5824bf301f..e01745e4173 100644--- a/app/components/activities/item_component.rb+++ b/app/components/activities/item_component.rb@@ -44,7 +44,7 @@ class Activities::ItemComponent < ViewComponent::Base # rubocop:disable OpenProjreturn if activity?(Project)return if activity_is_from_current_project?- kind = activity_is_from_subproject? ? 'subproject' : 'project'+ kind = activity_is_from_subproject? ? "subproject" : "project"suffix = I18n.t("events.title.#{kind}", name: link_to(@event.project.name, @event.project))"(#{suffix})".html_safe # rubocop:disable Rails/OutputSafetyend@@ -95,6 +95,10 @@ class Activities::ItemComponent < ViewComponent::Base # rubocop:disable OpenProjdata[:deleted]end+ def work_package?+ data[:work_package]+ end+def data@event.data || {}enddiff --git a/app/components/activities/item_subtitle_component.rb b/app/components/activities/item_subtitle_component.rbindex 211d07d797e..f27954e1cd3 100644--- a/app/components/activities/item_subtitle_component.rb+++ b/app/components/activities/item_subtitle_component.rb@@ -29,12 +29,13 @@#++class Activities::ItemSubtitleComponent < ViewComponent::Base- def initialize(user:, datetime:, is_creation:, is_deletion:, journable_type:)+ def initialize(user:, datetime:, is_creation:, is_deletion:, is_work_package:, journable_type:)super()@user = user@datetime = datetime@is_creation = is_creation@is_deletion = is_deletion+ @is_work_package = is_work_package@journable_type = journable_typeend@@ -42,9 +43,9 @@ class Activities::ItemSubtitleComponent < ViewComponent::Basereturn unless @user[- helpers.avatar(@user, size: 'mini'),- helpers.content_tag('span', helpers.link_to_user(@user), class: %w[spot-caption spot-caption_bold])- ].join(' ')+ helpers.avatar(@user, size: "mini"),+ helpers.content_tag("span", helpers.link_to_user(@user), class: %w[spot-caption spot-caption_bold])+ ].join(" ")enddef datetime_html@@ -52,19 +53,27 @@ class Activities::ItemSubtitleComponent < ViewComponent::Baseenddef time_entry?- @journable_type == 'TimeEntry'+ @journable_type == "TimeEntry"enddef i18n_key- i18n_key = 'activity.item.'.dup- i18n_key << (if @is_deletion- 'deleted_'- else- (@is_creation ? 'created_' : 'updated_')- end)- i18n_key << 'by_' if @user- i18n_key << 'on'- i18n_key << '_time_entry' if time_entry?+ i18n_key = +"activity.item."+ i18n_key << (@is_deletion ? deletion_selector : creation_selector)+ i18n_key << "by_" if @user+ i18n_key << "on"+ i18n_key << "_time_entry" if time_entry?i18n_keyend++ def deletion_selector+ @is_work_package ? "removed_" : "deleted_"+ end++ def creation_selector+ if @is_creation+ @is_work_package ? "added_" : "created_"+ else+ "updated_"+ end+ endenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 06a22a130d1..3bbcacf6c02 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1173,6 +1173,10 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}updated_on_time_entry: "logged time updated on %{datetime}"deleted_on: "deleted on %{datetime}"deleted_by_on: "deleted by %{user} on %{datetime}"+ added_on: "added on %{datetime}"+ added_by_on: "added by %{user} on %{datetime}"+ removed_on: "removed on %{datetime}"+ removed_by_on: "removed by %{user} on %{datetime}"parent_without_of: "Subproject"parent_no_longer: "No longer subproject of"time_entry:diff --git a/modules/meeting/app/models/activities/meeting_event_mapper.rb b/modules/meeting/app/models/activities/meeting_event_mapper.rbindex a94198a49af..ccf114f79c7 100644--- a/modules/meeting/app/models/activities/meeting_event_mapper.rb+++ b/modules/meeting/app/models/activities/meeting_event_mapper.rb@@ -75,11 +75,14 @@ class Activities::MeetingEventMapper < Activities::EventMapperparams = mapped_params(journal)agenda_changes.map do |agenda_item_id, changes|+ work_package = named_change(changes, "work_package_id")+params[:data] = {id: agenda_item_id,details: changes,initial: initial_change?(changes),- deleted: deleted_change?(changes)+ deleted: deleted_change?(changes),+ work_package:}params[:event_title] = agenda_item_title(journal, agenda_item_id, changes)@@ -143,7 +146,7 @@ class Activities::MeetingEventMapper < Activities::EventMapper.select { |key, _| key.start_with?("agenda_items_") }.reject { |key, _| key.end_with?("_position") }.each_with_object(Hash.new { |h, k| h[k] = {} }) do |(key, values), changes|- id, _ = key.gsub("agenda_items_", "").split("_", 2)+ id, = key.gsub("agenda_items_", "").split("_", 2)changes[id.to_i][key.to_sym] = valuesendenddiff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rbindex fc299a546ab..506a5176ccc 100644--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb@@ -223,7 +223,7 @@ RSpec.describe "history",history_page.open_history_modalitem = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: work_package.to_s.strip)- expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)# Update linked work package@@ -254,7 +254,7 @@ RSpec.describe "history",item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: changed_wp.to_s.strip)- expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "removed by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)# With a work package linked in another project@@ -273,7 +273,7 @@ RSpec.describe "history",history_page.open_history_modalitem = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)- expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)# Is not visible for view_only_user@@ -283,7 +283,7 @@ RSpec.describe "history",history_page.open_history_modalitem = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))- expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)login_as(user)@@ -293,7 +293,7 @@ RSpec.describe "history",item = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)- expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "removed by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)# Is not visible for view_only_user@@ -303,7 +303,7 @@ RSpec.describe "history",history_page.open_history_modalitem = history_page.first_itemexpect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))- expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "removed by")expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)end@@ -324,17 +324,17 @@ RSpec.describe "history",editor.set_markdown "# Hello there"show_page.in_edit_form(item) do- click_button "Save"+ click_link_or_button "Save"endhistory_page.open_history_modalwithin("li.op-activity-list--item", match: :first) doexpect(page).to have_css("li", text: "Notes set")- click_link "Details"+ click_link_or_button "Details"endexpect(page).to have_current_path /\/journals\/\d+\/diff\/agenda_items_\d+_notes/- expect(page).to have_css('ins.diffmod', text: "# Hello there")+ expect(page).to have_css("ins.diffmod", text: "# Hello there")endit "for a user with no permissions, renders an error", with_settings: { journal_aggregation_time_minutes: 0 } dodiff --git a/spec/components/activities/item_subtitle_component_spec.rb b/spec/components/activities/item_subtitle_component_spec.rbindex 70fe7342015..540b45404d7 100644--- a/spec/components/activities/item_subtitle_component_spec.rb+++ b/spec/components/activities/item_subtitle_component_spec.rb@@ -35,76 +35,84 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component dolet(:datetime) { Time.current }- subject { render_inline(described_class.new(user:, datetime:, is_creation:, is_deletion:, journable_type:)) }+ subject { render_inline(described_class.new(user:, datetime:, is_creation:, is_deletion:, is_work_package:, journable_type:)) }- context 'on creation with a user' do+ context "on creation with a user" dolet(:is_creation) { true }let(:user) { build_stubbed(:user) }- let(:journable_type) { 'WorkPackage' }+ let(:journable_type) { "WorkPackage" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("created by #{user.name} on #{format_time(datetime)}") }end- context 'on creation without a user' do+ context "on creation without a user" dolet(:is_creation) { true }let(:user) { nil }- let(:journable_type) { 'WorkPackage' }+ let(:journable_type) { "WorkPackage" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("created on #{format_time(datetime)}") }end- context 'on update with a user' do+ context "on update with a user" dolet(:is_creation) { false }let(:user) { build_stubbed(:user) }- let(:journable_type) { 'WorkPackage' }+ let(:journable_type) { "WorkPackage" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("updated by #{user.name} on #{format_time(datetime)}") }end- context 'on update without a user' do+ context "on update without a user" dolet(:is_creation) { false }let(:user) { nil }- let(:journable_type) { 'WorkPackage' }+ let(:journable_type) { "WorkPackage" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("updated on #{format_time(datetime)}") }end- context 'on delete with a user' do+ context "on delete with a user" dolet(:is_creation) { false }let(:user) { build_stubbed(:user) }- let(:journable_type) { 'Meeting' }+ let(:journable_type) { "Meeting" }let(:is_deletion) { true }+ let(:is_work_package) { false }it { is_expected.to have_text("deleted by #{user.name} on #{format_time(datetime)}") }end- context 'on delete without a user' do+ context "on delete without a user" dolet(:is_creation) { false }let(:user) { nil }- let(:journable_type) { 'Meeting' }+ let(:journable_type) { "Meeting" }let(:is_deletion) { true }+ let(:is_work_package) { false }it { is_expected.to have_text("deleted on #{format_time(datetime)}") }end- context 'on TimeEntry creation' do+ context "on TimeEntry creation" dolet(:is_creation) { true }let(:user) { build_stubbed(:user) }- let(:journable_type) { 'TimeEntry' }+ let(:journable_type) { "TimeEntry" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("time logged by #{user.name} on #{format_time(datetime)}") }end- context 'on TimeEntry updation' do+ context "on TimeEntry updation" dolet(:is_creation) { false }let(:user) { build_stubbed(:user) }- let(:journable_type) { 'TimeEntry' }+ let(:journable_type) { "TimeEntry" }let(:is_deletion) { false }+ let(:is_work_package) { false }it { is_expected.to have_text("logged time updated by #{user.name} on #{format_time(datetime)}") }end