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

Reorganize sharing components outside of the WorkPackage scope

Klaus Zanderscb9ccc92c91e
diff --git a/app/components/_index.sass b/app/components/_index.sass
index fa7b42a43c7..a05d3e6b1e6 100644
--- a/app/components/_index.sass
+++ b/app/components/_index.sass
@@ -1,5 +1,5 @@
-@import "work_packages/share/modal_body_component"
-@import "work_packages/share/invite_user_form_component"
+@import "shares/modal_body_component"
+@import "shares/invite_user_form_component"
@import "work_packages/progress/modal_body_component"
@import "open_project/common/attribute_component"
@import "filter/filters_component"
diff --git a/app/components/work_packages/share/bulk_permission_button_component.html.erb b/app/components/shares/bulk_permission_button_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/bulk_permission_button_component.html.erb
rename to app/components/shares/bulk_permission_button_component.html.erb
diff --git a/app/components/work_packages/share/bulk_permission_button_component.rb b/app/components/shares/bulk_permission_button_component.rb
similarity index 78%
rename from app/components/work_packages/share/bulk_permission_button_component.rb
rename to app/components/shares/bulk_permission_button_component.rb
index 1f0c2bad284..ce6679a72be 100644
--- a/app/components/work_packages/share/bulk_permission_button_component.rb
+++ b/app/components/shares/bulk_permission_button_component.rb
@@ -28,20 +28,18 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- class BulkPermissionButtonComponent < ApplicationComponent
- include WorkPackages::Share::Concerns::DisplayableRoles
+module Shares
+ class BulkPermissionButtonComponent < ApplicationComponent
+ include Shares::Concerns::DisplayableRoles
- def initialize(work_package:)
- super
+ def initialize(work_package:)
+ super
- @work_package = work_package
- end
+ @work_package = work_package
+ end
- def update_path
- work_package_shares_bulk_path(@work_package)
- end
+ def update_path
+ url_for([:bulk, @work_package, Member])
end
end
end
diff --git a/app/components/work_packages/share/bulk_selection_counter_component.html.erb b/app/components/shares/bulk_selection_counter_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/bulk_selection_counter_component.html.erb
rename to app/components/shares/bulk_selection_counter_component.html.erb
diff --git a/app/components/work_packages/share/bulk_selection_counter_component.rb b/app/components/shares/bulk_selection_counter_component.rb
similarity index 85%
rename from app/components/work_packages/share/bulk_selection_counter_component.rb
rename to app/components/shares/bulk_selection_counter_component.rb
index 6dc141ba6e8..2196cc6dec4 100644
--- a/app/components/work_packages/share/bulk_selection_counter_component.rb
+++ b/app/components/shares/bulk_selection_counter_component.rb
@@ -28,18 +28,16 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- class BulkSelectionCounterComponent < ApplicationComponent
- def initialize(count:)
- super
+module Shares
+ class BulkSelectionCounterComponent < ApplicationComponent
+ def initialize(count:)
+ super
- @count = count
- end
+ @count = count
+ end
- private
+ private
- attr_reader :count
- end
+ attr_reader :count
end
end
diff --git a/app/components/work_packages/share/concerns/authorization.rb b/app/components/shares/concerns/authorization.rb
similarity index 82%
rename from app/components/work_packages/share/concerns/authorization.rb
rename to app/components/shares/concerns/authorization.rb
index 4a927c0b598..862e07166a7 100644
--- a/app/components/work_packages/share/concerns/authorization.rb
+++ b/app/components/shares/concerns/authorization.rb
@@ -28,16 +28,14 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- module Concerns
- module Authorization
- extend ActiveSupport::Concern
+module Shares
+ module Concerns
+ module Authorization
+ extend ActiveSupport::Concern
- included do
- def sharing_manageable?
- User.current.allowed_in_project?(:share_work_packages, @work_package.project)
- end
+ included do
+ def sharing_manageable?
+ User.current.allowed_in_project?(:share_work_packages, @work_package.project)
end
end
end
diff --git a/app/components/work_packages/share/concerns/displayable_roles.rb b/app/components/shares/concerns/displayable_roles.rb
similarity index 61%
rename from app/components/work_packages/share/concerns/displayable_roles.rb
rename to app/components/shares/concerns/displayable_roles.rb
index ff0faa33834..79b887a48b4 100644
--- a/app/components/work_packages/share/concerns/displayable_roles.rb
+++ b/app/components/shares/concerns/displayable_roles.rb
@@ -28,23 +28,21 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- module Concerns
- module DisplayableRoles
- def options
- [
- { label: I18n.t("work_package.sharing.permissions.edit"),
- value: Role::BUILTIN_WORK_PACKAGE_EDITOR,
- description: I18n.t("work_package.sharing.permissions.edit_description") },
- { label: I18n.t("work_package.sharing.permissions.comment"),
- value: Role::BUILTIN_WORK_PACKAGE_COMMENTER,
- description: I18n.t("work_package.sharing.permissions.comment_description") },
- { label: I18n.t("work_package.sharing.permissions.view"),
- value: Role::BUILTIN_WORK_PACKAGE_VIEWER,
- description: I18n.t("work_package.sharing.permissions.view_description") }
- ]
- end
+module Shares
+ module Concerns
+ module DisplayableRoles
+ def options
+ [
+ { label: I18n.t("work_package.sharing.permissions.edit"),
+ value: Role::BUILTIN_WORK_PACKAGE_EDITOR,
+ description: I18n.t("work_package.sharing.permissions.edit_description") },
+ { label: I18n.t("work_package.sharing.permissions.comment"),
+ value: Role::BUILTIN_WORK_PACKAGE_COMMENTER,
+ description: I18n.t("work_package.sharing.permissions.comment_description") },
+ { label: I18n.t("work_package.sharing.permissions.view"),
+ value: Role::BUILTIN_WORK_PACKAGE_VIEWER,
+ description: I18n.t("work_package.sharing.permissions.view_description") }
+ ]
end
end
end
diff --git a/app/components/work_packages/share/counter_component.html.erb b/app/components/shares/counter_component.html.erb
similarity index 76%
rename from app/components/work_packages/share/counter_component.html.erb
rename to app/components/shares/counter_component.html.erb
index 71144ef8f38..c2c1bfec88f 100644
--- a/app/components/work_packages/share/counter_component.html.erb
+++ b/app/components/shares/counter_component.html.erb
@@ -5,9 +5,9 @@
# I'm able to manage shares if the only user that the work package is
# currently shared is myself, since I'm not able to manage my own share.
if sharing_manageable? && shared_with_anyone_else_other_than_myself?
- render(WorkPackages::Share::BulkSelectionCounterComponent.new(count:))
+ render(Shares::BulkSelectionCounterComponent.new(count:))
else
- render(WorkPackages::Share::ShareCounterComponent.new(count:))
+ render(Shares::ShareCounterComponent.new(count:))
end
end
end
diff --git a/app/components/work_packages/share/counter_component.rb b/app/components/shares/counter_component.rb
similarity index 67%
rename from app/components/work_packages/share/counter_component.rb
rename to app/components/shares/counter_component.rb
index ee2b0d786da..8da6c7f9cc1 100644
--- a/app/components/work_packages/share/counter_component.rb
+++ b/app/components/shares/counter_component.rb
@@ -28,30 +28,28 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- class CounterComponent < ApplicationComponent
- include ApplicationHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
- include WorkPackages::Share::Concerns::Authorization
+module Shares
+ class CounterComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include Shares::Concerns::Authorization
- def initialize(work_package:, count:)
- super
+ def initialize(work_package:, count:)
+ super
- @work_package = work_package
- @count = count
- end
+ @work_package = work_package
+ @count = count
+ end
- private
+ private
- attr_reader :work_package, :count
+ attr_reader :work_package, :count
- def shared_with_anyone_else_other_than_myself?
- Member.of_work_package(@work_package)
- .where.not(principal: User.current)
- .any?
- end
+ def shared_with_anyone_else_other_than_myself?
+ Member.of_work_package(@work_package)
+ .where.not(principal: User.current)
+ .any?
end
end
end
diff --git a/app/components/work_packages/share/invite_user_form_component.html.erb b/app/components/shares/invite_user_form_component.html.erb
similarity index 96%
rename from app/components/work_packages/share/invite_user_form_component.html.erb
rename to app/components/shares/invite_user_form_component.html.erb
index 2cff37583ab..8a62c75fa4f 100644
--- a/app/components/work_packages/share/invite_user_form_component.html.erb
+++ b/app/components/shares/invite_user_form_component.html.erb
@@ -13,11 +13,11 @@
grid_layout('invite-user-form',
tag: :div) do |invite_form|
invite_form.with_area('invitee') do
- render(WorkPackages::Share::Invitee.new(form))
+ render(Shares::Invitee.new(form))
end
invite_form.with_area('permission') do
- render(WorkPackages::Share::PermissionButtonComponent.new(
+ render(Shares::PermissionButtonComponent.new(
share: new_share,
form_arguments: { builder: form, name: "role_id" },
data: { 'test-selector': 'op-share-wp-invite-role' })
diff --git a/app/components/work_packages/share/invite_user_form_component.rb b/app/components/shares/invite_user_form_component.rb
similarity index 69%
rename from app/components/work_packages/share/invite_user_form_component.rb
rename to app/components/shares/invite_user_form_component.rb
index 94525603039..1189f8b5762 100644
--- a/app/components/work_packages/share/invite_user_form_component.rb
+++ b/app/components/shares/invite_user_form_component.rb
@@ -26,24 +26,22 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module WorkPackages
- module Share
- class InviteUserFormComponent < ApplicationComponent
- include ApplicationHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
- include WorkPackages::Share::Concerns::Authorization
+module Shares
+ class InviteUserFormComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include Shares::Concerns::Authorization
- def initialize(work_package:, errors: nil)
- super
+ def initialize(work_package:, errors: nil)
+ super
- @work_package = work_package
- @errors = errors
- end
+ @work_package = work_package
+ @errors = errors
+ end
- def new_share
- @new_share ||= Member.new(entity: @work_package, roles: [Role.new(builtin: Role::BUILTIN_WORK_PACKAGE_VIEWER)])
- end
+ def new_share
+ @new_share ||= Member.new(entity: @work_package, roles: [Role.new(builtin: Role::BUILTIN_WORK_PACKAGE_VIEWER)])
end
end
end
diff --git a/app/components/work_packages/share/invite_user_form_component.sass b/app/components/shares/invite_user_form_component.sass
similarity index 100%
rename from app/components/work_packages/share/invite_user_form_component.sass
rename to app/components/shares/invite_user_form_component.sass
diff --git a/app/components/work_packages/share/modal_body_component.html.erb b/app/components/shares/modal_body_component.html.erb
similarity index 91%
rename from app/components/work_packages/share/modal_body_component.html.erb
rename to app/components/shares/modal_body_component.html.erb
index fc5bc15cce0..156ca7b249a 100644
--- a/app/components/work_packages/share/modal_body_component.html.erb
+++ b/app/components/shares/modal_body_component.html.erb
@@ -2,7 +2,7 @@
component_wrapper(tag: 'turbo-frame') do
flex_layout(data: { turbo: true }) do |modal_content|
modal_content.with_row do
- render(WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package, errors: @errors))
+ render(Shares::InviteUserFormComponent.new(work_package: @work_package, errors: @errors))
end
modal_content.with_row(mt: 3,
@@ -13,7 +13,7 @@
border_box.with_header(color: :muted, data: { 'test-selector': 'op-share-wp-header' }) do
grid_layout('op-share-wp-modal-body--header', tag: :div, align_items: :center) do |header_grid|
header_grid.with_area(:counter, tag: :div) do
- render(WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: @shares.size))
+ render(Shares::CounterComponent.new(work_package: @work_package, count: @shares.size))
end
header_grid.with_area(:actions,
@@ -72,11 +72,11 @@
data: { 'work-packages--share--bulk-selection-target': 'bulkActions' }) do
if sharing_manageable?
concat(
- render(WorkPackages::Share::BulkPermissionButtonComponent.new(work_package: @work_package))
+ render(Shares::BulkPermissionButtonComponent.new(work_package: @work_package))
)
concat(
- form_with(url: work_package_shares_bulk_path(@work_package),
+ form_with(url: url_for([:bulk, @work_package, Member]),
method: :delete,
data: { 'work-packages--share--bulk-selection-target': 'bulkForm' }) do
render(Primer::Beta::IconButton.new(icon: "trash",
@@ -107,7 +107,7 @@
end
else
@shares.each do |share|
- render(WorkPackages::Share::ShareRowComponent.new(share: share, container: border_box))
+ render(Shares::ShareRowComponent.new(share: share, container: border_box))
end
end
end
diff --git a/app/components/shares/modal_body_component.rb b/app/components/shares/modal_body_component.rb
new file mode 100644
index 00000000000..b9b918a0a52
--- /dev/null
+++ b/app/components/shares/modal_body_component.rb
@@ -0,0 +1,178 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Shares
+ class ModalBodyComponent < ApplicationComponent
+ include ApplicationHelper
+ include MemberHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include Shares::Concerns::Authorization
+ include Shares::Concerns::DisplayableRoles
+
+ def initialize(work_package:, shares:, errors: nil)
+ super
+
+ @work_package = work_package
+ @shares = shares
+ @errors = errors
+ end
+
+ def self.wrapper_key
+ "work_package_share_list"
+ end
+
+ private
+
+ def insert_target_modified?
+ true
+ end
+
+ def insert_target_modifier_id
+ "op-share-wp-active-shares"
+ end
+
+ def blankslate_config
+ @blankslate_config ||= {}.tap do |config|
+ if params[:filters].blank?
+ config[:icon] = :people
+ config[:heading_text] = I18n.t("work_package.sharing.text_empty_state_header")
+ config[:description_text] = I18n.t("work_package.sharing.text_empty_state_description")
+ else
+ config[:icon] = :search
+ config[:heading_text] = I18n.t("work_package.sharing.text_empty_search_header")
+ config[:description_text] = I18n.t("work_package.sharing.text_empty_search_description")
+ end
+ end
+ end
+
+ def type_filter_options
+ [
+ { label: I18n.t("work_package.sharing.filter.project_member"),
+ value: { principal_type: "User", project_member: true } },
+ { label: I18n.t("work_package.sharing.filter.not_project_member"),
+ value: { principal_type: "User", project_member: false } },
+ { label: I18n.t("work_package.sharing.filter.project_group"),
+ value: { principal_type: "Group", project_member: true } },
+ { label: I18n.t("work_package.sharing.filter.not_project_group"),
+ value: { principal_type: "Group", project_member: false } }
+ ]
+ end
+
+ def type_filter_option_active?(_option)
+ principal_type_filter_value = current_filter_value(params[:filters], "principal_type")
+ project_member_filter_value = current_filter_value(params[:filters], "also_project_member")
+
+ return false if principal_type_filter_value.nil? || project_member_filter_value.nil?
+
+ principal_type_checked =
+ _option[:value][:principal_type] == principal_type_filter_value
+ membership_selected =
+ _option[:value][:project_member] == ActiveRecord::Type::Boolean.new.cast(project_member_filter_value)
+
+ principal_type_checked && membership_selected
+ end
+
+ def role_filter_option_active?(_option)
+ role_filter_value = current_filter_value(params[:filters], "role_id")
+
+ return false if role_filter_value.nil?
+
+ find_role_ids(_option[:value]).first == role_filter_value.to_i
+ end
+
+ def filter_url(type_option: nil, role_option: nil)
+ return url_for([@work_package, Member]) if type_option.nil? && role_option.nil?
+
+ args = {}
+ filter = []
+
+ filter += apply_role_filter(role_option)
+ filter += apply_type_filter(type_option)
+
+ args[:filters] = filter.to_json unless filter.empty?
+
+ url_for([@work_package, Member, **args])
+ end
+
+ def apply_role_filter(_option)
+ current_role_filter_value = current_filter_value(params[:filters], "role_id")
+ filter = []
+
+ if _option.nil? && current_role_filter_value.present?
+ # When there is already a role filter set and no new value passed, we want to keep that filter
+ filter = role_filter_for({ value: current_role_filter_value }, builtin_role: false)
+ elsif _option.present? && !role_filter_option_active?(_option)
+ # Only when the passed filter option is not the currently selected one, we apply the filter
+ filter = role_filter_for(_option)
+ end
+
+ filter
+ end
+
+ def role_filter_for(_option, builtin_role: true)
+ [{ role_id: { operator: "=", values: builtin_role ? find_role_ids(_option[:value]) : [_option[:value]] } }]
+ end
+
+ def apply_type_filter(_option)
+ current_type_filter_value = current_filter_value(params[:filters], "principal_type")
+ current_member_filter_value = current_filter_value(params[:filters], "also_project_member")
+ filter = []
+
+ if _option.nil? && current_type_filter_value.present? && current_member_filter_value.present?
+ # When there is already a type filter set and no new value passed, we want to keep that filter
+ value = { value: { principal_type: current_type_filter_value, project_member: current_member_filter_value } }
+ filter = type_filter_for(value)
+ elsif _option.present? && !type_filter_option_active?(_option)
+ # Only when the passed filter option is not the currently selected one, we apply the filter
+ filter = type_filter_for(_option)
+ end
+
+ filter
+ end
+
+ def type_filter_for(_option)
+ filter = []
+ if ActiveRecord::Type::Boolean.new.cast(_option[:value][:project_member])
+ filter.push({ also_project_member: { operator: "=", values: [OpenProject::Database::DB_VALUE_TRUE] } })
+ else
+ filter.push({ also_project_member: { operator: "=", values: [OpenProject::Database::DB_VALUE_FALSE] } })
+ end
+
+ filter.push({ principal_type: { operator: "=", values: [_option[:value][:principal_type]] } })
+ filter
+ end
+
+ def current_filter_value(filters, filter_key)
+ return nil if filters.nil?
+
+ given_filters = JSON.parse(filters).find { |key| key.key?(filter_key) }
+ given_filters ? given_filters[filter_key]["values"].first : nil
+ end
+ end
+end
diff --git a/app/components/work_packages/share/modal_body_component.sass b/app/components/shares/modal_body_component.sass
similarity index 100%
rename from app/components/work_packages/share/modal_body_component.sass
rename to app/components/shares/modal_body_component.sass
diff --git a/app/components/work_packages/share/modal_upsale_component.html.erb b/app/components/shares/modal_upsale_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/modal_upsale_component.html.erb
rename to app/components/shares/modal_upsale_component.html.erb
diff --git a/app/components/work_packages/share/modal_upsale_component.rb b/app/components/shares/modal_upsale_component.rb
similarity index 82%
rename from app/components/work_packages/share/modal_upsale_component.rb
rename to app/components/shares/modal_upsale_component.rb
index 4a387bec390..e2610156c88 100644
--- a/app/components/work_packages/share/modal_upsale_component.rb
+++ b/app/components/shares/modal_upsale_component.rb
@@ -26,16 +26,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module WorkPackages
- module Share
- class ModalUpsaleComponent < ApplicationComponent
- include ApplicationHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
+module Shares
+ class ModalUpsaleComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
- def self.wrapper_key
- "work_package_share_list"
- end
+ def self.wrapper_key
+ "work_package_share_list"
end
end
end
diff --git a/app/components/work_packages/share/permission_button_component.html.erb b/app/components/shares/permission_button_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/permission_button_component.html.erb
rename to app/components/shares/permission_button_component.html.erb
diff --git a/app/components/shares/permission_button_component.rb b/app/components/shares/permission_button_component.rb
new file mode 100644
index 00000000000..6de62dfb553
--- /dev/null
+++ b/app/components/shares/permission_button_component.rb
@@ -0,0 +1,84 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Shares
+ class PermissionButtonComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+ include Shares::Concerns::DisplayableRoles
+
+ def initialize(share:, **system_arguments)
+ super
+
+ @share = share
+ @system_arguments = system_arguments
+ end
+
+ # Switches the component to either update the share directly (by sending a PATCH to the share path)
+ # or be passive and work like a select inside a form.
+ def update_path
+ if share.persisted?
+ url_for([share.entity, share])
+ end
+ end
+
+ def option_active?(option)
+ option[:value] == active_role.builtin
+ end
+
+ def wrapper_uniq_by
+ share.id || @system_arguments.dig(:data, :"test-selector")
+ end
+
+ private
+
+ attr_reader :share
+
+ def active_role
+ if share.persisted?
+ share.roles
+ .merge(MemberRole.only_non_inherited)
+ .first
+ else
+ share.roles.first
+ end
+ end
+
+ def permission_name(value)
+ options.find { |option| option[:value] == value }[:label]
+ end
+
+ def form_inputs(role_id)
+ [].tap do |inputs|
+ inputs << { name: "role_ids[]", value: role_id }
+ inputs << { name: "filters", value: params[:filters] } if params[:filters]
+ end
+ end
+ end
+end
diff --git a/app/components/work_packages/share/share_counter_component.html.erb b/app/components/shares/share_counter_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/share_counter_component.html.erb
rename to app/components/shares/share_counter_component.html.erb
diff --git a/app/components/work_packages/share/share_counter_component.rb b/app/components/shares/share_counter_component.rb
similarity index 86%
rename from app/components/work_packages/share/share_counter_component.rb
rename to app/components/shares/share_counter_component.rb
index 0b882c56d5d..f30bbf15bc6 100644
--- a/app/components/work_packages/share/share_counter_component.rb
+++ b/app/components/shares/share_counter_component.rb
@@ -28,18 +28,16 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- class ShareCounterComponent < ApplicationComponent
- def initialize(count:)
- super
+module Shares
+ class ShareCounterComponent < ApplicationComponent
+ def initialize(count:)
+ super
- @count = count
- end
+ @count = count
+ end
- private
+ private
- attr_reader :count
- end
+ attr_reader :count
end
end
diff --git a/app/components/work_packages/share/share_row_component.html.erb b/app/components/shares/share_row_component.html.erb
similarity index 91%
rename from app/components/work_packages/share/share_row_component.html.erb
rename to app/components/shares/share_row_component.html.erb
index 53981984210..02737d53247 100644
--- a/app/components/work_packages/share/share_row_component.html.erb
+++ b/app/components/shares/share_row_component.html.erb
@@ -17,12 +17,12 @@
end
user_row_grid.with_area(:user_details, tag: :div, classes: 'ellipsis') do
- render(WorkPackages::Share::UserDetailsComponent.new(share:, manager_mode: share_editable?))
+ render(Shares::UserDetailsComponent.new(share:, manager_mode: share_editable?))
end
if share_editable?
user_row_grid.with_area(:button, tag: :div, color: :subtle) do
- render(WorkPackages::Share::PermissionButtonComponent.new(share:,
+ render(Shares::PermissionButtonComponent.new(share:,
data: { 'test-selector': 'op-share-wp-update-role' }))
end
diff --git a/app/components/work_packages/share/share_row_component.rb b/app/components/shares/share_row_component.rb
similarity index 53%
rename from app/components/work_packages/share/share_row_component.rb
rename to app/components/shares/share_row_component.rb
index 16d82a331a0..a5b376b8d0c 100644
--- a/app/components/work_packages/share/share_row_component.rb
+++ b/app/components/shares/share_row_component.rb
@@ -28,53 +28,51 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module WorkPackages
- module Share
- class ShareRowComponent < ApplicationComponent
- include ApplicationHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
- include WorkPackages::Share::Concerns::Authorization
+module Shares
+ class ShareRowComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include Shares::Concerns::Authorization
- def initialize(share:,
- container: nil)
- super
+ def initialize(share:,
+ container: nil)
+ super
- @share = share
- @work_package = share.entity
- @principal = share.principal
- @container = container
- end
+ @share = share
+ @work_package = share.entity
+ @principal = share.principal
+ @container = container
+ end
- def wrapper_uniq_by
- share.id
- end
+ def wrapper_uniq_by
+ share.id
+ end
- private
+ private
- attr_reader :share, :work_package, :principal, :container
+ attr_reader :share, :work_package, :principal, :container
- def share_editable?
- @share_editable ||= User.current != share.principal && sharing_manageable?
- end
+ def share_editable?
+ @share_editable ||= User.current != share.principal && sharing_manageable?
+ end
- def grid_css_classes
- if sharing_manageable?
- "op-share-wp-modal-body--user-row_manageable"
- else
- "op-share-wp-modal-body--user-row"
- end
+ def grid_css_classes
+ if sharing_manageable?
+ "op-share-wp-modal-body--user-row_manageable"
+ else
+ "op-share-wp-modal-body--user-row"
end
+ end
- def select_share_checkbox_options
- {
- name: "share_ids",
- value: share.id,
- scheme: :array,
- label: principal.name,
- visually_hide_label: true
- }
- end
+ def select_share_checkbox_options
+ {
+ name: "share_ids",
+ value: share.id,
+ scheme: :array,
+ label: principal.name,
+ visually_hide_label: true
+ }
end
end
end
diff --git a/app/components/work_packages/share/user_details_component.html.erb b/app/components/shares/user_details_component.html.erb
similarity index 100%
rename from app/components/work_packages/share/user_details_component.html.erb
rename to app/components/shares/user_details_component.html.erb
diff --git a/app/components/shares/user_details_component.rb b/app/components/shares/user_details_component.rb
new file mode 100644
index 00000000000..436d859e8c4
--- /dev/null
+++ b/app/components/shares/user_details_component.rb
@@ -0,0 +1,127 @@
+# 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 Shares
+ class UserDetailsComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include Shares::Concerns::DisplayableRoles
+
+ def initialize(share:,
+ manager_mode: User.current.allowed_in_project?(:share_work_packages, share.project),
+ invite_resent: false)
+ super
+
+ @share = share
+ @user = share.principal
+ @manager_mode = manager_mode
+ @invite_resent = invite_resent
+ end
+
+ private
+
+ attr_reader :user, :share
+
+ def manager_mode? = @manager_mode
+
+ def invite_resent? = @invite_resent
+
+ def wrapper_uniq_by
+ share.id
+ end
+
+ def authoritative_work_package_role_name
+ @authoritative_work_package_role_name = options.find do |option|
+ option[:value] == share.roles.first.builtin
+ end[:label]
+ end
+
+ def principal_show_path
+ case user
+ when User
+ user_path(user)
+ when Group
+ show_group_path(user)
+ else
+ placeholder_user_path(user)
+ end
+ end
+
+ def resend_invite_path
+ url_for([:resend_invite, share.entity, share])
+ end
+
+ def user_is_a_group?
+ @user_is_a_group ||= user.is_a?(Group)
+ end
+
+ def user_in_non_active_status?
+ user.locked? || user.invited?
+ end
+
+ # Is a user member of a project no matter whether inherited or directly assigned
+ def project_member?
+ Member.exists?(project: share.project,
+ principal: user,
+ entity: nil)
+ end
+
+ # Explicitly check whether the project membership was inherited by a group
+ def inherited_project_member?
+ Member.includes(:roles)
+ .references(:member_roles)
+ .where(project: share.project, principal: user, entity: nil) # membership in the project
+ .merge(MemberRole.only_inherited) # that was inherited
+ .any?
+ end
+
+ def project_group?
+ user_is_a_group? && project_member?
+ end
+
+ def part_of_a_shared_group?
+ share.member_roles.where.not(inherited_from: nil).any?
+ end
+
+ def part_of_a_group?
+ GroupUser.where(user_id: user.id).any?
+ end
+
+ def project_role_name
+ Member.where(project: share.project,
+ principal: user,
+ entity: nil)
+ .first
+ .roles
+ .first
+ .name
+ end
+ end
+end
diff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rb
deleted file mode 100644
index d3e59c2b11c..00000000000
--- a/app/components/work_packages/share/modal_body_component.rb
+++ /dev/null
@@ -1,180 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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 ModalBodyComponent < ApplicationComponent
- include ApplicationHelper
- include MemberHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
- include WorkPackages::Share::Concerns::Authorization
- include WorkPackages::Share::Concerns::DisplayableRoles
-
- def initialize(work_package:, shares:, errors: nil)
- super
-
- @work_package = work_package
- @shares = shares
- @errors = errors
- end
-
- def self.wrapper_key
- "work_package_share_list"
- end
-
- private
-
- def insert_target_modified?
- true
- end
-
- def insert_target_modifier_id
- "op-share-wp-active-shares"
- end
-
- def blankslate_config
- @blankslate_config ||= {}.tap do |config|
- if params[:filters].blank?
- config[:icon] = :people
- config[:heading_text] = I18n.t("work_package.sharing.text_empty_state_header")
- config[:description_text] = I18n.t("work_package.sharing.text_empty_state_description")
- else
- config[:icon] = :search
- config[:heading_text] = I18n.t("work_package.sharing.text_empty_search_header")
- config[:description_text] = I18n.t("work_package.sharing.text_empty_search_description")
- end
- end
- end
-
- def type_filter_options
- [
- { label: I18n.t("work_package.sharing.filter.project_member"),
- value: { principal_type: "User", project_member: true } },
- { label: I18n.t("work_package.sharing.filter.not_project_member"),
- value: { principal_type: "User", project_member: false } },
- { label: I18n.t("work_package.sharing.filter.project_group"),
- value: { principal_type: "Group", project_member: true } },
- { label: I18n.t("work_package.sharing.filter.not_project_group"),
- value: { principal_type: "Group", project_member: false } }
- ]
- end
-
- def type_filter_option_active?(_option)
- principal_type_filter_value = current_filter_value(params[:filters], "principal_type")
- project_member_filter_value = current_filter_value(params[:filters], "also_project_member")
-
- return false if principal_type_filter_value.nil? || project_member_filter_value.nil?
-
- principal_type_checked =
- _option[:value][:principal_type] == principal_type_filter_value
- membership_selected =
- _option[:value][:project_member] == ActiveRecord::Type::Boolean.new.cast(project_member_filter_value)
-
- principal_type_checked && membership_selected
- end
-
- def role_filter_option_active?(_option)
- role_filter_value = current_filter_value(params[:filters], "role_id")
-
- return false if role_filter_value.nil?
-
- find_role_ids(_option[:value]).first == role_filter_value.to_i
- end
-
- def filter_url(type_option: nil, role_option: nil)
- return url_for([@work_package, Member]) if type_option.nil? && role_option.nil?
-
- args = {}
- filter = []
-
- filter += apply_role_filter(role_option)
- filter += apply_type_filter(type_option)
-
- args[:filters] = filter.to_json unless filter.empty?
-
- url_for([@work_package, Member, **args])
- end
-
- def apply_role_filter(_option)
- current_role_filter_value = current_filter_value(params[:filters], "role_id")
- filter = []
-
- if _option.nil? && current_role_filter_value.present?
- # When there is already a role filter set and no new value passed, we want to keep that filter
- filter = role_filter_for({ value: current_role_filter_value }, builtin_role: false)
- elsif _option.present? && !role_filter_option_active?(_option)
- # Only when the passed filter option is not the currently selected one, we apply the filter
- filter = role_filter_for(_option)
- end
-
- filter
- end
-
- def role_filter_for(_option, builtin_role: true)
- [{ role_id: { operator: "=", values: builtin_role ? find_role_ids(_option[:value]) : [_option[:value]] } }]
- end
-
- def apply_type_filter(_option)
- current_type_filter_value = current_filter_value(params[:filters], "principal_type")
- current_member_filter_value = current_filter_value(params[:filters], "also_project_member")
- filter = []
-
- if _option.nil? && current_type_filter_value.present? && current_member_filter_value.present?
- # When there is already a type filter set and no new value passed, we want to keep that filter
- value = { value: { principal_type: current_type_filter_value, project_member: current_member_filter_value } }
- filter = type_filter_for(value)
- elsif _option.present? && !type_filter_option_active?(_option)
- # Only when the passed filter option is not the currently selected one, we apply the filter
- filter = type_filter_for(_option)
- end
-
- filter
- end
-
- def type_filter_for(_option)
- filter = []
- if ActiveRecord::Type::Boolean.new.cast(_option[:value][:project_member])
- filter.push({ also_project_member: { operator: "=", values: [OpenProject::Database::DB_VALUE_TRUE] } })
- else
- filter.push({ also_project_member: { operator: "=", values: [OpenProject::Database::DB_VALUE_FALSE] } })
- end
-
- filter.push({ principal_type: { operator: "=", values: [_option[:value][:principal_type]] } })
- filter
- end
-
- def current_filter_value(filters, filter_key)
- return nil if filters.nil?
-
- given_filters = JSON.parse(filters).find { |key| key.key?(filter_key) }
- given_filters ? given_filters[filter_key]["values"].first : nil
- end
- end
- end
-end
diff --git a/app/components/work_packages/share/permission_button_component.rb b/app/components/work_packages/share/permission_button_component.rb
deleted file mode 100644
index 07c8f242f8e..00000000000
--- a/app/components/work_packages/share/permission_button_component.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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 PermissionButtonComponent < ApplicationComponent
- include ApplicationHelper
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include WorkPackages::Share::Concerns::DisplayableRoles
-
- def initialize(share:, **system_arguments)
- super
-
- @share = share
- @system_arguments = system_arguments
- end
-
- # Switches the component to either update the share directly (by sending a PATCH to the share path)
- # or be passive and work like a select inside a form.
- def update_path
- if share.persisted?
- url_for([share.entity, share])
- end
- end
-
- def option_active?(option)
- option[:value] == active_role.builtin
- end
-
- def wrapper_uniq_by
- share.id || @system_arguments.dig(:data, :"test-selector")
- end
-
- private
-
- attr_reader :share
-
- def active_role
- if share.persisted?
- share.roles
- .merge(MemberRole.only_non_inherited)
- .first
- else
- share.roles.first
- end
- end
-
- def permission_name(value)
- options.find { |option| option[:value] == value }[:label]
- end
-
- def form_inputs(role_id)
- [].tap do |inputs|
- inputs << { name: "role_ids[]", value: role_id }
- inputs << { name: "filters", value: params[:filters] } if params[:filters]
- end
- end
- end
- end
-end
diff --git a/app/components/work_packages/share/user_details_component.rb b/app/components/work_packages/share/user_details_component.rb
deleted file mode 100644
index 11c9b3fce51..00000000000
--- a/app/components/work_packages/share/user_details_component.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-# 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
- # rubocop:disable OpenProject/AddPreviewForViewComponent
- class UserDetailsComponent < ApplicationComponent
- # rubocop:enable OpenProject/AddPreviewForViewComponent
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
- include WorkPackages::Share::Concerns::DisplayableRoles
-
- def initialize(share:,
- manager_mode: User.current.allowed_in_project?(:share_work_packages, share.project),
- invite_resent: false)
- super
-
- @share = share
- @user = share.principal
- @manager_mode = manager_mode
- @invite_resent = invite_resent
- end
-
- private
-
- attr_reader :user, :share
-
- def manager_mode? = @manager_mode
-
- def invite_resent? = @invite_resent
-
- def wrapper_uniq_by
- share.id
- end
-
- def authoritative_work_package_role_name
- @authoritative_work_package_role_name = options.find do |option|
- option[:value] == share.roles.first.builtin
- end[:label]
- end
-
- def principal_show_path
- case user
- when User
- user_path(user)
- when Group
- show_group_path(user)
- else
- placeholder_user_path(user)
- end
- end
-
- def resend_invite_path
- url_for([:resend_invite, share.entity, share])
- end
-
- def user_is_a_group?
- @user_is_a_group ||= user.is_a?(Group)
- end
-
- def user_in_non_active_status?
- user.locked? || user.invited?
- end
-
- # Is a user member of a project no matter whether inherited or directly assigned
- def project_member?
- Member.exists?(project: share.project,
- principal: user,
- entity: nil)
- end
-
- # Explicitly check whether the project membership was inherited by a group
- def inherited_project_member?
- Member.includes(:roles)
- .references(:member_roles)
- .where(project: share.project, principal: user, entity: nil) # membership in the project
- .merge(MemberRole.only_inherited) # that was inherited
- .any?
- end
-
- def project_group?
- user_is_a_group? && project_member?
- end
-
- def part_of_a_shared_group?
- share.member_roles.where.not(inherited_from: nil).any?
- end
-
- def part_of_a_group?
- GroupUser.where(user_id: user.id).any?
- end
-
- def project_role_name
- Member.where(project: share.project,
- principal: user,
- entity: nil)
- .first
- .roles
- .first
- .name
- end
- end
- end
-end
diff --git a/app/controllers/shares/bulk_controller.rb b/app/controllers/shares/bulk_controller.rb
index 0ec310ebbb4..9dbf7fe6c4e 100644
--- a/app/controllers/shares/bulk_controller.rb
+++ b/app/controllers/shares/bulk_controller.rb
@@ -69,8 +69,8 @@ class Shares::BulkController < ApplicationController
def respond_with_update_permission_buttons
@selected_shares.each do |share|
replace_via_turbo_stream(
- component: WorkPackages::Share::PermissionButtonComponent.new(share:,
- data: { "test-selector": "op-share-wp-update-role" })
+ component: Shares::PermissionButtonComponent.new(share:,
+ data: { "test-selector": "op-share-wp-update-role" })
)
end
@@ -79,7 +79,7 @@ class Shares::BulkController < ApplicationController
def respond_with_replace_modal
replace_via_turbo_stream(
- component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: find_shares)
+ component: Shares::ModalBodyComponent.new(work_package: @work_package, shares: find_shares)
)
respond_with_turbo_streams
@@ -88,12 +88,12 @@ class Shares::BulkController < ApplicationController
def respond_with_remove_shares
@selected_shares.each do |share|
remove_via_turbo_stream(
- component: WorkPackages::Share::ShareRowComponent.new(share:)
+ component: Shares::ShareRowComponent.new(share:)
)
end
update_via_turbo_stream(
- component: WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
+ component: Shares::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
)
respond_with_turbo_streams
diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb
index 0d67150d709..ddfcb285d65 100644
--- a/app/controllers/shares_controller.rb
+++ b/app/controllers/shares_controller.rb
@@ -45,7 +45,7 @@ class SharesController < ApplicationController
@shares = load_shares query
- render WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @shares, errors: @errors), layout: nil
+ render Shares::ModalBodyComponent.new(work_package: @work_package, shares: @shares, errors: @errors), layout: nil
end
def create
@@ -123,12 +123,12 @@ class SharesController < ApplicationController
def enterprise_check
return if EnterpriseToken.allows_to?(:work_package_sharing)
- render WorkPackages::Share::ModalUpsaleComponent.new
+ render Shares::ModalUpsaleComponent.new
end
def respond_with_replace_modal
replace_via_turbo_stream(
- component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package,
+ component: Shares::ModalBodyComponent.new(work_package: @work_package,
shares: @new_shares || find_shares,
errors: @errors)
)
@@ -138,17 +138,17 @@ class SharesController < ApplicationController
def respond_with_prepend_shares
replace_via_turbo_stream(
- component: WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package, errors: @errors)
+ component: Shares::InviteUserFormComponent.new(work_package: @work_package, errors: @errors)
)
update_via_turbo_stream(
- component: WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
+ component: Shares::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
)
@new_shares.each do |share|
prepend_via_turbo_stream(
- component: WorkPackages::Share::ShareRowComponent.new(share:),
- target_component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package,
+ component: Shares::ShareRowComponent.new(share:),
+ target_component: Shares::ModalBodyComponent.new(work_package: @work_package,
shares: find_shares,
errors: @errors)
)
@@ -159,7 +159,7 @@ class SharesController < ApplicationController
def respond_with_new_invite_form
replace_via_turbo_stream(
- component: WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package, errors: @errors)
+ component: Shares::InviteUserFormComponent.new(work_package: @work_package, errors: @errors)
)
respond_with_turbo_streams
@@ -167,7 +167,7 @@ class SharesController < ApplicationController
def respond_with_update_permission_button
replace_via_turbo_stream(
- component: WorkPackages::Share::PermissionButtonComponent.new(share: @share,
+ component: Shares::PermissionButtonComponent.new(share: @share,
data: { "test-selector": "op-share-wp-update-role" })
)
@@ -176,11 +176,11 @@ class SharesController < ApplicationController
def respond_with_remove_share
remove_via_turbo_stream(
- component: WorkPackages::Share::ShareRowComponent.new(share: @share)
+ component: Shares::ShareRowComponent.new(share: @share)
)
update_via_turbo_stream(
- component: WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
+ component: Shares::CounterComponent.new(work_package: @work_package, count: current_visible_member_count)
)
respond_with_turbo_streams
@@ -188,7 +188,7 @@ class SharesController < ApplicationController
def respond_with_update_user_details
update_via_turbo_stream(
- component: WorkPackages::Share::UserDetailsComponent.new(share: @share,
+ component: Shares::UserDetailsComponent.new(share: @share,
invite_resent: true)
)
diff --git a/app/forms/work_packages/share/invitee.rb b/app/forms/shares/invitee.rb
similarity index 98%
rename from app/forms/work_packages/share/invitee.rb
rename to app/forms/shares/invitee.rb
index de2d34f7369..4dd542a470c 100644
--- a/app/forms/work_packages/share/invitee.rb
+++ b/app/forms/shares/invitee.rb
@@ -25,7 +25,7 @@
#
# See COPYRIGHT and LICENSE files for more details.
#++
-module WorkPackages::Share
+module Shares
class Invitee < ApplicationForm
form do |user_invite_form|
user_invite_form.autocompleter(
diff --git a/spec/components/work_packages/share/user_details_component_spec.rb b/spec/components/shares/user_details_component_spec.rb
similarity index 99%
rename from spec/components/work_packages/share/user_details_component_spec.rb
rename to spec/components/shares/user_details_component_spec.rb
index aeb385aa6ca..5eefdb309e6 100644
--- a/spec/components/work_packages/share/user_details_component_spec.rb
+++ b/spec/components/shares/user_details_component_spec.rb
@@ -29,7 +29,7 @@
# ++
require "spec_helper"
-RSpec.describe WorkPackages::Share::UserDetailsComponent, type: :component do
+RSpec.describe Shares::UserDetailsComponent, type: :component do
subject { render_inline(described_class.new(share:, manager_mode:, invite_resent:)) }
shared_let(:project) { create(:project) }