Skip to content

Conversation

@MariaAga
Copy link
Member

@MariaAga MariaAga commented Nov 6, 2024

To test:

  1. Create a role
  2. Assign an organization and a location to the role
  3. Create a filter under the role with host permissions
    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 only location_ids. Before this pr the workaround would be to edit and submit the filter (with no changes) since on edit locations are already populated

@github-actions github-actions bot added the UI label Nov 6, 2024
@MariaAga MariaAga force-pushed the roles-taxonomy-on-create branch from baf4134 to f46f2a5 Compare November 6, 2024 16:26
@MariaAga MariaAga force-pushed the roles-taxonomy-on-create branch 2 times, most recently from 319787a to e2698dc Compare November 7, 2024 14:20
@MariaAga MariaAga force-pushed the roles-taxonomy-on-create branch from e2698dc to 1579997 Compare November 20, 2024 11:56
@MariaAga
Copy link
Member Author

thanks @ofedoren, updated

@MariaAga MariaAga marked this pull request as draft January 3, 2025 17:45
@MariaAga
Copy link
Member Author

MariaAga commented Jan 3, 2025

Draft until I finish "remove taxonimoes override from filter"

Copy link
Member

@ofedoren ofedoren left a 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)

ouiaId="taxonomy-search-alert"
variant="info"
title={__(
"The filter is scoped to the selected organizations and locations, therefore can't be unlimited"
Copy link
Member

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?

Suggested change
"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.

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, for consistency should we change the warning to be a field small warning or an alert?
The 2 options shown here:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Member

@ofedoren ofedoren left a 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

@MariaAga MariaAga force-pushed the roles-taxonomy-on-create branch 7 times, most recently from 4ea5855 to 30dd1f9 Compare January 30, 2025 13:40
Copy link
Member

@ofedoren ofedoren left a 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.

@MariaAga MariaAga force-pushed the roles-taxonomy-on-create branch from 30dd1f9 to d4b9075 Compare April 14, 2025 11:22
@MariaAga
Copy link
Member Author

Thanks for the reviews, I rebased and addressed the comments

can this be undrafted after the migration is uncommented or you're planning to do more changes?

Yes, migration is just scary

Copy link
Member

@ofedoren ofedoren left a 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)
Copy link
Member

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...

ofedoren
ofedoren previously approved these changes Oct 6, 2025
Copy link
Member

@ofedoren ofedoren left a 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.

@adamruzicka
Copy link
Contributor

UPD2: Ah... Since we're touching API (and hammer), I'm afraid we might need to touch FAM as well :/ Not that sure though.

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.

@adamruzicka adamruzicka merged commit 8a7e1b1 into theforeman:develop Oct 16, 2025
65 checks passed
@adamruzicka
Copy link
Contributor

Thank you @MariaAga & @ofedoren !

adamlazik1 added a commit to adamlazik1/foreman-tasks that referenced this pull request Oct 23, 2025
theforeman/foreman#10370 made changes to filters
which must be addressed here for tests to pass.
adamlazik1 added a commit to adamlazik1/foreman-tasks that referenced this pull request Oct 23, 2025
theforeman/foreman#10370 made changes to filters
which must be addressed here for tests to pass.
adamlazik1 added a commit to adamlazik1/foreman-tasks that referenced this pull request Oct 24, 2025
theforeman/foreman#10370 made changes to filters
which must be addressed here for tests to pass.
adamlazik1 added a commit to adamlazik1/foreman that referenced this pull request Oct 24, 2025
theforeman#10370 removed the method
`limited?`, so it shold be replaced here.
adamruzicka pushed a commit to theforeman/foreman-tasks that referenced this pull request Oct 24, 2025
theforeman/foreman#10370 made changes to filters
which must be addressed here for tests to pass.
adamlazik1 added a commit to adamlazik1/foreman that referenced this pull request Oct 24, 2025
theforeman#10370 removed the method
`limited?`, so it shold be replaced here.
adamlazik1 added a commit to adamlazik1/foreman that referenced this pull request Oct 24, 2025
theforeman#10370 removed the method
`limited?`, so it should be replaced here.
stejskalleos pushed a commit that referenced this pull request Nov 7, 2025
#10370 removed the method
`limited?`, so it should be replaced here.
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.

4 participants