The `ChatwootApp.chatwoot_cloud?` gate on the platform banners route in #13943 reads `InstallationConfig` from the database. Because `routes.rb` is evaluated during `Rails.application.initialize!`, this ran before the database existed on a fresh setup, breaking `bundle exec rake db:create` in CI and first-time installs with `ActiveRecord::NoDatabaseError: We could not find your database: chatwoot_test`. The route is now always mounted, and the cloud check moved to where the database is guaranteed to be available — the controller (`before_action`) and the super admin sidebar partial. Closes the CI failure introduced by #13943. ## How to test 1. Drop your local databases: `bundle exec rake db:drop` 2. Run `bundle exec rake db:create` — it should succeed (previously failed with `NoDatabaseError`) 3. Bring the DB back: `bundle exec rake db:setup` 4. On a non-cloud install, visit `/super_admin/platform_banners` — should 404, and the sidebar entry should be hidden 5. With `DEPLOYMENT_ENV=cloud` configured (cloud install), the page and sidebar entry should work as before ## What changed - `config/routes.rb` — always mount `resources :platform_banners` (no DB call at boot) - `app/controllers/super_admin/platform_banners_controller.rb` — `before_action` raises `ActionController::RoutingError` (404) when not on Chatwoot Cloud - `app/views/super_admin/application/_navigation.html.erb` — hides the sidebar entry on non-cloud installs --------- Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
59 lines
2.6 KiB
ERB
59 lines
2.6 KiB
ERB
<%#
|
|
# Navigation
|
|
|
|
This partial is used to display the navigation in Administrate.
|
|
By default, the navigation contains navigation links
|
|
for all resources in the admin dashboard,
|
|
as defined by the routes in the `admin/` namespace
|
|
%>
|
|
|
|
<%= vite_client_tag %>
|
|
<%= vite_javascript_tag 'superadmin_pages' %>
|
|
|
|
<%
|
|
sidebar_icons = {
|
|
accounts: 'icon-building-4-line',
|
|
users: 'icon-user-follow-line',
|
|
platform_apps: 'icon-apps-2-line',
|
|
agent_bots: 'icon-robot-line',
|
|
platform_banners: 'icon-megaphone-line',
|
|
}
|
|
%>
|
|
|
|
<div class="border-slate-100 border-r w-56 flex-shrink-0 justify-between h-full flex flex-col" role="navigation">
|
|
<div>
|
|
<div class="flex mx-4 mb-4 border-slate-100 border-b py-6">
|
|
<%= link_to image_tag('/brand-assets/logo_thumbnail.svg', alt: 'Chatwoot Admin Dashboard', class: 'h-10'), super_admin_root_url %>
|
|
<div class="flex flex-col ml-3">
|
|
<div class="text-sm">Chatwoot <%= Chatwoot.config[:version] %></div>
|
|
<div class="text-xs text-slate-700 mt-0.5">Super Admin Console</div>
|
|
</div>
|
|
</div>
|
|
|
|
<ul class="my-4">
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-grid-line', url: super_admin_root_url, label: 'Dashboard' } %>
|
|
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
|
<% next if ["account_users", "access_tokens", "installation_configs", "dashboard", "devise/sessions", "app_configs", "instance_statuses", "settings", "push_diagnostics"].include? resource.resource %>
|
|
<% next if resource.resource == "platform_banners" && !ChatwootApp.chatwoot_cloud? %>
|
|
<%= render partial: "nav_item", locals: {
|
|
icon: sidebar_icons[resource.resource.to_sym],
|
|
url: resource_index_route(resource),
|
|
label: display_resource_name(resource),
|
|
}
|
|
%>
|
|
|
|
<% end %>
|
|
<%= render 'settings_menu', open: settings_open? %>
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
<ul class="my-4">
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-mist-fill', url: sidekiq_web_url, label: 'Sidekiq Dashboard' } %>
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-health-book-line', url: super_admin_instance_status_url, label: 'Instance Health' } %>
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-mail-send-fill', url: super_admin_push_diagnostics_url, label: 'Push Diagnostics' } %>
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-dashboard-line', url: '/', label: 'Agent Dashboard' } %>
|
|
<%= render partial: "nav_item", locals: { icon: 'icon-logout-circle-r-line', url: super_admin_logout_url, label: 'Logout' } %>
|
|
</ul>
|
|
</div>
|
|
</div>
|