@@ -8,7 +8,11 @@ import React from 'react';
8
8
import CreateViewDialog from './CreateViewDialog.react' ;
9
9
import * as ViewPreferences from 'lib/ViewPreferences' ;
10
10
import { withRouter } from 'lib/withRouter' ;
11
+ import subscribeTo from 'lib/subscribeTo' ;
12
+ import { ActionTypes as SchemaActionTypes } from 'lib/stores/SchemaStore' ;
11
13
14
+ export default
15
+ @subscribeTo ( 'Schema' , 'schema' )
12
16
@withRouter
13
17
class Views extends TableView {
14
18
constructor ( ) {
@@ -28,12 +32,16 @@ class Views extends TableView {
28
32
}
29
33
30
34
componentWillMount ( ) {
31
- this . loadViews ( this . context ) ;
35
+ this . props . schema
36
+ . dispatch ( SchemaActionTypes . FETCH )
37
+ . then ( ( ) => this . loadViews ( this . context ) ) ;
32
38
}
33
39
34
40
componentWillReceiveProps ( nextProps , nextContext ) {
35
41
if ( this . context !== nextContext ) {
36
- this . loadViews ( nextContext ) ;
42
+ this . props . schema
43
+ . dispatch ( SchemaActionTypes . FETCH )
44
+ . then ( ( ) => this . loadViews ( nextContext ) ) ;
37
45
}
38
46
if ( this . props . params . name !== nextProps . params . name || this . context !== nextContext ) {
39
47
this . loadData ( nextProps . params . name ) ;
@@ -154,8 +162,8 @@ class Views extends TableView {
154
162
renderExtras ( ) {
155
163
if ( this . state . showCreate ) {
156
164
let classNames = [ ] ;
157
- if ( this . context ? .schema ) {
158
- const classes = this . context . schema . data . get ( 'classes' ) ;
165
+ if ( this . props . schema ?. data ) {
166
+ const classes = this . props . schema . data . get ( 'classes' ) ;
159
167
if ( classes ) {
160
168
classNames = Object . keys ( classes . toObject ( ) ) ;
161
169
}
@@ -182,5 +190,3 @@ class Views extends TableView {
182
190
return null ;
183
191
}
184
192
}
185
-
186
- export default Views ;
0 commit comments