Skip to content

Commit a64ff55

Browse files
author
Raushan Kumar Raman
committed
feat: added pg_hero and authentication for all_casa_admin user
1 parent 7b663e6 commit a64ff55

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ gem "wicked"
5959
gem "flipper"
6060
gem "flipper-active_record"
6161
gem "flipper-ui"
62-
62+
gem 'pghero'
63+
gem 'pg_query'
6364
group :development, :test do
6465
gem "bullet" # Detect and fix N+1 queries
6566
gem "byebug", platforms: %i[mri mingw x64_mingw] # Call 'byebug' anywhere in the code to stop execution and get a debugger console

Gemfile.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ GEM
254254
activerecord (>= 4.0.0)
255255
globalid (1.2.1)
256256
activesupport (>= 6.1)
257+
google-protobuf (4.29.3)
258+
bigdecimal
259+
rake (>= 13)
260+
google-protobuf (4.29.3-arm64-darwin)
261+
bigdecimal
262+
rake (>= 13)
263+
google-protobuf (4.29.3-x86_64-darwin)
264+
bigdecimal
265+
rake (>= 13)
266+
google-protobuf (4.29.3-x86_64-linux)
267+
bigdecimal
268+
rake (>= 13)
257269
groupdate (6.5.1)
258270
activesupport (>= 7)
259271
hashdiff (1.1.2)
@@ -354,6 +366,10 @@ GEM
354366
rexml (~> 3.2, >= 3.2.6)
355367
safe_shell (>= 1.0.3, < 2.0)
356368
pg (1.5.9)
369+
pg_query (6.0.0)
370+
google-protobuf (>= 3.25.3)
371+
pghero (3.6.1)
372+
activerecord (>= 6.1)
357373
pretender (0.5.0)
358374
actionpack (>= 6.1)
359375
pry (0.14.2)
@@ -654,6 +670,8 @@ DEPENDENCIES
654670
paranoia
655671
pdf-forms
656672
pg
673+
pg_query
674+
pghero
657675
pretender
658676
pry
659677
pry-byebug

app/views/layouts/_all_casa_admin_sidebar.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
Feature Flags
2929
<% end %>
3030
</li>
31+
<li class="nav-item">
32+
<%= link_to "/pg_dashboard" do %>
33+
<i class="lni lni-pencil-alt mr-10"></i>
34+
Pg Dashboard
35+
<% end %>
36+
</li>
3137
<li class="nav-item">
3238
<%= link_to destroy_all_casa_admin_session_path, id:"all-casa-log-out" do %>
3339
<i class="lni lni-exit mr-10"></i>

config/routes.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
devise_for :all_casa_admins, path: "all_casa_admins", controllers: {sessions: "all_casa_admins/sessions"}
1919
devise_for :users, controllers: {sessions: "users/sessions", passwords: "users/passwords"}
20+
authenticate :all_casa_admins do
21+
mount PgHero::Engine, at: 'pg_dashboard', constraints: lambda { |request|
22+
admin = request.env['warden'].user(:all_casa_admin)
23+
admin.present? && (admin.role == 'All Casa Admin' || admin.casa_admin?)
24+
}
25+
end
2026

2127
concern :with_datatable do
2228
post "datatable", on: :collection

db/schema.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
ActiveRecord::Schema[7.2].define(version: 2024_10_17_050129) do
1414
# These are extensions that must be enabled in order to support this database
15+
enable_extension "pg_stat_statements"
1516
enable_extension "plpgsql"
1617

1718
create_table "action_text_rich_texts", force: :cascade do |t|

0 commit comments

Comments
 (0)