<commit_before>class TreeBuilderMenuRoles < TreeBuilder
  has_kids_for Hash, [:x_get_tree_hash_kids]

  attr_reader :rpt_menu, :role_choice

  def initialize(name, type, sandbox, build, role_choice:, rpt_menu: nil)
    @rpt_menu    = rpt_menu || sandbox[:rpt_menu]
    @role_choice = role_choice

    super(name, type, sandbox, build)
  end

  # Used for testing convenience and to satisfy need for
  # tree data in controller

  def hash_tree
    @hash_tree ||= x_build_tree(@tree_state.x_tree(@name))
  end

  private

  def set_locals_for_render
    locals = {
      :click_url => "/report/menu_editor/",
      :onclick   => "miqMenuEditor"
    }

    super.merge!(locals)
  end

  def tree_init_options(_tree_name)
    { :lazy => false, :add_root => true }
  end

  def root_options
    [t = _("Top Level"), t, "100/folder.png", {:key => "xx-b__Report Menus for #{role_choice}"}]
  end

  # Typically another method will populate the children of a root object.
  # Since our data is an array of Strings or Arrays, we don't have ids to tie
  # parents to children. Therefore we include the children with the parent.
  # The :data key was chosen to avoid future conflicts with the :children key.
  #
  def x_get_tree_roots(count_only = false, _options)
    branches = menus.map do |i|<commit_msg>Null the root node image in MenuRolesTreeBuilder as it is the default<commit_after>class TreeBuilderMenuRoles < TreeBuilder
  has_kids_for Hash, [:x_get_tree_hash_kids]

  attr_reader :rpt_menu, :role_choice

  def initialize(name, type, sandbox, build, role_choice:, rpt_menu: nil)
    @rpt_menu    = rpt_menu || sandbox[:rpt_menu]
    @role_choice = role_choice

    super(name, type, sandbox, build)
  end

  # Used for testing convenience and to satisfy need for
  # tree data in controller

  def hash_tree
    @hash_tree ||= x_build_tree(@tree_state.x_tree(@name))
  end

  private

  def set_locals_for_render
    locals = {
      :click_url => "/report/menu_editor/",
      :onclick   => "miqMenuEditor"
    }

    super.merge!(locals)
  end

  def tree_init_options(_tree_name)
    { :lazy => false, :add_root => true }
  end

  def root_options
    [t = _("Top Level"), t, nil, {:key => "xx-b__Report Menus for #{role_choice}"}]
  end

  # Typically another method will populate the children of a root object.
  # Since our data is an array of Strings or Arrays, we don't have ids to tie
  # parents to children. Therefore we include the children with the parent.
  # The :data key was chosen to avoid future conflicts with the :children key.
  #
  def x_get_tree_roots(count_only = false, _options)
    branches = menus.map do |i|
{'fraction_non_alphanumeric': 0.09321712769988633, 'fraction_numerical': 0.0011367942402425162, 'mean_word_length': 3.6153846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '356349', 'n_tokens_mistral': 903, 'n_tokens_neox': 867, 'n_words': 278}