-
Notifications
You must be signed in to change notification settings - Fork 899
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
Fix group level and names for miq event #21569
Fix group level and names for miq event #21569
Conversation
@@ -35,13 +35,21 @@ class EventStream < ApplicationRecord | |||
|
|||
after_commit :emit_notifications, :on => :create | |||
|
|||
# TODO: Consider moving since this is EmsEvent specific. group, group_level and group_name exposed as a virtual columns for reports/api. | |||
GROUP_LEVELS = %i(critical detail warning).freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ This was mixing EmsEvent group levels with EventStream. Critical and warning were moved to EmsEvent, detail remains as a default here.
066954e
to
a0f93e2
Compare
Push down the constants into the correct classes. We had lots of EmsEvent data hardcoded in the EventStream and that needs to be split apart.
a0f93e2
to
c62c27d
Compare
Checked commits jrafanie/manageiq@660aeda~...c62c27d with ruby 2.6.3, rubocop 1.13.0, haml-lint 0.35.0, and yamllint |
return group, level | ||
end | ||
|
||
def self.group_name(group) | ||
return if group.nil? | ||
group = event_groups[group.to_sym] | ||
group.nil? ? 'Other' : group[:name] | ||
group.nil? ? DEFAULT_GROUP_NAME.to_s.capitalize : group[:name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this will break I18N - we may have to figure that out in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't know how to test it. I can ask around and do it in a followup.
hash = default_group_names_and_levels | ||
hash[:group_names].merge!(MiqEventDefinitionSet.all.pluck(:name, :description).to_h.symbolize_keys) | ||
group_levels.each do |level| | ||
hash[:group_levels][level] ||= level.to_s.capitalize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here - this may cause i18n issues unless the target string is already in the .po.
LGTM - my concerns are mostly around i18n but I'm not certain that was working prior to this, so don't want to hold it up...we can fix i18n afterwards. |
@@ -10,14 +10,18 @@ class EmsEvent < EventStream | |||
'Rename_Task', | |||
] | |||
|
|||
CLASS_GROUP_LEVELS = %i[critical warning].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For i18n, I think the better way to do this might be to make this:
CLASS_GROUP_LEVELS = %i[critical warning].freeze | |
CLASS_GROUP_LEVELS = [ | |
N_("Critical"), | |
N_("Warning") | |
].freeze |
Then later, or perhaps in another constant, do CLASS_GROUP_LEVELS.map { |l| l.downcase.to_sym }
This way, the strings are in the translation catalog, but the code can still use symbols.
DEFAULT_GROUP_NAME = :other | ||
DEFAULT_GROUP_LEVEL = :detail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, for i18n here, you'd do something like:
DEFAULT_GROUP_NAME = :other | |
DEFAULT_GROUP_LEVEL = :detail | |
DEFAULT_GROUP_NAME = N_("Other") | |
DEFAULT_GROUP_LEVEL = N_("Detail") |
Then later or perhaps in another constant you'd do DEFAULT_GROUP_NAME.downcase.to_sym
Merging without the i18n stuff - we can fix that in a follow up |
Looks like ui-classic is failing on missing Really weird that it doesn't show up in org code search: https://github.com/search?q=org%3AManageIQ+EmsEvent%3A%3AGROUP_LEVELS&type=code |
Broken by ManageIQ/manageiq#21569 The constant was defined in the base class, but was actually an EmsEvent concern so this was moved to a method for subclasses to override.
Opened ManageIQ/manageiq-ui-classic#7972 to fix the "oops, didn't cross repo test with ui-classic" |
I was noticing that ManageIQ/manageiq-api#1099 OPTIONS for event_streams was missing "other" and "detail" after #21552 was merged.
Part of ManageIQ/manageiq-api#1090
I realized this is because we had defaults for "other" and "detail" buried in code and didn't have defaults in the base class with overrides in the subclasses. This PR fixes some of this.
Here's an example of the JSON diff for OPTIONS on event_streams before and after this PR: