-
Notifications
You must be signed in to change notification settings - Fork 125
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
Dialog field - set load_values_on_init to true where show_refresh_button was not enabled #357
Conversation
Cc @gmcculloug @eclarizio |
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.
I think my only concern about all of this is that we should probably now be defaulting load_values_on_init
to be true, right? Previously, as you said, this was handled by the code, and this migration fixes any existing fields, but going forward new ones will be created with both show_refresh_button
and load_values_on_init
to be false. It might be weird for people used to the system that don't change those switches at all and now suddenly their newly created fields don't work.
Other than that I think this fix is straightforward
Agreed @eclarizio , will add that to the ui-components PR (assuming that's what sets the initial value), thanks :) |
Actually, should it be added here? For people that use the API to create fields? (Is that even a thing people do?) @gmcculloug Maybe you have some insight on this. |
Well, not in schema (or I don't know how), but possibly |
Yeah, that's probably fine |
…ton was not enabled Replaces code that was previously hardcoded in the model.. def load_values_on_init? return true unless show_refresh_button load_values_on_init end Needed to make it posssible to set both these fields to false, without breaking all the old fields where the value of `load_values_on_init` previously didn't matter. https://bugzilla.redhat.com/show_bug.cgi?id=1684567 https://bugzilla.redhat.com/show_bug.cgi?id=1684575
… set to true unless show_refresh_button was set
@himdel if this will be able to be backported, can you add the hammer/yes label. |
(EDIT: wrong place for the comment, moved to ManageIQ/manageiq#18600 (comment)) |
@JPrause We typically don't backport schema PRs. Is there a compelling reason for this one to be backported? |
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.
What is the actual relationship between these columns? Should they really be just one column with some logic around it?
migration_context :up do | ||
before do | ||
[true, false, nil].each do |show| | ||
[true, false, nil].each do |load| |
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.
Using keywords as variable names makes me nervous ... maybe load_value
here?
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.
Fixed 👍
end | ||
|
||
it "updates load_values_on_init" do | ||
expect(dialog_field_stub.pluck(:load_values_on_init)).to eq([true, false, nil, true, true, true, true, true, true]) |
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.
Can you add an explicit sort here so we don't get bit by locale or OS default sorting rules?
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.
I was hoping we can reliably get them in order they were created.
Is there any nice way of doing that?
(But I can live with sort too...)
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.
Added a sort_by(:id)
since we probably can rely on the ids being ascending, right?
And split into 3 lines to better show the relation.
Explicitly leaving the backport/no backport decision on @gmcculloug & @Loicavenel. It looks like there is a need for fields that will only refresh because other fields change in hammer, and this is the only (sane) way of achieving that. |
@carbonin it's described in this PR's description ;) Before, Now, But we still need to make sure that all those "assumed to be true" |
…order fits, don't use keywords
Okay, that makes sense @himdel As far as the backport decision, it actually seems to me that this cannot be backported because we wouldn't be able to rely on this logic for people who have already upgraded to hammer (and by extension will not run this migration). |
expect(dialog_field_stub.sort_by(:id).pluck(:load_values_on_init)).to eq([ | ||
true, false, nil, # show_button was true | ||
true, true, true, | ||
true, true, true, |
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.
I think I would just prefer individual specs for each case. For example:
it "doesnt update load_values_on_init when show_refresh_button is true" do
...
end
it "updates load_values_on_init when show_refresh_button is not true" do
...
end
Then we don't have to play this ordering game at all.
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, maybe better with less magic, fixing :)
Agreed that the whole feature can absolutely not work without the migration backported too, if that's what you mean, yes. (But if we did, it would, right?) |
No, because people who have already upgraded to hammer will not run this migration. Users are only expected to run migrations on major releases. This is why we don't backport migrations. |
Ah, well, in that case.. @miq-bot add_label hammer/no That pretty much settles it I think, unless we want to wrap it in a product feature switch or something like that. Thanks! :) |
let(:dialog_field_stub) { migration_stub(:DialogField) } | ||
|
||
migration_context :up do | ||
let (:show_button) { nil } |
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.
I don't think this is needed.
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.
It was, undefined local variable or method 'show_button' for #<RSpec::ExampleGroups::DialogFieldLoadValuesOnInit::Up:0x0000000009226718>
otherwise.
end | ||
|
||
context "when show_refresh_button is true" do | ||
let (:show_button) { true } |
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.
Pretty sure there shouldn't be a space between the let
and (
here. And that's why you're getting the rubocop issues.
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.
Same with the other let(:show_button)
calls.
… three possibilities
Thanks @carbonin , those should be resolved now.. |
have to move the definition up too
Checked commits https://github.com/himdel/manageiq-schema/compare/e8c1faa5dbbf46ae3d4c2ac2ac462da64dd988c2~...8252f75d908b68c5db84bf7cf6cb48b0d18ef731 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 db/migrate/20190327132620_dialog_field_load_values_on_init.rb
|
…ersion 1 export Applies the same change as ManageIQ/manageiq-schema#357 when importing older exported service dialogs. https://bugzilla.redhat.com/show_bug.cgi?id=1684575 https://bugzilla.redhat.com/show_bug.cgi?id=1684567
…ersion 1 export Applies the same change as ManageIQ/manageiq-schema#357 when importing older exported service dialogs. https://bugzilla.redhat.com/show_bug.cgi?id=1684575 https://bugzilla.redhat.com/show_bug.cgi?id=1684567
Replaces code that was previously hardcoded in the model..
Needed to make it posssible to set both these fields to false,
without breaking all the old fields where the value of
load_values_on_init
previously didn't matter.https://bugzilla.redhat.com/show_bug.cgi?id=1684575
https://bugzilla.redhat.com/show_bug.cgi?id=1684567
(Depended on by:
)