activeadmin-menu_tree 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0caee8014a99e9c19b47e24c1fe5f9c3950a6707f00389d7a6572dc1c4671024
4
- data.tar.gz: 48b3919992e7df05e26103655f8301ab405210b4f7b114fd097bd0aae2850c26
3
+ metadata.gz: ae470640145da2a76875e361c8e1a5bb99838ff72894c9fc8f66dd266226004c
4
+ data.tar.gz: bc6fe3ffe900a9e8a1430ca25a82815c32d67f3b0979df55fe9af4bd25d3e223
5
5
  SHA512:
6
- metadata.gz: 17618bae45e7f27646ad1aa1b65f0f8ab8dd221cdb5c949edb960e8e3d5ff01a837a7091ab7d772a149f9ce739c017bc56906fe939f30488794b6c4b731ba76b
7
- data.tar.gz: 5345872721f7072db40551286347bdd2a6d072ddfccf08e0fc1bf02f626d471960d5c9efd7bfea1887a64418fdaa060026104dd48552ce5f683ab27c19fc8260
6
+ metadata.gz: aa4d16bdde948794cc92965ffa9ec94cfbed5fdcf102c6300d941dbd6f8b80a73b69ced428cd884d37f40c582eab88d283b18299893f97cb8a69ff34a839ebbd
7
+ data.tar.gz: 53572e64a66d4aadd161f9d4f5c3d0d84ad4d9590d4310ef0c13334b205677ce447d45e4c7d4fbcb462c344d603e515152258b377d828dd829d2ac75bb786eea
@@ -36,6 +36,10 @@ module ActiveAdmin::MenuTree
36
36
 
37
37
  def format_options(item, index:, parent: nil)
38
38
  # TODO: validate option
39
+ if item.key?(:name)
40
+ ActiveAdmin::MenuTree.warn_deprecated("Use `id` key, instead of `name`.")
41
+ options[:id] ||= item[:name]
42
+ end
39
43
  options = item.except(:children)
40
44
  options[:priority] = index * 10
41
45
  options[:parent] = parent if parent.present?
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAdmin
4
+ module MenuTree
5
+ # ActiveAdmin::MenuTree::Logging module
6
+ module Logging
7
+ def debug?
8
+ ENV["MENU_TREE_DEBUG"]
9
+ end
10
+
11
+ def log_debug(message)
12
+ warn("[ActiveAdmin::MenuTree] #{message}") if debug?
13
+ end
14
+
15
+ def warn_deprecated(message)
16
+ warn("[ActiveAdmin::MenuTree] [DEPRECATION] #{message}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module MenuTree
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -4,6 +4,7 @@ require "active_support"
4
4
  require "active_support/core_ext"
5
5
 
6
6
  require_relative "menu_tree/version"
7
+ require_relative "menu_tree/logging"
7
8
  require_relative "menu_tree/config"
8
9
  require_relative "menu_tree/dsl"
9
10
 
@@ -13,6 +14,8 @@ module ActiveAdmin
13
14
  class Error < StandardError; end
14
15
 
15
16
  class << self
17
+ include ActiveAdmin::MenuTree::Logging
18
+
16
19
  def setup
17
20
  raise ActiveAdmin::MenuTree::Error, "No block given, require a block" unless block_given?
18
21
 
@@ -38,6 +41,7 @@ module ActiveAdmin
38
41
  menu_options = config.menu_options
39
42
  .reject{ |item| item[:id] == "Comment" }
40
43
 
44
+ ActiveAdmin::MenuTree.log_debug("menu_options: #{menu_options.inspect}")
41
45
  aa_config.namespace :admin do |admin|
42
46
  admin.build_menu do |menu|
43
47
  menu_options.each do |options|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-menu_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shuuuuuny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-13 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -61,6 +61,7 @@ files:
61
61
  - lib/activeadmin/menu_tree.rb
62
62
  - lib/activeadmin/menu_tree/config.rb
63
63
  - lib/activeadmin/menu_tree/dsl.rb
64
+ - lib/activeadmin/menu_tree/logging.rb
64
65
  - lib/activeadmin/menu_tree/version.rb
65
66
  - rbs_collection.lock.yaml
66
67
  - rbs_collection.yaml