-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name action items; allow removing them by name #3091
Name action items; allow removing them by name #3091
Conversation
I'm trying to decide whether it's okay to keep this as an array with optional names... It's a breaking change, but making the name required seems to fit the overall style of the rest of Active Admin. |
Hope that #3074 will be also merged before this pull-request. Afterwards it's anyway better to abstract actions should be shown in the index to an array, hash or similar structure. |
@seanlinsley If you are looking for input on that, my suggestion would be to just add this with a deprecation warning when calling @dmitry That pull-request looks interesting, but nothing to do with this one. This is about custom |
@amiel That's right. Sorry. Looks like I thought so because the same pattern I worked on recently: vs |
@dmitry no worries; they both have similar names |
@seanlinsley have you given this any more thought? Do you want me to rebase? |
Any updates on this? For a project I am working on it would be quite handy to remove the new action and substitute it with a custom one |
@seanlinsley Do you need anything else from me on this one? |
Hi @seanlinsley any eta on this? Cheers, Joel |
we can do it this way, so we have a backward compatibility. def action_item(name, options = {}, &block)
Deprecation.warn "using `action_item` without a name is deprecated! Use `action_item(:edit)`." unless name
config.add_action_item(name, options, &block)
end
def add_action_item(name = nil, options = {}, &block)
self.action_items << ActiveAdmin::ActionItem.new(name, options, &block)
end
def initialize(name, options = {}, &block)
@options, @block = options, block
self.name = name
normalize_display_options!
end |
I'd be happy to add the deprecation warning. Is that being requested? or is this waiting for a decision on that matter? |
The deprecation waring is a way that works with old and new code so we should use it! |
That message won't make sense to the end user since the method they called was |
Sorry, I'm not gone up far enough in the call stack. Updated my code example |
Ok, I've rebased on to master and added the name as the first parameter (optional with warning in the DSL). I can't run the tests right now, so I imagine this will fail. I can deal with that tomorrow, but figured I would get the ball rolling here for review. |
Resolve the failing test and I will merge it. |
@timhabermaas Thanks. I don't have any more time today, but I will try to get to it tomorrow :) |
Ok, I think this is ready. |
@seanlinsley you have turned of @coveralls? 👍 |
Sweet! Let me know if there's anything else you need for this pull-request. |
@amiel please smash your first three commits into one, they have to many changes of the signature of |
Ref #760 Name first parameter to action items. It is still optional in the DSL, but triggers a deprecation warning when not provided.
Ok, I squashed all of the commits. I also saw your comment about the |
Sorry you are right. |
Name action items; allow removing them by name
Thanks @timoschilling! I'm very happy to see this merged :) |
As discussed in #760, this allows for customizing what of the default action items are shown. It could also be used to allow for customizing action items per request, but that is beyond the scope of this pull-request.