From 8d75a695f3711a8fe00ea2aae563e0346251fe15 Mon Sep 17 00:00:00 2001 From: catosaurusrex2003 Date: Tue, 1 Oct 2024 21:50:11 +0530 Subject: [PATCH 1/3] fixed visibility of Blocks visualiser --- apps/studio/src/components/Sidebar.tsx | 19 +- pnpm-lock.yaml | 24857 +++++++++++------------ 2 files changed, 11443 insertions(+), 13433 deletions(-) diff --git a/apps/studio/src/components/Sidebar.tsx b/apps/studio/src/components/Sidebar.tsx index ef83bbfdb..b6912b88b 100644 --- a/apps/studio/src/components/Sidebar.tsx +++ b/apps/studio/src/components/Sidebar.tsx @@ -6,7 +6,7 @@ import { SettingsModal, ConfirmNewFileModal } from './Modals'; import { usePanelsState, panelsState, useDocumentsState } from '@/state'; -import type { FunctionComponent, ReactNode } from 'react'; +import { useEffect, useState, type FunctionComponent, type ReactNode } from 'react'; import type { PanelsState } from '@/state/panels.state'; import { driverObj } from '@/helpers/driver'; @@ -54,9 +54,13 @@ interface SidebarProps {} export const Sidebar: FunctionComponent = () => { const { show, secondaryPanelType } = usePanelsState(); - const document = useDocumentsState(state => state.documents['asyncapi']?.document) || null; - const isV3 = document?.version().startsWith('3.'); - + const [document, hasErrors] = useDocumentsState((state) => [ + state.documents['asyncapi']?.document, + state.documents['asyncapi']?.diagnostics?.errors.length > 0, + ]) || [null, false]; + + const [isV3, setIsV3] = useState(document?.version().startsWith('3.')); + if (show.activityBar === false) { return null; } @@ -125,6 +129,13 @@ export const Sidebar: FunctionComponent = () => { const getCurrentTourStep = localStorage.getItem('currentTourStep'); driverObj.drive(parseInt(getCurrentTourStep ?? '0', 10)); }; + + useEffect(() => { + // if the document has no errors then only update the setIsV3 variable + if (!hasErrors) { + setIsV3(document?.version().startsWith('3.')); + } + }, [document]); return (