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

Bug 1823253: Fix Textfilter issue in Filter Toolbar #5022

Merged

Conversation

bipuladh
Copy link
Contributor

  • textFilter was not passed to applyFilter.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Apr 13, 2020
@openshift-ci-robot
Copy link
Contributor

@bipuladh: This pull request references Bugzilla bug 1823253, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1823253: Fix Textfilter issue in Filter Toolbar

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bipuladh
Copy link
Contributor Author

/kind bug
/assign @TheRealJon

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 13, 2020
@TheRealJon
Copy link
Member

@bipuladh Just tested this and I am still getting runtime errors if I pass a filter parameter in the url:

http://localhost:9000/k8s/cluster/config.openshift.io~v1~OperatorHub/cluster/sources?name=test

Or if I try and filter on labels

@openshift-ci-robot openshift-ci-robot added component/olm Related to OLM component/shared Related to console-shared labels Apr 21, 2020
@bipuladh
Copy link
Contributor Author

bipuladh commented Apr 21, 2020

@TheRealJon Updated the PR. However, the fix was not straightforward since the structure of the payload used in catalog-source(source -> metadata -> labels) is different. I looked at files that use textFilter to perform filtering in a different manner, however, I did not come across anything that might need to use the fix that I have applied here. Please let me know if I am missing out on any such components. Thanks. :)

@bipuladh bipuladh force-pushed the toolbar-textfilter branch 6 times, most recently from 2f76489 to e0a1d0d Compare April 23, 2020 20:35
Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

I think an easier solution for the name filter problem would be to just change the default name filter in public/components/factory/table-filters.ts to something like this:

  name: (filter, obj) => fuzzyCaseInsensitive(filter, obj?.metadata?.name ?? obj?.name),

There are a few other custom name filters defined in table filters because of a similar issue where the name property isn't in metadata. Maybe we can add a TODO or FIXME comment to those to say that the default name filter will work for these resources after this update.

@bipuladh
Copy link
Contributor Author

I think an easier solution for the name filter problem would be to just change the default name filter in public/components/factory/table-filters.ts to something like this:

  name: (filter, obj) => fuzzyCaseInsensitive(filter, obj?.metadata?.name ?? obj?.name),

There are a few other custom name filters defined in table filters because of a similar issue where the name property isn't in metadata. Maybe we can add a TODO or FIXME comment to those to say that the default name filter will work for these resources after this update.

This suggestion would allow us to remove the usage of catalog-source-name but there are other table-filters that filter on other properties that are not directly under those two fields. For example projects, they use annotation to store the display name shown to the user, so the solution you’ve proposed will work for catalogSource but not for everything, textFilter is unavoidable.
But we can update it to your suggestion so that we can avoid table-filters which share the logic you proposed.

@TheRealJon
Copy link
Member

TheRealJon commented Apr 24, 2020

Yeah, I don't think that this suggestion would be a catch-all fix, but I think it would be good to have it handle the two most common scenarios (obj.name and obj.metadata.name). That might make it possible to remove at least 3 custom table filters. (catalog-source-name, alert-rule-name, and silence-name)

@bipuladh bipuladh force-pushed the toolbar-textfilter branch 2 times, most recently from 86b9fce to 8c16e68 Compare April 27, 2020 16:27
Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

Just want to update the getLabelsAsString function to take labels instead of the whole obj.

frontend/packages/console-shared/src/utils/label-filter.ts Outdated Show resolved Hide resolved
frontend/public/components/factory/table-filters.ts Outdated Show resolved Hide resolved
Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

/approve

@TheRealJon
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 28, 2020
@bipuladh
Copy link
Contributor Author

/assign @spadgett

@spadgett
Copy link
Member

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 28, 2020
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

This seems like the wrong approach to me. We shouldn't have magical fallbacks when the resource is not a k8s resource. We should instead provide a way to pass custom functions to the list page for getting the name or label when the resource doesn't have a metadata stanza.

We might just disable the name/label filters on this page. You should never have that many catalog sources. I'm not sure they're really helpful.

@spadgett
Copy link
Member

Sorry I realize you're getting different feedback on the PR, but I disagree a bit with @TheRealJon here. If it's not a k8s resource, I'd rather be explicit and fix it generally so we can handle any resource shape.

But again we might just remove the filters from this page as the easy fix.

@spadgett
Copy link
Member

Another approach would be to pass through the path to the labels or name as a prop with defaults like we do for ResoruceSummary:

https://github.com/openshift/console/blob/master/frontend/public/components/utils/details-page.tsx#L44-L45

@bipuladh
Copy link
Contributor Author

bipuladh commented Apr 28, 2020

This seems like the wrong approach to me. We shouldn't have magical fallbacks when the resource is not a k8s resource. We should instead provide a way to pass custom functions to the list page for getting the name or label when the resource doesn't have a metadata stanza.

We might just disable the name/label filters on this page. You should never have that many catalog sources. I'm not sure they're really helpful.

@spadgett
I and @TheRealJon discussed a few approaches.

  1. Make changes to the data (via flatten function) such that the data has metadata available similar to any other K8sResource.
  2. Add custom Name and Label filters via table-filters.
  3. Use the approach used above.

We chose 3 since obj.metadata.name and obj.name are the most common selectors that are used in the table filters at some point in the future we could remove those redundant table-filters that are declared. (1) has a bit more overhead.

@bipuladh
Copy link
Contributor Author

Sorry I realize you're getting different feedback on the PR, but I disagree a bit with @TheRealJon here. If it's not a k8s resource, I'd rather be explicit and fix it generally so we can handle any resource shape.

But again we might just remove the filters from this page as the easy fix.

We could disable the label filter. But name filter already has a custom table-filter and the fix would be very minimal.

@spadgett
Copy link
Member

Sorry, I'm strongly against (1) and (3). obj.name and obj.labels should not be common at all. That should be very rare, and we should be explicit when it's not a normal k8s object. We should also not create "fake" metadata stanzas for things that are not k8s resources.

The right way to fix this is to either make the filter function customizable or to pass the fields paths through as optional properties.

@spadgett
Copy link
Member

Put another way, the filter toolbar should have no knowledge of the special object created by the catalog source list. This creates tight coupling between these components. Filter toolbar should only know about k8s objects.

@TheRealJon
Copy link
Member

@spadgett @bipuladh I would rather see the customizable filter function than passing an extra path argument, but I'll defer to @spadgett here. The original changes just didn't seem quite right to me, so I was trying to work through some alternative approaches. But I see your point about tight coupling between the filter toolbar and list page item data structure.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2020
Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

As long as @spadgett is good with removing the label filter on this page, that's fine with me.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2020
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bipuladh, spadgett, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2020
@bipuladh
Copy link
Contributor Author

bipuladh commented May 4, 2020

/hold cancel
cc @spadgett @TheRealJon

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2020
@spadgett spadgett added this to the v4.5 milestone May 4, 2020
@openshift-merge-robot openshift-merge-robot merged commit 078ff1c into openshift:master May 4, 2020
@openshift-ci-robot
Copy link
Contributor

@bipuladh: All pull requests linked via external trackers have merged: openshift/console#5022. Bugzilla bug 1823253 has been moved to the MODIFIED state.

In response to this:

Bug 1823253: Fix Textfilter issue in Filter Toolbar

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/olm Related to OLM component/shared Related to console-shared kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants