From d46a9f3b2d722b0777637a29e0c6945c46e2bd9b Mon Sep 17 00:00:00 2001 From: Musale Martin Date: Tue, 9 Jul 2024 10:54:28 +0300 Subject: [PATCH] Fix: move getting resource version children to a function (#3244) --- .../auto-complete/suffix/SuffixRenderer.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/views/query-runner/query-input/auto-complete/suffix/SuffixRenderer.tsx b/src/app/views/query-runner/query-input/auto-complete/suffix/SuffixRenderer.tsx index 05972fa91..c65755482 100644 --- a/src/app/views/query-runner/query-input/auto-complete/suffix/SuffixRenderer.tsx +++ b/src/app/views/query-runner/query-input/auto-complete/suffix/SuffixRenderer.tsx @@ -23,11 +23,15 @@ const SuffixRenderer = () => { const getDocumentationLink = (): string | null => { const { queries } = samples; - + const getChildren = ()=> { + if (resources.data && Object.keys(resources.data).length > 0 && sampleQuery.selectedVersion in resources.data){ + return resources.data[sampleQuery.selectedVersion].children ?? []; + } + return []; + } const resourceDocumentationUrl = new DocumentationService({ sampleQuery, - source: Object.keys(resources.data).length > 0 ? - resources.data[sampleQuery.selectedVersion].children! : [] + source: getChildren() }).getDocumentationLink(); const sampleDocumentationUrl = new DocumentationService({