@@ -20,13 +20,15 @@ import RunNowButton from 'dashboard/Data/Jobs/RunNowButton.react';
20
20
import SidebarAction from 'components/Sidebar/SidebarAction' ;
21
21
import StatusIndicator from 'components/StatusIndicator/StatusIndicator.react' ;
22
22
import styles from 'dashboard/Data/Jobs/Jobs.scss' ;
23
+ import browserStyles from 'dashboard/Data/Browser/Browser.scss' ;
23
24
import subscribeTo from 'lib/subscribeTo' ;
24
25
import TableHeader from 'components/Table/TableHeader.react' ;
25
26
import TableView from 'dashboard/TableView.react' ;
26
27
import Toolbar from 'components/Toolbar/Toolbar.react' ;
27
28
28
29
let subsections = {
29
- scheduled : 'Scheduled Jobs' ,
30
+ all : 'All Jobs' ,
31
+ /*scheduled: 'Scheduled Jobs',*/
30
32
status : 'Job Status'
31
33
} ;
32
34
@@ -73,12 +75,7 @@ export default class Jobs extends TableView {
73
75
}
74
76
75
77
componentWillMount ( ) {
76
- this . props . jobs . dispatch ( ActionTypes . FETCH ) . always ( ( ) => {
77
- this . setState ( { loading : false } ) ;
78
- } ) ;
79
- this . context . currentApp . getJobStatus ( ) . then ( ( status ) => {
80
- this . setState ( { jobStatus : status } ) ;
81
- } ) ;
78
+ this . loadData ( ) ;
82
79
}
83
80
84
81
componentWillReceiveProps ( nextProps ) {
@@ -89,6 +86,7 @@ export default class Jobs extends TableView {
89
86
}
90
87
}
91
88
this . action = null ;
89
+ this . loadData ( ) ;
92
90
}
93
91
94
92
navigateToNew ( ) {
@@ -99,18 +97,37 @@ export default class Jobs extends TableView {
99
97
history . push ( this . context . generatePath ( `jobs/edit/${ jobId } ` ) )
100
98
}
101
99
100
+ loadData ( ) {
101
+ this . props . jobs . dispatch ( ActionTypes . FETCH ) . always ( ( ) => {
102
+ this . setState ( { loading : false } ) ;
103
+ } ) ;
104
+ this . context . currentApp . getJobStatus ( ) . then ( ( status ) => {
105
+ this . setState ( { jobStatus : status } ) ;
106
+ } ) ;
107
+ }
108
+
102
109
renderSidebar ( ) {
103
110
let current = this . props . params . section || '' ;
104
111
return (
105
112
< CategoryList current = { current } linkPrefix = { 'jobs/' } categories = { [
106
- { name : 'Scheduled Jobs' , id : 'scheduled' } ,
113
+ /* { name: 'Scheduled Jobs', id: 'scheduled' }, */
114
+ { name : 'All Jobs' , id : 'all' } ,
107
115
{ name : 'Job Status' , id : 'status' }
108
116
] } />
109
117
) ;
110
118
}
111
119
112
120
renderRow ( data ) {
113
- if ( this . props . params . section === 'scheduled' ) {
121
+ if ( this . props . params . section === 'all' ) {
122
+ return (
123
+ < tr key = { data . objectId } >
124
+ < td style = { { width : '60%' } } > { data . jobName } </ td >
125
+ < td className = { styles . buttonCell } >
126
+ < RunNowButton job = { data } width = { '100px' } />
127
+ </ td >
128
+ </ tr >
129
+ ) ;
130
+ } else if ( this . props . params . section === 'scheduled' ) {
114
131
return (
115
132
< tr key = { data . objectId } >
116
133
< td style = { { width : '20%' } } > { data . description } </ td >
@@ -142,7 +159,12 @@ export default class Jobs extends TableView {
142
159
}
143
160
144
161
renderHeaders ( ) {
145
- if ( this . props . params . section === 'scheduled' ) {
162
+ if ( this . props . params . section === 'all' ) {
163
+ return [
164
+ < TableHeader key = 'name' width = { 60 } > Name</ TableHeader > ,
165
+ < TableHeader key = 'actions' width = { 40 } > Actions</ TableHeader > ,
166
+ ] ;
167
+ } else if ( this . props . params . section === 'scheduled' ) {
146
168
return [
147
169
< TableHeader key = 'name' width = { 20 } > Name</ TableHeader > ,
148
170
< TableHeader key = 'func' width = { 20 } > Function</ TableHeader > ,
@@ -160,11 +182,18 @@ export default class Jobs extends TableView {
160
182
}
161
183
162
184
renderEmpty ( ) {
163
- if ( this . props . params . section === 'scheduled ' ) {
185
+ if ( this . props . params . section === 'all ' ) {
164
186
return (
165
187
< EmptyState
166
188
title = 'Cloud Jobs'
167
- description = 'Schedule your Cloud Code functions to run at specific times.'
189
+ description = 'Define Jobs on parse-server with Parse.Cloud.job()'
190
+ icon = 'cloud-happy' />
191
+ ) ;
192
+ } else if ( this . props . params . section === 'scheduled' ) {
193
+ return (
194
+ < EmptyState
195
+ title = 'Cloud Jobs'
196
+ description = 'Scheduling jobs is not supported on parse-server'
168
197
icon = 'cloud-happy' />
169
198
) ;
170
199
} else {
@@ -197,7 +226,7 @@ export default class Jobs extends TableView {
197
226
198
227
tableData ( ) {
199
228
let data = undefined ;
200
- if ( this . props . params . section === 'scheduled' ) {
229
+ if ( this . props . params . section === 'scheduled' || this . props . params . section === 'all' ) {
201
230
if ( this . props . jobs . data ) {
202
231
let jobs = this . props . jobs . data . get ( 'jobs' ) ;
203
232
if ( jobs ) {
@@ -210,13 +239,26 @@ export default class Jobs extends TableView {
210
239
return data ;
211
240
}
212
241
242
+ onRefresh ( ) {
243
+ this . setState ( {
244
+ toDelete : null ,
245
+ jobStatus : undefined ,
246
+ loading : true ,
247
+ } ) ;
248
+ this . loadData ( ) ;
249
+ }
250
+
213
251
renderToolbar ( ) {
214
252
if ( subsections [ this . props . params . section ] ) {
215
253
return (
216
254
< Toolbar
217
255
section = 'Jobs'
218
256
subsection = { subsections [ this . props . params . section ] }
219
257
details = { ReleaseInfo ( { release : this . props . release } ) } >
258
+ < a className = { browserStyles . toolbarButton } onClick = { this . onRefresh . bind ( this ) } >
259
+ < Icon name = 'refresh-solid' width = { 14 } height = { 14 } />
260
+ < span > Refresh</ span >
261
+ </ a >
220
262
{ this . props . availableJobs && this . props . availableJobs . length > 0 ?
221
263
< Button color = 'white' value = 'Schedule a job' onClick = { this . navigateToNew . bind ( this ) } /> : null }
222
264
</ Toolbar >
0 commit comments