Create wt-odlux directory
[ccsdk/features.git] / sdnr / wt-odlux / odlux / framework / src / components / routing / appFrame.tsx
1 /**
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt odlux
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 import React from 'react';
19
20 import { connect, Connect } from '../../flux/connect';
21
22 import { SetTitleAction } from '../../actions/titleActions';
23 import { AddErrorInfoAction } from '../../actions/errorActions';
24
25 import { IconType } from '../../models/iconDefinition';
26
27 export interface IAppFrameProps  {
28   title: string;
29   icon?: IconType;
30   appId?: string
31 }
32
33 /**
34  * Represents a component to wich will embed each single app providing the
35  * functionality to update the title and implement an exeprion border.
36  */
37 export class AppFrame extends React.Component<IAppFrameProps & Connect> {
38
39   public render(): JSX.Element {
40     return (
41       <div style={{ flex: "1", overflow: "hidden", display: "flex", flexDirection: "column" }}>
42         { this.props.children }
43       </div>
44      )
45     }
46
47   public componentDidMount() {
48     this.props.dispatch(new SetTitleAction(this.props.title, this.props.icon, this.props.appId));
49   }
50   public componentDidCatch(error: Error | null, info: object) {
51     this.props.dispatch(new AddErrorInfoAction({ error, info }));
52   }
53 }
54
55 export default connect()(AppFrame);