-
Notifications
You must be signed in to change notification settings - Fork 897
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 fields - make load_values_on_init independent of show_refresh_button #18600
Conversation
@himdel if this will be able to be backported, can you add the hammer/yes label. |
@JPrause this depends on a data migration, so, I'm not setting hammer/yes. (Looks like there is still some discussion about whether to backport with the migration, backport with a product setting, or not backport at all.) |
@@ -43,6 +43,7 @@ | |||
|
|||
context "when show_refresh_button is false" do | |||
let(:show_refresh_button) { false } | |||
let(:load_values_on_init) { 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.
Similar to the above specs that have multiple contexts for whether or not load_values_on_init
is true/false, I think this context also needs those contexts since the logic is changing, instead of simply setting it true
here just to make this one spec pass as it used to.
Essentially, we're missing the case where show_refresh_button
is false and load_values_on_init
is also false, since this is a thing that can actually happen now.
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.
Agreed, we need a new spec for the situation where both are false.
I will add those, the specs that are still failing are the same problem, they are a copy of the specs for load_values_on_init true, which is no longer the same.
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.
Right, but I meant as opposed to just setting this value so that it works like it used to. Sorry, my wording was poor.
@eclarizio I'm still working on the other dialog_field_text_box specs (EDIT: done), but.. for sorted item, Which, on the one hand makes sense, because there is no list of values to compare against, Do you think that's acceptable behaviour now? :) |
@miq-bot remove_label wip (Unless @eclarizio disagrees :)) |
Also added (Doing this on DialogField, just because no other dialogfield* models do anything similar, but also because it seems none of the other dialog fields classes are using that field for anything.) (The editor has the defaults hardcoded, so defaults for the ui will happen in ManageIQ/ui-components#376.) |
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.
@eclarizio I'm still working on the other dialog_field_text_box specs (EDIT: done), but.. for sorted item,
when show_refresh_button is false, load_values_on_init also false,
and the default value is not in the set of values provided,
it uses the default value anyway.Which, on the one hand makes sense, because there is no list of values to compare against,
but OTOH is a random difference from the load_values_on_init=true case, where the random defaullt value does not get used.Do you think that's acceptable behaviour now? :)
(talking about https://github.com/ManageIQ/manageiq/pull/18600/files#diff-2e3988a1d9dd5e5c9de21dd07757fdceR110)
Hmm, I think it's kinda weird, it's like they're providing a default value that could never actually exist. I think if the automate method isn't running because show_refresh_button
and load_values_on_init
are both false, it should just have the "<None>"
selected.
@gmcculloug Any input here?
Otherwise, I think it looks good 👍
Sorry, correction, I have no idea how to test what the field will be set to. |
Allso, the equivalent logic for dialog_field_text_box is just So no idea what should be happening there. |
dialog_field.initialize_value_context | ||
expect(dialog_field.default_value).to eq("test1") | ||
expect(dialog_field.default_value).to eq("test4") | ||
end | ||
|
||
it "sets the values to what should be returned from automate" do |
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 description should probably be changed since it's not actually returning values from automate anymore.
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.
Thanks, fixed :)
@@ -125,7 +126,7 @@ | |||
|
|||
it "sets the values to what should be returned from automate" do |
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 this one.
Well, in the UI, the only option to select would be "<None>", so I think when the user hits "submit", it would just submit
I think the above is the intended behavior, we should only be calling automate if both of those values are true. For sorted items, the logic is worded differently, but I think it still ends up being similar. I don't believe we have any devel docs 😢 |
Yes, in the UI. But ... how do I get that value from the model? (It's not |
…button Before, show_refresh_button being falsy meant that load_values_on_init would be considered true. Now, the two are independent, allowing for a field to only be refreshed by other fields. https://bugzilla.redhat.com/show_bug.cgi?id=1684575
…to explicitly set load_values_on_init true to test the same situation as before
…n_init=false spec previously, this was identical to show_refresh=false, load_on_init=true
…init=false show_refresh_button=false scenario
Checked commits https://github.com/himdel/manageiq/compare/1ca148ee613e1d9fde259c18eef8f588150b65bf~...33af34a371067be395189673e25576f1e6377948 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/models/dialog_field_text_box_spec.rb
|
@miq-bot add_label hammer/no (because ManageIQ/manageiq-schema#357 (comment)) |
Schema PR got merged, so this should be ready too... @eclarizio do you have any idea where to take the actual value from please? So that we can update the surprising test.. |
@himdel What do you mean by "the actual value"? If you're looking for the list of things that the sorted item should show, it could be If you're looking for the item in the list that should be selected, it should just be Hopefully that helped? |
Yeah, I meant "the value that ends up getting used" in that case. Which gets computed in the UI it seems, so I can't test that :(. None of those functions seem to give me any useful values in this case, @eclarizio are you OK with the current state, or do you have specific updates in mind? |
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.
Looks good to me 👍
Can we merge this one, I need it for test :) |
Oh yeah, one TODO here - importing old dialogs. |
@himdel I know I mentioned the import of old dialogs, but agree we can work on that in a separate PR. Not sure we can use the same basic logic that the migration uses for imports
as post-migration we would want to honor the settings on Do we need a version number or some other indicator in the exports? I'll merge this PR so we can keep the work moving but someone needs to merge the UI PR in the descripition. |
@himdel So I know the schema PR was hammer/no, but does that mean this and the ui-components PR can't be hammer/yes? The schema PR was just a data migration, right? So, in theory, if this and the ui-components PR get backported, then the users who would like to see this functionality would have to manually adjust their dialogs they care about and it should work, I think? |
@eclarizio Well, it could be hammer/yes if we introduce a product flag, or something like that, to enable it only on demand. Otherwise, without adjusting all their reports (or running the migration manually), most likely no dynamic field would ever load on init. (It's not about whether the users could adjust, it's about whether we can force all of them to adjust mid-release.) |
Thanks @gmcculloug , investigating :)
No problem, ui-components PR merged, released as 1.2.3, and created the "make the UIs use the thing" PRs :) (ManageIQ/manageiq-ui-classic#5441 + ManageIQ/manageiq-ui-service#1534) EDIT: and merged 👍 |
Maybe we do. Currently we just export the fields, I'm not seeing any versioning metadata. So unless we want to rely on assuming that That said, maybe that assumption could be enough for imports? |
=> created #18645 for import/export |
@tinaafitz My suggestion for backport is to "recouple" it in the hammer branch, but differently, so as to ensure the performance benefits of this PR. That is,
def load_values_on_init?
load_values_on_init.nil? ? true : load_values_on_init
end This way a "null" value (that is, a value that couldn't be set because the UI didn't allow you to because you didn't allow the refresh button), will be true (which matches the migration). With the new ui component, now that the value can be set independently, then we will ignore the nil check and use whatever is in the column. Regardless, whatever you do with backporting, if you start to allow "real" values in |
@Fryguy I was thinking opt-in only in hammer, I don't really see a way around that migration, so a product feature/setting to switch to the new version and assume the dialogs are just ok sounds like the only safe way. (I don't think we can assume
Great point, but if we hide it under a product feature, that just means using that to run the migration conditionally, would that work? |
Depends on (schema): ManageIQ/manageiq-schema#357 (merged)
Depended on by (ui-components): ManageIQ/ui-components#376
Before,
show_refresh_button
being falsy meant thatload_values_on_init
would be considered true.Now, the two are independent, allowing for a field to only be refreshed by other fields.
https://bugzilla.redhat.com/show_bug.cgi?id=1684575
https://bugzilla.redhat.com/show_bug.cgi?id=1684567
Cc @gmcculloug @eclarizio