aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/src/components/routing/appFrame.tsx
blob: 06ad5b434bd2df5cabbea4c372ec3868f5d2d251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as React from 'react';

import connect, { Connect } from '../../flux/connect';

import { SetTitleAction } from '../../actions/titleActions';
import { AddErrorInfoAction } from '../../actions/errorActions';

import { IconType } from '../../models/iconDefinition';

export interface IAppFrameProps  {
  title: string;
  icon?: IconType;
  appId?: string
}

/**
 * Represents a component to wich will embed each single app providing the
 * functionality to update the title and implement an exeprion border.
 */
export class AppFrame extends React.Component<IAppFrameProps & Connect> {

  public render(): JSX.Element {
    return (
      <div style={{ flex: "1", overflow: "auto", display: "flex", flexDirection: "column" }}>
        { this.props.children }
      </div>
     )
    }

  public componentDidMount() {
    this.props.dispatch(new SetTitleAction(this.props.title, this.props.icon, this.props.appId));
  }
  public componentDidCatch(error: Error | null, info: object) {
    this.props.dispatch(new AddErrorInfoAction({ error, info }));
  }
}

export default connect()(AppFrame);