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

Extract `WorkPackages::Share::ShareCounterComponent`

Aaron Contrerasfc56dcd4c429
diff --git a/app/components/work_packages/share/modal_body_component.html.erb b/app/components/work_packages/share/modal_body_component.html.erb
index 43a4a1a951e..f7b46c5e0ae 100644
--- a/app/components/work_packages/share/modal_body_component.html.erb
+++ b/app/components/work_packages/share/modal_body_component.html.erb
@@ -27,7 +27,7 @@
modal_content.with_row(mt: 3, data: { 'test-selector': 'op-share-wp-active-list'}) do
render(Primer::Beta::BorderBox.new) do |invited_user_list|
invited_user_list.with_header(color: :subtle, data: { 'test-selector': 'op-share-wp-active-count' }) do
- I18n.t('work_package.sharing.count', count: shared_users.count)
+ render(WorkPackages::Share::ShareCounterComponent.new(count: shared_users.count))
end
shared_users.each do |user|
diff --git a/app/components/work_packages/share/share_counter_component.html.erb b/app/components/work_packages/share/share_counter_component.html.erb
new file mode 100644
index 00000000000..b31a9a99ad3
--- /dev/null
+++ b/app/components/work_packages/share/share_counter_component.html.erb
@@ -0,0 +1,5 @@
+<%=
+ component_wrapper do
+ I18n.t('work_package.sharing.count', count:)
+ end
+%>
diff --git a/app/components/work_packages/share/share_counter_component.rb b/app/components/work_packages/share/share_counter_component.rb
new file mode 100644
index 00000000000..417a325534c
--- /dev/null
+++ b/app/components/work_packages/share/share_counter_component.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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.
+# ++
+
+module WorkPackages
+ module Share
+ class ShareCounterComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(count:)
+ super
+
+ @count = count
+ end
+
+ private
+
+ attr_reader :count
+ end
+ end
+end