admin_suite 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/admin_suite.css +128 -0
- data/app/controllers/admin_suite/application_controller.rb +31 -0
- data/app/controllers/admin_suite/dashboard_controller.rb +59 -226
- data/app/helpers/admin_suite/base_helper.rb +108 -108
- data/app/helpers/admin_suite/panels_helper.rb +1 -1
- data/app/javascript/controllers/admin_suite/file_upload_controller.js +9 -9
- data/app/javascript/controllers/admin_suite/json_editor_controller.js +8 -8
- data/app/javascript/controllers/admin_suite/searchable_select_controller.js +2 -2
- data/app/javascript/controllers/admin_suite/tag_select_controller.js +1 -1
- data/app/javascript/controllers/admin_suite/toggle_switch_controller.js +1 -1
- data/app/views/admin_suite/dashboard/index.html.erb +6 -15
- data/app/views/admin_suite/panels/_cards.html.erb +6 -6
- data/app/views/admin_suite/panels/_chart.html.erb +12 -12
- data/app/views/admin_suite/panels/_health.html.erb +14 -14
- data/app/views/admin_suite/panels/_recent.html.erb +11 -11
- data/app/views/admin_suite/panels/_stat.html.erb +24 -24
- data/app/views/admin_suite/panels/_table.html.erb +10 -10
- data/app/views/admin_suite/portals/show.html.erb +1 -1
- data/app/views/admin_suite/resources/_form.html.erb +1 -1
- data/app/views/admin_suite/resources/edit.html.erb +4 -4
- data/app/views/admin_suite/resources/index.html.erb +23 -23
- data/app/views/admin_suite/resources/new.html.erb +4 -4
- data/app/views/admin_suite/resources/show.html.erb +17 -17
- data/app/views/admin_suite/shared/_form.html.erb +8 -8
- data/app/views/admin_suite/shared/_json_editor_field.html.erb +4 -4
- data/app/views/admin_suite/shared/_sidebar.html.erb +4 -4
- data/app/views/admin_suite/shared/_topbar.html.erb +1 -1
- data/app/views/layouts/admin_suite/application.html.erb +4 -4
- data/docs/configuration.md +25 -0
- data/docs/portals.md +42 -0
- data/lib/admin_suite/configuration.rb +10 -0
- data/lib/admin_suite/engine.rb +9 -0
- data/lib/admin_suite/ui/field_renderer_registry.rb +2 -2
- data/lib/admin_suite/ui/form_field_renderer.rb +2 -2
- data/lib/admin_suite/ui/show_formatter_registry.rb +5 -5
- data/lib/admin_suite/ui/show_value_formatter.rb +1 -1
- data/lib/admin_suite/version.rb +1 -1
- data/lib/admin_suite.rb +31 -0
- data/test/dummy/log/test.log +1328 -440
- data/test/dummy/tmp/local_secret.txt +1 -1
- data/test/integration/dashboard_test.rb +57 -1
- metadata +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c02d71d37975d95a2c65ffeee97e37a5a969d38af1782fdc54d86db04188fdd28451c9f3a2be79410e2b66eede3b444ab30145534c96c013f3a6da03a3c32d1e
|
|
@@ -1,13 +1,69 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "test_helper"
|
|
4
|
+
require "tmpdir"
|
|
4
5
|
|
|
5
6
|
module AdminSuite
|
|
6
7
|
class DashboardTest < ActionDispatch::IntegrationTest
|
|
7
8
|
test "GET /internal/admin_suite renders dashboard" do
|
|
8
9
|
get "/internal/admin_suite"
|
|
9
10
|
assert_response :success
|
|
10
|
-
assert_includes response.body, "
|
|
11
|
+
assert_includes response.body, "Admin Suite"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "loads custom root dashboard definition from dashboard_globs" do
|
|
15
|
+
old_globs = AdminSuite.config.dashboard_globs
|
|
16
|
+
old_title = AdminSuite.config.root_dashboard_title
|
|
17
|
+
old_description = AdminSuite.config.root_dashboard_description
|
|
18
|
+
|
|
19
|
+
Dir.mktmpdir("admin-suite-dashboard") do |dir|
|
|
20
|
+
dashboard_rb = File.join(dir, "dashboard.rb")
|
|
21
|
+
|
|
22
|
+
File.write(dashboard_rb, <<~'RUBY')
|
|
23
|
+
# frozen_string_literal: true
|
|
24
|
+
|
|
25
|
+
AdminSuite.configure do |config|
|
|
26
|
+
config.root_dashboard_title = ->(controller) { "Custom Root #{controller.request.path}" }
|
|
27
|
+
config.root_dashboard_description = ->(_controller) { "Custom root description" }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
AdminSuite.root_dashboard do
|
|
31
|
+
row do
|
|
32
|
+
stat_panel "Custom A", -> { 11 }, span: 6, variant: :mini, color: :slate
|
|
33
|
+
stat_panel "Custom B", 22, span: 6, variant: :mini, color: :slate
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
RUBY
|
|
37
|
+
|
|
38
|
+
AdminSuite.reset_root_dashboard!
|
|
39
|
+
AdminSuite.config.dashboard_globs = [File.join(dir, "*.rb")]
|
|
40
|
+
|
|
41
|
+
get "/internal/admin_suite"
|
|
42
|
+
assert_response :success
|
|
43
|
+
|
|
44
|
+
# Title + description should come from the dashboard definition file.
|
|
45
|
+
assert_includes response.body, "Custom Root /internal/admin_suite"
|
|
46
|
+
assert_includes response.body, "Custom root description"
|
|
47
|
+
|
|
48
|
+
# DSL-driven panels should render.
|
|
49
|
+
assert_includes response.body, "Custom A"
|
|
50
|
+
assert_includes response.body, ">11<"
|
|
51
|
+
assert_includes response.body, "Custom B"
|
|
52
|
+
assert_includes response.body, ">22<"
|
|
53
|
+
|
|
54
|
+
# Ensure spans are emitted (used to drive column layout).
|
|
55
|
+
assert_includes response.body, "admin-suite-dashboard-row"
|
|
56
|
+
assert_equal 2, response.body.scan("grid-column: span 6 / span 6;").size
|
|
57
|
+
|
|
58
|
+
# Loader should mark the dashboard as loaded in non-dev envs (test).
|
|
59
|
+
assert AdminSuite.config.root_dashboard_loaded
|
|
60
|
+
assert AdminSuite.root_dashboard_definition.present?
|
|
61
|
+
end
|
|
62
|
+
ensure
|
|
63
|
+
AdminSuite.config.dashboard_globs = old_globs
|
|
64
|
+
AdminSuite.config.root_dashboard_title = old_title
|
|
65
|
+
AdminSuite.config.root_dashboard_description = old_description
|
|
66
|
+
AdminSuite.reset_root_dashboard!
|
|
11
67
|
end
|
|
12
68
|
end
|
|
13
69
|
end
|