rails_admin_next 3.0.3 → 4.0.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/Gemfile +3 -0
- data/README.md +20 -2
- data/app/assets/stylesheets/rails_admin/skin.css +240 -7
- data/app/assets/stylesheets/rails_admin/tokens.css +4 -0
- data/app/controllers/rails_admin_next/bulk_deletions_controller.rb +27 -0
- data/app/controllers/rails_admin_next/main_controller.rb +34 -5
- data/app/helpers/rails_admin_next/application_helper.rb +17 -2
- data/app/helpers/rails_admin_next/main_helper.rb +64 -0
- data/app/jobs/rails_admin_next/bulk_delete_job.rb +65 -0
- data/app/views/layouts/rails_admin_next/_head.html.erb +14 -6
- data/app/views/layouts/rails_admin_next/content.html.erb +1 -0
- data/app/views/rails_admin_next/bulk_deletions/_banner.html.erb +30 -0
- data/app/views/rails_admin_next/main/_batch.html.erb +9 -0
- data/app/views/rails_admin_next/main/_history_row.html.erb +32 -0
- data/app/views/rails_admin_next/main/_list_row.html.erb +19 -0
- data/app/views/rails_admin_next/main/_next_batch.html.erb +21 -0
- data/app/views/rails_admin_next/main/_selection_bar.html.erb +30 -0
- data/app/views/rails_admin_next/main/bulk_delete.html.erb +26 -6
- data/app/views/rails_admin_next/main/export.html.erb +1 -0
- data/app/views/rails_admin_next/main/history.html.erb +5 -36
- data/app/views/rails_admin_next/main/index.html.erb +28 -57
- data/config/importmap.rails_admin.rb +7 -2
- data/config/locales/rails_admin_next.en.yml +37 -4
- data/config/routes.rb +2 -0
- data/docs/UPGRADING.md +194 -1
- data/docs/security.md +18 -8
- data/lib/rails_admin_next/adapters/active_record.rb +7 -0
- data/lib/rails_admin_next/bulk_deletion/progress.rb +70 -0
- data/lib/rails_admin_next/bulk_deletion.rb +99 -0
- data/lib/rails_admin_next/config/actions/base.rb +7 -0
- data/lib/rails_admin_next/config/actions/bulk_delete.rb +94 -31
- data/lib/rails_admin_next/config/actions/export.rb +4 -0
- data/lib/rails_admin_next/config/actions/history_index.rb +1 -1
- data/lib/rails_admin_next/config/actions/history_show.rb +1 -1
- data/lib/rails_admin_next/config/actions/index.rb +6 -1
- data/lib/rails_admin_next/config/fields/types/action_text.rb +11 -0
- data/lib/rails_admin_next/config/sections/list.rb +1 -2
- data/lib/rails_admin_next/engine.rb +1 -0
- data/lib/rails_admin_next/extensions/paper_trail/auditing_adapter.rb +8 -3
- data/lib/rails_admin_next/support/action_text_editor.rb +36 -0
- data/lib/rails_admin_next/support/paginated_collection.rb +4 -5
- data/lib/rails_admin_next/version.rb +2 -2
- data/lib/rails_admin_next.rb +3 -0
- data/skills/rails-admin-next/SKILL.md +3 -3
- data/src/rails_admin/controllers/alert_controller.js +3 -1
- data/src/rails_admin/controllers/bulk_progress_controller.js +53 -0
- data/src/rails_admin/controllers/bulk_selection_controller.js +151 -0
- data/src/rails_admin/controllers/dropdown_controller.js +7 -5
- data/src/rails_admin/controllers/filtering_multiselect_controller.js +4 -0
- data/src/rails_admin/controllers/filtering_select_controller.js +4 -0
- data/src/rails_admin/controllers/index.js +6 -0
- data/src/rails_admin/controllers/infinite_scroll_controller.js +79 -0
- data/src/rails_admin/controllers/modal_controller.js +3 -1
- data/src/rails_admin/controllers/nested_form_controller.js +3 -2
- data/src/rails_admin/controllers/sidescroll_controller.js +41 -10
- data/src/rails_admin/interactions.js +4 -12
- metadata +23 -4
- data/app/views/rails_admin_next/main/_pagination.html.erb +0 -54
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15f1f39d2087993d1ef84025a544e0f188426b452d38ad2ccbbeb96c4d4b1c90
|
|
4
|
+
data.tar.gz: 579d223caa8d59d273f1fdfea9a61bd5412014f90e208b48e90987192260b4d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73a140a179b5856b9260bea95711e4ccbfc72aee5e279f4580444982439e418cdd5afc72b0397a52c3176729e893b83d009a4d49f56dce5da4203a1c0d84e6ae
|
|
7
|
+
data.tar.gz: 1b35ab200fe3bb2265cf1d78904d7c8e8d11725c1b97d6ea94174627699da6c1a391e175614ea97624aa089e11b253ddeff009520017e06e49a6523882de5475
|
data/Gemfile
CHANGED
|
@@ -18,6 +18,9 @@ group :test do
|
|
|
18
18
|
gem "factory_bot"
|
|
19
19
|
gem "generator_spec"
|
|
20
20
|
gem "image_processing"
|
|
21
|
+
# Only the Lexxy CI leg loads it. Lexxy replaces rich_text_area app-wide, so the whole suite
|
|
22
|
+
# runs on that leg, and the gem stays out of the gemspec: hosts bring their own editor.
|
|
23
|
+
gem "lexxy" if ENV["CI_ACTION_TEXT_EDITOR"] == "lexxy"
|
|
21
24
|
gem "pundit"
|
|
22
25
|
# Pinned within 0.10: Gemfile.lock is not committed here, so CI resolves fresh on every run
|
|
23
26
|
# and no Dependabot PR stages a release first, and the discovery spec drives Hyperdrive's
|
data/README.md
CHANGED
|
@@ -111,7 +111,7 @@ always match the installed version.
|
|
|
111
111
|
- Search and filtering
|
|
112
112
|
- Export data to CSV / JSON / XML
|
|
113
113
|
- File uploads (ActiveStorage)
|
|
114
|
-
- Rich text fields (ActionText
|
|
114
|
+
- Rich text fields (ActionText), in the host's editor: Trix or Lexxy
|
|
115
115
|
- Authentication (via [Devise][devise] or any other scheme)
|
|
116
116
|
- Authorization (via [Pundit][pundit], [ActionPolicy][action_policy] or a custom adapter)
|
|
117
117
|
- User action history (via [PaperTrail][papertrail])
|
|
@@ -145,6 +145,22 @@ end
|
|
|
145
145
|
|
|
146
146
|
This is also where you wire up [Devise][devise], [Pundit][pundit], and [PaperTrail][papertrail].
|
|
147
147
|
|
|
148
|
+
Ticking every loaded row of a list offers "Select all N matching", which hands "Export found" and
|
|
149
|
+
bulk delete the whole filtered set. A bulk delete larger than `background_threshold` (500 by
|
|
150
|
+
default) runs as background jobs on your ActiveJob adapter, with a progress banner kept in
|
|
151
|
+
`Rails.cache`:
|
|
152
|
+
|
|
153
|
+
```ruby
|
|
154
|
+
config.actions do
|
|
155
|
+
bulk_delete do
|
|
156
|
+
background_threshold 1_000 # Float::INFINITY keeps every delete in the request
|
|
157
|
+
authorization_limit 20_000 # with Pundit or ActionPolicy, larger sets are refused (default 10,000)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
A custom bulk action accepts every matching record with `register_instance_option(:all_matching?) { true }`.
|
|
163
|
+
|
|
148
164
|
Every admin page ends with a small "Made in Tokyo with ❤️ and 🤖" footer. To hide it:
|
|
149
165
|
|
|
150
166
|
```ruby
|
|
@@ -215,7 +231,7 @@ Compared to RailsAdmin, the following were intentionally removed:
|
|
|
215
231
|
- **Webpack, Webpacker, Vite, and Sprockets** — importmap + Propshaft only.
|
|
216
232
|
- **jQuery, jQuery-UI, Bootstrap's JS, and `@rails/ujs`** — replaced by Stimulus controllers.
|
|
217
233
|
- **Standalone WYSIWYG/code editors** (`bootstrap-wysihtml5`, `froala`, CKEditor, CodeMirror,
|
|
218
|
-
SimpleMDE) — they loaded from a CDN; use ActionText
|
|
234
|
+
SimpleMDE) — they loaded from a CDN; use ActionText rich text (Trix or Lexxy, self-hosted) or a plain
|
|
219
235
|
`:text` textarea instead.
|
|
220
236
|
- **Drag-to-reorder for multiple uploads** (it relied on jQuery-UI sortable).
|
|
221
237
|
- **flatpickr** — date/time fields use native HTML5 inputs (`type="date"`/`datetime-local`/`time`);
|
|
@@ -265,6 +281,8 @@ RailsAdminNext.config do |config|
|
|
|
265
281
|
end
|
|
266
282
|
```
|
|
267
283
|
|
|
284
|
+
A Lexxy rich-text editor follows the scheme and the `--ra-*` tokens. Trix stays light.
|
|
285
|
+
|
|
268
286
|
**Note for operators:** after upgrading, the admin renders dark for anyone whose OS prefers
|
|
269
287
|
dark. Pin `config.color_scheme = :light` to keep the old always-light rendering; if
|
|
270
288
|
something looks wrong in dark mode, please
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
|
|
104
104
|
/* === Admin skin: layout and navbar ====================================== */
|
|
105
105
|
body.rails_admin {
|
|
106
|
-
padding-top:
|
|
106
|
+
padding-top: var(--ra-navbar-height);
|
|
107
107
|
.navbar .edit_user_root_link {
|
|
108
108
|
position: relative;
|
|
109
109
|
img {
|
|
@@ -431,15 +431,18 @@ body.rails_admin #filters_box {
|
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
body.rails_admin .dashboard-statistics {
|
|
434
|
-
overflow
|
|
435
|
-
overscroll-behavior: contain;
|
|
434
|
+
overflow: auto hidden;
|
|
435
|
+
overscroll-behavior-x: contain;
|
|
436
436
|
}
|
|
437
437
|
body.rails_admin #sidescroll {
|
|
438
438
|
margin-bottom: 20px;
|
|
439
|
-
overflow-x: auto
|
|
439
|
+
/* overflow-x: auto alone computes overflow-y to auto as well, and with a
|
|
440
|
+
pixel of sub-pixel overflow the wrapper becomes a vertical scroller that
|
|
441
|
+
swallows wheel scrolling meant for the page. */
|
|
442
|
+
overflow: auto hidden;
|
|
440
443
|
/* Horizontal wheel/trackpad scrolls stop at the table edge instead of
|
|
441
444
|
chaining into a browser back/forward navigation gesture. */
|
|
442
|
-
overscroll-behavior: contain;
|
|
445
|
+
overscroll-behavior-x: contain;
|
|
443
446
|
.table {
|
|
444
447
|
margin-bottom: 0;
|
|
445
448
|
}
|
|
@@ -459,6 +462,163 @@ body.rails_admin #sidescroll {
|
|
|
459
462
|
body.rails_admin .pagination .page-item {
|
|
460
463
|
white-space: nowrap;
|
|
461
464
|
}
|
|
465
|
+
body.rails_admin .bulk-deletion-banner label {
|
|
466
|
+
display: block;
|
|
467
|
+
margin-bottom: 0.25rem;
|
|
468
|
+
}
|
|
469
|
+
body.rails_admin .bulk-deletion-banner progress {
|
|
470
|
+
width: 100%;
|
|
471
|
+
accent-color: var(--ra-primary);
|
|
472
|
+
}
|
|
473
|
+
/* Pinned under the navbar while any row is ticked. It sits outside #sidescroll
|
|
474
|
+
so a wide table scrolls sideways under it. */
|
|
475
|
+
body.rails_admin .selection-bar {
|
|
476
|
+
display: none;
|
|
477
|
+
position: sticky;
|
|
478
|
+
top: var(--ra-navbar-height);
|
|
479
|
+
z-index: 4;
|
|
480
|
+
flex-wrap: wrap;
|
|
481
|
+
align-items: center;
|
|
482
|
+
gap: 0.25rem 1rem;
|
|
483
|
+
min-height: var(--ra-selection-bar-height);
|
|
484
|
+
margin-bottom: 0.5rem;
|
|
485
|
+
padding: 0.25rem 0.75rem;
|
|
486
|
+
background-color: var(--ra-body-bg);
|
|
487
|
+
border-bottom: 1px solid var(--ra-border-color);
|
|
488
|
+
.selection-count,
|
|
489
|
+
.selection-menu {
|
|
490
|
+
white-space: nowrap;
|
|
491
|
+
}
|
|
492
|
+
.selection-offer,
|
|
493
|
+
.selection-clear {
|
|
494
|
+
padding: 0;
|
|
495
|
+
}
|
|
496
|
+
.selection-offer,
|
|
497
|
+
.selection-all-matching,
|
|
498
|
+
.selection-offer-short {
|
|
499
|
+
display: none;
|
|
500
|
+
}
|
|
501
|
+
.selection-menu {
|
|
502
|
+
margin-inline-start: auto;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/* On a phone Clear selection wraps onto a second line, so the bar is taller.
|
|
506
|
+
The count wraps beside the menu toggle rather than pushing it off the first
|
|
507
|
+
line. While the offer shows, or every match is selected, Clear selection
|
|
508
|
+
joins the toggle in place of the count and the short offer or the
|
|
509
|
+
all-matching text takes the second line, so neither state grows the bar. */
|
|
510
|
+
@media (max-width: 575.98px) {
|
|
511
|
+
:root {
|
|
512
|
+
--ra-selection-bar-height: 4.5rem;
|
|
513
|
+
}
|
|
514
|
+
body.rails_admin .selection-bar {
|
|
515
|
+
.selection-count {
|
|
516
|
+
flex: 1 1 0;
|
|
517
|
+
min-width: 0;
|
|
518
|
+
white-space: normal;
|
|
519
|
+
}
|
|
520
|
+
.selection-offer,
|
|
521
|
+
.selection-clear,
|
|
522
|
+
.selection-all-matching {
|
|
523
|
+
order: 1;
|
|
524
|
+
}
|
|
525
|
+
.selection-offer,
|
|
526
|
+
.selection-all-matching {
|
|
527
|
+
flex-basis: 100%;
|
|
528
|
+
text-align: start;
|
|
529
|
+
}
|
|
530
|
+
.selection-offer-full {
|
|
531
|
+
display: none;
|
|
532
|
+
}
|
|
533
|
+
.selection-offer-short {
|
|
534
|
+
display: inline;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
body.rails_admin
|
|
538
|
+
#bulk_form:has(fieldset.all-matching:enabled)
|
|
539
|
+
.selection-clear {
|
|
540
|
+
order: 0;
|
|
541
|
+
}
|
|
542
|
+
/* The offer already says every loaded row is ticked, and the line has no
|
|
543
|
+
room for that count beside Clear selection and the toggle. */
|
|
544
|
+
body.rails_admin
|
|
545
|
+
#bulk_form:has(fieldset.all-matching:disabled):has(
|
|
546
|
+
.list-batch > .list-batch-status
|
|
547
|
+
):not(:has(input[name="bulk_ids[]"]:not(:checked))) {
|
|
548
|
+
.selection-count {
|
|
549
|
+
display: none;
|
|
550
|
+
}
|
|
551
|
+
.selection-clear {
|
|
552
|
+
order: 0;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
body.rails_admin
|
|
557
|
+
#bulk_form:has(input[name="bulk_ids[]"]:checked)
|
|
558
|
+
.selection-bar {
|
|
559
|
+
display: flex;
|
|
560
|
+
}
|
|
561
|
+
/* Every loaded row is ticked while a batch has yet to load, so more records
|
|
562
|
+
match than the ticks cover: offer them all. */
|
|
563
|
+
body.rails_admin
|
|
564
|
+
#bulk_form:has(fieldset.all-matching:disabled):has(
|
|
565
|
+
.list-batch > .list-batch-status
|
|
566
|
+
):not(:has(input[name="bulk_ids[]"]:not(:checked)))
|
|
567
|
+
.selection-offer {
|
|
568
|
+
display: inline-block;
|
|
569
|
+
}
|
|
570
|
+
/* Every match is selected: the bar says so, and bulk actions that cannot act
|
|
571
|
+
on the whole set leave the menu. Hiding them is presentation only; the
|
|
572
|
+
server refuses an all-matching submit to an action that has not opted in. */
|
|
573
|
+
body.rails_admin #bulk_form:has(fieldset.all-matching:enabled) {
|
|
574
|
+
.selection-count {
|
|
575
|
+
display: none;
|
|
576
|
+
}
|
|
577
|
+
.selection-all-matching {
|
|
578
|
+
display: inline;
|
|
579
|
+
}
|
|
580
|
+
#bulk_menu li:has(> .bulk-link:not([data-all-matching])) {
|
|
581
|
+
display: none;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
html:has(body.rails_admin #bulk_form input[name="bulk_ids[]"]:checked) {
|
|
585
|
+
scroll-padding-top: calc(
|
|
586
|
+
var(--ra-navbar-height) + var(--ra-selection-bar-height) + 0.5rem
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
/* The next-batch frame under an infinite-scroll list: its link while idle,
|
|
590
|
+
the loading text while Turbo marks the frame busy, and the error beside the
|
|
591
|
+
link (relabelled Retry) once a load failed. The error is a live region, so
|
|
592
|
+
it stays displayed and is empty until a load fails. Child combinators keep
|
|
593
|
+
a loaded frame's state from reaching the frame nested inside it. */
|
|
594
|
+
body.rails_admin .list-batch {
|
|
595
|
+
display: block;
|
|
596
|
+
}
|
|
597
|
+
body.rails_admin .list-batch-status,
|
|
598
|
+
body.rails_admin .list-end {
|
|
599
|
+
display: flex;
|
|
600
|
+
align-items: center;
|
|
601
|
+
justify-content: center;
|
|
602
|
+
margin: 0 0 1rem;
|
|
603
|
+
color: var(--ra-gray-600);
|
|
604
|
+
}
|
|
605
|
+
body.rails_admin .list-batch-loading {
|
|
606
|
+
display: none;
|
|
607
|
+
}
|
|
608
|
+
body.rails_admin .list-batch-error {
|
|
609
|
+
color: var(--ra-danger);
|
|
610
|
+
&:not(:empty) {
|
|
611
|
+
margin-inline-end: 0.75rem;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
body.rails_admin .list-batch[busy] > .list-batch-status {
|
|
615
|
+
> .list-batch-loading {
|
|
616
|
+
display: inline;
|
|
617
|
+
}
|
|
618
|
+
> .list-batch-link {
|
|
619
|
+
display: none;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
462
622
|
|
|
463
623
|
/* === Admin skin: footer ================================================= */
|
|
464
624
|
body.rails_admin .admin-footer {
|
|
@@ -475,14 +635,14 @@ body.rails_admin .admin-footer {
|
|
|
475
635
|
body.rails_admin .admin-main {
|
|
476
636
|
display: flex;
|
|
477
637
|
flex-direction: column;
|
|
478
|
-
min-height: calc(100dvh -
|
|
638
|
+
min-height: calc(100dvh - var(--ra-navbar-height));
|
|
479
639
|
}
|
|
480
640
|
body.rails_admin .admin-main > .admin-footer {
|
|
481
641
|
margin-top: auto;
|
|
482
642
|
}
|
|
483
643
|
body.rails_admin .sidebar.btn-toggle-nav {
|
|
484
644
|
position: fixed;
|
|
485
|
-
top:
|
|
645
|
+
top: var(--ra-navbar-height);
|
|
486
646
|
bottom: 0;
|
|
487
647
|
overflow-y: auto;
|
|
488
648
|
/* Sidebar scrolling stops at its own ends instead of chaining to the
|
|
@@ -492,3 +652,76 @@ body.rails_admin .admin-footer {
|
|
|
492
652
|
scrollbar-gutter: stable;
|
|
493
653
|
}
|
|
494
654
|
}
|
|
655
|
+
|
|
656
|
+
/* === Rich text: Lexxy theme ============================================= */
|
|
657
|
+
/* Lexxy styles itself entirely through --lexxy-* variables, declared light-only
|
|
658
|
+
and unlayered on :root, where no layered rule can override them. Declaring
|
|
659
|
+
them on body instead wins by inheritance and reaches the modal <dialog> too.
|
|
660
|
+
The variables Lexxy derives with var() are restated here because they
|
|
661
|
+
resolve on :root, so body would otherwise inherit their light values. A host
|
|
662
|
+
overrides one with an unlayered rule on body.rails_admin. */
|
|
663
|
+
body.rails_admin {
|
|
664
|
+
--lexxy-color-ink: var(--ra-body-color);
|
|
665
|
+
--lexxy-color-ink-medium: var(--ra-gray-700);
|
|
666
|
+
--lexxy-color-ink-light: var(--ra-gray-600);
|
|
667
|
+
--lexxy-color-ink-lighter: var(--ra-gray-300);
|
|
668
|
+
--lexxy-color-ink-lightest: var(--ra-surface-muted);
|
|
669
|
+
/* Text on ink and accent fills (floating table controls, dialog buttons). */
|
|
670
|
+
--lexxy-color-ink-inverted: var(--ra-body-bg);
|
|
671
|
+
|
|
672
|
+
--lexxy-color-accent-dark: var(--ra-primary);
|
|
673
|
+
--lexxy-color-accent-medium: color-mix(
|
|
674
|
+
in oklch,
|
|
675
|
+
var(--ra-primary) 60%,
|
|
676
|
+
var(--ra-body-bg)
|
|
677
|
+
);
|
|
678
|
+
--lexxy-color-accent-light: color-mix(
|
|
679
|
+
in oklch,
|
|
680
|
+
var(--ra-primary) 30%,
|
|
681
|
+
var(--ra-body-bg)
|
|
682
|
+
);
|
|
683
|
+
--lexxy-color-accent-lightest: color-mix(
|
|
684
|
+
in oklch,
|
|
685
|
+
var(--ra-primary) 18%,
|
|
686
|
+
var(--ra-body-bg)
|
|
687
|
+
);
|
|
688
|
+
|
|
689
|
+
--lexxy-color-red: var(--ra-danger);
|
|
690
|
+
--lexxy-color-green: var(--ra-success);
|
|
691
|
+
--lexxy-color-blue: var(--ra-primary);
|
|
692
|
+
|
|
693
|
+
--lexxy-color-code-token-att: light-dark(#d73a49, #f97583);
|
|
694
|
+
--lexxy-color-code-token-comment: light-dark(#6a737d, #8b949e);
|
|
695
|
+
--lexxy-color-code-token-function: light-dark(#6f42c1, #d2a8ff);
|
|
696
|
+
--lexxy-color-code-token-operator: light-dark(#d73a49, #f97583);
|
|
697
|
+
--lexxy-color-code-token-property: light-dark(#005cc5, #79c0ff);
|
|
698
|
+
--lexxy-color-code-token-punctuation: light-dark(#24292e, #c9d1d9);
|
|
699
|
+
--lexxy-color-code-token-selector: light-dark(#22863a, #7ee787);
|
|
700
|
+
--lexxy-color-code-token-variable: light-dark(#e36209, #ffa657);
|
|
701
|
+
|
|
702
|
+
--lexxy-color-canvas: var(--lexxy-color-ink-inverted);
|
|
703
|
+
--lexxy-color-text: var(--lexxy-color-ink);
|
|
704
|
+
--lexxy-color-text-subtle: var(--lexxy-color-ink-medium);
|
|
705
|
+
--lexxy-color-link: var(--ra-link-color);
|
|
706
|
+
--lexxy-color-selected: var(--lexxy-color-accent-lightest);
|
|
707
|
+
--lexxy-color-selected-hover: var(--lexxy-color-accent-light);
|
|
708
|
+
--lexxy-color-selected-dark: var(--lexxy-color-blue);
|
|
709
|
+
--lexxy-color-selected-50: color-mix(
|
|
710
|
+
in oklch,
|
|
711
|
+
var(--lexxy-color-selected-dark) 50%,
|
|
712
|
+
transparent
|
|
713
|
+
);
|
|
714
|
+
--lexxy-color-code-bg: var(--lexxy-color-ink-lightest);
|
|
715
|
+
|
|
716
|
+
--lexxy-color-table-header-bg: var(--lexxy-color-ink-lightest);
|
|
717
|
+
--lexxy-color-table-cell-border: var(--lexxy-color-ink-lighter);
|
|
718
|
+
--lexxy-color-table-cell-selected: var(--lexxy-color-selected);
|
|
719
|
+
--lexxy-color-table-cell-selected-border: var(--lexxy-color-selected-dark);
|
|
720
|
+
--lexxy-color-table-cell-selected-bg: var(--lexxy-color-accent-lightest);
|
|
721
|
+
--lexxy-color-table-cell-add: var(--lexxy-color-selected-50);
|
|
722
|
+
--lexxy-color-table-cell-toggle: var(--lexxy-color-accent-lightest);
|
|
723
|
+
|
|
724
|
+
--lexxy-font-base: var(--ra-font-sans-serif);
|
|
725
|
+
--lexxy-font-mono: var(--ra-font-monospace);
|
|
726
|
+
--lexxy-focus-ring-color: var(--lexxy-color-accent-dark);
|
|
727
|
+
}
|
|
@@ -228,6 +228,10 @@
|
|
|
228
228
|
--ra-body-font-size: 0.85rem;
|
|
229
229
|
--ra-body-font-weight: 400;
|
|
230
230
|
--ra-body-line-height: 1.5;
|
|
231
|
+
|
|
232
|
+
--ra-navbar-height: 3.275rem;
|
|
233
|
+
/* The selection bar's height; a focused row scrolls clear of it. */
|
|
234
|
+
--ra-selection-bar-height: 3rem;
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
/*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAdminNext
|
|
4
|
+
# Answers the progress banner's polls. Session membership is the access rule: there is no
|
|
5
|
+
# record to authorize against, so a host's verify_authorized check is told so.
|
|
6
|
+
class BulkDeletionsController < ApplicationController
|
|
7
|
+
def show
|
|
8
|
+
skip_host_authorization_checks
|
|
9
|
+
# A poll every two seconds must neither rewrite the session cookie nor keep a timed-out
|
|
10
|
+
# session alive.
|
|
11
|
+
request.session_options[:skip] = true
|
|
12
|
+
|
|
13
|
+
if Array(session[BulkDeletion::Progress::SESSION_KEY]).include?(params[:id])
|
|
14
|
+
render partial: "banner", locals: {id: params[:id], summary: BulkDeletion::Progress.summary(params[:id])}
|
|
15
|
+
else
|
|
16
|
+
render html: helpers.turbo_frame_tag(helpers.bulk_deletion_frame_id(params[:id]), class: "bulk-deletion")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# Pundit's and ActionPolicy's after_action verifications, which a host parent controller may run.
|
|
23
|
+
def skip_host_authorization_checks
|
|
24
|
+
%i[skip_authorization skip_policy_scope skip_verify_authorized! skip_verify_authorized_scoped!].each { send(it) if respond_to?(it, true) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -10,14 +10,22 @@ module RailsAdminNext
|
|
|
10
10
|
|
|
11
11
|
before_action :check_for_cancel
|
|
12
12
|
|
|
13
|
-
helper_method :list_scopes
|
|
13
|
+
helper_method :list_scope, :list_scopes
|
|
14
14
|
|
|
15
15
|
def bulk_action
|
|
16
16
|
get_model
|
|
17
|
-
|
|
17
|
+
action = RailsAdminNext::Config::Actions.all(:bulkable, controller: self, abstract_model: @abstract_model).detect { it.route_fragment == params[:bulk_action] }
|
|
18
|
+
return unless action
|
|
19
|
+
|
|
20
|
+
if params[:all_matching].present?
|
|
21
|
+
return redirect_to(back_or_index, notice: I18n.t("admin.flash.noaction")) unless action.all_matching?
|
|
22
|
+
|
|
23
|
+
params.delete(:bulk_ids)
|
|
24
|
+
end
|
|
25
|
+
process(params[:bulk_action])
|
|
18
26
|
end
|
|
19
27
|
|
|
20
|
-
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = nil, pagination = !(params[:all] || params[:bulk_ids]))
|
|
28
|
+
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = nil, pagination = !(params[:all] || params[:bulk_ids] || all_matching?))
|
|
21
29
|
scope = model_config.scope
|
|
22
30
|
auth_scope = authorization_scope(auth_scope_key, model_config.abstract_model)
|
|
23
31
|
scope = scope.merge(auth_scope) if auth_scope
|
|
@@ -192,7 +200,8 @@ module RailsAdminNext
|
|
|
192
200
|
end
|
|
193
201
|
|
|
194
202
|
def check_for_cancel
|
|
195
|
-
|
|
203
|
+
# @action is not set yet, so the flag alone decides; bulk_action refuses it for an action that has not opted in.
|
|
204
|
+
cancelling = params[:_continue] || (params[:bulk_action] && !params[:bulk_ids] && params[:all_matching].blank?)
|
|
196
205
|
return unless cancelling
|
|
197
206
|
|
|
198
207
|
redirect_to(back_or_index, notice: I18n.t("admin.flash.noaction"))
|
|
@@ -208,10 +217,30 @@ module RailsAdminNext
|
|
|
208
217
|
options = options.merge(get_sort_hash(model_config))
|
|
209
218
|
options = options.merge(query: params[:query]) if params[:query].present?
|
|
210
219
|
options = options.merge(filters: params[:f]) if params[:f].present?
|
|
211
|
-
options = options.merge(bulk_ids: params[:bulk_ids]) if params[:bulk_ids]
|
|
220
|
+
options = options.merge(bulk_ids: params[:bulk_ids]) if params[:bulk_ids] && !all_matching?
|
|
212
221
|
model_config.abstract_model.all(options, scope)
|
|
213
222
|
end
|
|
214
223
|
|
|
224
|
+
def render_history
|
|
225
|
+
if batch_request?(@history)
|
|
226
|
+
render partial: "rails_admin_next/main/batch", layout: false,
|
|
227
|
+
locals: {collection: @history, row_partial: "history_row", row_locals: {}, url_proc: helpers.method(:history_batch_url)}
|
|
228
|
+
else
|
|
229
|
+
render @action.template_name
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# A request from a list's own next-batch frame, answered with the batch's rows alone. A host
|
|
234
|
+
# frame wrapping the list gets the whole page.
|
|
235
|
+
def batch_request?(collection)
|
|
236
|
+
request.headers["Turbo-Frame"].to_s.start_with?("list_batch_") && collection.respond_to?(:full_page?)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# The relation is always rebuilt from the filter params, so the flag never trusts a client-side count or ids.
|
|
240
|
+
def all_matching?
|
|
241
|
+
params[:all_matching].present? && @action.all_matching?
|
|
242
|
+
end
|
|
243
|
+
|
|
215
244
|
def list_scopes
|
|
216
245
|
@_list_scopes ||= @model_config.list.with(controller: self, view: view_context, object: @abstract_model.model.new).scopes
|
|
217
246
|
end
|
|
@@ -165,7 +165,7 @@ module RailsAdminNext
|
|
|
165
165
|
li_class = ["nav-item", "icon", "#{action.key}_#{parent}_link"]
|
|
166
166
|
.concat(action.enabled? ? [] : ["disabled"])
|
|
167
167
|
content_tag(:li, {class: li_class}.merge(only_icon ? {title: wording, rel: "tooltip"} : {})) do
|
|
168
|
-
label = rails_admin_icon(action.link_icon) + " " + content_tag(:span, wording, (only_icon ? {
|
|
168
|
+
label = rails_admin_icon(action.link_icon) + " " + content_tag(:span, wording, (only_icon ? {hidden: true} : {}))
|
|
169
169
|
if action.enabled? || !only_icon
|
|
170
170
|
href =
|
|
171
171
|
if action.enabled?
|
|
@@ -181,6 +181,21 @@ module RailsAdminNext
|
|
|
181
181
|
end.join(" ").html_safe
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
+
def bulk_deletion_frame_id(id) = "bulk_deletion_#{id}"
|
|
185
|
+
|
|
186
|
+
# One banner per background delete the reader started. An id leaves the session once a
|
|
187
|
+
# full page has shown its final result, so polls alone never drop a banner unseen.
|
|
188
|
+
def bulk_deletion_banners
|
|
189
|
+
key = RailsAdminNext::BulkDeletion::Progress::SESSION_KEY
|
|
190
|
+
ids = session[key]
|
|
191
|
+
return if ids.blank?
|
|
192
|
+
|
|
193
|
+
banners = ids.map { [it, RailsAdminNext::BulkDeletion::Progress.summary(it)] }
|
|
194
|
+
running = banners.reject { it.last.terminal? }.map(&:first)
|
|
195
|
+
session[key] = running.presence if running != ids
|
|
196
|
+
safe_join(banners.map { |id, summary| render("rails_admin_next/bulk_deletions/banner", id:, summary:) })
|
|
197
|
+
end
|
|
198
|
+
|
|
184
199
|
def bulk_menu(abstract_model = @abstract_model)
|
|
185
200
|
actions = actions(:bulkable, abstract_model)
|
|
186
201
|
return "" if actions.empty?
|
|
@@ -190,7 +205,7 @@ module RailsAdminNext
|
|
|
190
205
|
content_tag(:ul, id: "bulk_menu", class: "dropdown-menu dropdown-menu-end", role: "menu", popover: "auto") do
|
|
191
206
|
actions.collect do |action|
|
|
192
207
|
content_tag :li, role: "none" do
|
|
193
|
-
link_to wording_for(:bulk_link, action, abstract_model), "#", class: "dropdown-item bulk-link", role: "menuitem", tabindex: "-1", data: {action: action.
|
|
208
|
+
link_to wording_for(:bulk_link, action, abstract_model), "#", class: "dropdown-item bulk-link", role: "menuitem", tabindex: "-1", data: {bulk_action: action.action_name, all_matching: (true if action.all_matching?)}
|
|
194
209
|
end
|
|
195
210
|
end.join.html_safe
|
|
196
211
|
end
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module RailsAdminNext
|
|
4
4
|
module MainHelper
|
|
5
|
+
FILTER_OPERATOR_LABELS = {
|
|
6
|
+
"_blank" => "is_blank", "_not_null" => "is_present", "_null" => "is_blank", "_present" => "is_present",
|
|
7
|
+
"ends_with" => "ends_with", "false" => "false", "is" => "is_exactly", "last_week" => "last_week", "like" => "contains",
|
|
8
|
+
"not_like" => "does_not_contain", "starts_with" => "starts_with", "this_week" => "this_week",
|
|
9
|
+
"today" => "today", "true" => "true", "yesterday" => "yesterday"
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
5
12
|
def rails_admin_form_for(*args, &)
|
|
6
13
|
options = args.extract_options!.reverse_merge(builder: RailsAdminNext::FormBuilder)
|
|
7
14
|
(options[:html] ||= {})[:novalidate] ||= !RailsAdminNext::Config.browser_validations
|
|
@@ -21,6 +28,63 @@ module RailsAdminNext
|
|
|
21
28
|
"danger" # > 1/3 of max
|
|
22
29
|
end
|
|
23
30
|
|
|
31
|
+
# The query string alone: a list rendered by a form submission must not carry the form's
|
|
32
|
+
# fields into the URLs it builds, which the next-batch frame requests on its own.
|
|
33
|
+
def list_params
|
|
34
|
+
@_list_params ||= request.query_parameters.except("utf8", "bulk_export").with_indifferent_access.tap do |list_params|
|
|
35
|
+
list_params.delete(:query) if list_params[:query].blank?
|
|
36
|
+
list_params.delete(:sort_reverse) unless list_params[:sort_reverse] == "true"
|
|
37
|
+
list_params.delete(:sort) if list_params[:sort] == @model_config.list.sort_by.to_s
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def list_batch_url(page)
|
|
42
|
+
index_path(list_params.except(:page).merge(page:))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# From request.params, not list_params: a bulk confirmation receives the filter in the posted body.
|
|
46
|
+
def list_filter_hidden_fields
|
|
47
|
+
safe_join(URI.decode_www_form(request.params.slice("query", "f", "sort", "sort_reverse").to_query).map { |name, value| hidden_field_tag name, value, id: nil })
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def scope_label(scope)
|
|
51
|
+
I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# What selects an all-matching bulk delete: the search query, each filter as field, operator
|
|
55
|
+
# and value, and the scope tab, or the whole model when nothing narrows the list.
|
|
56
|
+
def bulk_delete_filter_summary
|
|
57
|
+
items = []
|
|
58
|
+
items << t("admin.form.bulk_delete_query", query: params[:query]) if params[:query].present?
|
|
59
|
+
(filters_from_params || {}).each do |name, filters|
|
|
60
|
+
label = filterable_fields.find { it.name.to_s == name }.label
|
|
61
|
+
filters.each_value do |filter|
|
|
62
|
+
next if filter["disabled"].present? || filter["o"] == "_discard"
|
|
63
|
+
|
|
64
|
+
operator, values = filter["o"], Array(filter["v"]).compact_blank
|
|
65
|
+
# Boolean and enum filters post their operator token as the value, as the statement builder reads it.
|
|
66
|
+
operator, values = values.first, [] if operator.blank? && values.one? && FILTER_OPERATOR_LABELS.key?(values.first)
|
|
67
|
+
operator_label = operator.presence && operator != "default" && t("admin.js.#{FILTER_OPERATOR_LABELS.fetch(operator, operator)}", default: operator.humanize)
|
|
68
|
+
items << [label, operator_label, values.join(" – ")].compact_blank.join(" ")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
# The scope the list applied, which is the first tab when the request names none.
|
|
72
|
+
items << t("admin.form.bulk_delete_scope", tab: scope_label(list_scope)) if list_scope
|
|
73
|
+
return tag.p(t("admin.form.bulk_delete_everything", model_label: @model_config.label)) if items.empty?
|
|
74
|
+
|
|
75
|
+
tag.p(t("admin.form.bulk_delete_matching", model_label_plural: @model_config.label_plural)) + tag.ul(safe_join(items.map { tag.li(it) }))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Built from the request path rather than url_for, which reads routing options such as
|
|
79
|
+
# script_name out of a symbolized query hash.
|
|
80
|
+
def history_batch_url(page)
|
|
81
|
+
"#{request.path}?#{request.query_parameters.except("page").merge("page" => page).to_query}"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def list_properties
|
|
85
|
+
@_list_properties ||= @model_config.list.with(controller:, view: self, object: @abstract_model.model.new).fields_for_table
|
|
86
|
+
end
|
|
87
|
+
|
|
24
88
|
def filterable_fields
|
|
25
89
|
@filterable_fields ||= @model_config.list.fields.select(&:filterable?)
|
|
26
90
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAdminNext
|
|
4
|
+
# Destroys one slice of a confirmed bulk delete. The request already decided authorization,
|
|
5
|
+
# since the adapters need the live controller; this job only walks the keys it was given.
|
|
6
|
+
class BulkDeleteJob < ActiveJob::Base
|
|
7
|
+
# What `audit_with` is evaluated against in a job: the submitting user and no request, so an
|
|
8
|
+
# auditing adapter learns who deleted each record from the job rather than from a controller.
|
|
9
|
+
AuditContext = Struct.new(:_current_user) do
|
|
10
|
+
def auditing_adapter
|
|
11
|
+
instance_eval(&RailsAdminNext::Config.audit_with)
|
|
12
|
+
@auditing_adapter
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Often enough for a banner that polls every two seconds, rarely enough to keep cache
|
|
17
|
+
# writes far below record destroys.
|
|
18
|
+
REPORT_EVERY = 100
|
|
19
|
+
REPORT_INTERVAL = 30.seconds
|
|
20
|
+
|
|
21
|
+
def perform(model_name, keys, progress_id, slice_index, whodunnit = nil, submitter = nil)
|
|
22
|
+
# A backend retry resumes from this slice's own entry, so records an earlier attempt
|
|
23
|
+
# destroyed stay counted as deleted instead of turning up as already gone.
|
|
24
|
+
counts = BulkDeletion::Progress.slice_counts(progress_id, slice_index) || BulkDeletion::Counts.zero
|
|
25
|
+
report = ->(state) { BulkDeletion::Progress.write_slice(progress_id, slice_index, counts, state:) }
|
|
26
|
+
report.call(:running)
|
|
27
|
+
reported_at = Time.current
|
|
28
|
+
|
|
29
|
+
abstract_model = AbstractModel.new(model_name)
|
|
30
|
+
user = locate(submitter)
|
|
31
|
+
auditing_adapter = AuditContext.new(user).auditing_adapter
|
|
32
|
+
audit = ->(record) { auditing_adapter&.delete_object(record, abstract_model, user) }
|
|
33
|
+
|
|
34
|
+
attributed(whodunnit) do
|
|
35
|
+
BulkDeletion.new(abstract_model, keys).destroy(audit:, start: counts, progress: lambda { |latest|
|
|
36
|
+
counts = latest
|
|
37
|
+
if (counts.done % REPORT_EVERY).zero? || reported_at < REPORT_INTERVAL.ago
|
|
38
|
+
report.call(:running)
|
|
39
|
+
reported_at = Time.current
|
|
40
|
+
end
|
|
41
|
+
})
|
|
42
|
+
end
|
|
43
|
+
report.call(:finished)
|
|
44
|
+
rescue
|
|
45
|
+
report&.call(:errored)
|
|
46
|
+
raise
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
# A user deleted since the request leaves the audit unattributed.
|
|
52
|
+
def locate(submitter)
|
|
53
|
+
gid = GlobalID.parse(submitter) if submitter.is_a?(String)
|
|
54
|
+
gid ? GlobalID::Locator.locate_many([gid], ignore_missing: true).first : submitter
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# PaperTrail writes each version from the model callback, reading the whodunnit the
|
|
58
|
+
# request had.
|
|
59
|
+
def attributed(whodunnit, &)
|
|
60
|
+
return yield unless whodunnit && defined?(::PaperTrail)
|
|
61
|
+
|
|
62
|
+
::PaperTrail.request(whodunnit:, &)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|