Skip to content

Commit

Permalink
fixed visibility of Blocks visualiser
Browse files Browse the repository at this point in the history
  • Loading branch information
catosaurusrex2003 committed Oct 1, 2024
1 parent a3f6fe0 commit 8d75a69
Show file tree
Hide file tree
Showing 2 changed files with 11,443 additions and 13,433 deletions.
19 changes: 15 additions & 4 deletions apps/studio/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -54,9 +54,13 @@ interface SidebarProps {}

export const Sidebar: FunctionComponent<SidebarProps> = () => {
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;
}
Expand Down Expand Up @@ -125,6 +129,13 @@ export const Sidebar: FunctionComponent<SidebarProps> = () => {
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 (
<div className="flex flex-col bg-gray-800 shadow-lg border-r border-gray-700 justify-between" id="sidebar">
Expand Down
Loading

0 comments on commit 8d75a69

Please sign in to comment.