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

Include Groups in shares list

Aaron Contrerase4932b86a877
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 fe881c3355b..4f5ee382f0d 100644
--- a/app/components/work_packages/share/modal_body_component.html.erb
+++ b/app/components/work_packages/share/modal_body_component.html.erb
@@ -5,7 +5,7 @@
render(WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package))
end
- if shared_users.none?
+ if shared_principals.none?
modal_content.with_row(mt: 3) do
render(Primer::Beta::Blankslate.new(border: true)) do |component|
component.with_visual_icon(icon: :people, size: :medium)
@@ -23,11 +23,11 @@
modal_content.with_row(mt: 3, data: { 'test-selector': 'op-share-wp-active-list'}) do
invited_user_list do |border_box|
border_box.with_header(color: :subtle, data: { 'test-selector': 'op-share-wp-active-count' }) do
- render(WorkPackages::Share::ShareCounterComponent.new(count: shared_users.count))
+ render(WorkPackages::Share::ShareCounterComponent.new(count: shared_principals.count))
end
- shared_users.each do |user|
- share = user.work_package_shares.where(entity: @work_package).first
+ shared_principals.each do |principal|
+ share = principal.work_package_shares.where(entity: @work_package).first
render(WorkPackages::Share::ShareRowComponent.new(share:,
container: border_box))
diff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rb
index f4e171669d4..f322d85c257 100644
--- a/app/components/work_packages/share/modal_body_component.rb
+++ b/app/components/work_packages/share/modal_body_component.rb
@@ -72,12 +72,12 @@ module WorkPackages
list_container.instance_variable_set(:@list_arguments, new_list_arguments)
end
- def shared_users
- @shared_users ||= User
- .having_entity_membership(@work_package)
- .includes(work_package_shares: :roles)
- .where(work_package_shares: { entity: @work_package })
- .ordered_by_name
+ def shared_principals
+ @shared_principals ||= Principal
+ .having_entity_membership(@work_package)
+ .includes(work_package_shares: :roles)
+ .where(work_package_shares: { entity: @work_package })
+ .ordered_by_name
end
end
end
diff --git a/app/components/work_packages/share/share_row_component.html.erb b/app/components/work_packages/share/share_row_component.html.erb
index c8ebbae2a58..e4f961d7fb9 100644
--- a/app/components/work_packages/share/share_row_component.html.erb
+++ b/app/components/work_packages/share/share_row_component.html.erb
@@ -1,8 +1,8 @@
<%=
- component_wrapper(:border_box_row, data: { 'test-selector': "op-share-wp-active-user-#{user.id}" }) do
+ component_wrapper(:border_box_row, data: { 'test-selector': "op-share-wp-active-user-#{principal.id}" }) do
grid_layout('op-share-wp-modal-body--user-row', tag: :div, align_items: :center, classes: 'ellipsis') do |user_row_grid|
user_row_grid.with_area(:user, tag: :div, classes: ' ellipsis') do
- render(Users::AvatarComponent.new(user: user, size: :medium))
+ render(Users::AvatarComponent.new(user: principal, size: :medium))
end
diff --git a/app/components/work_packages/share/share_row_component.rb b/app/components/work_packages/share/share_row_component.rb
index e9e8774d16b..f0d399b1f1c 100644
--- a/app/components/work_packages/share/share_row_component.rb
+++ b/app/components/work_packages/share/share_row_component.rb
@@ -42,7 +42,7 @@ module WorkPackages
@share = share
@work_package = share.entity
- @user = share.principal
+ @principal = share.principal
@container = container
end
@@ -64,7 +64,7 @@ module WorkPackages
private
- attr_reader :share, :work_package, :user, :container
+ attr_reader :share, :work_package, :principal, :container
def share_editable?
@share_editable ||= User.current != share.principal && sharing_manageable?
diff --git a/spec/features/work_packages/share_spec.rb b/spec/features/work_packages/share_spec.rb
index 3b1e6275215..7da4e77970e 100644
--- a/spec/features/work_packages/share_spec.rb
+++ b/spec/features/work_packages/share_spec.rb
@@ -148,13 +148,14 @@ RSpec.describe 'Work package sharing',
share_modal.expect_shared_count_of(5)
end
- it 'includes groups in the auto-completer search results' do
+ it 'allows seeing and managing group sharing' do
work_package_page.visit!
click_button 'Share'
share_modal.expect_open
- share_modal.invite_group(not_shared_yet_with_group, 'View')
+ share_modal.invite_group(not_shared_yet_with_group, 'Comment')
+ share_modal.expect_shared_with(not_shared_yet_with_group, 'Comment', position: 1)
end
end
diff --git a/spec/support/components/work_packages/share_modal.rb b/spec/support/components/work_packages/share_modal.rb
index 2500e154ee8..6903a6b7c2f 100644
--- a/spec/support/components/work_packages/share_modal.rb
+++ b/spec/support/components/work_packages/share_modal.rb
@@ -122,7 +122,7 @@ module Components
def expect_shared_count_of(count)
expect(active_list)
- .to have_selector('[data-test-selector="op-share-wp-active-count"]', text: "#{count} users")
+ .to have_css('[data-test-selector="op-share-wp-active-count"]', text: "#{count} users")
end
def expect_no_invite_option