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

Display project activities as 'Project attributes'

Christophe Bliard8e6aeaed73e4
diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb
new file mode 100644
index 00000000000..28ba29c7e59
--- /dev/null
+++ b/app/helpers/activity_helper.rb
@@ -0,0 +1,13 @@
+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
+end
diff --git a/app/models/activities/project_activity_provider.rb b/app/models/activities/project_activity_provider.rb
index e481c91dd1d..b38b3504e4a 100644
--- a/app/models/activities/project_activity_provider.rb
+++ b/app/models/activities/project_activity_provider.rb
@@ -27,7 +27,7 @@
#++
class Activities::ProjectActivityProvider < Activities::BaseActivityProvider
- activity_provider_for type: 'projects',
+ activity_provider_for type: 'project_attributes',
permission: :view_project
def event_query_projection
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb
index 24f7c7d877c..9755d8da5be 100644
--- a/app/views/activities/index.html.erb
+++ b/app/views/activities/index.html.erb
@@ -40,9 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
<% @events_by_day[day].sort { |x, y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<li class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<div class="title">
- <% event_type = e.event_type.start_with?('meeting') ? 'meetings' : e.event_type %>
- <% event_type = e.event_type == 'budget' ? 'budget' : event_type %>
- <%= icon_wrapper("icon-context icon-#{event_type}", e.event_name) %>
+ <%= icon_wrapper("icon-context icon-#{event_icon(e)}", e.event_name) %>
<span class="time"><%= format_time(e.event_datetime.to_time, false) %></span>
<% if (@project.nil? || @project != e.project) && e.project %>
<%= content_tag('span', link_to(e.project.name, e.project), class: 'project') %>
diff --git a/config/initializers/activity.rb b/config/initializers/activity.rb
index 1313d84821d..baa98927e17 100644
--- a/config/initializers/activity.rb
+++ b/config/initializers/activity.rb
@@ -31,8 +31,8 @@ require_relative '../constants/open_project/project_latest_activity'
Rails.application.reloader.to_prepare do
OpenProject::Activity.map do |activity|
activity.register :work_packages, class_name: '::Activities::WorkPackageActivityProvider'
- activity.register :projects, class_name: 'Activities::ProjectActivityProvider',
- default: false
+ activity.register :project_attributes, class_name: 'Activities::ProjectActivityProvider',
+ default: false
activity.register :changesets, class_name: 'Activities::ChangesetActivityProvider'
activity.register :news, class_name: 'Activities::NewsActivityProvider',
default: false
diff --git a/config/locales/en.yml b/config/locales/en.yml
index beebb25ee52..b2da478e629 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1381,11 +1381,11 @@ en:
error_attribute_not_highlightable: "Attribute(s) not highlightable: %{attributes}"
events:
- project: 'Project edited'
- projects: 'Project edited'
changeset: 'Changeset edited'
message: Message edited
news: News
+ project_attributes: 'Project attributes edited'
+ projects: 'Project edited'
reply: Replied
time_entry: 'Timelog edited'
wiki_page: 'Wiki page edited'
@@ -1871,6 +1871,7 @@ en:
label_product_version: "Product version"
label_professional_support: "Professional support"
label_profile: "Profile"
+ label_project_attribute_plural: "Project attributes"
label_project_count: "Total number of projects"
label_project_copy_notifications: "Send email notifications during the project copy"
label_project_latest: "Latest projects"
diff --git a/spec/features/activities/project_attributes_activity_spec.rb b/spec/features/activities/project_attributes_activity_spec.rb
new file mode 100644
index 00000000000..f5dc9eb7fc0
--- /dev/null
+++ b/spec/features/activities/project_attributes_activity_spec.rb
@@ -0,0 +1,57 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 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 'Project attributes activities' do
+ let(:user) do
+ create(:user,
+ member_in_project: project,
+ member_with_permissions: %w[view_wiki_pages
+ edit_wiki_pages
+ view_wiki_edits])
+ end
+ let(:project) { create(:project, enabled_module_names: %w[activity]) }
+
+ current_user { user }
+
+ it 'tracks the project\'s activities', js: true do
+ visit project_activity_index_path(project)
+
+ check 'Project attributes'
+
+ click_button 'Apply'
+
+ within("li.project_attributes") do
+ expect(page)
+ .to have_link("Project: #{project.name}")
+
+ expect(page).to have_selector(".hidden-for-sighted", text: 'Project attributes edited', visible: :hidden)
+ end
+ end
+end