diff --git a/app/components/work_packages/share/invite_user_form_component.html.erb b/app/components/work_packages/share/invite_user_form_component.html.erb index 89d370ada544..0b8653bd2437 100644 --- a/app/components/work_packages/share/invite_user_form_component.html.erb +++ b/app/components/work_packages/share/invite_user_form_component.html.erb @@ -37,7 +37,8 @@ end user_limit_row.with_column do - render(Primer::Beta::Text.new(color: :danger)) { I18n.t('work_package.sharing.text_user_limit_reached', count: OpenProject::Enterprise.open_seats_count) } + render(Primer::Beta::Text.new(color: :danger)) { I18n.t("work_package.sharing.warning_user_limit_reached#{'_admin' if User.current.admin?}", + upgrade_url: OpenProject::Enterprise.upgrade_url).html_safe } end end end diff --git a/app/controllers/concerns/accounts/user_limits.rb b/app/controllers/concerns/accounts/user_limits.rb index 575136a17c7f..649e3508c91e 100644 --- a/app/controllers/concerns/accounts/user_limits.rb +++ b/app/controllers/concerns/accounts/user_limits.rb @@ -89,10 +89,16 @@ def show_user_limit_error! end def user_limit_warning - warning = I18n.t( - :warning_user_limit_reached, - upgrade_url: OpenProject::Enterprise.upgrade_url - ) + warning = if current_user.admin? + I18n.t( + :warning_user_limit_reached_admin, + upgrade_url: OpenProject::Enterprise.upgrade_url + ) + else + I18n.t( + :warning_user_limit_reached + ) + end warning.html_safe end diff --git a/app/views/members/_member_form.html.erb b/app/views/members/_member_form.html.erb index 187ccb2eed1f..fa56e3d71053 100644 --- a/app/views/members/_member_form.html.erb +++ b/app/views/members/_member_form.html.erb @@ -104,7 +104,7 @@ See COPYRIGHT and LICENSE files for more details.
-

<%= I18n.t(:warning_user_limit_reached, upgrade_url: OpenProject::Enterprise.upgrade_path).html_safe %>

+

<%= I18n.t("warning_user_limit_reached#{'_admin' if current_user.admin?}", upgrade_url: OpenProject::Enterprise.upgrade_url).html_safe %>

<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f5a133c40be..2e273e904fa2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3200,8 +3200,9 @@ en: The activation email has expired. We sent you a new one to %{email}. Please click the link inside of it to activate your account. warning_user_limit_reached: > - User limit reached. You cannot activate any more users. - Please upgrade your plan or block members to allow for additional users. + Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this instance. + warning_user_limit_reached_admin: > + Adding additional users will exceed the current limit. Please upgrade your plan to be able to ensure external users are able to access this instance. warning_user_limit_reached_instructions: > You reached your user limit (%{current}/%{max} active users). Please contact sales@openproject.com to upgrade your Enterprise edition plan and add additional users. @@ -3265,10 +3266,12 @@ en: share: "Share" text_empty_state_description: "The work package has not been shared with anyone yet." text_empty_state_header: "No shared users" - text_user_limit_reached: - zero: "This instance has reached its user limit, you can’t share with new users. Please contact your administrator to add more members." - one: "Only 1 member left to reach the user limit of the instance. Please contact your administrator." - other: "Only %{count} members left to reach the user limit of the instance. Please contact your administrator." + text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package." + text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please upgrade your plan to be able to add more users.' + warning_user_limit_reached: > + Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package. + warning_user_limit_reached_admin: > + Adding additional users will exceed the current limit. Please upgrade your plan to be able to ensure external users are able to access this work package. working_days: info: > diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 6b637f9cd485..fd537b8b5dc0 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -80,7 +80,7 @@ end it "shows a user limit error" do - expect(flash[:error]).to match /user limit reached/i + expect(flash[:error]).to match /Adding additional users will exceed the current limit/i end it "redirects back to the user index" do @@ -96,7 +96,7 @@ end it "shows a user limit warning" do - expect(flash[:warning]).to match /user limit reached/i + expect(flash[:warning]).to match /Adding additional users will exceed the current limit/i end it "shows the new user page" do @@ -451,7 +451,7 @@ let(:user_limit_reached) { true } it "shows the user limit reached error and recommends to upgrade" do - expect(flash[:error]).to match /user limit reached.*upgrade/i + expect(flash[:error]).to match /Adding additional users will exceed the current limit.*upgrade/i end it "does not activate the user" do diff --git a/spec/features/members/invitation_spec.rb b/spec/features/members/invitation_spec.rb index 04664fc927b1..ab546fc78ed8 100644 --- a/spec/features/members/invitation_spec.rb +++ b/spec/features/members/invitation_spec.rb @@ -75,7 +75,6 @@ before do allow(OpenProject::Enterprise).to receive_messages( user_limit: 10, - user_limit_reached?: false, open_seats_count: 1 ) end @@ -87,15 +86,13 @@ members_page.search_and_select_principal! 'finkelstein@openproject.com', 'Send invite to finkelstein@openproject.com' - expect(members_page).not_to have_text sanitize_string(I18n.t(:warning_user_limit_reached, - upgrade_url: OpenProject::Enterprise.upgrade_path)), + expect(members_page).not_to have_text sanitize_string(I18n.t(:warning_user_limit_reached)), normalize_ws: true members_page.search_and_select_principal! 'frankenstein@openproject.com', 'Send invite to frankenstein@openproject.com' - expect(members_page).to have_text sanitize_string(I18n.t(:warning_user_limit_reached, - upgrade_url: OpenProject::Enterprise.upgrade_path)), + expect(members_page).to have_text sanitize_string(I18n.t(:warning_user_limit_reached)), normalize_ws: true end end diff --git a/spec/features/work_packages/share/multi_invite_spec.rb b/spec/features/work_packages/share/multi_invite_spec.rb index c4dda2f66bbc..edbe7e8d46fa 100644 --- a/spec/features/work_packages/share/multi_invite_spec.rb +++ b/spec/features/work_packages/share/multi_invite_spec.rb @@ -260,7 +260,6 @@ def inherited_member_roles(group:) before do allow(OpenProject::Enterprise).to receive_messages( user_limit: 10, - user_limit_reached?: false, open_seats_count: 1 ) end @@ -275,7 +274,7 @@ def inherited_member_roles(group:) # Add another non-existing user that would exceed the user limit share_modal.select_not_existing_user_option "hola@world.de" - share_modal.expect_user_limit_warning(open_seats: 1) + share_modal.expect_user_limit_warning end end end diff --git a/spec/support/components/work_packages/share_modal.rb b/spec/support/components/work_packages/share_modal.rb index c9a65ea63033..9ad2e1e83ef7 100644 --- a/spec/support/components/work_packages/share_modal.rb +++ b/spec/support/components/work_packages/share_modal.rb @@ -354,10 +354,10 @@ def expect_no_user_limit_warning end end - def expect_user_limit_warning(open_seats:) + def expect_user_limit_warning within modal_element do expect(page) - .to have_text(I18n.t('work_package.sharing.text_user_limit_reached', count: open_seats)) + .to have_text(I18n.t('work_package.sharing.warning_user_limit_reached')) end end end