import React, { Fragment, useEffect } from 'react'; import { StepAnalysisMenuPaneProps, StepAnalysisMenuPane } from './StepAnalysisMenuPane'; import { StepAnalysisSelectedPane, StepAnalysisSelectedPaneStateProps } from './StepAnalysisSelectedPane'; import { LoadingOverlay } from '../../Components'; import { StepAnalysisType } from '../../Utils/StepAnalysisUtils'; import './StepAnalysisView.scss'; export type StepAnalysisStateProps = StepAnalysisUnopenedPaneTypedProps | StepAnalysisLoadingMenuPaneTypedProps | StepAnalysisMenuPaneTypedProps | StepAnalysisSelectedPaneTypedProps; export interface StepAnalysisUnopenedPaneTypedProps { type: 'unopened-pane'; errorMessage: string | null; } export interface StepAnalysisLoadingMenuPaneTypedProps { type: 'loading-menu-pane'; } export type StepAnalysisMenuPaneTypedProps = { type: 'analysis-menu'; } & StepAnalysisMenuPaneProps; export type StepAnalysisSelectedPaneTypedProps = { type: 'selected-analysis'; } & StepAnalysisSelectedPaneStateProps; export interface StepAnalysisEventHandlers { loadChoice: (choice: StepAnalysisType) => void; loadSavedAnalysis: () => void; toggleDescription: () => void; toggleParameters: () => void; updateParamValues: (newParamValues: Record) => void; onFormSubmit: () => void; renameAnalysis: (newDisplayName: string) => void; duplicateAnalysis: () => void; } export const StepAnalysisView: React.SFC = props => { // only call this once useEffect(() => { props.loadSavedAnalysis() }, []); return ( { props.type === 'unopened-pane' &&
{ props.errorMessage != null &&

An error occurred while loading this analysis

{props.errorMessage}

}
} { props.type === 'loading-menu-pane' && (
Loading saved analysis...
) } { props.type === 'analysis-menu' && } { props.type === 'selected-analysis' && }
) }