activeadmin-menu_tree 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c09eb5f2943471291e5f48ea280f82c0b3007057a6717db372447a6b8dc9ab01
4
- data.tar.gz: a169f0d879cb014bab3974e45a86ad8e23ac129e8752a1a22b968f6a3b0a048e
3
+ metadata.gz: 0caee8014a99e9c19b47e24c1fe5f9c3950a6707f00389d7a6572dc1c4671024
4
+ data.tar.gz: 48b3919992e7df05e26103655f8301ab405210b4f7b114fd097bd0aae2850c26
5
5
  SHA512:
6
- metadata.gz: 28860c7fbd65dc2530a41a037145d59dbaf6c9cec497a40b696dad4349dac833d0dfc24803ecb1e0832c3273b33d1ca18c2c98ba1c2be6f178c1f53189dc75a2
7
- data.tar.gz: 63e48fef67ff9bd247c6e44e479cb32dff83038f9221953c91f764b94d6cd0a3d446b7e45ba42b419068c3683b531f9bea19a11964ced1b3e4c0849e6f4e6e05
6
+ metadata.gz: 17618bae45e7f27646ad1aa1b65f0f8ab8dd221cdb5c949edb960e8e3d5ff01a837a7091ab7d772a149f9ce739c017bc56906fe939f30488794b6c4b731ba76b
7
+ data.tar.gz: 5345872721f7072db40551286347bdd2a6d072ddfccf08e0fc1bf02f626d471960d5c9efd7bfea1887a64418fdaa060026104dd48552ce5f683ab27c19fc8260
data/README.md CHANGED
@@ -46,12 +46,12 @@ Write the configuration in a yaml file.
46
46
  # config/activeadmin-menu_tree.yml or anywhere you like
47
47
  activeadmin:
48
48
  menu_tree:
49
- - name: Dashboard
49
+ - id: Dashboard
50
50
  - label: Admin
51
51
  children:
52
- - name: AdminUser
52
+ - id: AdminUser
53
53
  label: Admin Users
54
- - name: Comment
54
+ - id: Comment
55
55
  label: Admin Comments
56
56
  ```
57
57
 
@@ -92,13 +92,13 @@ If you want to use dynamic specification using `proc` in menu_tree (instead of i
92
92
  ```ruby
93
93
  ActiveAdmin::MenuTree.setup do |config|
94
94
  config.menu_tree = [
95
- { name: "Dashboard", label: proc { I18n.t("active_admin.dashboard") } },
95
+ { id: "Dashboard", label: proc { I18n.t("active_admin.dashboard") } },
96
96
  {
97
97
  label: "Foo",
98
98
  if: proc { "Something dynamic" },
99
99
  children: [
100
- { name: "Bar" },
101
- { name: "Baz" }
100
+ { id: "Bar" },
101
+ { id: "Baz" }
102
102
  ]
103
103
  }
104
104
  ]
@@ -125,26 +125,26 @@ Or you can use other configuration gems like [global gem](https://github.com/rai
125
125
  ```yaml
126
126
  activeadmin:
127
127
  menu_tree:
128
- # Specify the resource name with `name`.
129
- - name: Dashboard
130
- - name: Product
128
+ # Specify the resource with `id`.
129
+ - id: Dashboard
130
+ - id: Product
131
131
  # Specify a menu label with `label`.
132
132
  - label: User Info
133
133
  # Specify child elements with `children`.
134
134
  children:
135
- - name: User
136
- - name: Profile
135
+ - id: User
136
+ - id: Profile
137
137
  - label: Admin
138
138
  children:
139
- - name: AdminUser
139
+ - id: AdminUser
140
140
  label: Admin Users
141
141
  # Comment resource will be handled specially.
142
- - name: Comment
142
+ - id: Comment
143
143
  label: Admin Comments
144
144
  - label: Others
145
145
  children:
146
- - name: Foo
147
- - name: Bar
146
+ - id: Foo
147
+ - id: Bar
148
148
  - label: Example Site
149
149
  # You can pass the other options available for `menu` DSL, like `url`, `html_options`.
150
150
  url: 'https://example.com'
@@ -165,6 +165,9 @@ activeadmin:
165
165
  target: blank
166
166
  ```
167
167
 
168
+ <img width="1573" alt="screenshot" src="https://user-images.githubusercontent.com/7542105/153759374-fd516cb8-8022-4e44-aad9-c97f77afc4e7.png">
169
+
170
+
168
171
  ## Development
169
172
 
170
173
  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.
@@ -17,8 +17,8 @@ module ActiveAdmin::MenuTree
17
17
  @menu_options = flatten_options(@menu_tree)
18
18
  end
19
19
 
20
- def find_menu_option(name:)
21
- menu_options.find { |item| item[:name] == name }
20
+ def find_menu_option(id:)
21
+ menu_options.find { |item| item[:id] == id }
22
22
  end
23
23
 
24
24
  private
@@ -38,7 +38,6 @@ module ActiveAdmin::MenuTree
38
38
  # TODO: validate option
39
39
  options = item.except(:children)
40
40
  options[:priority] = index * 10
41
- options[:id] ||= item[:name]
42
41
  options[:parent] = parent if parent.present?
43
42
  options
44
43
  end
@@ -4,8 +4,7 @@ module ActiveAdmin::MenuTree
4
4
  # ActiveAdmin::MenuTree::DSL class
5
5
  module DSL
6
6
  def menu_tree(**args)
7
- options = menu_tree_config.find_menu_option(name: config.resource_name.name) || {}
8
- options = options.except(:name)
7
+ options = menu_tree_config.find_menu_option(id: config.resource_name.name) || {}
9
8
  options = options.merge(args)
10
9
  menu(**options)
11
10
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module MenuTree
5
- VERSION = "0.1.3"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -32,12 +32,11 @@ module ActiveAdmin
32
32
  private
33
33
 
34
34
  def setup_menu_options(aa_config)
35
- comments_menu = config.find_menu_option(name: "Comment")
35
+ comments_menu = config.find_menu_option(id: "Comment")
36
36
  aa_config.comments_menu = comments_menu if comments_menu.present?
37
37
 
38
38
  menu_options = config.menu_options
39
- .reject{ |item| item[:name] == "Comment" }
40
- .map{ |item| item.except(:name) }
39
+ .reject{ |item| item[:id] == "Comment" }
41
40
 
42
41
  aa_config.namespace :admin do |admin|
43
42
  admin.build_menu do |menu|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-menu_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shuuuuuny