Skip to content

Commit

Permalink
Change the text of the user limit warning
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Nov 20, 2023
1 parent 972f6aa commit 557d4b7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions app/controllers/concerns/accounts/user_limits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/members/_member_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="op-toast -warning icon-warning d-none"
data-user-limit-target="limitWarning">
<div class="op-toast--content">
<p><%= I18n.t(:warning_user_limit_reached, upgrade_url: OpenProject::Enterprise.upgrade_path).html_safe %></p>
<p><%= I18n.t("warning_user_limit_reached#{'_admin' if current_user.admin?}", upgrade_url: OpenProject::Enterprise.upgrade_url).html_safe %></p>
</div>
</div>
<% end %>
Expand Down
15 changes: 9 additions & 6 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="%{upgrade_url}">upgrade your plan</a> 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 <a href="%{upgrade_url}">upgrade your plan</a> 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 [email protected] to upgrade your Enterprise edition plan and add additional users.
Expand Down Expand Up @@ -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 <a href="%{upgrade_url}">upgrade your plan</a> 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 <a href="%{upgrade_url}">upgrade your plan</a> to be able to ensure external users are able to access this work package.
working_days:
info: >
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions spec/features/members/invitation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
before do
allow(OpenProject::Enterprise).to receive_messages(
user_limit: 10,
user_limit_reached?: false,
open_seats_count: 1
)
end
Expand All @@ -87,15 +86,13 @@
members_page.search_and_select_principal! '[email protected]',
'Send invite to [email protected]'

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! '[email protected]',
'Send invite to [email protected]'

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
Expand Down
3 changes: 1 addition & 2 deletions spec/features/work_packages/share/multi_invite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "[email protected]"
share_modal.expect_user_limit_warning(open_seats: 1)
share_modal.expect_user_limit_warning
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/support/components/work_packages/share_modal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 557d4b7

Please sign in to comment.