ROX-30334: Rely on context instead of redux for usePermissions hook#16182
ROX-30334: Rely on context instead of redux for usePermissions hook#16182
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
Skipping CI for Draft Pull Request. |
|
Images are ready for the commit at 4c6195f. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16182 +/- ##
==========================================
- Coverage 48.71% 48.71% -0.01%
==========================================
Files 2606 2606
Lines 191771 191771
==========================================
- Hits 93418 93415 -3
- Misses 91024 91025 +1
- Partials 7329 7331 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5ecd4b9 to
1c986d8
Compare
e2497b3 to
286e5b2
Compare
There was a problem hiding this comment.
Hey @dvail - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `ui/apps/platform/src/Containers/ReduxUserPermissionProvider.tsx:18` </location>
<code_context>
+});
+
+export default function ReduxUserPermissionProvider({ children }: { children: React.ReactNode }) {
+ const { userRolePermissions, isLoadingPermissions } = useSelector(stateSelector);
+
+ return (
</code_context>
<issue_to_address>
No memoization for context value may cause unnecessary re-renders.
Consider using `useMemo` to memoize the context value and prevent unnecessary re-renders of consumers, especially if the provider wraps large parts of the app.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
sachaudh
left a comment
There was a problem hiding this comment.
LGTM 👍🏼 Minor comments about thoughts and suggestions.
ui/apps/platform/src/Containers/ReduxUserPermissionProvider.tsx
Outdated
Show resolved
Hide resolved
b57a431 to
323f0cf
Compare
286e5b2 to
4c6195f
Compare
Description
This replaces the direct usage of redux
selectorsin theusePermissions()hook with a call to a context instead. A context provider is added at the top level of the application that will use redux and sagas to handle permissions as they were previously handled in theusePermissions()hook.This will allow us to easily have a separate context provider in the OCP plugin that has user permission information without needing to integrate with redux.
User-facing documentation
Testing and quality
Automated testing
How I validated my change
Smoke test and manual verification that
mypermissionsendpoint is only ever called once when navigating around the application.CI e2e tests should be sufficient to catch edge cases.