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

Show lock actions of user with an icon on mobile

Oliver Güntherfa80c2e97210
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 9fb5c90c194..53f56cd7546 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -28,6 +28,7 @@
module UsersHelper
include OpenProject::FormTagHelper
+ include IconsHelper
##
# @param selected The option to be marked as selected.
@@ -96,25 +97,32 @@ module UsersHelper
result
end
+ def change_user_status_icons
+ {
+ "unlock" => "unlocked",
+ "activate" => "unlocked",
+ "lock" => "locked"
+ }
+ end
+
def change_user_status_buttons(user)
build_change_user_status_action(user) do |title, name|
- submit_tag(title, name:, class: "button")
+ button_tag(class: "button", name:, type: "submit", title:) do
+ concat op_icon("button--icon icon-#{change_user_status_icons[name]}")
+ concat content_tag(:span, title, class: "button--text")
+ end
end
end
def change_user_status_links(user)
- icons = {
- "unlock" => "unlocked",
- "activate" => "unlocked",
- "lock" => "locked"
- }
+
build_change_user_status_action(user) do |title, name|
link_to title,
change_status_user_path(user,
name.to_sym => "1",
back_url: request.fullpath),
method: :post,
- class: "icon icon-#{icons[name]}"
+ class: "icon icon-#{change_user_status_icons[name]}"
end
end
diff --git a/app/views/users/_toolbar.html.erb b/app/views/users/_toolbar.html.erb
index 1dae67593a6..1f6b49fad53 100644
--- a/app/views/users/_toolbar.html.erb
+++ b/app/views/users/_toolbar.html.erb
@@ -47,7 +47,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% if current_user.admin? %>
<% unless current_user.id == @user.id %>
- <li class="toolbar-item hidden-for-tablet">
+ <li class="toolbar-item">
<%= form_for @user,
:url => { :action => :change_status },
:method => :post do %>
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index c3bbe4c972e..e367c9b4191 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe UsersHelper do
end
it "contains a single button" do
- expect(buttons.scan("<input").count).to eq(1)
+ expect(buttons.scan("<button").count).to eq(1)
end
end
end
@@ -105,7 +105,7 @@ RSpec.describe UsersHelper do
end
it "returns inputs (buttons)" do
- expect(buttons.scan("<input").count).to eq(2)
+ expect(buttons.scan("<button").count).to eq(2)
end
it "contains 'Lock' and 'Reset Failed logins'" do