-
Notifications
You must be signed in to change notification settings - Fork 334
Fix secondary menu not updating reactively when CRDs are created #17781
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
cnotv
wants to merge
1
commit into
rancher:master
Choose a base branch
from
cnotv:bugfix/16664-secondary-menu-reactivity
base: master
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.
+211
−1
Open
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import SideNav from '@shell/components/SideNav.vue'; | ||
| import { COUNT } from '@shell/config/types'; | ||
|
|
||
| describe('component: SideNav', () => { | ||
| describe('countTypes', () => { | ||
| const countTypes = (SideNav as any).computed.countTypes; | ||
| const watchCountTypes = (SideNav as any).watch.countTypes; | ||
|
|
||
| const getStore = (counts: Record<string, any>) => ({ | ||
| getters: { | ||
| 'cluster/all': (type: string) => { | ||
| if (type === COUNT) { | ||
| return [{ counts }]; | ||
| } | ||
|
|
||
| return []; | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| it('returns an empty list when management is not ready', () => { | ||
| const types = countTypes.call({ | ||
| managementReady: false, | ||
| currentProduct: { inStore: 'cluster' }, | ||
| $store: getStore({ 'my.io.crd': { summary: { count: 5 } } }), | ||
| }); | ||
|
|
||
| expect(types).toStrictEqual([]); | ||
| }); | ||
|
|
||
| it('returns only types with a positive count, sorted by type id', () => { | ||
| const types = countTypes.call({ | ||
| managementReady: true, | ||
| currentProduct: { inStore: 'cluster' }, | ||
| $store: getStore({ | ||
| 'z.io.hidden': { summary: { count: 0 } }, | ||
| 'a.io.visible': { summary: { count: 3 } }, | ||
| 'c.io.not-visible': { summary: { count: -1 } }, | ||
| 'b.io.visible': { summary: { count: 1 } }, | ||
| 'd.io.bad-type': { summary: {} }, | ||
| }), | ||
| }); | ||
|
|
||
| expect(types).toStrictEqual(['a.io.visible', 'b.io.visible']); | ||
| }); | ||
|
|
||
| it('returns an empty list when count data is missing', () => { | ||
| const types = countTypes.call({ | ||
| managementReady: true, | ||
| currentProduct: { inStore: 'cluster' }, | ||
| $store: { | ||
| getters: { | ||
| 'cluster/all': (type: string) => { | ||
| if (type === COUNT) { | ||
| return []; | ||
| } | ||
|
|
||
| return []; | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| expect(types).toStrictEqual([]); | ||
| }); | ||
|
|
||
| it('queues a nav refresh when visible count types change', () => { | ||
| const queueUpdate = jest.fn(); | ||
| const logSideNavDebug = jest.fn(); | ||
|
|
||
| watchCountTypes.call({ queueUpdate, logSideNavDebug }, ['a.io.visible'], ['a.io.visible', 'b.io.visible']); | ||
|
|
||
| expect(queueUpdate).toHaveBeenCalledWith(); | ||
| }); | ||
|
|
||
| it('does not queue a nav refresh when visible count types are unchanged', () => { | ||
| const queueUpdate = jest.fn(); | ||
| const logSideNavDebug = jest.fn(); | ||
|
|
||
| watchCountTypes.call({ queueUpdate, logSideNavDebug }, ['a.io.visible'], ['a.io.visible']); | ||
|
|
||
| expect(queueUpdate).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
we might need to reconsider this.
re-rendering the side nav on count change was something we used to do but hit large performance issues given counts change a lot, and in some scenarios there's 1000s of schemas (i.e. crossplane world).
in theory all new schema's should be picked up via the computed property
allSchemasIdswhich has a watch that calls queueUpdate?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.
I have no idea about this logic, as you are the master.
I made this bug go away, but if you have tips, I welcome them and shove them to the AI :)
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.
Is the bug still reproducible when this part is removed? If not then it should be enough just to remove it. If so though it might be worth debugging the allSchemasIds part and see it can be fixed there
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.
That's the whole point of the fix, and it does not work without it.
If you want to have time to experiment, I leave it to you to play around and keep the PR open till you feel is ok.