Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: visibility of Blocks visualiser when error #1145

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-garlics-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/studio": patch
---

fixed the rendering of block visualiser when document has errors
25 changes: 18 additions & 7 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,12 +54,12 @@ 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.');

if (show.activityBar === false) {
return null;
}
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.'));

let navigation: NavItem[] = [
// navigation
Expand Down Expand Up @@ -125,6 +125,17 @@ 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]);

if (show.activityBar === false) {
return null;
}

return (
<div className="flex flex-col bg-gray-800 shadow-lg border-r border-gray-700 justify-between" id="sidebar">
Expand Down
Loading
Loading