Skip to content

Commit

Permalink
Code cleaning, minor fixes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac committed Sep 19, 2019
1 parent 1ea627b commit ac80223
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ angular.module('ManageIQ').service('eventNotifications', ['$timeout', '$window',
});

updateUnreadCount(events);
var x = 0;
_.forEach(state.groups, function(group) {
x += group.unreadCount;
});
ManageIQ.redux.store.dispatch({ type: '@@notifications/setUnreadCount', payload: x });
const totalUnreadCount = state.groups.reduce((sum, group) => (sum + group.unreadCount), 0);
ManageIQ.redux.store.dispatch({ type: '@@notifications/setUnreadCount', payload: totalUnreadCount });
notifyObservers();
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ $login-container-details-border-color-rgba: rgba(0, 0, 0, 0.5);
body.login.whitelabel {
background: url($img-bg-login-whitelabel);
background-size: 100% auto;
}
}
51 changes: 26 additions & 25 deletions app/helpers/application_helper/navbar.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
module ApplicationHelper
module Navbar
def menu_to_json(position)
structure = []
Menu::Manager.menu(position) do |menu_section|
next unless menu_section
structure << item_to_hash(menu_section)
end
structure
structure = []
Menu::Manager.menu(position) do |menu_section|
next unless menu_section

structure << item_to_hash(menu_section)
end
structure
end

def item_to_hash(item)
{
:id => item.id,
:name => item.name,
:icon => item.icon,
:placement => item.placement,
:before => item.try(:before),
:type => item.type,
:href => item.href,
:parent_id => item.try(:parent_id),
:feature => item.try(:feature),
:rbac_feature => item.try(:rbac_feature),
:defaults => item.try(:defaults),
:items => item.items.to_a.map(&method(:item_to_hash)),
:visible => item.visible?,
:link_params => item.link_params
}
end
%i[
id
name
icon
placement
before
type
href
parent_id
feature
rbac_feature
defaults
link_params
].each_with_object(:visible => item.visible?, :items => item.items.to_a.map(&method(:item_to_hash))) do |key, obj|
obj[key] = item.try(key)
end
end

# FIXME: The 'active' below is an active section not an item. That is wrong.
# What works is the "legacy" part that compares @layout to item.id.
# This assumes that these matches -- @layout and item.id. Moving forward we
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Top navbar test should render correctly 1`] = `
exports[`Top navbar tests should render correctly 1`] = `
<Provider
store={
Object {
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_right_section.html.haml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
= react('RightSection', { :customLogo => ::Settings.server.custom_logo, :currentUser => current_user, :helpMenu => menu_to_json(:help),:opsExplorerAllowed => ApplicationHelper.role_allows?(:feature => 'ops_explorer', :any => true), :applianceName => appliance_name, :miqGroups => current_user.miq_groups, :currentGroup => current_group, :userMenu => menu_to_json(:top_right) }, {:class => "nav navbar-nav navbar-right navbar-iconic"}, 'ul')
= react('RightSection', { :customLogo => ::Settings.server.custom_logo, :currentUser => current_user, :helpMenu => menu_to_json(:help),:opsExplorerAllowed => ApplicationHelper.role_allows?(:feature => 'ops_explorer', :any => true), :applianceName => appliance_name, :miqGroups => current_user.miq_groups, :currentGroup => current_group, :userMenu => menu_to_json(:top_right) }, {:class => "nav navbar-nav navbar-right navbar-iconic"}, 'ul')

0 comments on commit ac80223

Please sign in to comment.