iron_admin 0.7.0 → 0.8.0
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/CHANGELOG.md +129 -1
- data/README.md +48 -1
- data/UPGRADING.md +495 -8
- data/app/assets/tailwind/iron_admin/engine.css +79 -4
- data/app/components/iron_admin/dashboards/activity_feed_component/item_component.html.haml +6 -9
- data/app/components/iron_admin/dashboards/activity_feed_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/activity_feed_component.rb +21 -24
- data/app/components/iron_admin/dashboards/chart_component.html.haml +3 -5
- data/app/components/iron_admin/dashboards/chart_component.rb +86 -24
- data/app/components/iron_admin/dashboards/concerns/themed_card.rb +39 -0
- data/app/components/iron_admin/dashboards/metric_card_component.html.haml +8 -7
- data/app/components/iron_admin/dashboards/metric_card_component.rb +2 -0
- data/app/components/iron_admin/dashboards/progress_component.html.haml +11 -7
- data/app/components/iron_admin/dashboards/progress_component.rb +11 -6
- data/app/components/iron_admin/dashboards/quick_links_component/link_component.html.haml +8 -9
- data/app/components/iron_admin/dashboards/quick_links_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/quick_links_component.rb +4 -12
- data/app/components/iron_admin/dashboards/recent_table_component.html.haml +15 -10
- data/app/components/iron_admin/dashboards/recent_table_component.rb +49 -0
- data/app/components/iron_admin/dashboards/stats_grid_component/stat_component.html.haml +13 -14
- data/app/components/iron_admin/dashboards/stats_grid_component.html.haml +1 -0
- data/app/components/iron_admin/dashboards/stats_grid_component.rb +9 -11
- data/app/components/iron_admin/filters/bar_component.html.haml +8 -6
- data/app/components/iron_admin/filters/bar_component.rb +56 -9
- data/app/components/iron_admin/filters/control_styles.rb +82 -0
- data/app/components/iron_admin/filters/date_range_component.html.haml +9 -4
- data/app/components/iron_admin/filters/date_range_component.rb +10 -6
- data/app/components/iron_admin/filters/search_component.html.haml +4 -4
- data/app/components/iron_admin/filters/search_component.rb +3 -5
- data/app/components/iron_admin/filters/select_filter_component.html.haml +1 -1
- data/app/components/iron_admin/filters/select_filter_component.rb +5 -16
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.html.haml +9 -5
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.rb +10 -8
- data/app/components/iron_admin/form/belongs_to_component.html.haml +2 -2
- data/app/components/iron_admin/form/belongs_to_component.rb +4 -18
- data/app/components/iron_admin/form/checkbox_component.rb +2 -3
- data/app/components/iron_admin/form/concerns/form_input_behavior.rb +1 -1
- data/app/components/iron_admin/form/control_classes.rb +108 -0
- data/app/components/iron_admin/form/date_picker_component.rb +3 -7
- data/app/components/iron_admin/form/field_wrapper_component.html.haml +3 -3
- data/app/components/iron_admin/form/field_wrapper_component.rb +3 -3
- data/app/components/iron_admin/form/nested_form_component.html.haml +4 -5
- data/app/components/iron_admin/form/nested_form_component.rb +12 -2
- data/app/components/iron_admin/form/select_component.html.haml +1 -1
- data/app/components/iron_admin/form/select_component.rb +2 -16
- data/app/components/iron_admin/form/text_input_component.rb +1 -5
- data/app/components/iron_admin/form/textarea_component.rb +1 -5
- data/app/components/iron_admin/layout/flash_component.html.haml +1 -1
- data/app/components/iron_admin/layout/flash_component.rb +4 -3
- data/app/components/iron_admin/layout/navbar_component.html.haml +15 -9
- data/app/components/iron_admin/layout/navbar_component.rb +29 -1
- data/app/components/iron_admin/layout/shell_component.html.haml +4 -4
- data/app/components/iron_admin/layout/shell_component.rb +16 -3
- data/app/components/iron_admin/layout/sidebar_component.html.haml +21 -25
- data/app/components/iron_admin/layout/sidebar_component.rb +76 -1
- data/app/components/iron_admin/layout/theme_switcher_component.html.haml +15 -0
- data/app/components/iron_admin/layout/theme_switcher_component.rb +74 -0
- data/app/components/iron_admin/resources/actions_component.html.haml +15 -8
- data/app/components/iron_admin/resources/actions_component.rb +34 -2
- data/app/components/iron_admin/resources/breadcrumb_component.html.haml +3 -3
- data/app/components/iron_admin/resources/breadcrumb_component.rb +8 -7
- data/app/components/iron_admin/resources/bulk_actions_component.html.haml +9 -8
- data/app/components/iron_admin/resources/bulk_actions_component.rb +47 -4
- data/app/components/iron_admin/resources/data_table_component.html.haml +15 -15
- data/app/components/iron_admin/resources/data_table_component.rb +34 -3
- data/app/components/iron_admin/resources/related_list_component.html.haml +7 -7
- data/app/components/iron_admin/resources/related_list_component.rb +26 -2
- data/app/components/iron_admin/resources/show_field_component.html.haml +3 -3
- data/app/components/iron_admin/resources/show_field_component.rb +10 -4
- data/app/components/iron_admin/resources/styles.rb +136 -0
- data/app/components/iron_admin/ui/alert_component.html.haml +2 -2
- data/app/components/iron_admin/ui/alert_component.rb +27 -31
- data/app/components/iron_admin/ui/badge_component.rb +40 -20
- data/app/components/iron_admin/ui/button_component.rb +37 -11
- data/app/components/iron_admin/ui/card_component.rb +3 -3
- data/app/components/iron_admin/ui/dropdown_component.html.haml +1 -1
- data/app/components/iron_admin/ui/dropdown_component.rb +34 -13
- data/app/components/iron_admin/ui/empty_state_component.html.haml +4 -5
- data/app/components/iron_admin/ui/empty_state_component.rb +2 -2
- data/app/components/iron_admin/ui/modal_component.html.haml +5 -5
- data/app/components/iron_admin/ui/modal_component.rb +6 -4
- data/app/components/iron_admin/ui/pagination_component.html.haml +14 -14
- data/app/components/iron_admin/ui/pagination_component.rb +26 -9
- data/app/components/iron_admin/ui/scopes_component.html.haml +2 -2
- data/app/components/iron_admin/ui/scopes_component.rb +44 -11
- data/app/components/iron_admin/ui/tooltip_component.rb +11 -4
- data/app/controllers/iron_admin/application_controller.rb +58 -4
- data/app/controllers/iron_admin/audit_controller.rb +30 -6
- data/app/controllers/iron_admin/concerns/action_executable.rb +37 -0
- data/app/controllers/iron_admin/concerns/assignable_references.rb +149 -0
- data/app/controllers/iron_admin/concerns/authorizable.rb +11 -0
- data/app/controllers/iron_admin/concerns/blank_password_filterable.rb +21 -0
- data/app/controllers/iron_admin/concerns/event_emittable.rb +47 -7
- data/app/controllers/iron_admin/concerns/filterable.rb +34 -9
- data/app/controllers/iron_admin/concerns/nested_permittable.rb +5 -3
- data/app/controllers/iron_admin/concerns/nested_tenant_check.rb +159 -0
- data/app/controllers/iron_admin/concerns/polymorphic_references.rb +131 -0
- data/app/controllers/iron_admin/concerns/scopeable.rb +54 -7
- data/app/controllers/iron_admin/concerns/searchable.rb +3 -3
- data/app/controllers/iron_admin/concerns/tenant_assignable.rb +118 -0
- data/app/controllers/iron_admin/concerns/tenant_containment.rb +146 -0
- data/app/controllers/iron_admin/exports_controller.rb +2 -2
- data/app/controllers/iron_admin/imports_controller.rb +1 -1
- data/app/controllers/iron_admin/resources_controller.rb +48 -41
- data/app/controllers/iron_admin/search_controller.rb +1 -2
- data/app/controllers/iron_admin/themes_controller.rb +50 -0
- data/app/controllers/iron_admin/tools_controller.rb +58 -5
- data/app/helpers/iron_admin/action_form_helper.rb +19 -0
- data/app/helpers/iron_admin/application_helper.rb +93 -16
- data/app/helpers/iron_admin/assignable_records_helper.rb +32 -0
- data/app/helpers/iron_admin/component_overrides_helper.rb +9 -4
- data/app/helpers/iron_admin/field_display_helper.rb +88 -43
- data/app/helpers/iron_admin/related_records_helper.rb +51 -0
- data/app/helpers/iron_admin/theme_helper.rb +56 -46
- data/app/javascript/iron_admin/controllers/cp_bulk_select_controller.js +12 -0
- data/app/javascript/iron_admin/controllers/cp_chart_controller.js +4 -0
- data/app/javascript/iron_admin/controllers/cp_disclosure_controller.js +19 -0
- data/app/javascript/iron_admin/controllers/cp_search_shortcut_controller.js +39 -0
- data/app/javascript/iron_admin/index.js +4 -0
- data/app/views/iron_admin/audit/index.html.haml +78 -81
- data/app/views/iron_admin/dashboard/index.html.haml +10 -9
- data/app/views/iron_admin/form/_action_field.html.haml +50 -0
- data/app/views/iron_admin/form/_nested_row.html.haml +18 -13
- data/app/views/iron_admin/imports/new.html.haml +14 -13
- data/app/views/iron_admin/imports/preview.html.haml +24 -21
- data/app/views/iron_admin/resources/_form.html.haml +70 -68
- data/app/views/iron_admin/resources/action_form.html.haml +16 -59
- data/app/views/iron_admin/resources/bulk_action_form.html.haml +20 -58
- data/app/views/iron_admin/resources/edit.html.haml +3 -3
- data/app/views/iron_admin/resources/index.html.haml +87 -74
- data/app/views/iron_admin/resources/new.html.haml +2 -2
- data/app/views/iron_admin/resources/show.html.haml +53 -41
- data/app/views/iron_admin/search/index.html.haml +17 -9
- data/app/views/iron_admin/shared/_pagination.html.haml +13 -10
- data/app/views/iron_admin/shared/error.html.haml +16 -12
- data/app/views/iron_admin/tools/action_form.html.haml +9 -55
- data/app/views/iron_admin/tools/show.html.haml +4 -5
- data/app/views/layouts/iron_admin/_document_head.html.haml +24 -0
- data/app/views/layouts/iron_admin/application.html.haml +4 -17
- data/app/views/layouts/iron_admin/minimal.html.haml +7 -0
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +1 -0
- data/docs/FAQ.md +87 -37
- data/docs/README.md +8 -2
- data/docs/components/README.md +6 -2
- data/docs/components/dashboard-components.md +24 -35
- data/docs/components/filter-components.md +44 -92
- data/docs/components/form-components.md +16 -32
- data/docs/components/resource-components.md +46 -27
- data/docs/components/ui-components.md +44 -26
- data/docs/getting-started/installation.md +5 -1
- data/docs/getting-started/quick-start.md +36 -23
- data/docs/guides/authentication.md +182 -42
- data/docs/guides/components.md +97 -15
- data/docs/guides/custom-adapters.md +24 -4
- data/docs/guides/dashboard.md +68 -44
- data/docs/guides/export.md +24 -8
- data/docs/guides/extending.md +206 -51
- data/docs/guides/fields.md +229 -70
- data/docs/guides/imports.md +33 -18
- data/docs/guides/resources.md +333 -111
- data/docs/guides/theming.md +930 -58
- data/docs/guides/troubleshooting.md +7 -3
- data/docs/plugin-system-design.md +8 -7
- data/docs/reference/configuration.md +51 -16
- data/docs/reference/routes.md +1 -0
- data/docs/reference/theme-properties.md +101 -38
- data/lib/generators/iron_admin/install/templates/initializer.rb.tt +7 -2
- data/lib/generators/iron_admin/install_audit/templates/create_iron_admin_audit_entries.rb.tt +2 -0
- data/lib/iron_admin/action_field.rb +11 -0
- data/lib/iron_admin/adapters/active_record.rb +95 -0
- data/lib/iron_admin/adapters/base.rb +107 -0
- data/lib/iron_admin/adapters/http/query.rb +21 -0
- data/lib/iron_admin/adapters/http.rb +84 -4
- data/lib/iron_admin/adapters/mongoid.rb +96 -2
- data/lib/iron_admin/audit_log.rb +64 -6
- data/lib/iron_admin/authentication_warning.rb +31 -0
- data/lib/iron_admin/concerns/filter_definable.rb +15 -1
- data/lib/iron_admin/concerns/nestable.rb +25 -0
- data/lib/iron_admin/concerns/scope_countable.rb +56 -0
- data/lib/iron_admin/concerns/soft_deletable.rb +28 -9
- data/lib/iron_admin/configuration/components.rb +14 -3
- data/lib/iron_admin/configuration/theme/neutral_defaults.rb +179 -0
- data/lib/iron_admin/configuration/theme.rb +292 -87
- data/lib/iron_admin/configuration.rb +340 -45
- data/lib/iron_admin/dashboard.rb +22 -38
- data/lib/iron_admin/engine.rb +16 -2
- data/lib/iron_admin/errors.rb +3 -0
- data/lib/iron_admin/field.rb +78 -17
- data/lib/iron_admin/field_inferrer.rb +61 -3
- data/lib/iron_admin/field_override_warning.rb +67 -0
- data/lib/iron_admin/import/import_preview.rb +56 -7
- data/lib/iron_admin/import/importer.rb +91 -14
- data/lib/iron_admin/import/tenant_precheck.rb +67 -0
- data/lib/iron_admin/plugin/registration.rb +64 -0
- data/lib/iron_admin/plugin_registry.rb +3 -2
- data/lib/iron_admin/policy.rb +22 -12
- data/lib/iron_admin/policy_coverage_warning.rb +46 -0
- data/lib/iron_admin/request_context.rb +18 -0
- data/lib/iron_admin/resource.rb +218 -77
- data/lib/iron_admin/resource_registry.rb +86 -13
- data/lib/iron_admin/scope_counts.rb +73 -0
- data/lib/iron_admin/tenant_scope.rb +30 -0
- data/lib/iron_admin/tool.rb +61 -12
- data/lib/iron_admin/tool_context.rb +10 -6
- data/lib/iron_admin/version.rb +1 -1
- data/lib/iron_admin.rb +29 -2
- metadata +37 -7
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
1
|
+
-# Authentication denials turn iron_admin_error_navigation? off. Skip the
|
|
2
|
+
-# policy check and the links: a nil visitor makes user.admin? raise.
|
|
3
|
+
-# The only local is error, so a host override can declare strict locals.
|
|
4
|
+
- back_resource = @resource_class if iron_admin_error_navigation? && @resource_class&.crud_allowed?(:read, iron_admin_current_user)
|
|
5
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
6
|
+
%section#cp-error-page.max-w-md.mx-auto.mt-8.p-8.text-center{ class: "#{t.card_bg} #{t.border_width} #{t.card_border} #{t.border_radius} #{t.card_shadow}", "aria-labelledby": "cp-error-page-title" }
|
|
7
|
+
%p.text-sm.font-medium.tabular-nums{ class: t.muted_text }= Rack::Utils.status_code(error)
|
|
8
|
+
%h1#cp-error-page-title.mt-2{ class: "#{t.page_title} #{t.heading_font}" }= I18n.t("iron_admin.errors.#{error}.title")
|
|
9
|
+
%p.mt-2.text-sm{ class: t.muted_text }= I18n.t("iron_admin.errors.#{error}.message")
|
|
10
|
+
- if iron_admin_error_navigation?
|
|
11
|
+
.mt-6
|
|
12
|
+
- if back_resource
|
|
13
|
+
= render IronAdmin::Ui::ButtonComponent.new(text: I18n.t("iron_admin.errors.back_to_resource", resource: back_resource.label),
|
|
14
|
+
href: resources_path(back_resource.resource_name))
|
|
15
|
+
- else
|
|
16
|
+
= render IronAdmin::Ui::ButtonComponent.new(text: I18n.t("iron_admin.errors.back_to_dashboard"), href: root_path)
|
|
@@ -1,57 +1,11 @@
|
|
|
1
|
-
.
|
|
2
|
-
%h1.
|
|
1
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-lg.mx-auto
|
|
2
|
+
%h1.mb-6{ class: "#{t.page_title} #{t.heading_font}" }= @declared_action.label
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
= field.label
|
|
9
|
-
- if field.required
|
|
10
|
-
%span.text-red-500 *
|
|
4
|
+
.p-6{ class: cp_card }
|
|
5
|
+
= form_tag @form_url, method: :post, class: "space-y-5" do
|
|
6
|
+
- @form_fields.each do |field|
|
|
7
|
+
= render "iron_admin/form/action_field", field: field, scope: "tool_action"
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
id: "tool_action_#{field.name}",
|
|
16
|
-
class: cp_filter_input_class,
|
|
17
|
-
placeholder: field.placeholder,
|
|
18
|
-
required: field.required
|
|
19
|
-
- when :textarea
|
|
20
|
-
= text_area_tag "tool_action[#{field.name}]", field.default,
|
|
21
|
-
id: "tool_action_#{field.name}",
|
|
22
|
-
class: "#{cp_filter_input_class} h-24",
|
|
23
|
-
placeholder: field.placeholder,
|
|
24
|
-
required: field.required
|
|
25
|
-
- when :number
|
|
26
|
-
= number_field_tag "tool_action[#{field.name}]", field.default,
|
|
27
|
-
id: "tool_action_#{field.name}",
|
|
28
|
-
class: cp_filter_input_class,
|
|
29
|
-
placeholder: field.placeholder,
|
|
30
|
-
step: "any",
|
|
31
|
-
required: field.required
|
|
32
|
-
- when :boolean
|
|
33
|
-
.flex.items-center.gap-2
|
|
34
|
-
= check_box_tag "tool_action[#{field.name}]", "1", field.default,
|
|
35
|
-
id: "tool_action_#{field.name}",
|
|
36
|
-
class: "rounded border-gray-300"
|
|
37
|
-
%span.text-sm{ class: cp_body_text }= field.label
|
|
38
|
-
- when :date
|
|
39
|
-
= date_field_tag "tool_action[#{field.name}]", field.default,
|
|
40
|
-
id: "tool_action_#{field.name}",
|
|
41
|
-
class: cp_filter_input_class,
|
|
42
|
-
required: field.required
|
|
43
|
-
- when :datetime
|
|
44
|
-
= datetime_field_tag "tool_action[#{field.name}]", field.default,
|
|
45
|
-
id: "tool_action_#{field.name}",
|
|
46
|
-
class: cp_filter_input_class,
|
|
47
|
-
required: field.required
|
|
48
|
-
- when :select
|
|
49
|
-
%select{ name: "tool_action[#{field.name}]", id: "tool_action_#{field.name}",
|
|
50
|
-
class: cp_filter_input_class, required: field.required }
|
|
51
|
-
%option{ value: "" }= field.placeholder || "Select..."
|
|
52
|
-
- (field.options || []).each do |opt|
|
|
53
|
-
%option{ value: opt, selected: field.default == opt }= opt.to_s.humanize
|
|
54
|
-
|
|
55
|
-
.flex.items-center.gap-3.pt-3.border-t.border-gray-100
|
|
56
|
-
%button{ type: "submit", class: cp_btn_primary }= I18n.t("iron_admin.tools.action_form.submit", default: "Execute")
|
|
57
|
-
= link_to I18n.t("iron_admin.form.cancel_button"), tool_path(@tool_class.tool_name), class: "text-sm #{cp_link_muted}"
|
|
9
|
+
.flex.items-center.gap-3.pt-5.border-t{ class: t.card_border }
|
|
10
|
+
%button{ type: "submit", class: cp_btn_primary }= I18n.t("iron_admin.tools.action_form.submit", default: "Execute")
|
|
11
|
+
= link_to I18n.t("iron_admin.form.cancel_button"), tool_path(@tool_class.tool_name), class: cp_btn_secondary
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
.
|
|
1
|
+
.px-4.sm:px-6.lg:px-8.py-6.max-w-7xl.mx-auto
|
|
2
2
|
.flex.items-center.justify-between.mb-6
|
|
3
|
-
%h1
|
|
3
|
+
%h1{ class: "#{t.page_title} #{t.heading_font}" }= @tool_class.label
|
|
4
4
|
.overflow-hidden{ class: cp_card }
|
|
5
5
|
.p-6
|
|
6
6
|
%p.text-sm.mb-6{ class: cp_muted_text }
|
|
@@ -11,15 +11,14 @@
|
|
|
11
11
|
- @tool_class.defined_tool_actions.each do |action|
|
|
12
12
|
- next unless action.allowed?(iron_admin_current_user)
|
|
13
13
|
- if action.has_form?
|
|
14
|
-
= link_to tool_action_form_path(@tool_class.tool_name, action.name),
|
|
15
|
-
class: "#{t.btn_secondary} px-4 py-2 text-sm font-medium rounded-lg inline-flex items-center gap-2" do
|
|
14
|
+
= link_to tool_action_form_path(@tool_class.tool_name, action.name), class: cp_btn_secondary do
|
|
16
15
|
- if action.icon
|
|
17
16
|
= heroicon action.icon, variant: :mini, options: { class: "h-4 w-4" }
|
|
18
17
|
= action.label
|
|
19
18
|
- else
|
|
20
19
|
= button_to tool_action_path(@tool_class.tool_name, action.name),
|
|
21
20
|
method: :post,
|
|
22
|
-
class:
|
|
21
|
+
class: cp_btn_secondary,
|
|
23
22
|
data: action.confirm ? { turbo_confirm: action.confirm_message || I18n.t("iron_admin.tools.confirm_default", default: "Are you sure?") } : {} do
|
|
24
23
|
- if action.icon
|
|
25
24
|
= heroicon action.icon, variant: :mini, options: { class: "h-4 w-4" }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
%meta{ charset: "utf-8" }
|
|
2
|
+
%meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
3
|
+
%meta{ name: "color-scheme", content: theme.dark? ? "dark" : "light" }
|
|
4
|
+
%title= IronAdmin.configuration.title
|
|
5
|
+
- if IronAdmin.configuration.favicon.present?
|
|
6
|
+
-# type: nil, because favicon_link_tag would claim image/x-icon for any file.
|
|
7
|
+
= favicon_link_tag IronAdmin.configuration.favicon, type: nil
|
|
8
|
+
= csrf_meta_tags
|
|
9
|
+
= csp_meta_tag
|
|
10
|
+
- if theme.font_stylesheet_url.present?
|
|
11
|
+
- if cp_google_fonts?
|
|
12
|
+
%link{ rel: "preconnect", href: "https://fonts.googleapis.com" }
|
|
13
|
+
%link{ rel: "preconnect", href: "https://fonts.gstatic.com", crossorigin: "anonymous" }
|
|
14
|
+
%link{ rel: "stylesheet", href: theme.font_stylesheet_url }
|
|
15
|
+
= stylesheet_link_tag "tailwind", "data-turbo-track": "reload"
|
|
16
|
+
- if defined?(ActionText)
|
|
17
|
+
= stylesheet_link_tag "trix", "data-turbo-track": "reload"
|
|
18
|
+
= javascript_importmap_tags
|
|
19
|
+
%script{ type: "module" }
|
|
20
|
+
import "iron_admin"
|
|
21
|
+
- if defined?(ActionText)
|
|
22
|
+
%script{ type: "module" }
|
|
23
|
+
import "trix"
|
|
24
|
+
import "@rails/actiontext"
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
+
- theme = IronAdmin.current_theme
|
|
1
2
|
!!!
|
|
2
|
-
%html{ lang: I18n.locale }
|
|
3
|
+
%html{ lang: I18n.locale, class: theme.scheme_class }
|
|
3
4
|
%head
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
%title= IronAdmin.configuration.title
|
|
7
|
-
= csrf_meta_tags
|
|
8
|
-
= csp_meta_tag
|
|
9
|
-
= stylesheet_link_tag "tailwind", "data-turbo-track": "reload"
|
|
10
|
-
- if defined?(ActionText)
|
|
11
|
-
= stylesheet_link_tag "trix", "data-turbo-track": "reload"
|
|
12
|
-
= javascript_importmap_tags
|
|
13
|
-
%script{ type: "module" }
|
|
14
|
-
import "iron_admin"
|
|
15
|
-
- if defined?(ActionText)
|
|
16
|
-
%script{ type: "module" }
|
|
17
|
-
import "trix"
|
|
18
|
-
import "@rails/actiontext"
|
|
19
|
-
%body.text-gray-900.antialiased{ class: IronAdmin.configuration.theme.main_bg }
|
|
5
|
+
= render "layouts/iron_admin/document_head", theme: theme
|
|
6
|
+
%body{ class: "antialiased #{theme.main_bg} #{theme.body_text} #{theme.font_family}" }
|
|
20
7
|
= render iron_admin_component(:shell, current_user: iron_admin_current_user) do
|
|
21
8
|
= yield
|
data/config/importmap.rb
CHANGED
|
@@ -11,7 +11,9 @@ pin "iron_admin/controllers/cp_alert_controller", to: "iron_admin/controllers/cp
|
|
|
11
11
|
pin "iron_admin/controllers/cp_bulk_select_controller", to: "iron_admin/controllers/cp_bulk_select_controller.js"
|
|
12
12
|
pin "iron_admin/controllers/cp_chart_controller", to: "iron_admin/controllers/cp_chart_controller.js"
|
|
13
13
|
pin "iron_admin/controllers/cp_color_field_controller", to: "iron_admin/controllers/cp_color_field_controller.js"
|
|
14
|
+
pin "iron_admin/controllers/cp_disclosure_controller", to: "iron_admin/controllers/cp_disclosure_controller.js"
|
|
14
15
|
pin "iron_admin/controllers/cp_modal_controller", to: "iron_admin/controllers/cp_modal_controller.js"
|
|
15
16
|
pin "iron_admin/controllers/cp_nested_form_controller", to: "iron_admin/controllers/cp_nested_form_controller.js"
|
|
17
|
+
pin "iron_admin/controllers/cp_search_shortcut_controller", to: "iron_admin/controllers/cp_search_shortcut_controller.js"
|
|
16
18
|
pin "iron_admin/controllers/cp_sidebar_controller", to: "iron_admin/controllers/cp_sidebar_controller.js"
|
|
17
19
|
pin "iron_admin/controllers/filter_operator_controller", to: "iron_admin/controllers/filter_operator_controller.js"
|
data/config/locales/en.yml
CHANGED
|
@@ -13,6 +13,10 @@ en:
|
|
|
13
13
|
resources:
|
|
14
14
|
errors:
|
|
15
15
|
invalid_json: "Invalid JSON. The record was not saved."
|
|
16
|
+
not_assignable: "is not available"
|
|
17
|
+
nested_not_assignable: "%{association} refer to a record that is not available"
|
|
18
|
+
outside_tenant: "This change would put the record outside your tenant."
|
|
19
|
+
tenant_unverifiable: "This change cannot be checked against your tenant, so it was not saved."
|
|
16
20
|
create:
|
|
17
21
|
success: "%{model} created."
|
|
18
22
|
update:
|
|
@@ -31,6 +35,13 @@ en:
|
|
|
31
35
|
not_completed: "Bulk action was not completed"
|
|
32
36
|
failure: "Action failed: %{error}"
|
|
33
37
|
inaccessible: "Some records are not accessible"
|
|
38
|
+
action_form:
|
|
39
|
+
record: "Applies to %{model} #%{id}."
|
|
40
|
+
record_with_label: "Applies to %{model} #%{id} (%{label})."
|
|
41
|
+
bulk_action_form:
|
|
42
|
+
selected:
|
|
43
|
+
one: "Applies to 1 selected record."
|
|
44
|
+
other: "Applies to %{count} selected records."
|
|
34
45
|
index:
|
|
35
46
|
new_button: "New %{model}"
|
|
36
47
|
import_button: "Import"
|
|
@@ -70,6 +81,7 @@ en:
|
|
|
70
81
|
one: "%{count} row detected."
|
|
71
82
|
other: "%{count} rows detected."
|
|
72
83
|
mapping_title: "Column mapping"
|
|
84
|
+
table_label: "Rows to import"
|
|
73
85
|
status_column: "Status"
|
|
74
86
|
valid_status: "Valid"
|
|
75
87
|
back_button: "Back"
|
|
@@ -82,16 +94,23 @@ en:
|
|
|
82
94
|
missing_file: "Choose a file to import."
|
|
83
95
|
file_too_large: "The file is larger than %{size}. Split it into smaller files."
|
|
84
96
|
not_saved: "The record could not be saved."
|
|
97
|
+
outside_tenant: "This row would put the record outside your tenant."
|
|
98
|
+
tenant_unverifiable: "This row cannot be checked against your tenant, so it was not imported."
|
|
99
|
+
not_permitted:
|
|
100
|
+
create: "You are not allowed to create this record."
|
|
101
|
+
update: "You are not allowed to update this record."
|
|
85
102
|
fields:
|
|
86
103
|
select_placeholder: "Select..."
|
|
87
104
|
boolean_enable: "Enable %{field}"
|
|
88
105
|
boolean_true: "Yes"
|
|
89
106
|
boolean_false: "No"
|
|
107
|
+
empty_value: "Not set"
|
|
90
108
|
url_placeholder: "https://"
|
|
91
109
|
email_placeholder: "user@example.com"
|
|
92
110
|
file_remove: "Remove"
|
|
93
111
|
markdown_placeholder: "Write markdown here..."
|
|
94
112
|
tags_placeholder: "Type and press Enter to add..."
|
|
113
|
+
tags_remove: "Remove %{tag}"
|
|
95
114
|
color_placeholder: "#000000"
|
|
96
115
|
color_picker_label: "%{field} picker"
|
|
97
116
|
color_invalid: "Enter a hex color such as #1a2b3c or #abc."
|
|
@@ -110,6 +129,10 @@ en:
|
|
|
110
129
|
dismiss: "Dismiss"
|
|
111
130
|
modal:
|
|
112
131
|
close: "Close"
|
|
132
|
+
theme_switcher:
|
|
133
|
+
button_label: "Theme: %{theme}"
|
|
134
|
+
menu_label: "Themes"
|
|
135
|
+
unknown: "That theme is not available."
|
|
113
136
|
nested_form:
|
|
114
137
|
add_button: "Add row"
|
|
115
138
|
remove_button: "Remove"
|
data/config/routes.rb
CHANGED
|
@@ -2,6 +2,7 @@ IronAdmin::Engine.routes.draw do
|
|
|
2
2
|
root "dashboard#index"
|
|
3
3
|
|
|
4
4
|
get "search", to: "search#index", as: :search
|
|
5
|
+
post "theme", to: "themes#update", as: :theme
|
|
5
6
|
get "audit", to: "audit#index", as: :audit
|
|
6
7
|
get "live/:stream", to: "live#show", as: :live
|
|
7
8
|
get "autocomplete/:resource_name", to: "resources#autocomplete", as: :autocomplete
|
data/docs/FAQ.md
CHANGED
|
@@ -59,18 +59,26 @@ IronAdmin infers fields from your database schema. Ensure:
|
|
|
59
59
|
### How do I hide a field?
|
|
60
60
|
|
|
61
61
|
```ruby
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
module IronAdmin
|
|
63
|
+
module Resources
|
|
64
|
+
class UserResource < IronAdmin::Resource
|
|
65
|
+
field :password_digest, visible: false
|
|
66
|
+
field :secret, visible: ->(user) { user.admin? }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
65
69
|
end
|
|
66
70
|
```
|
|
67
71
|
|
|
68
72
|
### How do I make a field read-only?
|
|
69
73
|
|
|
70
74
|
```ruby
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
module IronAdmin
|
|
76
|
+
module Resources
|
|
77
|
+
class UserResource < IronAdmin::Resource
|
|
78
|
+
field :email, readonly: true
|
|
79
|
+
field :role, readonly: ->(user) { !user.admin? }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
74
82
|
end
|
|
75
83
|
```
|
|
76
84
|
|
|
@@ -79,17 +87,25 @@ Readonly fields are left out of the form and are never mass-assigned on create o
|
|
|
79
87
|
### How do I customize field display in the index table?
|
|
80
88
|
|
|
81
89
|
```ruby
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
module IronAdmin
|
|
91
|
+
module Resources
|
|
92
|
+
class UserResource < IronAdmin::Resource
|
|
93
|
+
index_fields :id, :name, :email, :role, :created_at
|
|
94
|
+
end
|
|
95
|
+
end
|
|
84
96
|
end
|
|
85
97
|
```
|
|
86
98
|
|
|
87
99
|
### How do I create a custom action?
|
|
88
100
|
|
|
89
101
|
```ruby
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
module IronAdmin
|
|
103
|
+
module Resources
|
|
104
|
+
class UserResource < IronAdmin::Resource
|
|
105
|
+
action :lock, icon: "lock-closed", confirm: true do |record|
|
|
106
|
+
record.update!(locked_at: Time.current)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
93
109
|
end
|
|
94
110
|
end
|
|
95
111
|
```
|
|
@@ -103,9 +119,8 @@ Configure authentication in the initializer:
|
|
|
103
119
|
```ruby
|
|
104
120
|
IronAdmin.configure do |config|
|
|
105
121
|
config.authenticate do |controller|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
end
|
|
122
|
+
user = User.find_by(id: controller.session[:user_id])
|
|
123
|
+
controller.redirect_to "/login" unless user&.admin?
|
|
109
124
|
end
|
|
110
125
|
end
|
|
111
126
|
```
|
|
@@ -115,11 +130,15 @@ end
|
|
|
115
130
|
Use policies:
|
|
116
131
|
|
|
117
132
|
```ruby
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
module IronAdmin
|
|
134
|
+
module Resources
|
|
135
|
+
class UserResource < IronAdmin::Resource
|
|
136
|
+
policy do
|
|
137
|
+
allow :read
|
|
138
|
+
allow :update, if: ->(user) { user&.admin? }
|
|
139
|
+
deny :delete
|
|
140
|
+
end
|
|
141
|
+
end
|
|
123
142
|
end
|
|
124
143
|
end
|
|
125
144
|
```
|
|
@@ -129,8 +148,12 @@ Once a resource has a `policy` block, every CRUD action must be allowed explicit
|
|
|
129
148
|
Or use `deny_actions` for simple cases:
|
|
130
149
|
|
|
131
150
|
```ruby
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
module IronAdmin
|
|
152
|
+
module Resources
|
|
153
|
+
class AuditLogResource < IronAdmin::Resource
|
|
154
|
+
deny_actions :create, :update, :delete
|
|
155
|
+
end
|
|
156
|
+
end
|
|
134
157
|
end
|
|
135
158
|
```
|
|
136
159
|
|
|
@@ -169,8 +192,12 @@ created_at:2025-01-01..2025-12-31
|
|
|
169
192
|
### How do I customize which fields are searchable?
|
|
170
193
|
|
|
171
194
|
```ruby
|
|
172
|
-
|
|
173
|
-
|
|
195
|
+
module IronAdmin
|
|
196
|
+
module Resources
|
|
197
|
+
class UserResource < IronAdmin::Resource
|
|
198
|
+
searchable :name, :email
|
|
199
|
+
end
|
|
200
|
+
end
|
|
174
201
|
end
|
|
175
202
|
```
|
|
176
203
|
|
|
@@ -185,16 +212,24 @@ CSV and JSON exports are enabled by default. Access via:
|
|
|
185
212
|
### How do I customize export fields?
|
|
186
213
|
|
|
187
214
|
```ruby
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
module IronAdmin
|
|
216
|
+
module Resources
|
|
217
|
+
class UserResource < IronAdmin::Resource
|
|
218
|
+
export_fields :id, :name, :email, :created_at
|
|
219
|
+
end
|
|
220
|
+
end
|
|
190
221
|
end
|
|
191
222
|
```
|
|
192
223
|
|
|
193
224
|
### How do I disable export?
|
|
194
225
|
|
|
195
226
|
```ruby
|
|
196
|
-
|
|
197
|
-
|
|
227
|
+
module IronAdmin
|
|
228
|
+
module Resources
|
|
229
|
+
class SecretResource < IronAdmin::Resource
|
|
230
|
+
exports # Empty to disable
|
|
231
|
+
end
|
|
232
|
+
end
|
|
198
233
|
end
|
|
199
234
|
```
|
|
200
235
|
|
|
@@ -203,21 +238,32 @@ end
|
|
|
203
238
|
### How do I create a custom dashboard?
|
|
204
239
|
|
|
205
240
|
```ruby
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
241
|
+
module IronAdmin
|
|
242
|
+
module Dashboards
|
|
243
|
+
class AdminDashboard < IronAdmin::Dashboard
|
|
244
|
+
metric :total_users, format: :number do
|
|
245
|
+
User.count
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
recent :users, limit: 5
|
|
249
|
+
end
|
|
209
250
|
end
|
|
210
|
-
|
|
211
|
-
recent :users, limit: 5
|
|
212
251
|
end
|
|
213
252
|
```
|
|
214
253
|
|
|
215
254
|
### How do I add charts?
|
|
216
255
|
|
|
217
256
|
```ruby
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
module IronAdmin
|
|
258
|
+
module Dashboards
|
|
259
|
+
class AdminDashboard < IronAdmin::Dashboard
|
|
260
|
+
chart :signups_by_month, type: :bar do
|
|
261
|
+
# groupdate is not a dependency. The block must return a Hash of label => value.
|
|
262
|
+
# group_by keeps row order. YYYY-MM keys sort chronologically. Zero-fill empty months if you need all twelve.
|
|
263
|
+
signups = User.where(created_at: 11.months.ago.beginning_of_month..).pluck(:created_at)
|
|
264
|
+
signups.group_by { |created_at| created_at.strftime("%Y-%m") }.transform_values(&:count).sort.to_h
|
|
265
|
+
end
|
|
266
|
+
end
|
|
221
267
|
end
|
|
222
268
|
end
|
|
223
269
|
```
|
|
@@ -229,8 +275,12 @@ end
|
|
|
229
275
|
IronAdmin automatically preloads `belongs_to` associations. For custom preloading:
|
|
230
276
|
|
|
231
277
|
```ruby
|
|
232
|
-
|
|
233
|
-
|
|
278
|
+
module IronAdmin
|
|
279
|
+
module Resources
|
|
280
|
+
class OrderResource < IronAdmin::Resource
|
|
281
|
+
preload :customer, :line_items
|
|
282
|
+
end
|
|
283
|
+
end
|
|
234
284
|
end
|
|
235
285
|
```
|
|
236
286
|
|
data/docs/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Convention-over-configuration admin panel engine for Ruby on Rails.
|
|
4
4
|
|
|
5
|
+
**[Live demo](https://demo.ironadmin.rubylab.app/)** · [Demo source](https://github.com/rubylab-app/meridian_magazine)
|
|
6
|
+
|
|
7
|
+
The demo is Meridian Magazine, a Rails 8 app built with IronAdmin: sign in by picking an
|
|
8
|
+
admin, an editor or an author (no password).
|
|
9
|
+
|
|
5
10
|
## Table of Contents
|
|
6
11
|
|
|
7
12
|
### Getting Started
|
|
@@ -15,7 +20,7 @@ Convention-over-configuration admin panel engine for Ruby on Rails.
|
|
|
15
20
|
- [Dashboard](guides/dashboard.md) - Configure metrics, charts, and recent records
|
|
16
21
|
- [Fields](guides/fields.md) - Field types, inference, and customization
|
|
17
22
|
- [Authentication & Authorization](guides/authentication.md) - Secure your admin panel
|
|
18
|
-
- [Theming](guides/theming.md) -
|
|
23
|
+
- [Theming](guides/theming.md) - The Neutral look, named themes, the theme switcher and every theme property
|
|
19
24
|
- [Components](guides/components.md) - Override and extend UI components
|
|
20
25
|
- [Export](guides/export.md) - CSV and JSON export
|
|
21
26
|
- [Imports](guides/imports.md) - CSV and JSON import with a validated preview
|
|
@@ -43,12 +48,13 @@ Comprehensive documentation for all built-in ViewComponents:
|
|
|
43
48
|
|
|
44
49
|
- [Configuration](reference/configuration.md) - All configuration options
|
|
45
50
|
- [Routes](reference/routes.md) - Route reference
|
|
46
|
-
- [Theme
|
|
51
|
+
- [Theme Reference](reference/theme-properties.md) - Theme methods, constants, helpers and property names
|
|
47
52
|
|
|
48
53
|
## Quick Links
|
|
49
54
|
|
|
50
55
|
| Task | Documentation |
|
|
51
56
|
|------|---------------|
|
|
57
|
+
| See a working app | [Live demo](https://demo.ironadmin.rubylab.app/) ([source](https://github.com/rubylab-app/meridian_magazine)) |
|
|
52
58
|
| Install IronAdmin | [Installation Guide](getting-started/installation.md) |
|
|
53
59
|
| Create first resource | [Quick Start](getting-started/quick-start.md) |
|
|
54
60
|
| Customize appearance | [Theming Guide](guides/theming.md) |
|
data/docs/components/README.md
CHANGED
|
@@ -51,14 +51,18 @@ Components can be rendered in views using ViewComponent's `render` helper:
|
|
|
51
51
|
|
|
52
52
|
## Theme Integration
|
|
53
53
|
|
|
54
|
-
All components
|
|
54
|
+
All components use the theme of the current request (`IronAdmin.current_theme`), so they follow
|
|
55
|
+
the theme switcher. Inside the built-in components, the `theme` method returns it:
|
|
55
56
|
|
|
56
57
|
```ruby
|
|
57
58
|
def card_classes
|
|
58
|
-
"#{theme.card_bg} #{theme.card_border} #{theme.border_radius}"
|
|
59
|
+
"#{theme.card_bg} #{theme.border_width} #{theme.card_border} #{theme.border_radius}"
|
|
59
60
|
end
|
|
60
61
|
```
|
|
61
62
|
|
|
63
|
+
In components of your own, read `IronAdmin.current_theme` too (see
|
|
64
|
+
[Using the theme in your own components](../guides/theming.md#using-the-theme-in-your-own-components)).
|
|
65
|
+
|
|
62
66
|
## Overriding Components
|
|
63
67
|
|
|
64
68
|
Override any component globally or per-resource. See [Components Guide](../guides/components.md) for details.
|