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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
show suggestion to use administration interface only when current user has permission for that
Ivan Kuchinde4222df7a93
diff --git a/app/components/members/delete_member_dialog_component.html.erb b/app/components/members/delete_member_dialog_component.html.erbindex d2a2ae5a577..2627b23cdf6 100644--- a/app/components/members/delete_member_dialog_component.html.erb+++ b/app/components/members/delete_member_dialog_component.html.erb@@ -73,7 +73,11 @@ See COPYRIGHT and LICENSE files for more details.<% else %><% dialog.with_body do %><%= paragraph { scoped_t(:cannot_delete_group_member) } %>- <%= paragraph { scoped_t(:cannot_delete_group_member_note_html, administration_settings_link:) } %>+ <% if may_manage_user? %>+ <%= paragraph { scoped_t(:cannot_delete_group_member_note_admin_html, administration_settings_link:) } %>+ <% else %>+ <%= paragraph { scoped_t(:cannot_delete_group_member_note_non_admin) } %>+ <% end %><% end %><% dialog.with_footer do %>diff --git a/app/components/members/delete_member_dialog_component.rb b/app/components/members/delete_member_dialog_component.rbindex 1f6688c0c52..27c1c6a2958 100644--- a/app/components/members/delete_member_dialog_component.rb+++ b/app/components/members/delete_member_dialog_component.rb@@ -38,6 +38,7 @@ module Members:can_delete?,:can_delete_roles?,:can_delete_shares?,+ :may_manage_user?,to: :rowdelegate :principal,diff --git a/app/components/members/delete_work_package_shares_dialog_component.html.erb b/app/components/members/delete_work_package_shares_dialog_component.html.erbindex 7e6afe7d6ab..94caee53131 100644--- a/app/components/members/delete_work_package_shares_dialog_component.html.erb+++ b/app/components/members/delete_work_package_shares_dialog_component.html.erb@@ -89,7 +89,11 @@ See COPYRIGHT and LICENSE files for more details.<% when other_shared_work_packages_count? %><% dialog.with_body do %><%= paragraph { scoped_t(:cannot_remove_inherited_with_role, shared_role_name:) } %>- <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>+ <% if may_manage_user? %>+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_admin_html, administration_settings_link:) } %>+ <% else %>+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_non_admin) } %>+ <% end %><% end %><% dialog.with_footer do %>@@ -98,7 +102,11 @@ See COPYRIGHT and LICENSE files for more details.<% else %><% dialog.with_body do %><%= paragraph { scoped_t(:cannot_remove_inherited, shared_role_name:) } %>- <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>+ <% if may_manage_user? %>+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_admin_html, administration_settings_link:) } %>+ <% else %>+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_non_admin) } %>+ <% end %><% end %><% dialog.with_footer do %>diff --git a/app/components/members/delete_work_package_shares_dialog_component.rb b/app/components/members/delete_work_package_shares_dialog_component.rbindex 2ac186131f2..27cc84d2d37 100644--- a/app/components/members/delete_work_package_shares_dialog_component.rb+++ b/app/components/members/delete_work_package_shares_dialog_component.rb@@ -38,6 +38,7 @@ module Members:shared_work_packages_link,:all_shared_work_packages_link,:administration_settings_link,+ :may_manage_user?,to: :rowdelegate :shared_role_id,diff --git a/app/components/members/row_component.rb b/app/components/members/row_component.rbindex 604b27a25f0..f29b65ab5a6 100644--- a/app/components/members/row_component.rb+++ b/app/components/members/row_component.rb@@ -155,6 +155,7 @@ module Membersdef may_delete? = table.authorize_deletedef may_view_shared_work_packages? = table.authorize_work_package_shares_viewdef may_delete_shares? = table.authorize_work_package_shares_delete+ def may_manage_user? = table.authorize_manage_userdef can_update? = may_update? && !table.hide_roles?def can_delete? = may_delete? && member.project_role? && member.deletable?diff --git a/app/components/members/table_component.rb b/app/components/members/table_component.rbindex 8e567c8ec77..1737238a52f 100644--- a/app/components/members/table_component.rb+++ b/app/components/members/table_component.rb@@ -34,6 +34,7 @@ module Members:authorize_delete,:authorize_work_package_shares_view,:authorize_work_package_shares_delete,+ :authorize_manage_user,:available_roles,:is_filtered,:shared_role_name,diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rbindex 7d8e6e90275..4b64724d3fe 100644--- a/app/controllers/members_controller.rb+++ b/app/controllers/members_controller.rb@@ -146,6 +146,7 @@ class MembersController < ApplicationControllerauthorize_delete: authorize_for("members", :destroy),authorize_work_package_shares_view: authorize_for("work_packages/shares", :update),authorize_work_package_shares_delete: authorize_for("work_packages/shares/bulk", :destroy),+ authorize_manage_user: current_user.allowed_globally?(:manage_user),is_filtered: Members::UserFilterComponent.filtered?(params),shared_role_name:}diff --git a/config/locales/en.yml b/config/locales/en.ymlindex ea8ee0c94dd..fc518c26967 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -372,7 +372,8 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}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."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_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_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."delete_work_package_shares_dialog:title: "Revoke work package shares"shared_with_this_user_html:@@ -388,7 +389,8 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}will_not_affect_inherited_shares: "(This will not affect work packages shared with their group)."cannot_remove_inherited: "The work packages shares shared via groups cannot be removed."cannot_remove_inherited_with_role: "The work packages shares with role %{shared_role_name} are shared via groups and cannot be removed."- cannot_remove_inherited_note_html: "You can either revoke the share to the group or remove this specific member from the group in the %{administration_settings_link}."+ cannot_remove_inherited_note_admin_html: "You can either revoke the share to the group or remove this specific member from the group in the %{administration_settings_link}."+ cannot_remove_inherited_note_non_admin: "You can either revoke the share to the group or contact your administrator to remove this specific member from the group."will_revoke_access_but_for_inherited: "This action will revoke their access to all of them, but the work packages shared with a group."will_revoke_access_to_all: "This action will revoke their access to all of them."diff --git a/spec/components/members/delete_member_dialog_component_spec.rb b/spec/components/members/delete_member_dialog_component_spec.rbindex 2eceb8200b9..1c08dc3f545 100644--- a/spec/components/members/delete_member_dialog_component_spec.rb+++ b/spec/components/members/delete_member_dialog_component_spec.rb@@ -42,11 +42,13 @@ RSpec.describe Members::DeleteMemberDialogComponent, type: :component doshared_work_packages_count:,shared_work_packages_link:,administration_settings_link:,+ may_manage_user?: may_manage_user?,**stubs)endlet(:shared_work_packages_count) { 3 }let(:shared_work_packages_link) { "[shared work packages link]" }let(:administration_settings_link) { "[administration settings link]" }+ let(:may_manage_user?) { true }before doallow(member).to receive(:inherited_shared_work_packages_count?).and_return(true)diff --git a/spec/components/members/delete_work_package_shares_dialog_component_spec.rb b/spec/components/members/delete_work_package_shares_dialog_component_spec.rbindex 4e75a62b1a5..88e31cf6882 100644--- a/spec/components/members/delete_work_package_shares_dialog_component_spec.rb+++ b/spec/components/members/delete_work_package_shares_dialog_component_spec.rb@@ -50,13 +50,15 @@ RSpec.describe Members::DeleteWorkPackageSharesDialogComponent, type: :componentshared_work_packages_count:,all_shared_work_packages_link:,shared_work_packages_link:,- administration_settings_link:)+ administration_settings_link:,+ may_manage_user?: may_manage_user?)endlet(:all_shared_work_packages_count) { 5 }let(:shared_work_packages_count) { 3 }let(:all_shared_work_packages_link) { "[all shared work packages link]" }let(:shared_work_packages_link) { "[shared work packages link]" }let(:administration_settings_link) { "[administration settings link]" }+ let(:may_manage_user?) { true }before doallow(member).to receive_messages(stubs)