{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/1680","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/1680/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/1680/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/1680/events","html_url":"https://github.com/ManageIQ/manageiq/pull/1680","id":57595221,"number":1680,"title":"Menu Plugins For external sites","user":{"login":"martinpovolny","id":51095,"avatar_url":"https://avatars.githubusercontent.com/u/51095?v=3","gravatar_id":"","url":"https://api.github.com/users/martinpovolny","html_url":"https://github.com/martinpovolny","followers_url":"https://api.github.com/users/martinpovolny/followers","following_url":"https://api.github.com/users/martinpovolny/following{/other_user}","gists_url":"https://api.github.com/users/martinpovolny/gists{/gist_id}","starred_url":"https://api.github.com/users/martinpovolny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinpovolny/subscriptions","organizations_url":"https://api.github.com/users/martinpovolny/orgs","repos_url":"https://api.github.com/users/martinpovolny/repos","events_url":"https://api.github.com/users/martinpovolny/events{/privacy}","received_events_url":"https://api.github.com/users/martinpovolny/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/ui","name":"ui","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-02-13T12:52:20Z","updated_at":"2015-03-09T17:17:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/1680","html_url":"https://github.com/ManageIQ/manageiq/pull/1680","diff_url":"https://github.com/ManageIQ/manageiq/pull/1680.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/1680.patch"},"body":"## Using Menu Plugins ##\r\n\r\nFor plugins that implement integration with an external web site we need a possibility to define:\r\n\r\n 1. Menu sections and menu items\r\n  1. for top_right menu\r\n  1. for main menu\r\n 1. RBAC features for the menu items that are editable using Config --> Configuration --> Role\r\n\r\nCustom menu sections and items can be defined under `vmdb/product/menubar`.\r\n\r\nCustom RBAC features can be defined under `vmdb/db/fixtures/miq_product_features/`.\r\n\r\nAssignments of the custom RBAC features to pre-defined roles can be defined under `vmdb/db/fixtures/miq_user_roles`.\r\n\r\nFor the current version of ManageIQ a package with a UI plugin should drop appropriate files into these locations.\r\n\r\n**A custom menu section definition is a yaml file with these keys:**\r\n```\r\ntype: section\r\nname: Red Hat\r\nid: redhat\r\nbefore: svc\r\nplacement: top_right\r\nsection_type: big_iframe\r\nhref: http://www.redhat.com\r\n```\r\n\r\n * `type`, `name`, `id` are mandatory\r\n * `placement` with value of `top_right` means top-right menu, omitted or `default` means main menu\r\n * `section_type` `default` creates a menu section with the same type as built-in menu sections; `big_iframe` requires a defined `href` and creates a menu section that when clicked replaces the 2nd menu level and all below with an iframe containing site given in the `href`. This is only valid for main menu items.\r\n * `before` allows to define the position of the menu section relative to other menu secrion\r\n\r\n**A custom menu item definition is a yaml file withe these keys:**\r\n```\r\ntype: item\r\nname: Homepage\r\nid: rht3\r\nfeature: redhat\r\nrbac:\r\n  feature: redhat\r\nparent: redhat\r\nhref: http://www.redhat.com\r\nitem_type: big_iframe\r\n```\r\n * `type`, `name`, `id`, `parent`, `feature` and `rbac` are mandatory\r\n * `feature` has to be defined as RBAC feature\r\n * `rbac` contains arguments passwd to `role_allows?` call when a decision about whether a menu item should be presented to a particular user is done\r\n * `item_type` and `href` ha similar meaning as `section_type` above\r\n * `parent` must reference an existing menu section\r\n\r\n\r\n---\r\n\r\nDONE:\r\n  * Menu Section definition including `default` and `top_right` *placement*. And possibility to specify ordering by *after*.\r\n  * Settings/Access Control/Role knows about items that exist as features and can edit them.\r\n  * Allow adding of RBAC features (now only existing features will be saved when editing a Role in Settings/Access Control/Role which is enough for testing but not for production)\r\n  * Styling\r\n\r\nFuture work:\r\n * restore CSP header and X-Frame-Options header; now these are disabled for `/dashboard/iframe`, we should just relax them by adding some URLs for the plugin\r\n * maybe? Implement `rake` task for post-inst scripts for plugins\r\n\r\nExample usage\r\n----\r\n\r\n**product/menubar/custom_redhat_section.yml**\r\n```\r\ntype: section\r\nname: Red Hat\r\nid: redhat\r\nbefore: svc\r\nsection_type: big_iframe\r\nhref: http://www.redhat.com\r\n```\r\n\r\n**product/menubar/custom_redhat.yml**\r\n```\r\ntype: item\r\nname: Homepage\r\nid: rht3\r\nfeature: redhat\r\nrbac:\r\n  feature: redhat\r\nparent: redhat\r\nhref: http://www.redhat.com\r\nitem_type: big_iframe\r\n```\r\n\r\n**product/menubar/custom_redhat_courses.yml**\r\n```\r\ntype: item\r\nname: Courses\r\nid: rht2\r\nfeature: redhat\r\nrbac:\r\n  feature: redhat\r\nparent: redhat\r\nhref: http://www.redhat.com/en/services/training/all-courses-exams\r\nitem_type: big_iframe\r\n```\r\n\r\n![custom-menu](https://cloud.githubusercontent.com/assets/51095/6288736/64631086-b91b-11e4-8a56-7cc437f52807.png)\r\n\r\n 1. custom menu based on the definition above\r\n 1. settings in the `Configure/Configuration/Access Control/Roles` (the \"About\" is replaced with the correct text in current PR)\r\n 1. custom menu with *placement*: `top_right`                                                                                \r\n\r\n**product/menubar/top_right_section1.yml**\r\n```\r\ntype: section                                                                                       \r\nname: Custom section 1                                                                              \r\nplacement: top_right                                                                                \r\nid: custom_top  \r\n```\r\n\r\n**db/fixtures/miq_product_features/redhat-miq_product_features.yml**\r\n```\r\n---\r\n:name: Red Hat\r\n:description: Access to Red Hat sectioin\r\n:feature_type: node\r\n:identifier: redhat\r\n:children:\r\n\r\n- :name: Red Hat Forums\r\n  :description: Access to Red Hat forums\r\n  :feature_type: node\r\n  :identifier: redhat_forum\r\n- :name: Red Hat Whatever\r\n  :description: Access to Red Hat whatever...\r\n  :feature_type: node\r\n  :identifier: redhat_whatever\r\n```\r\n\r\n**db/fixtures/miq_user_roles/redhat.yml**\r\n```\r\n--- \r\n\r\n- :name: EvmRole-super_administrator\r\n  :miq_product_feature_identifiers:\r\n  - redhat\r\n  - redhat_forum\r\n  - redhat_whatever\r\n```\r\n\r\n![menu-new](https://cloud.githubusercontent.com/assets/51095/6485935/98a477fc-c287-11e4-8c5c-2aa66e03acb6.png)\r\n"},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments/77898955","html_url":"https://github.com/ManageIQ/manageiq/pull/1680#issuecomment-77898955","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/1680","id":77898955,"user":{"login":"miq-bot","id":7806257,"avatar_url":"https://avatars.githubusercontent.com/u/7806257?v=3","gravatar_id":"","url":"https://api.github.com/users/miq-bot","html_url":"https://github.com/miq-bot","followers_url":"https://api.github.com/users/miq-bot/followers","following_url":"https://api.github.com/users/miq-bot/following{/other_user}","gists_url":"https://api.github.com/users/miq-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/miq-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miq-bot/subscriptions","organizations_url":"https://api.github.com/users/miq-bot/orgs","repos_url":"https://api.github.com/users/miq-bot/repos","events_url":"https://api.github.com/users/miq-bot/events{/privacy}","received_events_url":"https://api.github.com/users/miq-bot/received_events","type":"User","site_admin":false},"created_at":"2015-03-09T17:17:57Z","updated_at":"2015-03-09T17:17:57Z","body":"<rubocop />Checked commits https://github.com/martinpovolny/manageiq/commit/517a4ea4b884480056867df8f254d748b17e9c76 .. https://github.com/martinpovolny/manageiq/commit/9d5cecd2896590a730893068cf32dd0345cdf2ae with rubocop 0.27.1\n9 files checked, 12 offenses detected\n\n**vmdb/app/controllers/dashboard_controller.rb**\n- [ ] :large_orange_diamond: - [Line 24](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/controllers/dashboard_controller.rb#L24), Col 18 - [Style/RescueModifier](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Style/RescueModifier) - Avoid using `rescue` in its modifier form.\n- [ ] :small_blue_diamond: - [Line 17](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/controllers/dashboard_controller.rb#L17), Col 3 - [Metrics/AbcSize](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/AbcSize) - Assignment Branch Condition size for iframe is too high. [20.32/15]\n\n**vmdb/app/models/miq_product_feature.rb**\n- [ ] :large_orange_diamond: - [Line 10](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_product_feature.rb#L10), Col 41 - [Style/RedundantSelf](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Style/RedundantSelf) - Redundant `self` detected.\n- [ ] :large_orange_diamond: - [Line 90](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_product_feature.rb#L90), Col 7 - [Style/RedundantSelf](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Style/RedundantSelf) - Redundant `self` detected.\n\n**vmdb/app/models/miq_user_role.rb**\n- [ ] :large_orange_diamond: - [Line 20](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_user_role.rb#L20), Col 41 - [Style/RedundantSelf](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Style/RedundantSelf) - Redundant `self` detected.\n- [ ] :large_orange_diamond: - [Line 155](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_user_role.rb#L155), Col 9 - [Style/RedundantSelf](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Style/RedundantSelf) - Redundant `self` detected.\n- [ ] :small_blue_diamond: - [Line 160](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_user_role.rb#L160), Col 3 - [Metrics/AbcSize](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/AbcSize) - Assignment Branch Condition size for seed_from_array is too high. [21.73/15]\n- [ ] :small_blue_diamond: - [Line 160](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/models/miq_user_role.rb#L160), Col 3 - [Metrics/CyclomaticComplexity](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/CyclomaticComplexity) - Cyclomatic complexity for seed_from_array is too high. [7/6]\n\n**vmdb/app/presenters/menu/custom_loader.rb**\n- [ ] :small_blue_diamond: - [Line 37](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/presenters/menu/custom_loader.rb#L37), Col 121 - [Metrics/LineLength](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/LineLength) - Line is too long. [129/120]\n- [ ] :small_blue_diamond: - [Line 39](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/presenters/menu/custom_loader.rb#L39), Col 121 - [Metrics/LineLength](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/LineLength) - Line is too long. [125/120]\n\n**vmdb/app/presenters/menu/item.rb**\n- [ ] :small_blue_diamond: - [Line 3](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/presenters/menu/item.rb#L3), Col 19 - [Metrics/ParameterLists](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/ParameterLists) - Avoid parameter lists longer than 5 parameters.\n\n**vmdb/app/presenters/menu/section.rb**\n- [ ] :small_blue_diamond: - [Line 3](https://github.com/martinpovolny/manageiq/blob/9d5cecd2896590a730893068cf32dd0345cdf2ae/vmdb/app/presenters/menu/section.rb#L3), Col 19 - [Metrics/ParameterLists](http://rubydoc.info/gems/rubocop/0.27.1/RuboCop/Cop/Metrics/ParameterLists) - Avoid parameter lists longer than 5 parameters.\n"}}