1
1
import i18n from '@dhis2/d2-i18n'
2
2
import { PropTypes } from '@dhis2/prop-types'
3
- import Sidebar from 'd2-ui/lib/sidebar/Sidebar.component'
4
3
import { Card , CardText } from 'material-ui/Card'
5
4
import CircularProgress from 'material-ui/CircularProgress'
6
5
import FontIcon from 'material-ui/FontIcon'
7
6
import LinearProgress from 'material-ui/LinearProgress'
8
- import Snackbar from 'material-ui/Snackbar'
9
7
import React from 'react'
10
8
import actions from '../actions'
11
9
import appHubStore from '../stores/appHub.store'
@@ -43,20 +41,16 @@ const styles = {
43
41
fontWeight : 300 ,
44
42
maxWidth : 734 ,
45
43
} ,
46
- snackbar : {
47
- // left: '2rem',
48
- right : 'initial' ,
49
- } ,
50
44
menuLabel : {
51
45
position : 'relative' ,
52
46
top : - 6 ,
53
47
marginLeft : 16 ,
54
48
} ,
55
49
}
56
50
57
- class App extends React . Component {
58
- constructor ( props , context ) {
59
- super ( props , context )
51
+ class CustomApps extends React . Component {
52
+ constructor ( props ) {
53
+ super ( props )
60
54
61
55
this . state = {
62
56
installedApps : [ ] ,
@@ -66,24 +60,6 @@ class App extends React.Component {
66
60
appHub : { } ,
67
61
lastUpdate : null ,
68
62
}
69
-
70
- // Bind 'this' for functions that need it
71
- ; [
72
- 'setSection' ,
73
- 'progress' ,
74
- 'closeSnackbar' ,
75
- 'showSnackbar' ,
76
- 'search' ,
77
- ] . forEach ( fn => {
78
- this [ fn ] = this [ fn ] . bind ( this )
79
- } )
80
- }
81
-
82
- getChildContext ( ) {
83
- return {
84
- d2 : this . props . d2 ,
85
- muiTheme : AppTheme ,
86
- }
87
63
}
88
64
89
65
componentDidMount ( ) {
@@ -113,16 +89,6 @@ class App extends React.Component {
113
89
actions . refreshApps . subscribe ( ( ) => {
114
90
this . setState ( { uploading : false } )
115
91
} ) ,
116
- actions . showSnackbarMessage . subscribe ( params => {
117
- if ( this . state . snackbar ) {
118
- this . setState ( { snackbar : undefined } )
119
- setTimeout ( ( ) => {
120
- this . setState ( { snackbar : params . data } )
121
- } , 150 )
122
- } else {
123
- this . setState ( { snackbar : params . data } )
124
- }
125
- } ) ,
126
92
actions . installAppVersion . subscribe ( ( { data } ) => {
127
93
const app = appHubStore . getAppFromVersionId ( data [ 0 ] )
128
94
this . setSection (
@@ -136,18 +102,11 @@ class App extends React.Component {
136
102
137
103
componentWillUnmount ( ) {
138
104
this . subscriptions . forEach ( subscription => {
139
- subscription . dispose ( )
105
+ subscription . remove ( )
140
106
} )
141
107
}
142
108
143
- setSection ( key ) {
144
- if ( this . sidebar ) {
145
- this . sidebar . clearSearchBox ( )
146
- }
147
- this . setState ( { section : key , appSearch : undefined } )
148
- }
149
-
150
- progress ( p ) {
109
+ progress = p => {
151
110
if ( p ) {
152
111
if ( p === 1 ) {
153
112
this . setState ( { uploading : false , progress : undefined } )
@@ -159,15 +118,7 @@ class App extends React.Component {
159
118
}
160
119
}
161
120
162
- closeSnackbar ( ) {
163
- this . setState ( { snackbar : undefined } )
164
- }
165
-
166
- showSnackbar ( message ) {
167
- this . setState ( { snackbar : message } )
168
- }
169
-
170
- search ( text ) {
121
+ search = text => {
171
122
if ( text . length > 0 ) {
172
123
this . setState ( {
173
124
appSearch : this . state . installedApps
@@ -219,7 +170,6 @@ class App extends React.Component {
219
170
< CircularProgress
220
171
mode = "indeterminate"
221
172
color = "#6688AA"
222
- // size={0.75}
223
173
value = { this . state . progress }
224
174
/>
225
175
< br />
@@ -234,14 +184,13 @@ class App extends React.Component {
234
184
235
185
renderSection ( key , apps , showUpload ) {
236
186
if ( key === 'store' ) {
237
- return < AppHub appHub = { this . state . appHub } d2 = { this . props . d2 } />
187
+ return < AppHub appHub = { this . state . appHub } />
238
188
}
239
189
240
190
const filter = ( key && key . toString ( ) . toUpperCase ( ) ) || 'APP'
241
191
242
192
return (
243
193
< AppList
244
- d2 = { this . props . d2 }
245
194
installedApps = { apps }
246
195
uploadProgress = { this . progress }
247
196
transitionUnmount = { this . state . unmountSection }
@@ -317,29 +266,10 @@ class App extends React.Component {
317
266
) ,
318
267
} ) )
319
268
320
- const reffer = r => {
321
- this . sidebar = r
322
- }
323
-
324
269
return (
325
270
< div className = "app" >
326
271
< SelfUpdateNoticeBox appHub = { this . state . appHub } />
327
- < Sidebar
328
- sections = { sections }
329
- currentSection = { this . state . section }
330
- onChangeSection = { this . setSection }
331
- showSearchField
332
- onChangeSearchText = { this . search }
333
- ref = { reffer }
334
- />
335
- < Snackbar
336
- message = { this . state . snackbar || '' }
337
- autoHideDuration = { 2500 }
338
- onRequestClose = { this . closeSnackbar }
339
- open = { ! ! this . state . snackbar }
340
- style = { styles . snackbar }
341
- />
342
- < div className = "content-area" >
272
+ < div >
343
273
{ this . state . appSearch
344
274
? this . renderSearchResults ( )
345
275
: this . renderSection (
@@ -354,13 +284,5 @@ class App extends React.Component {
354
284
)
355
285
}
356
286
}
357
- App . propTypes = {
358
- d2 : PropTypes . object . isRequired ,
359
- }
360
-
361
- App . childContextTypes = {
362
- d2 : PropTypes . object ,
363
- muiTheme : PropTypes . object ,
364
- }
365
287
366
- export default App
288
+ export default CustomApps
0 commit comments