Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing pluggable menus #1454

Merged
merged 3 commits into from
May 30, 2017
Merged

Conversation

skateman
Copy link
Member

These changes will allow us to declare menu items in external plugins. I implemented a new Menu::CustomLoader singleton, in which you can .register your menu items. For now this can be done from an initializer block declared in a Rails Engine.

The .register method can take a Menu::Section or a Menu::Item as an argument with the same syntax as we're using in the Menu::DefaultMenu.

For example this will create a new Test section with a Test item pointing to the /test URL:

# inside a rails engine definition
initializer 'ui.plugin' do
  Menu::CustomLoader.register(
    Menu::Section.new(:spike, N_('Test'), 'fa fa-map-pin', [
      Menu::Item.new('plug', N_('Test'), 'some_feature', {:feature => 'some_feature', :any => true}, '/test')
    ])
)
end

In the future I'd like to take out the menu declarations into a better place, e.g. app/menus and have some kind of auto-registering feature inside the engine. The syntax of the menu declaration should be also DSL-ized and used in the Menu::DefaultMenu too.

@martinpovolny what do you think?

@miq-bot miq-bot added the wip label May 29, 2017
@miq-bot
Copy link
Member

miq-bot commented May 29, 2017

Checked commits skateman/manageiq-ui-classic@52e71a5~...c020733 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
5 files checked, 9 offenses detected

app/presenters/menu/yaml_loader.rb

@martinpovolny
Copy link
Member

Cool. Pretty minimal changes to reach the goal. 👍

@martinpovolny
Copy link
Member

I think that there's no need to spend time on the "future steps" at this point. Rather we can attack the other items on the minimal requirements list for a pluggable UI.

@skateman
Copy link
Member Author

Sure, I wasn't thinking about doing anything more in this PR. However, I'll create a separate one where we have our extended Rails Engine with some plugin definition DSL where we can register menus and other stuff.

Marking it as a non-wip...

@skateman skateman changed the title [WIP] Introducing pluggable menus Introducing pluggable menus May 29, 2017
@miq-bot miq-bot removed the wip label May 29, 2017
@martinpovolny
Copy link
Member

Have you tested the old custom menu loading (Insights)?

@skateman
Copy link
Member Author

@martinpovolny I copied some productization ymls to my development setup, it's showing up in the Menu::Manager.instance but not in the menu, not even on master so I'm probably missing something. Going to try on an appliance...

@skateman
Copy link
Member Author

@martinpovolny tested, it works

@martinpovolny martinpovolny added this to the Sprint 62 Ending Jun 5, 2017 milestone May 30, 2017
@martinpovolny martinpovolny merged commit 23cf40e into ManageIQ:master May 30, 2017
@skateman skateman deleted the pluggable-menus branch August 21, 2017 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants