[solved] Add our own menu


#1

Hello everybody.

First of all, I’m new in ManageIQ world, and I hope my English will not be too bad.

I’d like to add my own menu in ManageIQ (like Cloud Intelligence, Service, Clouds, etc…) with my own pages.
I’ve created my route, my controller, my view, and everything works fine when I type the url.

I’ve edited the file app/presenters/menu/default_menu.rb to add a new “specific_menu_section” that looks like that :

def steph_menu_section
         Menu::Section.new(:set, N_("Steph"), [
          Menu::Item.new('steph', N_('steph'),   'steph',  {:feature => 'tasks', :any => true},  '/test_steph'),
          Menu::Item.new('steph2',      N_('steph2'),         'bottlenecks',        {:feature => 'tasks', :any => true},        '/test_steph2'),
          
        ])
      end

It almost works… but I need some informations : where can I add a new feature (like tasks, bottlenecks…) and what is the third parameter of Item.new ?

Thanks everyone for your help.


#2

@dclarizio can your review this question by @Merrick28 and forward to a SME if necessary.


#3

Hello,

I think I have found the answer :

In database, insert a new record in the “miq_product_features” table.
•identifier : short text without spaces and in lowercase
•name : name of the rbac point
•description : description of the rbac point
•feature_type : node
•protected : false
•parent_id : 1 if you wish the rbac entry at the top, otherwise the id of another record in “miq_product_features” table
•created_at : now()
•updated_at : now()
•hidden : false

Then edit the app/presenters/menu/default_menu.rb

If you wish to create a new top category, before the def default_menu section add :

def mymenu_menu_section
         Menu::Section.new(:set, N_("My Menu"), [

        ])
      end

Replace mymenu by the name you want.

In the def default_menu section, before the .compact, add the name of your section in the array (in this case, it would by mymenu_menu_section)

In the array of the Section.new you choose, you can add entries like that :

Menu::Item.new('col1', N_(Name),   'feature',  {:feature => 'feature', :any => true},  '/dest_url'),

Arguments :
•col1 : it will be the identifier of the submenu (I don’t know if it’s used elsewhere)
•Name : the name of the menu as it will appear
•feature (twice) : the name of the RBAC feature you want to use (either an existing one or the one you created earlier)
•/dest_url : the url you will be redirected to after a clic on this menu

Of course, the dest_url must exist.


#4

Awesome @Merrick28,…I’m glad you figured it out!
and thanks for posting the details,…this hopefully will help others.

BTW,…thanks for also marking the subject line with [solved]
That helps bring attention to others.


#5

@Merrick28 I believe there is a way to just drop a yml file into db/fixtures/miq_product_features directory, and those will be automatically seeded…then you should not need to edit the code.


#6

Hello @Fryguy, I was just about to look at it, as I saw that my nex record in table miq_product_features was removed after a evm restart.
I will let you know as soon as I will have to time to test again.

Thanks again for your help


#7

@Fryguy
I believe you’re right. I added my new menu items to the following locations:

/var/www/miq/vmdb/product/menubar
and
/var/www/miq/vmdb/db/fixtures/miq_product_features

Then updated the permissions.yml file in: /var/www/miq/vmdb/config/

Then recompiled and it worked. However, I’m only able to redirect to another webpage. Does anyone know which file I need to edit to add a new blank page where I can create a web form? Do I need to edit the file that @Merrick28 is referring to app/presenters/menu/default_menu.rb


#8

Not sure about setting up a form, but just for reference and anyone else looking at this, there’s a little more detail in this post we wrote up a while ago: http://www.tigeriq.co/menu-plugins-for-external-sites-on-cfme-4-1/

It should still be valid for 4.2


#9

Hey Krain. So for the Red Hat access items. They specify href: /redhat_access/insights/

What creates the directory /redhat_access/ ?

If I wanted to add a new section for my company for example, I might want to set href: /mycompany/* so that I can use this space for integration with our I.T ticketing system. I noticed that the /var/www/miq/vmdb/app/presenters/menu/custom_loader.rb script is the one that pulls in the *.yml files. Is there another script I need to edit to create a new directory to achieve this goal?

I followed that guide you linked to create a new menu item, it’s just this last hurdle I need to cross. Very good post with helpful details!