@@ -11,6 +11,8 @@ import DatasetComponent from './DatasetComponent'
11
11
import DatasetListContainer from '../containers/DatasetListContainer'
12
12
import CommitDetailsContainer from '../containers/CommitDetailsContainer'
13
13
14
+ import { CSSTransition } from 'react-transition-group'
15
+
14
16
import { defaultSidebarWidth } from '../reducers/ui'
15
17
16
18
import {
@@ -21,8 +23,6 @@ import {
21
23
Mutations
22
24
} from '../models/store'
23
25
24
- import { CSSTransition } from 'react-transition-group'
25
-
26
26
export interface DatasetProps {
27
27
// redux state
28
28
ui : UI
@@ -46,6 +46,8 @@ interface DatasetState {
46
46
peername : string
47
47
name : string
48
48
saveIsLoading : boolean
49
+ workingDatasetIsLoading : boolean
50
+ activeTab : string
49
51
}
50
52
51
53
const logo = require ( '../assets/qri-blob-logo-tiny.png' ) //eslint-disable-line
@@ -56,7 +58,9 @@ export default class Dataset extends React.Component<DatasetProps> {
56
58
state = {
57
59
peername : null ,
58
60
name : null ,
59
- saveIsLoading : false
61
+ saveIsLoading : false ,
62
+ workingDatasetIsLoading : true ,
63
+ activeTab : this . props . selections . activeTab
60
64
}
61
65
62
66
componentDidMount ( ) {
@@ -74,7 +78,7 @@ export default class Dataset extends React.Component<DatasetProps> {
74
78
// working dataset is selected and trigger api call(s)
75
79
static getDerivedStateFromProps ( nextProps : DatasetProps , prevState : DatasetState ) {
76
80
const { peername : newPeername , name : newName } = nextProps . selections
77
- const { peername, name } = prevState
81
+ const { peername, name, workingDatasetIsLoading , activeTab } = prevState
78
82
// when new props arrive, compare selections.peername and selections.name to
79
83
// previous. If either is different, fetch data
80
84
if ( ( newPeername !== peername ) || ( newName !== name ) ) {
@@ -87,6 +91,23 @@ export default class Dataset extends React.Component<DatasetProps> {
87
91
}
88
92
}
89
93
94
+ // make sure that the component we are trying to show actually exists in this version of the dataset
95
+ if ( ( workingDatasetIsLoading && ! nextProps . workingDataset . isLoading && nextProps . selections . activeTab === 'status' ) ||
96
+ ( activeTab === 'history' && nextProps . selections . activeTab === 'status' ) ) {
97
+ const { workingDataset, selections, setSelectedListItem } = nextProps
98
+ const { component } = selections
99
+ const { status } = workingDataset
100
+ if ( component === '' || ! status [ component ] ) {
101
+ if ( status [ 'meta' ] ) {
102
+ setSelectedListItem ( 'component' , 'meta' )
103
+ }
104
+ if ( status [ 'body' ] ) {
105
+ setSelectedListItem ( 'component' , 'body' )
106
+ }
107
+ setSelectedListItem ( 'component' , 'schema' )
108
+ }
109
+ }
110
+
90
111
// check state to see if there was a successful save
91
112
// successful save means mutations.save.isLoading was true and is now false,
92
113
// and mutations.save.error is falsy
@@ -101,7 +122,9 @@ export default class Dataset extends React.Component<DatasetProps> {
101
122
}
102
123
103
124
return {
104
- saveIsLoading : newSaveIsLoading
125
+ saveIsLoading : newSaveIsLoading ,
126
+ activeTab : nextProps . selections . activeTab ,
127
+ workingDatasetIsLoading : nextProps . workingDataset . isLoading
105
128
}
106
129
}
107
130
@@ -110,6 +133,7 @@ export default class Dataset extends React.Component<DatasetProps> {
110
133
const { ui, selections, workingDataset } = this . props
111
134
const { showDatasetList, datasetSidebarWidth } = ui
112
135
const {
136
+ name,
113
137
activeTab,
114
138
component : selectedComponent ,
115
139
commit : selectedCommit
@@ -197,7 +221,7 @@ export default class Dataset extends React.Component<DatasetProps> {
197
221
/>
198
222
</ Resizable >
199
223
< div className = 'content-wrapper' >
200
- { showDatasetList && < div className = 'overlay' > </ div > }
224
+ { showDatasetList && < div className = 'overlay' onClick = { toggleDatasetList } > </ div > }
201
225
< div className = 'transition-group' >
202
226
< CSSTransition
203
227
in = { activeTab === 'status' }
@@ -219,7 +243,6 @@ export default class Dataset extends React.Component<DatasetProps> {
219
243
</ CSSTransition >
220
244
</ div >
221
245
</ div >
222
-
223
246
</ div >
224
247
{
225
248
showDatasetList && (
0 commit comments