-
Notifications
You must be signed in to change notification settings - Fork 17
fix(Header): wait for capabilities before show content #3145
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
base: main
Are you sure you want to change the base?
Conversation
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.
3 files reviewed, 3 comments
| return Boolean(data || error); | ||
| } | ||
|
|
||
| export function useAllCapablitiesStatus() { |
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.
syntax: typo: 'Capablities' should be 'Capabilities'
| export function useAllCapablitiesStatus() { | |
| export function useAllCapabilitiesStatus() { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/store/reducers/capabilities/hooks.ts
Line: 33:33
Comment:
**syntax:** typo: 'Capablities' should be 'Capabilities'
```suggestion
export function useAllCapabilitiesStatus() {
```
How can I resolve this? If you propose a fix, please make it concise.
src/containers/App/Content.tsx
Outdated
| import {authenticationApi} from '../../store/reducers/authentication/authentication'; | ||
| import { | ||
| useCapabilitiesQuery, | ||
| useAllCapablitiesStatus, |
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.
syntax: typo: 'Capablities' should be 'Capabilities'
| useAllCapablitiesStatus, | |
| useAllCapabilitiesStatus, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/containers/App/Content.tsx
Line: 17:17
Comment:
**syntax:** typo: 'Capablities' should be 'Capabilities'
```suggestion
useAllCapabilitiesStatus,
```
How can I resolve this? If you propose a fix, please make it concise.
src/containers/Header/Header.tsx
Outdated
| import {environment} from '../../store'; | ||
| import { | ||
| useAddClusterFeatureAvailable, | ||
| useAllCapablitiesStatus, |
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.
syntax: typo: 'Capablities' should be 'Capabilities'
| useAllCapablitiesStatus, | |
| useAllCapabilitiesStatus, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/containers/Header/Header.tsx
Line: 22:22
Comment:
**syntax:** typo: 'Capablities' should be 'Capabilities'
```suggestion
useAllCapabilitiesStatus,
```
How can I resolve this? If you propose a fix, please make it concise.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.
Pull request overview
This PR addresses a timing issue where the Header component could render before capabilities data is fully loaded. A new custom hook useAllCapablitiesStatus centralizes the logic for checking both cluster and meta capabilities loading status, which is then used to conditionally render Header content.
Key changes:
- Created a reusable hook to check the combined loading state of both capabilities queries
- Modified Header to wait for capabilities to load before rendering its content
- Refactored Content.tsx to use the new hook, eliminating code duplication
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/store/reducers/capabilities/hooks.ts | Introduces new hook useAllCapablitiesStatus to centralize capabilities loading state checking |
| src/containers/Header/Header.tsx | Updates Header to wait for capabilities before rendering content using the new hook |
| src/containers/App/Content.tsx | Refactors to use the new centralized hook, removing duplicated logic |
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.
3 files reviewed, no comments
Greptile Overview
Greptile Summary
Refactored capability loading to prevent header from displaying before capabilities are loaded.
Key changes:
useAllCapabilitiesStatushook that consolidates both cluster and meta capabilities loading stateGetCapabilitiescomponent to use the new hook, removing duplicate logicuseCapabilitiesQuery,useMetaCapabilitiesLoaded,useMetaCapabilitiesQuery) from Content.tsxThe refactoring improves code maintainability by centralizing capability loading logic and fixes a UX issue where the header would briefly appear before capabilities were fully loaded.
Confidence Score: 5/5
useAllCapabilitiesStatushook properly consolidates loading logic, uses React.useMemo for performance optimization, and maintains the same functional behavior. All imports are correctly updated, and the implementation follows React best practices.Important Files Changed
File Analysis
useAllCapabilitiesStatushook that returns both loading state and errorGetCapabilitiescomponent by using newuseAllCapabilitiesStatushook, removed unused importsSequence Diagram
sequenceDiagram participant Header participant useAllCapabilitiesStatus participant Content/GetCapabilities participant capabilitiesApi participant metaCapabilitiesApi Header->>useAllCapabilitiesStatus: Call hook Content/GetCapabilities->>useAllCapabilitiesStatus: Call hook useAllCapabilitiesStatus->>capabilitiesApi: useGetClusterCapabilitiesQuery() useAllCapabilitiesStatus->>metaCapabilitiesApi: useGetMetaCapabilitiesQuery() capabilitiesApi-->>useAllCapabilitiesStatus: {data, error} metaCapabilitiesApi-->>useAllCapabilitiesStatus: Check loaded status useAllCapabilitiesStatus->>useAllCapabilitiesStatus: Calculate loading state<br/>(!capabilitiesLoaded || !metaCapabilitiesLoaded) useAllCapabilitiesStatus-->>Header: {loading, error} useAllCapabilitiesStatus-->>Content/GetCapabilities: {loading, error} alt loading = true Header->>Header: Return null (hide content) Content/GetCapabilities->>Content/GetCapabilities: Show LoaderWrapper else loading = false Header->>Header: Render breadcrumbs & controls Content/GetCapabilities->>Content/GetCapabilities: Render children endCI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: ✅
Current: 66.06 MB | Main: 66.06 MB
Diff: +0.83 KB (0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information