CloudForms UI add new menu button

11:51 , , 1 Comments


During the latest CloudForms integration with external system we have needed to add custom page. But first of all we have to add some custom menu button which will be a reference to custom page.
custom menu button Test Application
You can find all classes responsible for menu loading in ${VMDB}/app/presenters/menu directory.
Here following files:
manager.rbmain class Menu::Manager
section.rbtop-menu buttons (Services, Clouds, Infrastructure, ...)
item.rbmenu buttons (Providers, Clusters, Hosts, ...)
default_menu.rbloads default menu shipped with ManageIQ
custom_loader.rbloads menu buttons from custom YAML files
Create custom YAML file in directory ${VMDB}/product/menubar/
---
# Custom menubar for Test application
# in Infrastructure menu
type: item
parent: inf
id: "test_app"
name: "Test Application"
feature: "test_app"
rbac:
  feature: test_app
href: '/test'
type: item there are currently only 2 supported values:
  •  section
  •  item (whatever not "section" is considered to be item)
parent: inf means it will be added to Infrastructure section (full list in default_menu.rb)
feature: "test_app" defines associated "Product Feature"
rbac: feature: test_app defines list of "Product Features", which make this menu visible. Most of cases it's the same as feature: value.
href: '/test' URL routes to application page

As we specified custom Product Feature "test_app" then we need to create such feature.
Create custom directory ${VMDB}/db/fixtures/miq_product_features/ and create here file feature_test_app.yml.
For example, define view access rules 'List' and 'Show' collapsed with common parent rule 'View'.
---
#Test Application
:name: Test Application
:description: Test Application Views and Access Rules
:feature_type: node
:identifier: test_app
:parent:
:children:
- :name: View 
  :description: View Test Application
  :feature_type: view
  :identifier: test_app_view
  :children:
  - :name: List
    :description: Display Lists of Test Application
    :feature_type: view
    :identifier: test_app_list
  - :name: Show
    :description: Display Individual Items of Test Application
    :feature_type: view
    :identifier: test_app_show
It allows us to configure roles access to this product feature:
configuration of role access: custom product feature
Restart CFME:
$> cd /var/www/miq/vmdb/
$> rake evm:restart
After click on custom button it redirects to specified '/test_app' URL.

TODO: next time custom application page

Daniil Satsura

IBA Group, Minsk

1 comment:

  1. patiently waiting for the custom application page creation :)

    ReplyDelete