From a6ae88371f6c304d07355c211f5533ddbdeb840f Mon Sep 17 00:00:00 2001 From: Dev Catalin <20538711+devcatalin@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:20:06 +0300 Subject: [PATCH] feat: scroll to current dry run --- .../ExplorerPane/DryRunsPane/DryRunsPane.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/organisms/ExplorerPane/DryRunsPane/DryRunsPane.tsx b/src/components/organisms/ExplorerPane/DryRunsPane/DryRunsPane.tsx index c01471fd8..9efdc7e6a 100644 --- a/src/components/organisms/ExplorerPane/DryRunsPane/DryRunsPane.tsx +++ b/src/components/organisms/ExplorerPane/DryRunsPane/DryRunsPane.tsx @@ -1,4 +1,4 @@ -import {useRef} from 'react'; +import {useLayoutEffect, useRef} from 'react'; import {Skeleton} from 'antd'; @@ -27,6 +27,8 @@ const DryRunsPane: React.FC = () => { const list = useAppSelector(dryRunNodesSelector); const isLoading = useAppSelector(state => (state.main.previewOptions.isLoading ? true : state.ui.isFolderLoading)); + const preview = useAppSelector(state => state.main.preview); + const ref = useRef(null); const rowVirtualizer = useVirtualizer({ @@ -36,6 +38,30 @@ const DryRunsPane: React.FC = () => { scrollToFn: elementScroll, }); + useLayoutEffect(() => { + if (!preview) { + return; + } + + const index = list.findIndex(item => { + if (item.type === 'command' && preview.type === 'command') { + return item.commandId === preview.commandId; + } + if (item.type === 'helm-values' && preview.type === 'helm') { + return item.valuesId === preview.valuesFileId; + } + if (item.type === 'helm-config' && preview.type === 'helm-config') { + return item.configId === preview.configId; + } + if (item.type === 'kustomize' && preview.type === 'kustomize') { + return item.kustomizationId === preview.kustomizationId; + } + return false; + }); + + rowVirtualizer.scrollToIndex(index); + }, [preview, list, rowVirtualizer]); + if (isLoading) { return (