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
Implement invite button on the user's profile
Klaus Zandersa8e57970f668
diff --git a/app/components/users/row_component.rb b/app/components/users/row_component.rbindex c9974723345..09c3b0358c8 100644--- a/app/components/users/row_component.rb+++ b/app/components/users/row_component.rb@@ -45,7 +45,8 @@ module Usersdef loginicon = helpers.avatar user, size: :mini- link = link_to h(user.login), edit_user_path(user)++ link = link_to h(user.login), allowed_management_user_profile_path(user)icon + linkenddiff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 10e31c7731f..b7fb777eb05 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -207,7 +207,7 @@ class UsersController < ApplicationControllerflash[:error] = I18n.t(:notice_internal_server_error, app_title: Setting.app_title)end- redirect_to edit_user_path(@user)+ redirect_to helpers.allowed_management_user_profile_path(@user)enddef destroy@@ -233,6 +233,7 @@ class UsersController < ApplicationControllerdef can_show_user?return true if current_user.allowed_to_globally?(:manage_user)+ return true if current_user.allowed_to_globally?(:create_user)return true if @user == User.current(@user.active? || @user.registered?) \diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rbindex f1d9b955bcf..56dcdb06ce8 100644--- a/app/helpers/users_helper.rb+++ b/app/helpers/users_helper.rb@@ -126,6 +126,14 @@ module UsersHelperuser ? user.name : I18n.t('user.deleted')end+ def allowed_management_user_profile_path(user)+ if User.current.allowed_to_globally?(:manage_user)+ edit_user_path(user)+ else+ user_path(user)+ end+ end+def can_users_have_auth_source?AuthSource.any? && !OpenProject::Configuration.disable_password_login?enddiff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erbindex 91c7e4cc119..e77f48b16b7 100644--- a/app/views/users/show.html.erb+++ b/app/views/users/show.html.erb@@ -26,13 +26,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.See COPYRIGHT and LICENSE files for more details.++#%>-<% content_for :header_tags do %><%= call_hook :users_show_head %><% end %><% html_title t(:label_administration), t(:label_user_plural) -%><%= toolbar title: "#{avatar @user} #{h(@user.name)}".html_safe do %>- <% if User.current.admin? %>+ <% if User.current.allowed_to_globally?(:manage_user) %><li class="toolbar-item"><%= link_to edit_user_path(@user), class: 'button', accesskey: accesskey(:edit) do %><%= op_icon('button--icon icon-edit') %>@@ -40,8 +39,19 @@ See COPYRIGHT and LICENSE files for more details.<% end %></li><% end %>+ <% if current_user.allowed_to_globally?(:create_user) %>+ <li class="toolbar-item hidden-for-mobile">+ <%= form_for(@user, html: { class: 'toolbar-item' },+ url: { action: :resend_invitation },+ method: :post) do |_form| %>+ <button class="button" title="<%= t(:tooltip_resend_invitation) %>">+ <%= op_icon('button--icon icon-mail1') %>+ <span class="button--text"><%= t(:label_send_invitation) %></span>+ </button>+ <% end %>+ </li>+ <% end %><% end %>-<div class="grid-block medium-up-2"><div class="grid-content"><%= call_hook :view_account_left_top, user: @user %>@@ -57,9 +67,7 @@ See COPYRIGHT and LICENSE files for more details.<% end %></ul><% end %>-<%= call_hook :view_account_left_middle, user: @user %>-<% unless @memberships.empty? %><h3><%=t(:label_project_plural)%></h3><ul>@@ -73,7 +81,6 @@ See COPYRIGHT and LICENSE files for more details.<% end %><%= call_hook :view_account_left_bottom, user: @user %></div>-<div class="grid-content"><% unless @events.empty? %><h3>@@ -83,11 +90,9 @@ See COPYRIGHT and LICENSE files for more details.<%=t(:label_reported_work_packages)%>: <%= @user.reported_work_package_count %></p><%= render(Activities::DaysComponent.new(events: @events, display_user: false, header_tag: 'h4', activity_page: @activity_page)) %>-<%= other_formats_links do |f| %><%= f.link_to 'Atom', url: {controller: '/activities', action: 'index', id: nil, user_id: @user, key: User.current.rss_key} %><% end %>-<% content_for :header_tags do %><%= auto_discovery_link_tag(:atom, controller: '/activities', action: 'index', user_id: @user, format: :atom, key: User.current.rss_key) %><% end %>@@ -95,5 +100,4 @@ See COPYRIGHT and LICENSE files for more details.<%= call_hook :view_account_right_bottom, user: @user %></div></div>-<% html_title h(@user.name) %>diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 96d423e7922..588c3e4eb4f 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -54,7 +54,7 @@ Rails.application.reloader.to_prepare do{# TODO: edit is added because the resend invitiation link is currently displayed on the edit page,# maybe we need to move that to the show page?- users: %i[index show edit new create resend_invitation],+ users: %i[index show new create resend_invitation],'users/memberships': %i[create],admin: %i[index]},