Skip to content

Commit

Permalink
Have a default home page for the admin panel
Browse files Browse the repository at this point in the history
Need this to support different levels of access. This is a page that everyone can see (who has access to the admin panel)
  • Loading branch information
mlandauer committed Sep 10, 2024
1 parent fea9abb commit 62dc1e3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/controllers/admin/homes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# typed: strict
# frozen_string_literal: true

module Admin
class HomesController < Admin::ApplicationController
extend T::Sig

sig { void }
def index; end
end
end
8 changes: 8 additions & 0 deletions app/dashboards/home_dashboard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# typed: strict
# frozen_string_literal: true

require "administrate/custom_dashboard"

class HomeDashboard < Administrate::CustomDashboard
resource "Homes"
end
12 changes: 12 additions & 0 deletions app/policies/admin/homes_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# typed: strict

module Admin
class HomesPolicy < ApplicationPolicy
extend T::Sig

sig { returns(T::Boolean) }
def index?
true
end
end
end
6 changes: 6 additions & 0 deletions app/views/admin/homes/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="main-content__header">
<h1 class="main-content__page-title">Administration Panel</h1>
</div>
<div class="main-content__body">
<a href="https://en.wikipedia.org/wiki/With_great_power_comes_great_responsibility">With great power comes great responsibility</a>
</div>
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def matches?(request)
mount Flipper::UI.app(Flipper) => "flipper", as: :flipper
end

# We need to a consistent place accessible by all the roles to make the
# root route for the admin interface
resources :homes, only: :index
resources :users, except: [:new, :create] do
collection do
get :export_confirmed_emails
Expand Down Expand Up @@ -55,7 +58,7 @@ def matches?(request)
resources :test_emails, only: [:index, :create]
resources :roles, only: [:index, :show]

root to: "users#index"
root to: "homes#index"
end

constraints subdomain: "api" do
Expand Down

0 comments on commit 62dc1e3

Please sign in to comment.