diff --git a/shell/components/nav/WindowManager/ContainerShell.vue b/shell/components/nav/WindowManager/ContainerShell.vue index 40bf9289f4..801a0e5219 100644 --- a/shell/components/nav/WindowManager/ContainerShell.vue +++ b/shell/components/nav/WindowManager/ContainerShell.vue @@ -128,7 +128,14 @@ export default { async mounted() { const nodeId = this.pod.spec?.nodeName; - await this.$store.dispatch('cluster/find', { type: NODE, id: nodeId }); + try { + const schema = this.$store.getters[`cluster/schemaFor`](NODE); + + if (schema) { + await this.$store.dispatch('cluster/find', { type: NODE, id: nodeId }); + } + } catch {} + await this.setupTerminal(); await this.connect(); diff --git a/shell/components/nav/WindowManager/__tests__/ContainerShell.test.ts b/shell/components/nav/WindowManager/__tests__/ContainerShell.test.ts index 72f23d18f2..b7a9b46ae2 100644 --- a/shell/components/nav/WindowManager/__tests__/ContainerShell.test.ts +++ b/shell/components/nav/WindowManager/__tests__/ContainerShell.test.ts @@ -18,6 +18,7 @@ jest.mock('@shell/utils/crypto', () => { describe('component: ContainerShell', () => { const action = jest.fn(); const translate = jest.fn(); + const schemaFor = jest.fn(); const onData = jest.fn(); const loadAddon = jest.fn(); const open = jest.fn(); @@ -66,7 +67,10 @@ describe('component: ContainerShell', () => { mocks: { $store: { dispatch: action, - getters: { 'i18n/t': translate } + getters: { + 'i18n/t': translate, + 'cluster/schemaFor': schemaFor + } } } }; @@ -99,9 +103,23 @@ describe('component: ContainerShell', () => { expect(windowElement.exists()).toBe(true); }); - it('the find action for the node is called', async() => { + it('the find action for the node is called if schemaFor finds a schema for NODE', async() => { resetMocks(); - await wrapperPostMounted(defaultContainerShellParams); + const testSchemaFindsSchemaParams = { + ...defaultContainerShellParams, + mocks: { + ...defaultContainerShellParams.mocks, + $store: { + ...defaultContainerShellParams.mocks.$store, + getters: { + ...defaultContainerShellParams.mocks.$store.getters, + 'cluster/schemaFor': jest.fn().mockImplementation(() => true) + } + } + } + }; + + await wrapperPostMounted(testSchemaFindsSchemaParams); const actionParams = action.mock.calls[0]; diff --git a/shell/models/pod.js b/shell/models/pod.js index e8b42ea826..0e235f4c54 100644 --- a/shell/models/pod.js +++ b/shell/models/pod.js @@ -34,7 +34,13 @@ export default class Pod extends WorkloadService { } get node() { - this.$dispatch(`find`, { type: NODE, id: this.spec.nodeName }); + try { + const schema = this.$store.getters[`cluster/schemaFor`](NODE); + + if (schema) { + this.$dispatch(`find`, { type: NODE, id: this.spec.nodeName }); + } + } catch {} return this.$getters['byId'](NODE, this.spec.nodeName); }