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
convert Topology filters localStorage to userSettings #7326
Conversation
8ed58c5
to
1a5c01d
Compare
@@ -48,7 +43,7 @@ interface StateProps { | |||
|
|||
interface DispatchProps { | |||
onSelectTab?: (name: string) => void; | |||
onFiltersChange: (filters: DisplayFilters) => void; | |||
// onFiltersChange: (filters: DisplayFilters) => void; |
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.
can remove comment
|
||
const TOPOLOGY_DISPLAY_FILTERS_CONFIG_MAP_KEY = `devcosole.topology.filters`; | ||
|
||
const getTopologyFilters = (appliedFilters) => { |
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.
nit: can we have type for appliedFilters
TOPOLOGY_DISPLAY_FILTERS_CONFIG_MAP_KEY, | ||
getDefaultAppliedFilters(), | ||
); | ||
const [filtersLoaded, setFiltersLoaded] = React.useState<boolean>(false); |
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.
Do we need this useState , can't we rely on appliedFiltersLoaded
?
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.
Yes, this is needed because filters depend on the data which is coming from user settings(appliedFilters). so once the user settings is loaded we need to update the filters as well and notify the component that all of the data is loaded.
/cc @jerolimov |
|
||
const useAppliedDisplayFilters = (): DisplayFilters => { | ||
return useSelector((state: RootState) => getAppliedTopologyFilters(state)); | ||
const useAppliedDisplayFilters = (): { [filiterKey: string]: boolean } => { |
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.
Typo
const useAppliedDisplayFilters = (): { [filiterKey: string]: boolean } => { | |
const useAppliedDisplayFilters = (): { [filterKey: string]: boolean } => { |
import { getAppliedFilters } from '../redux/action'; | ||
import { DisplayFilters } from '../topology-types'; | ||
|
||
const TOPOLOGY_DISPLAY_FILTERS_CONFIG_MAP_KEY = `devcosole.topology.filters`; |
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.
const TOPOLOGY_DISPLAY_FILTERS_CONFIG_MAP_KEY = `devcosole.topology.filters`; | |
const TOPOLOGY_DISPLAY_FILTERS_USERSETTINGS_KEY = `devconsole.topology.filters`; |
Typo in the key. And wdyt about using usersettings key instead of configmap key?
@sahil143 When having a When adding a console.warn to When selecting
After reload the page it sends two updates:
Any ideas? Did you need more info? We can make a call if you cant reproduce this. |
boolean, | ||
SetTopologyFilters, | ||
] => { | ||
const [appliedFilters, setAppliedFilters, appliedFiltersLoaded] = useUserSettings( |
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.
@invincibleJai Should this not use the fallback wrapper?
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 for noticing this, used the wrapper useUserSettingsCompatibility
.
] => { | ||
const [appliedFilters, setAppliedFilters, appliedFiltersLoaded] = useUserSettings( | ||
TOPOLOGY_DISPLAY_FILTERS_CONFIG_MAP_KEY, | ||
getDefaultAppliedFilters(), |
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.
@sahil143 I thought our goal here was to get rid of the reducer and obfuscate local storage... why are we using this as the defaults?
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.
fixed.
[setAppliedFilters], | ||
); | ||
|
||
return [filters, appliedFilters, appliedFilters && filtersLoaded, setTopologyFilters]; |
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.
If appliedFilters
are what we have stored in user settings... and filters
are just appliedFilters
with added defaults... why are we providing both back? Wouldn't we want just filters
?
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.
Because appliedFilters
is also being used in component.
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.
Hmmm... we probably should look to refactor that -- let's go with this for now since it's the status quo with the implementation. But it seems like an odd situation.
@@ -34,36 +31,29 @@ import QuickSearchButton from './quick-search/QuickSearchButton'; | |||
import { getNamespaceDashboardKialiLink } from '../utils/topology-utils'; | |||
|
|||
import './TopologyFilterBar.scss'; | |||
import { FilterContext } from './FilterProvider'; |
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.
Nit: sort
import { useDeepCompareMemoize } from '@console/shared/src'; | ||
import { FilterContext } from './FilterProvider'; | ||
import { useContext } from 'react'; |
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.
Nit: Sort
I was able to reproduce this on master as well. I think we can log a bug to handle this. |
@andrewballantyne @jerolimov Addressed all comments. Please review again. |
Verified the changes all works as expected apart from what mentioned above (this is observed in master as well so can be taken as separate issue) |
@sahil143 @invincibleJai Yeah works "similar" to master, it was saved successfully and then override when loading the page. As discussed in slack this is by design because the list of available resource types changes per project. /lgtm |
import * as React from 'react'; | ||
import { useUserSettingsCompatibility } from '@console/shared'; | ||
import { DEFAULT_TOPOLOGY_FILTERS } from './const'; | ||
import { getAppliedFilters } from '../redux/action'; |
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.
getAppliedFilters
was only used in this Provider. Can we remove it from redux/action.ts
since it looks like that we still use redux here?!
[setAppliedFilters], | ||
); | ||
|
||
return [filters, appliedFilters, appliedFilters && filtersLoaded, setTopologyFilters]; |
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.
Hmmm... we probably should look to refactor that -- let's go with this for now since it's the status quo with the implementation. But it seems like an odd situation.
add typings remove comments address review comments refactor
/lgtm |
/test e2e-gcp-console |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, christianvogt, jerolimov, sahil143 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
Fixes: https://issues.redhat.com/browse/ODC-5038
Removed
filter
andappliedFilters
from redux/local storage and added in userSettings.Screen shots / Gifs for design review: No UI changes
Unit test coverage report:
Test setup:
Browser conformance: