|
@@ -15,7 +15,7 @@ import { GlobalState } from "../../components/globalState";
|
|
require("./actionTabs.scss");
|
|
require("./actionTabs.scss");
|
|
|
|
|
|
interface IActionTabsComponentProps {
|
|
interface IActionTabsComponentProps {
|
|
- scene: Scene,
|
|
|
|
|
|
+ scene?: Scene,
|
|
noCommands?: boolean,
|
|
noCommands?: boolean,
|
|
noHeader?: boolean,
|
|
noHeader?: boolean,
|
|
noExpand?: boolean,
|
|
noExpand?: boolean,
|
|
@@ -23,7 +23,7 @@ interface IActionTabsComponentProps {
|
|
popupMode?: boolean,
|
|
popupMode?: boolean,
|
|
onPopup?: () => void,
|
|
onPopup?: () => void,
|
|
onClose?: () => void,
|
|
onClose?: () => void,
|
|
- globalState: GlobalState
|
|
|
|
|
|
+ globalState?: GlobalState
|
|
}
|
|
}
|
|
|
|
|
|
export class ActionTabsComponent extends React.Component<IActionTabsComponentProps, { selectedEntity: any, selectedIndex: number }> {
|
|
export class ActionTabsComponent extends React.Component<IActionTabsComponentProps, { selectedEntity: any, selectedIndex: number }> {
|
|
@@ -36,53 +36,66 @@ export class ActionTabsComponent extends React.Component<IActionTabsComponentPro
|
|
|
|
|
|
let initialIndex = 0;
|
|
let initialIndex = 0;
|
|
|
|
|
|
- const validationResutls = this.props.globalState.validationResults;
|
|
|
|
- if (validationResutls) {
|
|
|
|
- if (validationResutls.issues.numErrors || validationResutls.issues.numWarnings) {
|
|
|
|
- initialIndex = 3;
|
|
|
|
|
|
+ if(this.props.globalState){
|
|
|
|
+ const validationResutls = this.props.globalState.validationResults;
|
|
|
|
+ if (validationResutls) {
|
|
|
|
+ if (validationResutls.issues.numErrors || validationResutls.issues.numWarnings) {
|
|
|
|
+ initialIndex = 3;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
this.state = { selectedEntity: null, selectedIndex: initialIndex }
|
|
this.state = { selectedEntity: null, selectedIndex: initialIndex }
|
|
}
|
|
}
|
|
|
|
|
|
componentWillMount() {
|
|
componentWillMount() {
|
|
- this._onSelectionChangeObserver = this.props.globalState.onSelectionChangedObservable.add((entity) => {
|
|
|
|
- this.setState({ selectedEntity: entity, selectedIndex: 0 });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- this._onTabChangedObserver = this.props.globalState.onTabChangedObservable.add(index => {
|
|
|
|
- this.setState({ selectedIndex: index });
|
|
|
|
- });
|
|
|
|
|
|
+ if(this.props.globalState){
|
|
|
|
+ this._onSelectionChangeObserver = this.props.globalState.onSelectionChangedObservable.add((entity) => {
|
|
|
|
+ this.setState({ selectedEntity: entity, selectedIndex: 0 });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this._onTabChangedObserver = this.props.globalState.onTabChangedObservable.add(index => {
|
|
|
|
+ this.setState({ selectedIndex: index });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
- if (this._onSelectionChangeObserver) {
|
|
|
|
- this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangeObserver);
|
|
|
|
- }
|
|
|
|
|
|
+ if(this.props.globalState){
|
|
|
|
+ if (this._onSelectionChangeObserver) {
|
|
|
|
+ this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangeObserver);
|
|
|
|
+ }
|
|
|
|
|
|
- if (this._onTabChangedObserver) {
|
|
|
|
- this.props.globalState.onTabChangedObservable.remove(this._onTabChangedObserver);
|
|
|
|
|
|
+ if (this._onTabChangedObserver) {
|
|
|
|
+ this.props.globalState.onTabChangedObservable.remove(this._onTabChangedObserver);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
changeSelectedTab(index: number) {
|
|
changeSelectedTab(index: number) {
|
|
- this.props.globalState.onTabChangedObservable.notifyObservers(index);
|
|
|
|
|
|
+ if(this.props.globalState){
|
|
|
|
+ this.props.globalState.onTabChangedObservable.notifyObservers(index);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
renderContent() {
|
|
renderContent() {
|
|
- return (
|
|
|
|
- <TabsComponent selectedIndex={this.state.selectedIndex} onSelectedIndexChange={(value) => this.changeSelectedTab(value)}>
|
|
|
|
- <PropertyGridTabComponent
|
|
|
|
- title="Properties" icon={faFileAlt} scene={this.props.scene} selectedEntity={this.state.selectedEntity}
|
|
|
|
- globalState={this.props.globalState}
|
|
|
|
- onSelectionChangedObservable={this.props.globalState.onSelectionChangedObservable}
|
|
|
|
- onPropertyChangedObservable={this.props.globalState.onPropertyChangedObservable} />
|
|
|
|
- <DebugTabComponent title="Debug" icon={faBug} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
- <StatisticsTabComponent title="Statistics" icon={faChartBar} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
- <ToolsTabComponent title="Tools" icon={faWrench} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
- </TabsComponent>
|
|
|
|
- )
|
|
|
|
|
|
+ if(this.props.globalState && this.props.scene){
|
|
|
|
+ return (
|
|
|
|
+ <TabsComponent selectedIndex={this.state.selectedIndex} onSelectedIndexChange={(value) => this.changeSelectedTab(value)}>
|
|
|
|
+ <PropertyGridTabComponent
|
|
|
|
+ title="Properties" icon={faFileAlt} scene={this.props.scene} selectedEntity={this.state.selectedEntity}
|
|
|
|
+ globalState={this.props.globalState}
|
|
|
|
+ onSelectionChangedObservable={this.props.globalState.onSelectionChangedObservable}
|
|
|
|
+ onPropertyChangedObservable={this.props.globalState.onPropertyChangedObservable} />
|
|
|
|
+ <DebugTabComponent title="Debug" icon={faBug} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
+ <StatisticsTabComponent title="Statistics" icon={faChartBar} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
+ <ToolsTabComponent title="Tools" icon={faWrench} scene={this.props.scene} globalState={this.props.globalState} />
|
|
|
|
+ </TabsComponent>
|
|
|
|
+ )
|
|
|
|
+ }else{
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
onClose() {
|
|
onClose() {
|
|
@@ -105,7 +118,7 @@ export class ActionTabsComponent extends React.Component<IActionTabsComponentPro
|
|
<div id="actionTabs">
|
|
<div id="actionTabs">
|
|
{
|
|
{
|
|
!this.props.noHeader &&
|
|
!this.props.noHeader &&
|
|
- <HeaderComponent title="INSPECTOR" handleBack={true} noClose={this.props.noClose} noExpand={this.props.noExpand} noCommands={this.props.noCommands} onClose={() => this.onClose()} onPopup={() => this.onPopup()} onSelectionChangedObservable={this.props.globalState.onSelectionChangedObservable} />
|
|
|
|
|
|
+ <HeaderComponent title="INSPECTOR" handleBack={true} noClose={this.props.noClose} noExpand={this.props.noExpand} noCommands={this.props.noCommands} onClose={() => this.onClose()} onPopup={() => this.onPopup()} onSelectionChangedObservable={this.props.globalState ? this.props.globalState.onSelectionChangedObservable : undefined} />
|
|
}
|
|
}
|
|
{this.renderContent()}
|
|
{this.renderContent()}
|
|
</div>
|
|
</div>
|
|
@@ -128,7 +141,7 @@ export class ActionTabsComponent extends React.Component<IActionTabsComponentPro
|
|
<Resizable id="actionTabs" minWidth={300} maxWidth={600} size={{ height: "100%" }} minHeight="100%" enable={{ top: false, right: false, bottom: false, left: true, topRight: false, bottomRight: false, bottomLeft: false, topLeft: false }}>
|
|
<Resizable id="actionTabs" minWidth={300} maxWidth={600} size={{ height: "100%" }} minHeight="100%" enable={{ top: false, right: false, bottom: false, left: true, topRight: false, bottomRight: false, bottomLeft: false, topLeft: false }}>
|
|
{
|
|
{
|
|
!this.props.noHeader &&
|
|
!this.props.noHeader &&
|
|
- <HeaderComponent title="INSPECTOR" handleBack={true} noClose={this.props.noClose} noExpand={this.props.noExpand} noCommands={this.props.noCommands} onClose={() => this.onClose()} onPopup={() => this.onPopup()} onSelectionChangedObservable={this.props.globalState.onSelectionChangedObservable} />
|
|
|
|
|
|
+ <HeaderComponent title="INSPECTOR" handleBack={true} noClose={this.props.noClose} noExpand={this.props.noExpand} noCommands={this.props.noCommands} onClose={() => this.onClose()} onPopup={() => this.onPopup()} onSelectionChangedObservable={this.props.globalState ? this.props.globalState.onSelectionChangedObservable : undefined} />
|
|
}
|
|
}
|
|
{this.renderContent()}
|
|
{this.renderContent()}
|
|
</Resizable>
|
|
</Resizable>
|