Skip to content
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

Add priority option to action item #5334

Merged
merged 3 commits into from
Feb 7, 2018
Merged

Add priority option to action item #5334

merged 3 commits into from
Feb 7, 2018

Conversation

andreslemik
Copy link
Contributor

@andreslemik andreslemik commented Jan 28, 2018

Able to add action item to the beginning of action items via adding priority: 0.

action_item :view, only: :show, priority: 0 do
  link_to 'View on site', post_path(post) if post.published?
end

image

@codecov
Copy link

codecov bot commented Jan 28, 2018

Codecov Report

Merging #5334 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5334      +/-   ##
==========================================
+ Coverage   98.29%   98.29%   +<.01%     
==========================================
  Files         294      294              
  Lines       10982    10989       +7     
==========================================
+ Hits        10795    10802       +7     
  Misses        187      187
Impacted Files Coverage Δ
spec/unit/resource/action_items_spec.rb 94.87% <100%> (+0.75%) ⬆️
lib/active_admin/resource/action_items.rb 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f71b375...a978705. Read the comment docs.

@varyonic
Copy link
Contributor

Interesting idea, I would like to see more feedback from others. My first thought is to add a priority attribute, like for menu items.

@Fivell
Copy link
Member

Fivell commented Jan 29, 2018

@varyonic I think priority is better one, since we already have such option also for sidebar

@andreslemik
Copy link
Contributor Author

@varyonic, @Fivell I was change this like for sidebar.

Copy link
Member

@Fivell Fivell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreslemik , can you please also add note in documentation about new option here https://github.com/activeadmin/activeadmin/blob/master/docs/8-custom-actions.md#action-items

@@ -32,6 +32,16 @@
expect(resource.action_items.first.html_class).to eq("action_item test")
end

it 'should be ordered by priority' do
resource.add_action_item :first, priority: 0 do
# Empty ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add one action item without priority to this example for testing default priority

@Fivell Fivell changed the title Add action item to the beginning Add priority option to action item Jan 29, 2018
@@ -110,6 +110,10 @@ def initialize(name, options = {}, &block)
def html_class
"action_item #{@options[:class]}".rstrip
end

def priority
@options[:priority] || 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreslemik please fix docs for add_action_item method with including description for new option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fivell, all done

@Fivell
Copy link
Member

Fivell commented Feb 2, 2018

@varyonic what do you think ?

@zorab47 zorab47 merged commit a971426 into activeadmin:master Feb 7, 2018
deivid-rodriguez pushed a commit that referenced this pull request Nov 14, 2018
Add priority option to action item

(cherry picked from commit a971426)
@deivid-rodriguez deivid-rodriguez mentioned this pull request Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants