Skip to content

Commit

Permalink
Фикс определения типа открываемой вкладки (#432)
Browse files Browse the repository at this point in the history
Closes #429
  • Loading branch information
Roundabout1 authored Sep 5, 2024
1 parent 1e0816e commit 46607f2
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/renderer/src/components/MainContainer/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { twMerge } from 'tailwind-merge';
import { CodeEditor, DiagramEditor } from '@renderer/components';
import { SerialMonitorTab } from '@renderer/components/SerialMonitor';
import { useTabs } from '@renderer/store/useTabs';
import { Tab as TabType } from '@renderer/types/tabs';

import { Tab } from './Tab';

Expand Down Expand Up @@ -35,6 +36,21 @@ export const Tabs: React.FC = () => {
return <NotInitialized />;
}

const selectTab = (item: TabType) => {
switch (item.type) {
case 'editor':
return <DiagramEditor />;
case 'transition':
case 'state':
case 'code':
return <CodeEditor initialValue={item.code} language={item.language} />;
case 'serialMonitor':
return <SerialMonitorTab />;
default:
return undefined;
}
};

return (
<>
<section
Expand Down Expand Up @@ -63,13 +79,7 @@ export const Tabs: React.FC = () => {
key={item.name}
className={twMerge('hidden h-[calc(100vh-44.19px)]', activeTab === item.name && 'block')}
>
{item.type === 'editor' ? (
<DiagramEditor />
) : item.type === 'code' ? (
<CodeEditor initialValue={item.code} language={item.language} />
) : (
<SerialMonitorTab />
)}
{selectTab(item)}
</div>
))}
</>
Expand Down

0 comments on commit 46607f2

Please sign in to comment.