mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 20:48:07 +00:00
fix: broken link in admin account user list (#11661)
- Add a dummy link for account users page that redirect back to user page - move common account user form in user and account super admin pages to a partial fixes: #10757
This commit is contained in:
@@ -2,6 +2,13 @@ class SuperAdmin::AccountUsersController < SuperAdmin::ApplicationController
|
||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||
# For example, you may want to send an email after a foo is updated.
|
||||
#
|
||||
|
||||
# Since account/user page - account user role attribute links to the show page
|
||||
# Handle with a redirect to the user show page
|
||||
def show
|
||||
redirect_to super_admin_user_path(requested_resource.user)
|
||||
end
|
||||
|
||||
def create
|
||||
resource = resource_class.new(resource_params)
|
||||
authorize_resource(resource)
|
||||
|
||||
@@ -91,55 +91,7 @@ as well as a link to its edit page.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="main-content__body">
|
||||
<% account_user_page =
|
||||
Administrate::Page::Form.new(AccountUserDashboard.new, AccountUser.new) %>
|
||||
<%= form_for([namespace, account_user_page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if account_user_page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= t(
|
||||
"administrate.form.errors",
|
||||
pluralized_errors:
|
||||
pluralize(
|
||||
account_user_page.resource.errors.count,
|
||||
t("administrate.form.error"),
|
||||
),
|
||||
resource_name: display_resource_name(account_user_page.resource_name),
|
||||
) %>
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% account_user_page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% account_user_page.attributes.each do |title, attributes| -%>
|
||||
<% attributes.each do |attribute| %>
|
||||
<% if attribute.name == "account" %>
|
||||
<%= f.hidden_field("account_id", value: page.resource.id) %>
|
||||
<% else %>
|
||||
<div
|
||||
class="
|
||||
field-unit field-unit--<%= attribute.html_class %>
|
||||
field-unit--<%= requireness(attribute) %>
|
||||
"
|
||||
>
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</section>
|
||||
<%= render 'super_admin/shared/account_user_form', page: page, namespace: namespace, resource_type: 'account' %>
|
||||
|
||||
<%= render partial: "seed_data", locals: { page: page } %>
|
||||
|
||||
|
||||
54
app/views/super_admin/shared/_account_user_form.html.erb
Normal file
54
app/views/super_admin/shared/_account_user_form.html.erb
Normal file
@@ -0,0 +1,54 @@
|
||||
<%#
|
||||
# Account User Form Partial
|
||||
|
||||
This partial renders the account user creation form.
|
||||
Used by both account and user show pages.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`: The Administrate page object (Account or User)
|
||||
- `namespace`: The current namespace (usually :super_admin)
|
||||
- `resource_type`: Either 'account' or 'user' to determine hidden field
|
||||
%>
|
||||
|
||||
<section class="main-content__body">
|
||||
<% account_user_page = Administrate::Page::Form.new(AccountUserDashboard.new, AccountUser.new) %>
|
||||
<%= form_for([namespace, account_user_page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if account_user_page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= t(
|
||||
"administrate.form.errors",
|
||||
pluralized_errors: pluralize(
|
||||
account_user_page.resource.errors.count,
|
||||
t("administrate.form.error")
|
||||
),
|
||||
resource_name: display_resource_name(account_user_page.resource_name)
|
||||
) %>
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% account_user_page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% account_user_page.attributes.each do |title, attributes| -%>
|
||||
<% attributes.each do |attribute| %>
|
||||
<% if attribute.name == resource_type %>
|
||||
<%= f.hidden_field("#{resource_type}_id", value: page.resource.id) %>
|
||||
<% else %>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -56,44 +56,6 @@ as well as a link to its edit page.
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="main-content__body">
|
||||
<% account_user_page = Administrate::Page::Form.new(AccountUserDashboard.new, AccountUser.new) %>
|
||||
<%= form_for([namespace, account_user_page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if account_user_page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= t(
|
||||
"administrate.form.errors",
|
||||
pluralized_errors: pluralize(account_user_page.resource.errors.count, t("administrate.form.error")),
|
||||
resource_name: display_resource_name(account_user_page.resource_name)
|
||||
) %>
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% account_user_page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% account_user_page.attributes.each do |title, attributes| -%>
|
||||
<% attributes.each do |attribute| %>
|
||||
<% if attribute.name == "user" %>
|
||||
<%= f.hidden_field('user_id', value: page.resource.id) %>
|
||||
<% else %>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</section>
|
||||
<%= render 'super_admin/shared/account_user_form', page: page, namespace: namespace, resource_type: 'user' %>
|
||||
|
||||
<%= render partial: "impersonate", locals: {page: page} %>
|
||||
|
||||
@@ -533,7 +533,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
# resources that doesn't appear in primary navigation in super admin
|
||||
resources :account_users, only: [:new, :create, :destroy]
|
||||
resources :account_users, only: [:new, :create, :show, :destroy]
|
||||
end
|
||||
authenticated :super_admin do
|
||||
mount Sidekiq::Web => '/monitoring/sidekiq'
|
||||
|
||||
Reference in New Issue
Block a user