From 6fa4a3eaa110c3c1292aac4aac58e3c4c7479f72 Mon Sep 17 00:00:00 2001 From: Nikhil Kuriakose Date: Wed, 25 Jun 2025 11:23:32 +0200 Subject: [PATCH] chore(editor): Making health call only if custom hosted templates (#16686) --- packages/frontend/editor-ui/src/init.test.ts | 4 ---- packages/frontend/editor-ui/src/init.ts | 6 ------ .../frontend/editor-ui/src/views/TemplatesSearchView.vue | 5 +++++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/frontend/editor-ui/src/init.test.ts b/packages/frontend/editor-ui/src/init.test.ts index 20cd7a3d6a..cdc5755976 100644 --- a/packages/frontend/editor-ui/src/init.test.ts +++ b/packages/frontend/editor-ui/src/init.test.ts @@ -137,7 +137,6 @@ describe('Init', () => { it('should not init authenticated features if user is not logged in', async () => { const cloudStoreSpy = vi.spyOn(cloudPlanStore, 'initialize'); - const templatesTestSpy = vi.spyOn(settingsStore, 'testTemplatesEndpoint'); const sourceControlSpy = vi.spyOn(sourceControlStore, 'getPreferences'); const nodeTranslationSpy = vi.spyOn(nodeTypesStore, 'getNodeTranslationHeaders'); vi.mocked(useUsersStore).mockReturnValue({ currentUser: null } as ReturnType< @@ -146,14 +145,12 @@ describe('Init', () => { await initializeAuthenticatedFeatures(); expect(cloudStoreSpy).not.toHaveBeenCalled(); - expect(templatesTestSpy).not.toHaveBeenCalled(); expect(sourceControlSpy).not.toHaveBeenCalled(); expect(nodeTranslationSpy).not.toHaveBeenCalled(); }); it('should init authenticated features only once if user is logged in', async () => { const cloudStoreSpy = vi.spyOn(cloudPlanStore, 'initialize'); - const templatesTestSpy = vi.spyOn(settingsStore, 'testTemplatesEndpoint'); const sourceControlSpy = vi.spyOn(sourceControlStore, 'getPreferences'); const nodeTranslationSpy = vi.spyOn(nodeTypesStore, 'getNodeTranslationHeaders'); vi.mocked(useUsersStore).mockReturnValue({ currentUser: { id: '123' } } as ReturnType< @@ -163,7 +160,6 @@ describe('Init', () => { await initializeAuthenticatedFeatures(); expect(cloudStoreSpy).toHaveBeenCalled(); - expect(templatesTestSpy).toHaveBeenCalled(); expect(sourceControlSpy).toHaveBeenCalled(); expect(nodeTranslationSpy).toHaveBeenCalled(); diff --git a/packages/frontend/editor-ui/src/init.ts b/packages/frontend/editor-ui/src/init.ts index f7543a5a82..cfb6c62c61 100644 --- a/packages/frontend/editor-ui/src/init.ts +++ b/packages/frontend/editor-ui/src/init.ts @@ -121,12 +121,6 @@ export async function initializeAuthenticatedFeatures( } } - if (settingsStore.isTemplatesEnabled) { - try { - await settingsStore.testTemplatesEndpoint(); - } catch (e) {} - } - if (rootStore.defaultLocale !== 'en') { await nodeTypesStore.getNodeTranslationHeaders(); } diff --git a/packages/frontend/editor-ui/src/views/TemplatesSearchView.vue b/packages/frontend/editor-ui/src/views/TemplatesSearchView.vue index 47259f5ec4..1739ec8b0c 100644 --- a/packages/frontend/editor-ui/src/views/TemplatesSearchView.vue +++ b/packages/frontend/editor-ui/src/views/TemplatesSearchView.vue @@ -301,6 +301,11 @@ onMounted(async () => { restoreSearchFromRoute(); + // Check if templates are enabled and check if the local templates store is available + if (settingsStore.isTemplatesEnabled) { + settingsStore.testTemplatesEndpoint().catch(() => {}); + } + setTimeout(() => { // Check if there is scroll position saved in route and scroll to it const scrollOffset = route.meta?.scrollOffset;