{"id":15554162,"url":"https://github.com/shuuuuun/activeadmin-menu_tree","last_synced_at":"2025-07-30T09:07:41.581Z","repository":{"id":40008963,"uuid":"403205306","full_name":"shuuuuun/activeadmin-menu_tree","owner":"shuuuuun","description":"Allows ActiveAdmin menus to be managed in tree format.","archived":false,"fork":false,"pushed_at":"2024-03-18T17:07:22.000Z","size":159,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-08T23:33:43.528Z","etag":null,"topics":["activeadmin","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuuuuun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-05T03:23:51.000Z","updated_at":"2023-01-09T10:22:30.000Z","dependencies_parsed_at":"2024-01-17T05:07:39.845Z","dependency_job_id":"a7845ef4-2906-4d98-b65a-c522a07568bb","html_url":"https://github.com/shuuuuun/activeadmin-menu_tree","commit_stats":{"total_commits":146,"total_committers":4,"mean_commits":36.5,"dds":0.2808219178082192,"last_synced_commit":"2ff3bded84e1e445599a8388cd4ac82dbca78da7"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuuuuun%2Factiveadmin-menu_tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuuuuun%2Factiveadmin-menu_tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuuuuun%2Factiveadmin-menu_tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuuuuun%2Factiveadmin-menu_tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuuuuun","download_url":"https://codeload.github.com/shuuuuun/activeadmin-menu_tree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225297553,"owners_count":17452010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activeadmin","rails","ruby"],"created_at":"2024-10-02T14:50:39.990Z","updated_at":"2024-11-19T20:12:24.229Z","avatar_url":"https://github.com/shuuuuun.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveAdmin::MenuTree\n\n[![Gem Version](https://badge.fury.io/rb/activeadmin-menu_tree.svg)](https://badge.fury.io/rb/activeadmin-menu_tree)\n[![Ruby](https://github.com/shuuuuun/activeadmin-menu_tree/actions/workflows/main.yml/badge.svg)](https://github.com/shuuuuun/activeadmin-menu_tree/actions/workflows/main.yml)\n\nAllows [ActiveAdmin](https://github.com/activeadmin/activeadmin) menus to be managed in tree format.\n\nThis is a wrapper library for managing ActiveAdmin's menu structure in a simple yaml format, and automatically setting the priority and parent.\n\n### Motivation\n\nI felt that the normal way of specifying menus in ActiveAdmin is inconvenient when changing it in an application.\n\nSpecifically, the two points are as follows:\n- Order control by `priority`.\n  - To change the order of the menu, we need to change the priority of each resource one by one.\n- Managing hierarchical relationships with `parent`.\n  - To create a hierarchy, we need to create a parent menu with initializer, and then specify the parent menu from each resource.\n\nThe configuration is scattered and burdensome to change.\n\nThis gem solves these problems.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activeadmin-menu_tree'\n```\n\nAnd then execute:\n\n    $ bundle install\n\n## Usage\n\n### Only 2 steps\n\nIn your Rails project with ActiveAdmin.\n\n#### 1. Setup menu_tree\n\nWrite the configuration in a yaml file.\n```yaml\n# config/activeadmin-menu_tree.yml or anywhere you like\nactiveadmin:\n  menu_tree:\n    - id: Dashboard\n    - label: Admin\n      children:\n        - id: AdminUser\n          label: Admin Users\n        - id: Comment\n          label: Admin Comments\n```\n\nLoad it in initializer.\n```ruby\n# config/initializers/activeadmin-menu_tree.rb\nActiveAdmin::MenuTree.setup do |config|\n  config.menu_tree = YAML.load_file(Rails.root.join(\"config/activeadmin-menu_tree.yml\"))[\"activeadmin\"][\"menu_tree\"]\nend\n```\n\n#### 2. Call `menu_tree` in ActiveAdmin Resources\n\nYou can use `menu_tree` instead of `menu` in ActiveAdmin Resource.\n```ruby\n# app/admin/admin_users.rb\nActiveAdmin.register AdminUser do\n  # No need to specify `priority` or `parent`.\n  menu_tree\n  # ...\nend\n\n# app/admin/dashboard.rb\nActiveAdmin.register_page \"Dashboard\" do\n  # The options available for `menu` can be passed as is.\n  menu_tree label: proc { I18n.t(\"active_admin.dashboard\") }\n  # ...\nend\n\n# Comment resource will be handled specially.\n```\n\n### Other ways to load configuration\n\nIt is also possible to simply use hash instead of yaml.  \nIf you want to use dynamic specification using `proc` in menu_tree (instead of in ActiveAdmin Resource), you may want to use this one.\n\n```ruby\nActiveAdmin::MenuTree.setup do |config|\n  config.menu_tree = [\n    { id: \"Dashboard\", label: proc { I18n.t(\"active_admin.dashboard\") } },\n    {\n      label: \"Foo\",\n      if: proc { \"Something dynamic\" },\n      children: [\n        { id: \"Bar\" },\n        { id: \"Baz\" }\n      ]\n    }\n  ]\nend\n```\n\nIf your project uses the [config gem](https://github.com/rubyconfig/config), you can use it by converting it to hash with `to_hash` as follows:\n```ruby\nActiveAdmin::MenuTree.setup do |config|\n  config.menu_tree = Settings.activeadmin.menu_tree.map(\u0026:to_hash)\nend\n```\n```yaml\n# config/settings.yml\nactiveadmin:\n  menu_tree:\n    # ...\n```\n\nOr you can use other configuration gems like [global gem](https://github.com/railsware/global) by converting them to hash as well.\n\n### Full configuration example\n\n```yaml\nactiveadmin:\n  menu_tree:\n    # Specify the resource with `id`.\n    - id: Dashboard\n    - id: Product\n    # Specify a menu label with `label`.\n    - label: User Info\n      # Specify child elements with `children`.\n      children:\n        - id: User\n        - id: Profile\n    - label: Admin\n      children:\n        - id: AdminUser\n          label: Admin Users\n        # Comment resource will be handled specially.\n        - id: Comment\n          label: Admin Comments\n    - label: Others\n      children:\n        - id: Foo\n        - id: Bar\n    - label: Example Site\n      # You can pass the other options available for `menu` DSL, like `url`, `html_options`.\n      url: 'https://example.com'\n      html_options:\n        target: blank\n    # Nesting of children is also available.\n    - label: Lorem\n      children:\n        - label: ipsum\n          children:\n            - label: dolor\n              children:\n                - label: sit\n                  children:\n                    - label: amet\n                      url: 'https://wikipedia.org/wiki/Lorem_ipsum'\n                      html_options:\n                        target: blank\n```\n\n\u003cimg width=\"1573\" alt=\"screenshot\" src=\"https://user-images.githubusercontent.com/7542105/153759374-fd516cb8-8022-4e44-aad9-c97f77afc4e7.png\"\u003e\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/shuuuuun/activeadmin-menu_tree.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuuuuun%2Factiveadmin-menu_tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuuuuun%2Factiveadmin-menu_tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuuuuun%2Factiveadmin-menu_tree/lists"}