File tree Expand file tree Collapse file tree 2 files changed +80
-2
lines changed Expand file tree Collapse file tree 2 files changed +80
-2
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ import { PanelEditor } from './PanelEditor';
9
9
const TITLE_HEIGHT = 27 ;
10
10
const PANEL_BORDER = 2 ;
11
11
12
- export interface PanelChromeProps {
12
+ export interface Props {
13
13
panel : PanelModel ;
14
14
dashboard : DashboardModel ;
15
15
component : any ;
16
16
}
17
17
18
- export class PanelChrome extends React . Component < PanelChromeProps , any > {
18
+ export class PanelChrome extends React . Component < Props , any > {
19
19
constructor ( props ) {
20
20
super ( props ) ;
21
21
Original file line number Diff line number Diff line change
1
+ import React , { Component , ComponentClass } from 'react' ;
2
+
3
+ export interface OuterProps {
4
+ type : string ;
5
+ queries : any [ ] ;
6
+ isVisible : boolean ;
7
+ }
8
+
9
+ export interface AddedProps {
10
+ data : any [ ] ;
11
+ }
12
+
13
+ interface State {
14
+ isLoading : boolean ;
15
+ data : any [ ] ;
16
+ }
17
+
18
+ const DataPanel = ( ComposedComponent : ComponentClass < AddedProps & OuterProps > ) => {
19
+ class Wrapper extends Component < OuterProps , State > {
20
+ public static defaultProps = {
21
+ isVisible : true ,
22
+ } ;
23
+
24
+ constructor ( props : OuterProps ) {
25
+ super ( props ) ;
26
+
27
+ this . state = {
28
+ isLoading : false ,
29
+ data : [ ] ,
30
+ } ;
31
+ }
32
+
33
+ public componentDidMount ( ) {
34
+ this . issueQueries ( ) ;
35
+ }
36
+
37
+ public issueQueries = ( ) => {
38
+ const { queries, isVisible } = this . props ;
39
+
40
+ if ( ! isVisible ) {
41
+ return ;
42
+ }
43
+
44
+ if ( ! queries . length ) {
45
+ this . setState ( { data : [ { message : 'no queries' } ] } ) ;
46
+ return ;
47
+ }
48
+
49
+ this . setState ( { isLoading : true } ) ;
50
+ } ;
51
+
52
+ public render ( ) {
53
+ const { data, isLoading } = this . state ;
54
+
55
+ if ( ! data . length ) {
56
+ return (
57
+ < div className = "no-data" >
58
+ < p > No Data</ p >
59
+ </ div >
60
+ ) ;
61
+ }
62
+
63
+ if ( isLoading ) {
64
+ return (
65
+ < div className = "loading" >
66
+ < p > Loading</ p >
67
+ </ div >
68
+ ) ;
69
+ }
70
+
71
+ return < ComposedComponent { ...this . props } data = { data } /> ;
72
+ }
73
+ }
74
+
75
+ return Wrapper ;
76
+ } ;
77
+
78
+ export default DataPanel ;
You can’t perform that action at this time.
0 commit comments