zorab47 / active_admin-subnav

Enhanced sub-navigation for nested ActiveAdmin resources
MIT License
20 stars 5 forks source link

[discussion] update to recent activeadmin features #5

Open Fivell opened 7 years ago

Fivell commented 7 years ago

Hello @zorab47 , hope you're doing well and someday this gem will be merged to activeadmin. I just wanted to notify you about next changes that can reflect to this gem.

1) about pages pages are supports belongs_to, so there is no reason to skip pages from active_admin-subnav take a look https://github.com/activeadmin/activeadmin/pull/4759

2) about extra setup

# Provide access to the parent resource record: Site.
# Without this extra setup the parent record will not be accessible. Any
# calls to `#parent` will return the Arbre parent element and not the
# ActiveAdmin resource.

can you explain why this needed ? and why it is not possible to use helpers.parent in arbre https://github.com/Fivell/activeadmin/blob/05877d45d464d1911ca7d53072c81516c7614281/features/registering_pages.feature#L181

3) about controller hack

https://github.com/zorab47/active_admin-subnav/blob/master/lib/active_admin/subnav/extensions/base_controller.rb#L11

Can you please explain why this needed, maybe we'll find more clean workaround for this

Thanks

zorab47 commented 7 years ago

I'm happy to help get this integrated into ActiveAdmin. Answers are below:

  1. Pages aren't skipped. They just require a bit more setup due to item 2 (calling #parent in Arbre context)
  2. It has to do with the Arbre context and variable resolution. My thought is Arbre is intercepting the call for 'parent' though its use of method_missing and returns the parent HTML node. It should be the same issue discussed in https://github.com/activeadmin/activeadmin/pull/2770. Solving this issue would be very helpful in many places.
    • It is possible to use helpers.parent, but it seems strange when the docs for inherited_resources's belongs_to suggest using the controller#parent method directly.
    • I didn't realize that Arbre provided the helpers method for this purpose until you mentioned it.
  3. The controller hack is to ensure the ID of the parent resource is available when generating URLs for the sub menu items (if I remember correctly).

Have you experienced the issue related to calling #parent in an Arbre context? Perhaps my resources are configured in a strange way??

Fivell commented 7 years ago

@zorab47 , yes I had, but after I figured out that parent can be called on helpers. So helpers.parent works instead of parent

Fivell commented 7 years ago

@zorab47 , I will setup your gem when I have free time and check if something can be improved.

zorab47 commented 7 years ago

FYI, I've released a new version with compatibility with ActiveAdmin 1.0.0.