-
Notifications
You must be signed in to change notification settings - Fork 666
CONSOLE-4989: bump to react-redux 8
#15854
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
Open
logonoff
wants to merge
3
commits into
openshift:main
Choose a base branch
from
logonoff:CONSOLE-4989-redux
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+179
−110
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
frontend/packages/console-app/src/actions/hooks/useGroupActions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
frontend/packages/console-app/src/actions/providers/user-provider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,49 @@ | ||||||||||
| import type { FC } from 'react'; | ||||||||||
| import { useCallback, useRef, useEffect } from 'react'; | ||||||||||
| import { | ||||||||||
| isFeatureFlagHookProvider, | ||||||||||
| FeatureFlagHookProvider, | ||||||||||
| useResolvedExtensions, | ||||||||||
| SetFeatureFlag, | ||||||||||
| } from '@console/dynamic-plugin-sdk'; | ||||||||||
| import { featureFlagController } from '@console/internal/actions/features'; | ||||||||||
| import FeatureFlagExtensionHookResolver from './FeatureFlagExtensionHookResolver'; | ||||||||||
| import { setFlag } from '@console/internal/actions/flags'; | ||||||||||
| import { useConsoleDispatch } from '@console/shared/src/hooks/useConsoleDispatch'; | ||||||||||
| import { useConsoleSelector } from '@console/shared/src/hooks/useConsoleSelector'; | ||||||||||
| import { FeatureFlagExtensionHookResolver } from './FeatureFlagExtensionHookResolver'; | ||||||||||
|
|
||||||||||
| const FeatureFlagExtensionLoader: FC = () => { | ||||||||||
| const useFeatureFlagController = () => { | ||||||||||
| const dispatch = useConsoleDispatch(); | ||||||||||
| const flags = useConsoleSelector(({ FLAGS }) => FLAGS); | ||||||||||
|
|
||||||||||
| // Keep a ref to the flags map to avoid time-of-check to time-of-use issues | ||||||||||
| // if the flags change between render and the callback being invoked | ||||||||||
| const flagsRef = useRef(flags); | ||||||||||
|
|
||||||||||
| useEffect(() => { | ||||||||||
| flagsRef.current = flags; | ||||||||||
| }, [flags]); | ||||||||||
|
|
||||||||||
| return useCallback<SetFeatureFlag>( | ||||||||||
| (flag, enabled) => { | ||||||||||
| // Defer dispatch to next event loop tick to avoid "Cannot update a component | ||||||||||
| // while rendering a different component" error | ||||||||||
| queueMicrotask(() => { | ||||||||||
| if (flagsRef.current.get(flag) === enabled) { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| return; | ||||||||||
| } | ||||||||||
| dispatch(setFlag(flag, enabled)); | ||||||||||
| }); | ||||||||||
| }, | ||||||||||
| [dispatch], | ||||||||||
| ); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| export const FeatureFlagExtensionLoader: FC = () => { | ||||||||||
| const [flagProvider, flagProviderResolved] = useResolvedExtensions<FeatureFlagHookProvider>( | ||||||||||
| isFeatureFlagHookProvider, | ||||||||||
| ); | ||||||||||
| const featureFlagController = useFeatureFlagController(); | ||||||||||
|
|
||||||||||
| if (flagProviderResolved) { | ||||||||||
| return ( | ||||||||||
| <> | ||||||||||
|
|
@@ -32,4 +65,3 @@ const FeatureFlagExtensionLoader: FC = () => { | |||||||||
| } | ||||||||||
| return null; | ||||||||||
| }; | ||||||||||
| export default FeatureFlagExtensionLoader; | ||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...tend/packages/console-shared/src/components/dashboard/utilization-card/prometheus-hook.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
frontend/packages/console-shared/src/hooks/useConsoleDispatch.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useDispatch } from 'react-redux'; | ||
| import type { AnyAction } from 'redux'; | ||
| import type { ThunkDispatch } from 'redux-thunk'; | ||
| import type { RootState } from '@console/internal/redux'; | ||
|
|
||
| // TODO: When upgrading to react-redux v9, use the built-in `withTypes` method. | ||
| // See: https://github.com/reduxjs/react-redux/releases/tag/v9.1.0 | ||
|
|
||
| /** | ||
| * A hook to access the console redux `dispatch` function. | ||
| * | ||
| * See {@link useDispatch} for more details. | ||
| */ | ||
| export const useConsoleDispatch: () => ThunkDispatch<RootState, undefined, AnyAction> = useDispatch; |
12 changes: 12 additions & 0 deletions
12
frontend/packages/console-shared/src/hooks/useConsoleSelector.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { TypedUseSelectorHook, useSelector } from 'react-redux'; | ||
| import type { RootState } from '@console/internal/redux'; | ||
|
|
||
| // TODO: When upgrading to react-redux v9, use the built-in `withTypes` method. | ||
| // See: https://github.com/reduxjs/react-redux/releases/tag/v9.1.0 | ||
|
|
||
| /** | ||
| * A hook to access the console redux state. | ||
| * | ||
| * See {@link useSelector} for more details. | ||
| */ | ||
| export const useConsoleSelector: TypedUseSelectorHook<RootState> = useSelector; |
12 changes: 12 additions & 0 deletions
12
frontend/packages/console-shared/src/hooks/useConsoleStore.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useStore } from 'react-redux'; | ||
| import type store from '@console/internal/redux'; | ||
|
|
||
| // TODO: When upgrading to react-redux v9, use the built-in `withTypes` method. | ||
| // See: https://github.com/reduxjs/react-redux/releases/tag/v9.1.0 | ||
|
|
||
| /** | ||
| * A hook to access the console redux store. | ||
| * | ||
| * See {@link useStore} for more details. | ||
| */ | ||
| export const useConsoleStore = useStore as () => typeof store; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note that
react-reduxis Console provided shared module, using the default configi.e. plugins are built with the assumption that Console provides v7 impl. without plugin provided fallback.
So this is effectively a breaking change in Console provided shared modules.