Skip to content

Commit eab8cf3

Browse files
committed
fix: populate classes in Views dialog
1 parent 5f61237 commit eab8cf3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/dashboard/Data/Views/Views.react.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import React from 'react';
88
import CreateViewDialog from './CreateViewDialog.react';
99
import * as ViewPreferences from 'lib/ViewPreferences';
1010
import { withRouter } from 'lib/withRouter';
11+
import subscribeTo from 'lib/subscribeTo';
12+
import { ActionTypes as SchemaActionTypes } from 'lib/stores/SchemaStore';
1113

14+
export default
15+
@subscribeTo('Schema', 'schema')
1216
@withRouter
1317
class Views extends TableView {
1418
constructor() {
@@ -28,12 +32,16 @@ class Views extends TableView {
2832
}
2933

3034
componentWillMount() {
31-
this.loadViews(this.context);
35+
this.props.schema
36+
.dispatch(SchemaActionTypes.FETCH)
37+
.then(() => this.loadViews(this.context));
3238
}
3339

3440
componentWillReceiveProps(nextProps, nextContext) {
3541
if (this.context !== nextContext) {
36-
this.loadViews(nextContext);
42+
this.props.schema
43+
.dispatch(SchemaActionTypes.FETCH)
44+
.then(() => this.loadViews(nextContext));
3745
}
3846
if (this.props.params.name !== nextProps.params.name || this.context !== nextContext) {
3947
this.loadData(nextProps.params.name);
@@ -154,8 +162,8 @@ class Views extends TableView {
154162
renderExtras() {
155163
if (this.state.showCreate) {
156164
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');
159167
if (classes) {
160168
classNames = Object.keys(classes.toObject());
161169
}
@@ -182,5 +190,3 @@ class Views extends TableView {
182190
return null;
183191
}
184192
}
185-
186-
export default Views;

0 commit comments

Comments
 (0)