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

Add attribute value filter #27

Merged

Conversation

jgbernalp
Copy link
Contributor

@jgbernalp jgbernalp commented Sep 26, 2022

These changes introduce filters based on user UI selections. Using a LogQL parser the console plugin is able to generate UI filters from a query and vice versa.

Part of this PR:

  • Include the components for attribute filtering
  • Include a LogQL parser
  • synchronize the query content with the selected filters ( double direction editing: UI <-> Query expression)
Screen.Recording.2022-09-26.at.15.55.46.mov

Completes: https://issues.redhat.com/browse/LOG-2983 & https://issues.redhat.com/browse/OU-69

@jgbernalp jgbernalp marked this pull request as draft September 26, 2022 11:50
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 26, 2022
@openshift-ci openshift-ci bot requested a review from kyoto September 26, 2022 11:50
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 26, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jgbernalp

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 26, 2022
@jgbernalp jgbernalp changed the title Add attribute value filter [WIP] Add attribute value filter Sep 26, 2022
@jgbernalp jgbernalp marked this pull request as ready for review September 26, 2022 11:59
@jgbernalp
Copy link
Contributor Author

/retest

@jgbernalp jgbernalp changed the title [WIP] Add attribute value filter Add attribute value filter Sep 26, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 26, 2022
@jgbernalp jgbernalp force-pushed the add-atribute-value-filter branch 2 times, most recently from d5066cf to 3b3fa46 Compare September 26, 2022 15:02
@jgbernalp
Copy link
Contributor Author

/retest

@jgbernalp jgbernalp marked this pull request as draft September 28, 2022 12:05
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 28, 2022
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 29, 2022
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 4, 2022
@jgbernalp jgbernalp force-pushed the add-atribute-value-filter branch 2 times, most recently from 9509170 to aa3a174 Compare October 4, 2022 12:56
@jgbernalp jgbernalp marked this pull request as ready for review October 4, 2022 13:39
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2022
@jgbernalp
Copy link
Contributor Author

/retest

@jgbernalp
Copy link
Contributor Author

/retest-required

src/index.tsx Outdated Show resolved Hide resolved
cypress/fixtures/resource-api-fixtures.ts Outdated Show resolved Hide resolved
src/components/filters/search-select.css Show resolved Hide resolved
src/components/filters/filter.types.ts Show resolved Hide resolved
src/attribute-filters.tsx Outdated Show resolved Hide resolved
src/attribute-filters.tsx Outdated Show resolved Hide resolved
src/attribute-filters.tsx Outdated Show resolved Hide resolved
src/attribute-filters.tsx Outdated Show resolved Hide resolved
src/attribute-filters.tsx Outdated Show resolved Hide resolved
return undefined;
}

const unknownFilter = severity.has('unknown')
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to handle this unknown case separately rather than inside the flatMap below?

src/attribute-filters.tsx Outdated Show resolved Hide resolved
src/pages/logs-dev-page.tsx Outdated Show resolved Hide resolved
src/hooks/useUrlState.ts Outdated Show resolved Hide resolved
src/hooks/useUrlState.ts Outdated Show resolved Hide resolved
src/hooks/useUrlState.ts Outdated Show resolved Hide resolved
@jgbernalp
Copy link
Contributor Author

/retest

@jgbernalp jgbernalp force-pushed the add-atribute-value-filter branch 2 times, most recently from ff54f2c to 6769f1c Compare October 7, 2022 13:05
history.push(`${location.pathname}?${queryParams.toString()}`);
};

const setValuesFromParams = (newQueryParams: URLSearchParams) => {
Copy link
Member

Choose a reason for hiding this comment

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

For my comment #27 (review), rather than just renaming the parameter, I was wondering if you could avoid passing in a parameter at all and use queryParams here? Or maybe queryParams won't yet be set when the function is first called?

Taking it a bit further, would something like this work?

useEffect(() => {
  const queryValue = queryParams.get(QUERY_PARAM_KEY) ?? initialQuery;
  const tenantValue = queryParams.get(TENANT_PARAM_KEY) ?? DEFAULT_TENANT;
  const showResourcesValue =
    queryParams.get(SHOW_RESOURCES_PARAM_KEY) ?? DEFAULT_SHOW_RESOURCES;

  setQuery(queryValue);
  setTenant(tenantValue);
  setAreResourcesShown(showResourcesValue === '1');
  setFilters(filtersFromQuery({ query: queryValue, attributes }));
}, [queryParams])

And then you wouldn't need the other two useEffects at all.

Copy link
Contributor Author

@jgbernalp jgbernalp Oct 13, 2022

Choose a reason for hiding this comment

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

Yes, having the useEffect listening into the history rather than the queryValue allowed that the text input didn't loose the caret position.

But in fact this was an issue in the input and shouldn't be solved in the useURLState hook. I changed it to use just one useEffect and adjusted the input proxying the prop in an internal state so the caret position is kept while the url parameter changes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 13, 2022

@jgbernalp: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@kyoto
Copy link
Member

kyoto commented Oct 14, 2022

/lgtm
Thanks @jgbernalp!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2022
@openshift-merge-robot openshift-merge-robot merged commit abed616 into openshift:main Oct 14, 2022
@jgbernalp jgbernalp deleted the add-atribute-value-filter branch January 2, 2023 09:32
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. 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

3 participants