activeadmin_favorites 0.1.6 → 0.1.8
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 +9 -0
- data/README.md +1 -3
- data/lib/activeadmin/favorites/version.rb +1 -1
- data/lib/activeadmin/favorites/view_paths.rb +38 -14
- metadata +1 -2
- data/app/views/active_admin/_html_head.html.erb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c6a1ca67243ef7bcf12defce94d288b0afca716511a3a04f6326ecce641e784
|
|
4
|
+
data.tar.gz: 0150e3932226fe8890a22dac1889d57f8e74fb868928ec8027763a8e07acfc0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 520cd1dec8f6f362b90163d65f8a3d3231f603481a7f95354600cd455cde6fbe37eaaae3bd5b3f26e90cae6bd784075b4dfb4432b4f43747cde70f25ff2ba7fe
|
|
7
|
+
data.tar.gz: 510d6d7d6b0bc26017bca1d6ff576ba3e835f95215dba7a299ca810d40ea44d541f88e21526449a575f27b41535b1fb1e1e76a5902d9947223a132d3d5984d04
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.1.8 (2026-10-29)
|
|
4
|
+
|
|
5
|
+
- Fix Active Admin view-path detection so sibling gems such as `activeadmin-command_palette` are not treated as Active Admin. Prefer `ActiveAdmin::Engine.root`, with a fallback that requires a digit version segment after `activeadmin-`.
|
|
6
|
+
- Remove the gem `active_admin/_html_head` override. Hosts must link `activeadmin_favorites/personalization_menu` from their own Active Admin head.
|
|
7
|
+
|
|
8
|
+
## 0.1.7 (2026-10-29)
|
|
9
|
+
|
|
10
|
+
- Fix engine view path order so favorites sits immediately before ActiveAdmin and host `app/views` stays ahead of the gem `_html_head`. Rails engines prepend view paths; the previous reorder left favorites first whenever it was already ahead of ActiveAdmin.
|
|
11
|
+
|
|
3
12
|
## 0.1.6 (2026-10-27)
|
|
4
13
|
|
|
5
14
|
- Link the personalization menu stylesheet from Active Admin's HTML head so hosts no longer need a Tailwind `@import` of the Propshaft path.
|
data/README.md
CHANGED
|
@@ -61,9 +61,7 @@ When using ActionPolicy, add `save_lens_favorite?` and `reset?` to `ActiveAdmin:
|
|
|
61
61
|
|
|
62
62
|
### Stylesheet
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
If the host overrides `active_admin/_html_head`, add the link there:
|
|
64
|
+
Link `activeadmin_favorites/personalization_menu` from the host Active Admin HTML head so the cogwheel dropdown can scroll the catalog while keeping action buttons in view. The file is plain CSS served through Propshaft; it does not need Tailwind processing. The gem does not ship `active_admin/_html_head`, so customized host heads keep their stylesheet names and extra tags.
|
|
67
65
|
|
|
68
66
|
```erb
|
|
69
67
|
<%= stylesheet_link_tag "activeadmin_favorites/personalization_menu" %>
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
module Favorites
|
|
5
|
-
# Place this engine's views
|
|
6
|
-
# overrides (catalog injection) win
|
|
5
|
+
# Place this engine's views immediately before ActiveAdmin's so resource
|
|
6
|
+
# index/show overrides (catalog injection) win. Rails engines prepend their
|
|
7
|
+
# view paths, so favorites can otherwise sit ahead of the host app/views.
|
|
7
8
|
module ViewPaths
|
|
8
9
|
module_function
|
|
9
10
|
|
|
10
11
|
def prefer_over_active_admin!(view_paths)
|
|
11
12
|
path_strings = view_paths.to_a.map { |path| path.to_s }
|
|
12
13
|
reordered = reorder_path_strings(path_strings)
|
|
13
|
-
return view_paths if reordered
|
|
14
|
+
return view_paths if reordered == path_strings
|
|
14
15
|
|
|
15
16
|
ActionView::PathSet.new(reordered)
|
|
16
17
|
end
|
|
@@ -25,24 +26,47 @@ module ActiveAdmin
|
|
|
25
26
|
|
|
26
27
|
def reorder_path_strings(path_strings)
|
|
27
28
|
favorites_root = Engine.root.join("app/views").to_s
|
|
28
|
-
|
|
29
|
+
active_admin_root = active_admin_views_root(path_strings)
|
|
30
|
+
return path_strings unless path_strings.include?(favorites_root) && active_admin_root
|
|
31
|
+
return path_strings if already_before_active_admin?(path_strings, favorites_root, active_admin_root)
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
place_before_active_admin(path_strings, favorites_root, active_admin_root)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def active_admin_views_root(path_strings)
|
|
37
|
+
engine_root = active_admin_engine_views_root
|
|
38
|
+
return engine_root if engine_root && path_strings.include?(engine_root)
|
|
39
|
+
|
|
40
|
+
path_strings.find { |path| path.match?(ACTIVE_ADMIN_GEM_VIEWS) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def active_admin_engine_views_root
|
|
44
|
+
return unless defined?(::ActiveAdmin::Engine)
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
::ActiveAdmin::Engine.root.join("app/views").to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def already_before_active_admin?(path_strings, favorites_root, active_admin_root)
|
|
50
|
+
path_strings.index(favorites_root) == path_strings.index(active_admin_root) - 1
|
|
51
|
+
end
|
|
38
52
|
|
|
53
|
+
def place_before_active_admin(path_strings, favorites_root, active_admin_root)
|
|
39
54
|
moved = path_strings.dup
|
|
40
|
-
moved.
|
|
55
|
+
moved.delete(favorites_root)
|
|
41
56
|
moved.insert(moved.index(active_admin_root), favorites_root)
|
|
42
57
|
moved
|
|
43
58
|
end
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
|
|
60
|
+
# Versioned Active Admin gem only (`activeadmin-4...`), not siblings such as
|
|
61
|
+
# `activeadmin-command_palette-...`.
|
|
62
|
+
ACTIVE_ADMIN_GEM_VIEWS = %r{/gems/activeadmin-\d[^/]*/app/views\z}
|
|
63
|
+
|
|
64
|
+
module_function :reorder_path_strings, :active_admin_views_root,
|
|
65
|
+
:active_admin_engine_views_root, :already_before_active_admin?,
|
|
66
|
+
:place_before_active_admin
|
|
67
|
+
private_class_method :reorder_path_strings, :active_admin_views_root,
|
|
68
|
+
:active_admin_engine_views_root, :already_before_active_admin?,
|
|
69
|
+
:place_before_active_admin
|
|
46
70
|
end
|
|
47
71
|
end
|
|
48
72
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeadmin_favorites
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -355,7 +355,6 @@ files:
|
|
|
355
355
|
- app/models/active_admin/favorites/lens_favorite.rb
|
|
356
356
|
- app/models/active_admin/favorites/view_lens/layout.rb
|
|
357
357
|
- app/models/active_admin/favorites/view_lens_default.rb
|
|
358
|
-
- app/views/active_admin/_html_head.html.erb
|
|
359
358
|
- app/views/active_admin/favorites/_lens_catalog_data.html.erb
|
|
360
359
|
- app/views/active_admin/favorites/_macro_fields.html.erb
|
|
361
360
|
- app/views/active_admin/favorites/_personalization_trigger.html.erb
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<%= stylesheet_link_tag "active_admin" %>
|
|
2
|
-
<%= stylesheet_link_tag ActiveAdmin::Favorites::PERSONALIZATION_MENU_STYLESHEET %>
|
|
3
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
-
<%= csrf_meta_tags %>
|
|
5
|
-
<%= csp_meta_tag %>
|
|
6
|
-
<% # On page load or when changing themes, best to add inline in `head` to avoid FOUC %>
|
|
7
|
-
<%= javascript_tag nonce: true do %>
|
|
8
|
-
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
9
|
-
document.documentElement.classList.add('dark')
|
|
10
|
-
} else {
|
|
11
|
-
document.documentElement.classList.remove('dark')
|
|
12
|
-
}
|
|
13
|
-
<% end %>
|
|
14
|
-
<%= javascript_importmap_tags "active_admin", importmap: ActiveAdmin.importmap %>
|