-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #37987 - Filters remove override, unlimted, and taxonomies #10370
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
Fixes #37987 - Filters remove override, unlimted, and taxonomies #10370
Conversation
baf4134 to
f46f2a5
Compare
319787a to
e2698dc
Compare
db/migrate/20241105143353_regenerate_taxonomy_search_for_filters_with_override_false.rb
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/routes/FiltersForm/NewFiltersFormPage.js
Outdated
Show resolved
Hide resolved
e2698dc to
1579997
Compare
|
thanks @ofedoren, updated |
|
Draft until I finish "remove taxonimoes override from filter" |
webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js
Outdated
Show resolved
Hide resolved
69d381a to
c054e59
Compare
ofedoren
left a comment
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.
There are some comments, you can ignore until the final review (pasting them just so I don't lose them)
app/controllers/concerns/foreman/controller/parameters/filter.rb
Outdated
Show resolved
Hide resolved
| ouiaId="taxonomy-search-alert" | ||
| variant="info" | ||
| title={__( | ||
| "The filter is scoped to the selected organizations and locations, therefore can't be unlimited" |
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 helpful or just nitpicking, but I actually had trouble parsing what the alert meant. Do you think this would be better?
| "The filter is scoped to the selected organizations and locations, therefore can't be unlimited" | |
| "You cannot use unlimited filtering because the filter is scoped to the organizations and locations inherited from the role." |
I propose s/selected/inherited because 1. I think you don't really "select" orgs/locs anymore and 2. "inherited" is used in the descriptions on lines 122 and 135, I think consistency would help users connect the dots more quickly.
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.
Would it be better to move the info alert below the (greyed-out) unlimited checkbox?
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.
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.
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.
Sorry, I have a hard time deciding which of the two options would be better. What do you think?
I guess what I feel most strongly about here is the wording -- as suggested above.
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, @MariaAga, LGTM, just few cents inline (consider previous comments as well). Small rubocop issue as well https://github.com/theforeman/foreman/actions/runs/12709621398/job/35429016546?pr=10370
UPD: Reminder for me to remove related stuff from hammer: https://github.com/theforeman/hammer-cli-foreman/blob/master/lib/hammer_cli_foreman/filter.rb#L13
db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb
Outdated
Show resolved
Hide resolved
4ea5855 to
30dd1f9
Compare
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.
@MariaAga, can this be undrafted after the migration is uncommented or you're planning to do more changes?
Also, while checking something, I've found we have another, but rather small, PF5 related issue here: https://github.com/theforeman/foreman/blob/develop/webpack/assets/javascripts/react_app/components/common/Pf4DualList/DualListWithIds.js#L42
it should be
const onListChange = (_e, newAvailableOptions, newChosenOptions) => {now
UPD: just noticed, this needs a rebase.
db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb
Outdated
Show resolved
Hide resolved
30dd1f9 to
d4b9075
Compare
|
Thanks for the reviews, I rebased and addressed the comments
Yes, migration is just scary |
ofedoren
left a comment
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, @MariaAga, but this seems to have less changes then before, for example all changes from e.g. #10370 (review) are gone. Is that intentional? At very least leaving enforce_override_flag seems against the idea of the PR.
| @@ -0,0 +1,10 @@ | |||
| class RegenerateTaxonomySearchForFiltersWithOverrideFalse < ActiveRecord::Migration[6.1] | |||
| def change | |||
| filters = Filter.where(role_id: Role.where(origin: nil).or(Role.where(builtin: 2))).where(override: false).where(taxonomy_search: 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.
where(taxonomy_search: nil)Was it in the previous iteration of commit? I thought we wanted to explicitly override any overridden searches, this will only add instead thus leaving overridden searches, which seems wrong...
5102aff to
c6930c8
Compare
c6930c8 to
a7591dd
Compare
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, @MariaAga and @adamruzicka, I'm afraid I have nothing to add, but one nitpick that can be ignored :)
UPD: I've created a ticket for hammer part: https://projects.theforeman.org/issues/38805. I'll probably pick this myself.
UPD2: Ah... Since we're touching API (and hammer), I'm afraid we might need to touch FAM as well :/ Not that sure though.
a7591dd to
3e5be59
Compare
I already looked. Unless I'm misreading it, the functionality that is being removed was never implemented there so we shouldn't need to do anything. |
theforeman/foreman#10370 made changes to filters which must be addressed here for tests to pass.
theforeman/foreman#10370 made changes to filters which must be addressed here for tests to pass.
theforeman/foreman#10370 made changes to filters which must be addressed here for tests to pass.
theforeman#10370 removed the method `limited?`, so it shold be replaced here.
theforeman/foreman#10370 made changes to filters which must be addressed here for tests to pass.
theforeman#10370 removed the method `limited?`, so it shold be replaced here.
theforeman#10370 removed the method `limited?`, so it should be replaced here.
#10370 removed the method `limited?`, so it should be replaced here.

To test:
before the pr: no taxonomy_search in the DB, and the filter is marked as unlimited
Added a migration to regenerate the taxonomy_search field of all filters which have override set to false to make them honor the organizations and locations set on the role.
Added a ui block on the unlimited checkbox if there are taxonomies in place.
Fixed "build_taxonomy_search" as it relayed on
locations, but on creation there are onlylocation_ids. Before this pr the workaround would be to edit and submit the filter (with no changes) since on editlocationsare already populated