@@ -87,9 +87,13 @@ class SurveyShow extends Component<any, State> {
87
87
}
88
88
}
89
89
90
+ surveyIsRunning ( survey ) {
91
+ return survey && survey . state == "running"
92
+ }
93
+
90
94
showHistograms ( ) {
91
95
const { survey } = this . props
92
- return survey && survey . state == "running"
96
+ return this . surveyIsRunning ( survey )
93
97
}
94
98
95
99
stopSurvey ( ) {
@@ -201,7 +205,7 @@ class SurveyShow extends Component<any, State> {
201
205
202
206
let stopComponent = null
203
207
let switchComponent = null
204
- if ( ! readOnly && survey . state == "running" ) {
208
+ if ( ! readOnly && this . surveyIsRunning ( survey ) ) {
205
209
if ( project . level == "owner" || project . level == "admin" ) {
206
210
let lockOpenClass , lockClass
207
211
if ( survey . locked ) {
@@ -303,6 +307,7 @@ class SurveyShow extends Component<any, State> {
303
307
label : "Success rate" ,
304
308
color : "#000000" ,
305
309
id : "successRate" ,
310
+ isRunning : this . surveyIsRunning ( survey ) ,
306
311
values : percentages . successRate . map ( ( v ) => ( {
307
312
time : new Date ( v . date ) ,
308
313
value : Number ( v . percent ) ,
@@ -311,7 +316,7 @@ class SurveyShow extends Component<any, State> {
311
316
312
317
313
318
forecasts = forecasts . map ( ( d ) => {
314
- if ( this . shouldForecast ( d , 100 , survey . state == "running" ) ) {
319
+ if ( this . shouldForecast ( d , 100 , this . surveyIsRunning ( survey ) ) ) {
315
320
return {
316
321
...d ,
317
322
forecast : this . getForecast ( d . values [ 0 ] , d . values [ d . values . length - 1 ] , 100 ) ,
0 commit comments