diff --git a/src/Components/Editor/Editor.tsx b/src/Components/Editor/Editor.tsx
index 507fa58..5309f8f 100644
--- a/src/Components/Editor/Editor.tsx
+++ b/src/Components/Editor/Editor.tsx
@@ -279,14 +279,11 @@ export function Editor(props: IEditorProps): JSX.Element {
return (
setNewHistory(
SelectContainer(
container,
diff --git a/src/Components/UI/UI.tsx b/src/Components/UI/UI.tsx
index c9afe1e..2c4683a 100644
--- a/src/Components/UI/UI.tsx
+++ b/src/Components/UI/UI.tsx
@@ -1,16 +1,11 @@
import * as React from 'react';
import { ElementsList } from '../ElementsList/ElementsList';
import { History } from '../History/History';
-import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
-import { IContainerModel } from '../../Interfaces/IContainerModel';
-import { IHistoryState } from '../../Interfaces/IHistoryState';
import { Bar } from '../Bar/Bar';
-import { IAvailableSymbol } from '../../Interfaces/IAvailableSymbol';
import { Symbols } from '../Symbols/Symbols';
import { SymbolsSidebar } from '../SymbolsList/SymbolsList';
import { PropertyType } from '../../Enums/PropertyType';
import { Messages } from '../Messages/Messages';
-import { ICategory } from '../../Interfaces/ICategory';
import { Sidebar } from '../Sidebar/Sidebar';
import { Components } from '../Components/Components';
import { Viewer } from '../Viewer/Viewer';
@@ -19,17 +14,11 @@ import { IMessage } from '../../Interfaces/IMessage';
import { DISABLE_API } from '../../utils/default';
import { UseWorker, UseAsync } from './UseWorker';
import { FindContainerById } from '../../utils/itertools';
-import { IAPIConfiguration } from '../../Interfaces/IAPIConfiguration';
+import { IEditorState } from '../../Interfaces/IEditorState';
+import { GetCurrentHistoryState } from '../Editor/Editor';
export interface IUIProps {
- selectedContainer: IContainerModel | undefined
- current: IHistoryState
- history: IHistoryState[]
- historyCurrentStep: number
- availableContainers: IAvailableContainer[]
- availableSymbols: IAvailableSymbol[]
- categories: ICategory[]
- apiConfiguration: IAPIConfiguration | undefined
+ editorState: IEditorState
selectContainer: (containerId: string) => void
deleteContainer: (containerId: string) => void
onPropertyChange: (key: string, value: string | number | boolean | number[], type?: PropertyType) => void
@@ -67,21 +56,23 @@ function UseSetOrToggleSidebar(
};
}
-export function UI(props: IUIProps): JSX.Element {
+export function UI({ editorState, ...methods }: IUIProps): JSX.Element {
const [selectedSidebar, setSelectedSidebar] = React.useState(SidebarType.Components);
const [messages, setMessages] = React.useState([]);
+ const current = GetCurrentHistoryState(editorState.history, editorState.historyCurrentStep);
+ const configuration = editorState.configuration;
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (window.Worker && !DISABLE_API) {
UseWorker(
- props.current,
- props.apiConfiguration?.apiGetFeedbackUrl,
+ current,
+ configuration.APIConfiguration?.apiGetFeedbackUrl,
setMessages
);
} else if (!DISABLE_API) {
UseAsync(
- props.current,
- props.apiConfiguration?.apiGetFeedbackUrl,
+ current,
+ configuration.APIConfiguration?.apiGetFeedbackUrl,
setMessages
);
}
@@ -94,61 +85,63 @@ export function UI(props: IUIProps): JSX.Element {
let leftChildren: JSX.Element = (<>>);
let rightChildren: JSX.Element = (<>>);
- const mainContainer = FindContainerById(props.current.containers, props.current.mainContainer)
+ const mainContainer = FindContainerById(current.containers, current.mainContainer);
if (mainContainer === undefined) {
throw new Error('Tried to initialized UI but there is no main container!');
}
+ const selectedContainer = FindContainerById(current.containers, current.selectedContainerId);
+
switch (selectedSidebar) {
case SidebarType.Components:
leftSidebarTitle = 'Components';
leftChildren = ;
rightSidebarTitle = 'Elements';
rightChildren = ;
break;
case SidebarType.Symbols:
leftSidebarTitle = 'Symbols';
leftChildren = ;
rightSidebarTitle = 'Symbols';
rightChildren = ;
break;
case SidebarType.History:
leftSidebarTitle = 'Timeline';
leftChildren = ;
break;
case SidebarType.Messages:
leftSidebarTitle = 'Messages';
leftChildren = setMessages([])}
/>;
@@ -157,8 +150,8 @@ export function UI(props: IUIProps): JSX.Element {
case SidebarType.Settings:
leftSidebarTitle = 'Settings';
leftChildren = ;
break;
}
@@ -166,7 +159,7 @@ export function UI(props: IUIProps): JSX.Element {
const isLeftSidebarOpen = selectedSidebar !== SidebarType.None;
const isRightSidebarOpen = selectedSidebar === SidebarType.Components || selectedSidebar === SidebarType.Symbols;
- let isLeftSidebarOpenClasses = new Set([
+ const isLeftSidebarOpenClasses = new Set([
'left-sidebar',
'left-16',
'-bottom-full',
@@ -222,9 +215,9 @@ export function UI(props: IUIProps): JSX.Element {