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
Render user activity list like in project activity
Christophe Bliard2bde2c22d0a1
diff --git a/app/components/activity_item_component.html.erb b/app/components/activity_item_component.html.erbindex fe153ce65d3..1a035af67a2 100644--- a/app/components/activity_item_component.html.erb+++ b/app/components/activity_item_component.html.erb@@ -1,24 +1,24 @@-<li class="op-project-activity-list--item">- <div class="op-project-activity-list--item-title">+<li class="op-activity-list--item">+ <div class="op-activity-list--item-title"><%= link_to format_activity_title(@event.event_title), @event.event_path %><% if display_belonging_project? -%>(Project: <%= content_tag('span', link_to(@event.project.name, @event.project), class: 'project') %>)<% end -%></div>- <div class="op-project-activity-list--item-subtitle">+ <div class="op-activity-list--item-subtitle"><%= @journal.initial? ? "created by" : "updated by" %><%= avatar(@event.event_author, size: 'mini') %> <span class="spot-caption spot-caption_bold"><%= link_to_user(@event.event_author) %></span>on <%= format_time(@event.event_datetime.to_time, true) %></div><% if @event.event_description.present? -%>- <div class="op-project-activity-list--item-description">+ <div class="op-activity-list--item-description"><%= truncate_formatted_text(@event.event_description) %></div><% end -%><% if show_details? -%>- <ul class="op-project-activity-list--item-details">+ <ul class="op-activity-list--item-details"><% rendered_details.each do |detail| -%>- <li class="op-project-activity-list--item-detail"><%= detail %></li>+ <li class="op-activity-list--item-detail"><%= detail %></li><% end -%></ul><% end -%>diff --git a/app/components/activity_item_component.rb b/app/components/activity_item_component.rbindex 704dbe47a32..141a993db69 100644--- a/app/components/activity_item_component.rb+++ b/app/components/activity_item_component.rb@@ -30,7 +30,6 @@class ActivityItemComponent < ViewComponent::Basedelegate :avatar,- :format_activity_title,:format_time,:link_to_user,:truncate_formatted_text,@@ -57,4 +56,8 @@ class ActivityItemComponent < ViewComponent::Base.map { |detail| @journal.render_detail(detail) }.compactend++ def format_activity_title(text)+ helpers.truncate_single_line(text, length: 100)+ endenddiff --git a/app/components/activity_list_component.html.erb b/app/components/activity_list_component.html.erbindex 54460e70275..bcc67a5beda 100644--- a/app/components/activity_list_component.html.erb+++ b/app/components/activity_list_component.html.erb@@ -1,4 +1,4 @@-<ul class="op-project-activity-list">+<ul class="op-activity-list"><% @events.each do |event| -%><% journal = @journals_by_id[event.event_id] -%><%= render(ActivityItemComponent.new(event:, journal:)) %>diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 8f3623f27b3..b730c42ef6d 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -76,7 +76,6 @@ class UsersController < ApplicationController.visible(current_user)events = Activities::Fetcher.new(User.current, author: @user).events(nil, nil, limit: 10)- @events_by_day = events.group_by { |e| e.event_datetime.to_date }if !current_user.allowed_to_globally?(:manage_user) &&(!(@user.active? ||@@ -85,11 +84,24 @@ class UsersController < ApplicationControllerrender_404elserespond_to do |format|- format.html { render layout: 'no_menu' }+ format.html do+ show_respond_html(events)+ endendendend+ def show_respond_html(events)+ @events_by_day = events.group_by { |e| e.event_datetime.to_date }+ @journals_by_id = Journal+ .includes(:data, :customizable_journals, :attachable_journals, :bcf_comment)+ .find(events.pluck(:event_id))+ .then { |journals| ::API::V3::Activities::ActivityEagerLoadingWrapper.wrap(journals) }+ .index_by(&:id)++ render layout: 'no_menu'+ end+def new@user = User.new(language: Setting.default_language)enddiff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rbdeleted file mode 100644index 28ba29c7e59..00000000000--- a/app/helpers/activity_helper.rb+++ /dev/null@@ -1,13 +0,0 @@-module ActivityHelper- def event_icon(event)- # meeting_agenda and meeting_minutes- if event.event_type.start_with?('meeting')- 'meetings'- # project_attributes- elsif event.event_type.start_with?('project')- 'projects'- else- event.event_type- end- end-enddiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex f078aec7fb5..6632c3e848e 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -101,10 +101,6 @@ module ApplicationHelperlink_to I18n.t(:button_delete), url, optionsend- def format_activity_title(text)- h(truncate_single_line(text, length: 100))- end-def format_activity_day(date)date == User.current.today ? I18n.t(:label_today).titleize : format_date(date)enddiff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erbindex 76633ec687f..d3d4cef5f43 100644--- a/app/views/activities/index.html.erb+++ b/app/views/activities/index.html.erb@@ -33,9 +33,9 @@ See COPYRIGHT and LICENSE files for more details.subtitle: t(:label_date_from_to, start: format_date(@date_to - @days), end: format_date(@date_to-1))%>-<div class="op-project-activity-days">+<div class="op-activity-days"><% @events_by_day.sort_by { |day, _events| day }.reverse_each do |day, events| %>- <h3 class="op-project-activity-days--header"><%= format_activity_day(day) %></h3>+ <h3 class="op-activity-days--header"><%= format_activity_day(day) %></h3><%= render(ActivityListComponent.new(events:, journals_by_id: @journals_by_id)) %><% end -%>diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erbindex 74a0984731e..48754937f9b 100644--- a/app/views/users/show.html.erb+++ b/app/views/users/show.html.erb@@ -80,24 +80,11 @@ See COPYRIGHT and LICENSE files for more details.<p><%=t(:label_reported_work_packages)%>: <%= @user.reported_work_package_count %></p>- <div id="activity">- <% @events_by_day.keys.sort.reverse.each do |day| %>- <h4><%= format_activity_day(day) %></h4>- <ul class="generic-list">- <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>- <li class="<%= e.event_type %>">- <div class="title">- <%= icon_wrapper("icon-context icon-#{event_icon(e)}", e.event_name) %>- <span class="time"><%= format_time(e.event_datetime, false) %></span>- <%= content_tag('span', h(e.project), class: 'project') %>- <%= link_to format_activity_title(e.event_title), e.event_url %>- </div>- <div class="description">- <%= truncate_formatted_text(e.event_description) %>- </div>- </li>- <% end -%>- </ul>+ <div id="activity" class="op-activity-days">+ <% @events_by_day.sort_by { |day, _events| day }.reverse_each do |day, events| -%>+ <h4 class="op-activity-days--header"><%= format_activity_day(day) %></h3>++ <%= render(ActivityListComponent.new(events:, journals_by_id: @journals_by_id)) %><% end -%></div>diff --git a/frontend/src/global_styles/content/_project_activity_days.sass b/frontend/src/global_styles/content/_activity_days.sasssimilarity index 89%rename from frontend/src/global_styles/content/_project_activity_days.sassrename to frontend/src/global_styles/content/_activity_days.sassindex d43112964f6..e456151c3a1 100644--- a/frontend/src/global_styles/content/_project_activity_days.sass+++ b/frontend/src/global_styles/content/_activity_days.sass@@ -1,4 +1,4 @@-.op-project-activity-days+.op-activity-daysdisplay: flexflex-direction: columnmargin: 0diff --git a/frontend/src/global_styles/content/_project_activity_list.sass b/frontend/src/global_styles/content/_activity_list.sasssimilarity index 96%rename from frontend/src/global_styles/content/_project_activity_list.sassrename to frontend/src/global_styles/content/_activity_list.sassindex df816b299bf..140e1229542 100644--- a/frontend/src/global_styles/content/_project_activity_list.sass+++ b/frontend/src/global_styles/content/_activity_list.sass@@ -1,4 +1,4 @@-.op-project-activity-list+.op-activity-listdisplay: flexflex-direction: columnlist-style: nonediff --git a/frontend/src/global_styles/content/_index.sass b/frontend/src/global_styles/content/_index.sassindex 3fee075bc6c..5497c4a6765 100644--- a/frontend/src/global_styles/content/_index.sass+++ b/frontend/src/global_styles/content/_index.sass@@ -35,7 +35,6 @@@import attributes_group@import information_section@import widget_box-@import list@import work_packages@import table@import tables@@ -75,8 +74,8 @@@import version@import project_status@import sidebar-@import project_activity_list-@import project_activity_days+@import activity_list+@import activity_days@import menus/menu_blocks@import editor/indexdiff --git a/frontend/src/global_styles/content/_list.lsg b/frontend/src/global_styles/content/_list.lsgdeleted file mode 100644index fd718ad250c..00000000000--- a/frontend/src/global_styles/content/_list.lsg+++ /dev/null@@ -1,49 +0,0 @@-# Generic lists--```-<ul class="generic-list">- <li class="work-package-edit">- <div class="title">- <span class="icon-context icon-work_package-edit"></span>- <span class="hidden-for-sighted">Edit work package</span>- <span class="time">16:00</span>- <a href="#">Phase #15: Go-Live (To be scheduled)</a>- </div>- <div class="description">Lorem ipsum</div>- <div class="author">- <img class="avatar-mini" src="/assets/default-avatar.png" />- Anonymous- </div>- </li>- <li class="news me">- <div class="title">- <span class="icon-context icon-news"></span>- <span class="hidden-for-sighted">News</span>- <span class="time">09:10</span>- <a href="#">Lorem ipsum dolor</a>- </div>- <div class="description"></div>- <div class="author">- <img src="http://gravatar.com/avatar/cb4f282fed12016bd18a879c1f27ff97" class="avatar-mini" />- <a href="#">Reinhold Weber</a>- </div>- </li>- <li class="message me">- <div class="title">- <span class="icon-context icon-message"></span>- <span class="hidden-for-sighted">Edit message</span>- <span class="time">20:24</span>- <a href="#">Demo Forum: RE: Hello world!</a>- </div>- <div class="description">- Reinhold Weber wrote:<br>- > Lorem ipsum dolor sit amet- </div>- <div class="author">- <img src="http://gravatar.com/avatar/cb4f282fed12016bd18a879c1f27ff97" class="avatar-mini" />- <a href="#">Reinhold Weber</a>- </div>- </li>-</ul>--```diff --git a/frontend/src/global_styles/content/_list.sass b/frontend/src/global_styles/content/_list.sassdeleted file mode 100644index 0ef4045291e..00000000000--- a/frontend/src/global_styles/content/_list.sass+++ /dev/null@@ -1,67 +0,0 @@-//-- 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.-//++--.generic-list- margin: 0- padding: 0-- li- list-style: none- margin-bottom: 24px-- .title- font-weight: bold-- .icon-context:before- vertical-align: -2px-- .me- .time- border-bottom: 1px solid var(--gray-dark)-- .time,- .description- color: var(--gray-dark)-- .time,- .description,- .author- font-size: 0.9em-- .description,- .author- padding-left: 30px-- .description- font-style: italic-- .author- margin-bottom: 1em-- .avatar-mini- margin: 0 10px 0 0diff --git a/modules/costs/spec/features/time_entries_spec.rb b/modules/costs/spec/features/time_entries_spec.rbindex c905e445efc..201de50ca84 100644--- a/modules/costs/spec/features/time_entries_spec.rb+++ b/modules/costs/spec/features/time_entries_spec.rb@@ -85,7 +85,7 @@ describe 'Work Package table cost entries', js: true docheck('Budgets')click_on 'Apply'- expect(page).to have_selector('.op-project-activity-list--item-title', text: '10.00 hours')- expect(page).to have_selector('.op-project-activity-list--item-title', text: '2.50 hours')+ expect(page).to have_selector('.op-activity-list--item-title', text: '10.00 hours')+ expect(page).to have_selector('.op-activity-list--item-title', text: '2.50 hours')endenddiff --git a/modules/meeting/spec/features/meetings_activity_spec.rb b/modules/meeting/spec/features/meetings_activity_spec.rbindex c37e6d5e6e5..114d895b2e5 100644--- a/modules/meeting/spec/features/meetings_activity_spec.rb+++ b/modules/meeting/spec/features/meetings_activity_spec.rb@@ -47,9 +47,9 @@ describe 'Meetings', js: true docheck 'Meetings'click_on 'Apply'- expect(page).to have_selector('.op-project-activity-list--item-title', text: 'Minutes: Awesome meeting!')- expect(page).to have_selector('.op-project-activity-list--item-title', text: 'Agenda: Awesome meeting!')- expect(page).to have_selector('.op-project-activity-list--item-title', text: 'Meeting: Awesome meeting!')+ expect(page).to have_selector('.op-activity-list--item-title', text: 'Minutes: Awesome meeting!')+ expect(page).to have_selector('.op-activity-list--item-title', text: 'Agenda: Awesome meeting!')+ expect(page).to have_selector('.op-activity-list--item-title', text: 'Meeting: Awesome meeting!')endendenddiff --git a/spec/components/activity_item_component_spec.rb b/spec/components/activity_item_component_spec.rbindex 77747cfd31a..bb2c3f15071 100644--- a/spec/components/activity_item_component_spec.rb+++ b/spec/components/activity_item_component_spec.rb@@ -31,8 +31,6 @@require "rails_helper"RSpec.describe ActivityItemComponent, type: :component do- pending "add some examples to (or delete) #{__FILE__}"-let(:event) doActivities::Event.new(event_title: "Event Title",@@ -46,9 +44,10 @@ RSpec.describe ActivityItemComponent, type: :component dolet(:project) { build_stubbed(:project) }let(:journal) { build_stubbed(:project_journal, journable: project) }- it "renders the title" do+ it 'renders the title escaped' do+ event.event_title = 'Hello <b>World</b>!'render_inline(described_class.new(event:, journal:))- expect(page).to have_css('.op-project-activity-list--item-title', text: 'Event Title')+ expect(page).to have_css('.op-activity-list--item-title', text: 'Hello <b>World</b>!')endenddiff --git a/spec/features/activities/project_attributes_activity_spec.rb b/spec/features/activities/project_attributes_activity_spec.rbindex fdbc2cc9869..e7df5c06c8e 100644--- a/spec/features/activities/project_attributes_activity_spec.rb+++ b/spec/features/activities/project_attributes_activity_spec.rb@@ -81,7 +81,7 @@ describe 'Project attributes activities' doclick_button 'Apply'- within("li.op-project-activity-list--item", match: :first) do+ within("li.op-activity-list--item", match: :first) doexpect(page).to have_link("Project: #{project.name}")diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rbnew file mode 100644index 00000000000..f99c1115b8e--- /dev/null+++ b/spec/features/users/show_spec.rb@@ -0,0 +1,51 @@+#-- 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.+#++++require 'spec_helper'++describe 'index users', js: true do+ current_user { create(:admin) }++ let(:index_page) { Pages::Admin::Users::Index.new }++ it 'works almost correctly', with_settings: { journal_aggregation_time_minutes: 0 } do+ # create some activities+ project = create(:project_with_types)+ project.update(name: 'new name', description: 'new project description')++ work_package = create(:work_package, author: current_user, project:)+ work_package.update(subject: 'new subject', description: 'new work package description')++ visit user_path(current_user)++ expect(page).to have_selector('li', text: "Project: #{project.name}")+ expected_work_package_title = "#{work_package.type.name} ##{work_package.id}: #{work_package.subject} " \+ "(Project: #{work_package.project.name})"+ expect(page).to have_selector('li', text: expected_work_package_title)+ end+end