import React from "react"; import { computed, makeObservable } from "mobx"; import { observer } from "mobx-react"; import { ListNavigation } from "project-editor/ui-components/ListNavigation"; import { SubNavigation, SubNavigationItem } from "project-editor/ui-components/SubNavigation"; import { ProjectContext } from "project-editor/project/context"; import { Page } from "project-editor/features/page/page"; import { Action } from "project-editor/features/action/action"; import { NavigationStore } from "project-editor/store/navigation"; //////////////////////////////////////////////////////////////////////////////// export const VariablesTab = observer( class VariablesTab extends React.Component { static contextType = ProjectContext; declare context: React.ContextType; constructor(props: any) { super(props); makeObservable(this, { localVariables: computed }); } get localVariables() { const editor = this.context.editorsStore.activeEditor; if (editor) { const object = editor.object; if (object instanceof Page || object instanceof Action) { return object.localVariables; } } return undefined; } render() { const items: SubNavigationItem[] = [ { name: NavigationStore.VARIABLES_SUB_NAVIGATION_ITEM_GLOBAL, component: ( ), numItems: this.context.project.variables.globalVariables.length } ]; if (this.context.projectTypeTraits.hasFlowSupport) { if (this.localVariables) { items.push({ name: NavigationStore.VARIABLES_SUB_NAVIGATION_ITEM_LOCAL, component: ( ), numItems: this.localVariables?.length ?? 0 }); } items.push({ name: NavigationStore.VARIABLES_SUB_NAVIGATION_ITEM_STRUCTS, component: ( ), numItems: this.context.project.variables.structures.length }); } items.push({ name: NavigationStore.VARIABLES_SUB_NAVIGATION_ITEM_ENUMS, component: ( ), numItems: this.context.project.variables.enums.length }); return ( ); } } );