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

separate texts in dialog when removing group member

Ivan Kuchin751d79fe2343
diff --git a/app/components/members/delete_member_dialog_component.html.erb b/app/components/members/delete_member_dialog_component.html.erb
index 2627b23cdf6..efccd2d22b5 100644
--- a/app/components/members/delete_member_dialog_component.html.erb
+++ b/app/components/members/delete_member_dialog_component.html.erb
@@ -33,20 +33,28 @@ See COPYRIGHT and LICENSE files for more details.
<% case %>
<% when can_delete_roles? && can_delete_shares? %>
<% dialog.with_body do %>
- <% if can_delete? %>
+ <% if !can_delete? %>
+ <%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
+ <%= paragraph { scoped_t(:also_user_has_shares_html, shared_work_packages_link:, count: shared_work_packages_count) } %>
<%= paragraph do %>
- <%= scoped_t(:will_remove_the_users_role) %>
- <%= scoped_t(:however_shares_with_user_html, shared_work_packages_link:, count: shared_work_packages_count) %>
+ <%= scoped_t(:remove_just_user_or_shares_too) %>
+ <%= scoped_t(:will_not_affect_inherited_shares) if inherited_shared_work_packages_count? %>
<% end %>
+ <% elsif principal.is_a?(Group) %>
<%= paragraph do %>
- <%= scoped_t(:would_you_like_to_remove_the_shares_too) %>
- <%= scoped_t(:will_not_affect_inherited_shares) if inherited_shared_work_packages_count? %>
+ <%= scoped_t(:will_remove_the_groups_role) %>
+ <%= scoped_t(:however_shares_with_group_html, shared_work_packages_link:, count: shared_work_packages_count) %>
+ <% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:would_you_like_to_remove_the_shares_with_group_too) %>
<% end %>
<% else %>
- <%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
- <%= paragraph { scoped_t(:also_user_has_shares_html, shared_work_packages_link:, count: shared_work_packages_count) } %>
<%= paragraph do %>
- <%= scoped_t(:remove_just_user_or_shares_too) %>
+ <%= scoped_t(:will_remove_the_users_role) %>
+ <%= scoped_t(:however_shares_with_user_html, shared_work_packages_link:, count: shared_work_packages_count) %>
+ <% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:would_you_like_to_remove_the_shares_with_user_too) %>
<%= scoped_t(:will_not_affect_inherited_shares) if inherited_shared_work_packages_count? %>
<% end %>
<% end %>
@@ -59,10 +67,12 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% when can_delete_roles? %>
<% dialog.with_body do %>
- <% if can_delete? %>
- <%= paragraph { scoped_t(:will_remove_all_access_priveleges) } %>
- <% else %>
+ <% if !can_delete? %>
<%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
+ <% elsif principal.is_a?(Group) %>
+ <%= paragraph { scoped_t(:will_remove_all_access_priveleges_group) } %>
+ <% else %>
+ <%= paragraph { scoped_t(:will_remove_all_access_priveleges_user) } %>
<% end %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fc518c26967..3bef1f4140a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -360,17 +360,23 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
delete_member_dialog:
title: "Remove member"
will_remove_the_users_role: "This will remove the user’s role from this project."
+ will_remove_the_groups_role: "This will remove the group role from this project."
however_shares_with_user_html:
one: "However, %{shared_work_packages_link} has also been shared with this user."
other: "However, %{shared_work_packages_link} have also been shared with this user."
- would_you_like_to_remove_the_shares_too: "A user that has been removed as member can still access shared work packages. Would you like to remove the shares too?"
+ however_shares_with_group_html:
+ one: "However, %{shared_work_packages_link} has also been shared with this group."
+ other: "However, %{shared_work_packages_link} have also been shared with this group."
+ would_you_like_to_remove_the_shares_with_user_too: "A user that has been removed as member can still access shared work packages. Would you like to remove the shares too?"
+ would_you_like_to_remove_the_shares_with_group_too: "A group that has been removed as member can still access shared work packages. Would you like to remove the shares too?"
will_not_affect_inherited_shares: "(This will not affect work packages shared with their group)."
can_remove_direct_but_not_shared_role: "You can remove this user as a direct project member but a group they are in is also a member of this project, so they will continue being a member via the group."
also_user_has_shares_html:
one: "Also, %{shared_work_packages_link} has been shared with this user."
other: "Also, %{shared_work_packages_link} have been shared with this user."
remove_just_user_or_shares_too: "Do you want to remove just the user as a direct member (and keep the shares) or remove the work package shares too?"
- will_remove_all_access_priveleges: "Deleting this member will remove all access privileges of the user to the project. The user will still exist as part of the instance."
+ will_remove_all_access_priveleges_user: "Deleting this member will remove all access privileges of the user to the project. The user will still exist as part of the instance."
+ will_remove_all_access_priveleges_group: "Deleting this member will remove all access privileges of the group to the project. The group will still exist as part of the instance."
cannot_delete_group_member: "You cannot delete this member because they belong to a group that is itself a member of this project."
cannot_delete_group_member_note_admin_html: "You can either remove the group as a member of the project or this specific member from the group in the %{administration_settings_link}."
cannot_delete_group_member_note_non_admin: "You can either remove the group as a member of the project or contact your administrator to remove this specific member from the group."
diff --git a/spec/components/members/delete_member_dialog_component_spec.rb b/spec/components/members/delete_member_dialog_component_spec.rb
index 1c08dc3f545..2eda2feb51b 100644
--- a/spec/components/members/delete_member_dialog_component_spec.rb
+++ b/spec/components/members/delete_member_dialog_component_spec.rb
@@ -50,35 +50,66 @@ RSpec.describe Members::DeleteMemberDialogComponent, type: :component do
let(:administration_settings_link) { "[administration settings link]" }
let(:may_manage_user?) { true }
- before do
- allow(member).to receive(:inherited_shared_work_packages_count?).and_return(true)
- end
-
context "when project membership and work package shares can be deleted" do
let(:stubs) { { can_delete?: true, can_delete_roles?: true, can_delete_shares?: true } }
- it "renders dialog" do
- render_inline(described_class.new(member, row:))
+ context "when principal is a User" do
+ let(:principal) { build_stubbed(:user) }
- expect(page).to have_css "dialog"
- expect(page).to have_css "h1", text: "Remove member"
+ before do
+ allow(member).to receive(:inherited_shared_work_packages_count?).and_return(true)
+ end
- expect(page).to have_css "scrollable-region", normalize_ws: true, exact_text: <<~TEXT.squish
- This will remove the user’s role from this project. However, [shared work packages link] have also been shared with this user.
- A user that has been removed as member can still access shared work packages. Would you like to remove the shares too?
- (This will not affect work packages shared with their group).
- TEXT
+ it "renders dialog" do
+ render_inline(described_class.new(member, row:))
- expect(page).to have_button "Cancel"
- expect(page).to have_css "a.Button", count: 2
- expect(page).to have_css "a.Button", text: "Remove member"
- expect(page).to have_css "a.Button", text: "Remove member and shares"
+ expect(page).to have_css "dialog"
+ expect(page).to have_css "h1", text: "Remove member"
+
+ expect(page).to have_css "scrollable-region", normalize_ws: true, exact_text: <<~TEXT.squish
+ This will remove the user’s role from this project.
+ However, [shared work packages link] have also been shared with this user.
+ A user that has been removed as member can still access shared work packages. Would you like to remove the shares too?
+ (This will not affect work packages shared with their group).
+ TEXT
+
+ expect(page).to have_button "Cancel"
+ expect(page).to have_css "a.Button", count: 2
+ expect(page).to have_css "a.Button", text: "Remove member"
+ expect(page).to have_css "a.Button", text: "Remove member and shares"
+ end
+ end
+
+ context "when principal is a Group" do
+ let(:principal) { build_stubbed(:group) }
+
+ it "renders dialog" do
+ render_inline(described_class.new(member, row:))
+
+ expect(page).to have_css "dialog"
+ expect(page).to have_css "h1", text: "Remove member"
+
+ expect(page).to have_css "scrollable-region", normalize_ws: true, exact_text: <<~TEXT.squish
+ This will remove the group role from this project.
+ However, [shared work packages link] have also been shared with this group.
+ A group that has been removed as member can still access shared work packages. Would you like to remove the shares too?
+ TEXT
+
+ expect(page).to have_button "Cancel"
+ expect(page).to have_css "a.Button", count: 2
+ expect(page).to have_css "a.Button", text: "Remove member"
+ expect(page).to have_css "a.Button", text: "Remove member and shares"
+ end
end
end
context "when project roles and work package shares can be deleted, but not project membership" do
let(:stubs) { { can_delete?: false, can_delete_roles?: true, can_delete_shares?: true } }
+ before do
+ allow(member).to receive(:inherited_shared_work_packages_count?).and_return(true)
+ end
+
it "renders dialog" do
render_inline(described_class.new(member, row:))