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

Fix assumption that all field.values are objects #227

Merged
merged 1 commit into from
Jan 4, 2018

Conversation

eclarizio
Copy link
Member

This got changed back in #223, but it makes it so that when you try to edit anything other than drop down or radio button fields (the ones that use objects for their values), it attempts to call .filter on a string and ends up blowing up silently in JS with you unable to edit your fields.

@romanblanco @martinpovolny please review

@miq-bot add_label gaprindashvili/yes

@martinpovolny
Copy link
Member

@romanblanco : please, review ASAP

Copy link
Member

@romanblanco romanblanco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good 👍 Thanks @eclarizio

@@ -48,7 +48,9 @@ export default class DialogEditorService {
*/
public getDialogTabs() {
this.forEachDialogField((field: any) => {
field.values = field.values.filter(value => value[0] && value[1]);
if (! _.isEmpty(field.values) && _.isObject(field.values)) {
Copy link
Contributor

@karelhala karelhala Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but better to use _.isArray, since this will take in effect any Object. isEmpty does not need to be there, because filtering over empty array does nothing.

if (field.hasOwnProperty('values') && _.isArray(field.values)) {
  field.values = field.values.filter(value => value[0] && value[1]);
}

@miq-bot
Copy link
Member

miq-bot commented Jan 4, 2018

Checked commit eclarizio@e6a183b with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. 🍰

@eclarizio
Copy link
Member Author

Thanks @karelhala, fixed.

@karelhala karelhala merged commit 4788fc0 into ManageIQ:master Jan 4, 2018
@himdel
Copy link
Contributor

himdel commented Jan 5, 2018

@miq-bot add_label gaprindashvili/backported
@miq-bot remove_label gaprindashvili/yes

This was released in manageiq-ui-components 1.0.4, backported to gaprindashvili via ManageIQ/manageiq-ui-classic#3175 .

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.

None yet

7 participants