activeadmin-menu_tree 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a653a9f1c51e633dff273004db51decc6fb83ae1fc65c1fe80115710704cc13e
4
+ data.tar.gz: e1ffa9b248cdd6c63920877695d49b51cc94d4cc4cf89de4cd7919a94a9413ad
5
+ SHA512:
6
+ metadata.gz: 3b0c9d1405c3b35a27255cfdeedf18ccece589991c7fa8f91c28b518a7cabac180cb940406112c1d065055a5281ac894389a41a4ae65320f6836a1af47be0f7d
7
+ data.tar.gz: 569b99a28bf7cfc8277915138e0ff5f3d579f95b07ed791867f44651b225c2edb47259610f09a61635592ad60a1f7486004c94272decf34008b3b3520a13ac0a
@@ -0,0 +1,47 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ rubocop:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Install bundler
15
+ run: gem install bundler
16
+ - name: Setup
17
+ run: bin/setup
18
+ - name: Rubocop
19
+ run: bundle exec rake rubocop
20
+ rspec:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: 3.0.0
28
+ - name: Install bundler
29
+ run: gem install bundler
30
+ - name: Setup
31
+ run: bin/setup
32
+ - name: RSpec
33
+ run: bundle exec rake spec
34
+ steep:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - name: Set up Ruby
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: 3.0.0
42
+ - name: Install bundler
43
+ run: gem install bundler
44
+ - name: Setup
45
+ run: bin/setup
46
+ - name: Steep
47
+ run: bundle exec steep check
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+ /vendor/bundle
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ /.gem_rbs_collection
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+ DisplayCopNames: true
5
+ DisplayStyleGuide: true
6
+ ExtraDetails: true
7
+ Exclude:
8
+ - 'spec/dummy/**/*'
9
+
10
+ Style/ClassAndModuleChildren:
11
+ Enabled: false
12
+
13
+ Style/Lambda:
14
+ Enabled: false
15
+
16
+ Style/StringLiterals:
17
+ Enabled: true
18
+ EnforcedStyle: double_quotes
19
+
20
+ Style/StringLiteralsInInterpolation:
21
+ Enabled: true
22
+ EnforcedStyle: double_quotes
23
+
24
+ Style/TrailingCommaInHashLiteral:
25
+ Enabled: false
26
+
27
+ Layout/LineLength:
28
+ Max: 120
29
+
30
+ Layout/SpaceBeforeBlockBraces:
31
+ Enabled: false
32
+
33
+ Metrics/BlockLength:
34
+ Exclude:
35
+ - 'spec/**/*'
36
+
37
+ Metrics/MethodLength:
38
+ Max: 15
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in activeadmin-menu_tree.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rbs"
10
+ gem "rspec", "~> 3.0"
11
+ gem "rubocop", "~> 0.80"
12
+ gem "steep"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 shuuuuuny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,22 @@
1
+ .PHONY: rake/* rbs/* typeprof/* steep/*
2
+
3
+ rake/tasks:
4
+ rake --tasks
5
+
6
+ rbs/prototype: rbs/prototype/lib
7
+
8
+ rbs/prototype/lib:
9
+ for file in $$(find lib -name "*.rb" -type f | sort); do \
10
+ echo $${file}; \
11
+ mkdir -p sig/$$(dirname $${file}); \
12
+ rbs prototype rb $${file} > sig/$${file}s; \
13
+ done
14
+
15
+ # rbs/prototype/runtime:
16
+ # rbs prototype runtime -R spec/spec_helper.rb
17
+
18
+ typeprof/lib:
19
+ typeprof lib/**/*.rb
20
+
21
+ steep/check:
22
+ steep check
data/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # ActiveAdmin::MenuTree
2
+
3
+ <!-- TODO: badge -->
4
+
5
+ Allows [ActiveAdmin](https://github.com/activeadmin/activeadmin) menus to be managed in tree format.
6
+
7
+ This is a wrapper library for managing ActiveAdmin's menu structure in a simple yaml format, and automatically setting the priority and parent.
8
+
9
+ ### Motivation
10
+
11
+ I felt that the normal way of specifying menus in ActiveAdmin is inconvenient when changing it in an application.
12
+
13
+ Specifically, the two points are as follows:
14
+ - Order control by `priority`.
15
+ - To change the order of the menu, we need to change the priority of each resource one by one.
16
+ - Managing hierarchical relationships with `parent`.
17
+ - To create a hierarchy, we need to create a parent menu with initializer, and then specify the parent menu from each resource.
18
+
19
+ The configuration is scattered and burdensome to change.
20
+
21
+ This gem solves these problems.
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```ruby
28
+ gem 'activeadmin-menu_tree'
29
+ ```
30
+
31
+ And then execute:
32
+
33
+ $ bundle install
34
+
35
+ ## Usage
36
+
37
+ ### Only 2 steps
38
+
39
+ In your Rails project with ActiveAdmin.
40
+
41
+ #### 1. Setup menu_tree
42
+
43
+ Write the configuration in a yaml file.
44
+ ```yaml
45
+ # config/activeadmin-menu_tree.yml or anywhere you like
46
+ activeadmin:
47
+ menu_tree:
48
+ - name: Dashboard
49
+ - label: Admin
50
+ children:
51
+ - name: AdminUser
52
+ label: Admin Users
53
+ - name: Comment
54
+ label: Admin Comments
55
+ ```
56
+
57
+ Load it in initializer.
58
+ ```ruby
59
+ # config/initializers/activeadmin-menu_tree.rb
60
+ ActiveAdmin::MenuTree.setup do |config|
61
+ config.menu_tree = YAML.load_file(Rails.root.join("config/activeadmin-menu_tree.yml"))["activeadmin"]["menu_tree"]
62
+ end
63
+ ```
64
+
65
+ #### 2. Call `menu_tree` in ActiveAdmin Resources
66
+
67
+ You can use `menu_tree` instead of `menu` in ActiveAdmin Resource.
68
+ ```ruby
69
+ # app/admin/admin_users.rb
70
+ ActiveAdmin.register AdminUser do
71
+ # No need to specify `priority` or `parent`.
72
+ menu_tree
73
+ # ...
74
+ end
75
+
76
+ # app/admin/dashboard.rb
77
+ ActiveAdmin.register_page "Dashboard" do
78
+ # The options available for `menu` can be passed as is.
79
+ menu_tree label: proc { I18n.t("active_admin.dashboard") }
80
+ # ...
81
+ end
82
+
83
+ # Comment resource will be handled specially.
84
+ ```
85
+
86
+ ### Other ways to load configuration
87
+
88
+ It is also possible to simply use hash instead of yaml.
89
+ ```ruby
90
+ ActiveAdmin::MenuTree.setup do |config|
91
+ config.menu_tree = [{
92
+ name: "Dashboard"
93
+ }, {
94
+ label: "Foo",
95
+ children: [{
96
+ name: "Bar"
97
+ }, {
98
+ name: "Baz"
99
+ }]
100
+ }]
101
+ end
102
+ ```
103
+
104
+ If 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:
105
+ ```ruby
106
+ ActiveAdmin::MenuTree.setup do |config|
107
+ config.menu_tree = Settings.activeadmin.menu_tree.map(&:to_hash)
108
+ end
109
+ ```
110
+ ```yaml
111
+ # config/settings.yml
112
+ activeadmin:
113
+ menu_tree:
114
+ # ...
115
+ ```
116
+
117
+ Or you can use other configuration gems like [global gem](https://github.com/railsware/global) by converting them to hash as well.
118
+
119
+ ### Full configuration example
120
+ ```yaml
121
+ activeadmin:
122
+ menu_tree:
123
+ # Specify the resource name with `name`.
124
+ - name: Dashboard
125
+ - name: Product
126
+ # Specify a menu label with `label`.
127
+ - label: User Info
128
+ # Specify child elements with `children`.
129
+ children:
130
+ - name: User
131
+ - name: Profile
132
+ - label: Admin
133
+ children:
134
+ - name: AdminUser
135
+ label: Admin Users
136
+ # Comment resource will be handled specially.
137
+ - name: Comment
138
+ label: Admin Comments
139
+ - label: Others
140
+ children:
141
+ - name: Foo
142
+ - name: Bar
143
+ - label: Example Site
144
+ # You can pass the other options available for `menu` DSL, like `url`, `html_options`.
145
+ url: 'https://example.com'
146
+ html_options:
147
+ target: blank
148
+ ```
149
+
150
+ ## Development
151
+
152
+ After 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.
153
+
154
+ To 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).
155
+
156
+ ## Contributing
157
+
158
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shuuuuun/activeadmin-menu_tree.
159
+
160
+ ## License
161
+
162
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/Steepfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature "sig"
5
+
6
+ check "lib"
7
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/activeadmin/menu_tree/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "activeadmin-menu_tree"
7
+ spec.version = ActiveAdmin::MenuTree::VERSION
8
+ spec.authors = ["shuuuuuny"]
9
+ spec.email = []
10
+
11
+ spec.summary = "Allows ActiveAdmin menus to be managed in tree format."
12
+ spec.description = "This is a wrapper library for managing ActiveAdmin's menu structure in a simple yaml format, and automatically setting the priority and parent."
13
+ spec.homepage = "https://github.com/shuuuuun/activeadmin-menu_tree"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/shuuuuun/activeadmin-menu_tree"
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "activeadmin", "~> 2.8"
31
+ spec.add_dependency "activesupport"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "activeadmin/menu_tree"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAdmin::MenuTree
4
+ class Config
5
+ attr_reader :menu_tree, :menu_options
6
+
7
+ def initialize
8
+ @menu_tree = []
9
+ @menu_options = []
10
+ end
11
+
12
+ def menu_tree=(new_value)
13
+ raise ActiveAdmin::MenuTree::Error, "Invalid config" unless new_value.is_a? Array
14
+
15
+ @menu_tree = new_value.map(&:deep_symbolize_keys)
16
+ @menu_options = flatten_menu_tree
17
+ end
18
+
19
+ def find_menu_option(name:)
20
+ menu_options.find { |item| item[:name] == name }
21
+ end
22
+
23
+ private
24
+
25
+ def flatten_menu_tree
26
+ menu_tree.map.with_index(1) do |item, index|
27
+ options = format_options(item, index: index)
28
+ next options unless item[:children].is_a? Array
29
+
30
+ children =
31
+ item[:children].map.with_index(1) do |child, child_index|
32
+ format_options(child, index: child_index, parent: item[:label])
33
+ end
34
+
35
+ [options] + children
36
+ end.flatten.compact
37
+ end
38
+
39
+ def format_options(item, index:, parent: nil)
40
+ options = item.except(:children)
41
+ options[:priority] = index * 10
42
+ options[:label] ||= item[:name]&.pluralize&.titleize || ""
43
+ options[:parent] = parent if parent.present?
44
+ options
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAdmin::MenuTree
4
+ module DSL
5
+ def menu_tree(**args)
6
+ options = menu_tree_config.find_menu_option(name: config.resource_name.name) || {}
7
+ options = options.except(:name)
8
+ options = options.merge(args)
9
+ menu(**options)
10
+ end
11
+
12
+ private
13
+
14
+ def menu_tree_config
15
+ ActiveAdmin::MenuTree.config
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAdmin
4
+ module MenuTree
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/core_ext"
5
+
6
+ require_relative "menu_tree/version"
7
+ require_relative "menu_tree/config"
8
+ require_relative "menu_tree/dsl"
9
+
10
+ module ActiveAdmin
11
+ module MenuTree
12
+ class Error < StandardError; end
13
+
14
+ class << self
15
+ def setup
16
+ raise ActiveAdmin::MenuTree::Error, "No block given, require a block" unless block_given?
17
+
18
+ yield(config)
19
+
20
+ ActiveAdmin.before_load do |aa_config|
21
+ ActiveAdmin::DSL.prepend ActiveAdmin::MenuTree::DSL
22
+
23
+ setup_menu_options(aa_config)
24
+ end
25
+ end
26
+
27
+ def config
28
+ @config ||= Config.new
29
+ end
30
+
31
+ private
32
+
33
+ def setup_menu_options(aa_config)
34
+ comments_menu = config.find_menu_option(name: "Comment")
35
+ aa_config.comments_menu = comments_menu if comments_menu.present?
36
+
37
+ menu_options = config.menu_options
38
+ .reject{ |item| item[:name] == "Comment" }
39
+ .map{ |item| item.except(:name) }
40
+
41
+ aa_config.namespace :admin do |admin|
42
+ admin.build_menu do |menu|
43
+ menu_options.each do |options|
44
+ menu.add(**options)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,96 @@
1
+ ---
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+ path: ".gem_rbs_collection"
8
+ gems:
9
+ - name: actionpack
10
+ version: '6.0'
11
+ source:
12
+ type: git
13
+ name: ruby/gem_rbs_collection
14
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
15
+ remote: https://github.com/ruby/gem_rbs_collection.git
16
+ repo_dir: gems
17
+ - name: actionview
18
+ version: '6.0'
19
+ source:
20
+ type: git
21
+ name: ruby/gem_rbs_collection
22
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
23
+ remote: https://github.com/ruby/gem_rbs_collection.git
24
+ repo_dir: gems
25
+ - name: activemodel
26
+ version: '6.0'
27
+ source:
28
+ type: git
29
+ name: ruby/gem_rbs_collection
30
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
31
+ remote: https://github.com/ruby/gem_rbs_collection.git
32
+ repo_dir: gems
33
+ - name: activerecord
34
+ version: '6.1'
35
+ source:
36
+ type: git
37
+ name: ruby/gem_rbs_collection
38
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
39
+ remote: https://github.com/ruby/gem_rbs_collection.git
40
+ repo_dir: gems
41
+ - name: activesupport
42
+ version: '6.0'
43
+ source:
44
+ type: git
45
+ name: ruby/gem_rbs_collection
46
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
47
+ remote: https://github.com/ruby/gem_rbs_collection.git
48
+ repo_dir: gems
49
+ - name: ast
50
+ version: '2.4'
51
+ source:
52
+ type: git
53
+ name: ruby/gem_rbs_collection
54
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
55
+ remote: https://github.com/ruby/gem_rbs_collection.git
56
+ repo_dir: gems
57
+ - name: nokogiri
58
+ version: '1.11'
59
+ source:
60
+ type: git
61
+ name: ruby/gem_rbs_collection
62
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
63
+ remote: https://github.com/ruby/gem_rbs_collection.git
64
+ repo_dir: gems
65
+ - name: parallel
66
+ version: '1.20'
67
+ source:
68
+ type: git
69
+ name: ruby/gem_rbs_collection
70
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
71
+ remote: https://github.com/ruby/gem_rbs_collection.git
72
+ repo_dir: gems
73
+ - name: rack
74
+ version: 2.2.2
75
+ source:
76
+ type: git
77
+ name: ruby/gem_rbs_collection
78
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
79
+ remote: https://github.com/ruby/gem_rbs_collection.git
80
+ repo_dir: gems
81
+ - name: railties
82
+ version: '6.0'
83
+ source:
84
+ type: git
85
+ name: ruby/gem_rbs_collection
86
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
87
+ remote: https://github.com/ruby/gem_rbs_collection.git
88
+ repo_dir: gems
89
+ - name: rainbow
90
+ version: '3.0'
91
+ source:
92
+ type: git
93
+ name: ruby/gem_rbs_collection
94
+ revision: 2f3c0db60f184a09b3b195ad729a9aa1e2945d1b
95
+ remote: https://github.com/ruby/gem_rbs_collection.git
96
+ repo_dir: gems
@@ -0,0 +1,15 @@
1
+ # Download sources
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ # A directory to install the downloaded RBSs
9
+ path: .gem_rbs_collection
10
+
11
+ gems:
12
+ # Skip loading rbs gem's RBS.
13
+ # It's unnecessary if you don't use rbs as a library.
14
+ - name: rbs
15
+ ignore: true
@@ -0,0 +1,6 @@
1
+ module ActiveAdmin
2
+ module DSL
3
+ def config: () -> untyped
4
+ def menu: (**untyped options) -> void
5
+ end
6
+ end
@@ -0,0 +1,18 @@
1
+ module ActiveAdmin::MenuTree
2
+ class Config
3
+ attr_reader menu_tree: Array[untyped]
4
+ attr_reader menu_options: Array[untyped]
5
+
6
+ def initialize: () -> void
7
+
8
+ def menu_tree=: (untyped new_value) -> untyped
9
+
10
+ def find_menu_option: (name: String) -> untyped
11
+
12
+ private
13
+
14
+ def flatten_menu_tree: () -> untyped
15
+
16
+ def format_options: (untyped item, index: untyped index, ?parent: untyped? parent) -> untyped
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveAdmin::MenuTree
2
+ module DSL
3
+ include ActiveAdmin::DSL
4
+
5
+ def menu_tree: (**untyped args) -> void
6
+
7
+ private
8
+
9
+ def menu_tree_config: () -> Config
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveAdmin
2
+ module MenuTree
3
+ VERSION: ::String
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveAdmin
2
+ module MenuTree
3
+ class Error < StandardError
4
+ end
5
+
6
+ def self.setup: () { (untyped) -> untyped } -> untyped
7
+
8
+ def self.config: () -> Config
9
+
10
+ private
11
+
12
+ def self.setup_menu_options: (untyped aa_config) -> untyped
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveAdmin
2
+ def self.before_load: () { (untyped) -> void } -> void
3
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin-menu_tree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - shuuuuuny
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeadmin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This is a wrapper library for managing ActiveAdmin's menu structure in
42
+ a simple yaml format, and automatically setting the priority and parent.
43
+ email: []
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".github/workflows/main.yml"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".rubocop.yml"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - Makefile
55
+ - README.md
56
+ - Rakefile
57
+ - Steepfile
58
+ - activeadmin-menu_tree.gemspec
59
+ - bin/console
60
+ - bin/setup
61
+ - lib/activeadmin/menu_tree.rb
62
+ - lib/activeadmin/menu_tree/config.rb
63
+ - lib/activeadmin/menu_tree/dsl.rb
64
+ - lib/activeadmin/menu_tree/version.rb
65
+ - rbs_collection.lock.yaml
66
+ - rbs_collection.yaml
67
+ - sig/lib/activeadmin.rbs
68
+ - sig/lib/activeadmin/dsl.rbs
69
+ - sig/lib/activeadmin/menu_tree.rbs
70
+ - sig/lib/activeadmin/menu_tree/config.rbs
71
+ - sig/lib/activeadmin/menu_tree/dsl.rbs
72
+ - sig/lib/activeadmin/menu_tree/version.rbs
73
+ homepage: https://github.com/shuuuuun/activeadmin-menu_tree
74
+ licenses:
75
+ - MIT
76
+ metadata:
77
+ homepage_uri: https://github.com/shuuuuun/activeadmin-menu_tree
78
+ source_code_uri: https://github.com/shuuuuun/activeadmin-menu_tree
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.7.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.2.28
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Allows ActiveAdmin menus to be managed in tree format.
98
+ test_files: []