- <% 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? %>
-
-
- <%= 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),
- ) %>
-
-
-
- <% account_user_page.resource.errors.full_messages.each do |message| %>
- - <%= message %>
- <% end %>
-
-
- <% 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 %>
-
- <%= render_field attribute, f: f %>
-
- <% end %>
- <% end %>
- <% end -%>
-
-
- <%= f.submit %>
-
- <% end %>
-
-
+ <%= render 'super_admin/shared/account_user_form', page: page, namespace: namespace, resource_type: 'account' %>
<%= render partial: "seed_data", locals: { page: page } %>
diff --git a/app/views/super_admin/shared/_account_user_form.html.erb b/app/views/super_admin/shared/_account_user_form.html.erb
new file mode 100644
index 000000000..5179571b6
--- /dev/null
+++ b/app/views/super_admin/shared/_account_user_form.html.erb
@@ -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
+%>
+
+
+ <% 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? %>
+
+
+ <%= 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)
+ ) %>
+
+
+
+ <% account_user_page.resource.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% 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 %>
+
+ <%= render_field attribute, f: f %>
+
+ <% end %>
+ <% end %>
+ <% end -%>
+
+
+ <%= f.submit %>
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/super_admin/users/show.html.erb b/app/views/super_admin/users/show.html.erb
index 622f95724..d8b2c6102 100644
--- a/app/views/super_admin/users/show.html.erb
+++ b/app/views/super_admin/users/show.html.erb
@@ -56,44 +56,6 @@ as well as a link to its edit page.
-
- <% 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? %>
-
-
- <%= 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)
- ) %>
-
-
-
- <% account_user_page.resource.errors.full_messages.each do |message| %>
- - <%= message %>
- <% end %>
-
-
- <% 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 %>
-
- <%= render_field attribute, f: f %>
-
- <% end %>
- <% end %>
- <% end -%>
-
-
- <%= f.submit %>
-
-<% end %>
-
-
+<%= render 'super_admin/shared/account_user_form', page: page, namespace: namespace, resource_type: 'user' %>
<%= render partial: "impersonate", locals: {page: page} %>
diff --git a/config/routes.rb b/config/routes.rb
index fbecd2d50..ebec6894b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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'