15
15
*/
16
16
17
17
class HydratorPlusPlusConfigStore {
18
- constructor ( HydratorPlusPlusConfigDispatcher , HydratorPlusPlusCanvasFactory , GLOBALS , mySettings , HydratorPlusPlusConsoleActions , $stateParams , NonStorePipelineErrorFactory , HydratorPlusPlusHydratorService , $q , HydratorPlusPlusPluginConfigFactory , uuid , $state , HYDRATOR_DEFAULT_VALUES , myHelpers , MY_CONFIG , EventPipe , myPipelineApi , myAppsApi , HydratorPlusPlusNodeService ) {
18
+ constructor ( HydratorPlusPlusConfigDispatcher , HydratorPlusPlusCanvasFactory , GLOBALS , mySettings , HydratorPlusPlusConsoleActions , $stateParams , NonStorePipelineErrorFactory , HydratorPlusPlusHydratorService , $q , HydratorPlusPlusPluginConfigFactory , uuid , $state , HYDRATOR_DEFAULT_VALUES , myHelpers , MY_CONFIG , EventPipe , myPipelineApi , myAppsApi , HydratorPlusPlusNodeService , myAlertOnValium ) {
19
19
'ngInject' ;
20
20
this . state = { } ;
21
21
this . mySettings = mySettings ;
@@ -36,6 +36,7 @@ class HydratorPlusPlusConfigStore {
36
36
this . myPipelineApi = myPipelineApi ;
37
37
this . myAppsApi = myAppsApi ;
38
38
this . isDistributed = MY_CONFIG . isEnterprise ? true : false ;
39
+ this . myAlertOnValium = myAlertOnValium ;
39
40
40
41
this . changeListeners = [ ] ;
41
42
this . setDefaults ( ) ;
@@ -70,7 +71,28 @@ class HydratorPlusPlusConfigStore {
70
71
this . changeListeners . splice ( index , 1 ) ;
71
72
} ;
72
73
}
74
+ checkPipelineJsonSize ( ) {
75
+ const MB = 1024 * 1024 ; // Bytes
76
+ try {
77
+ const pipelineJson = this . getConfigForExport ( ) ;
78
+ delete pipelineJson . __ui__ ;
79
+ const jsonBlob = new Blob ( [ JSON . stringify ( pipelineJson , null , 4 ) ] , { type : 'application/json' } ) ;
80
+ const blobSize = jsonBlob . size || 1 ;
81
+ const blobSizeInMBRounded = ( blobSize / MB ) . toFixed ( 2 ) ;
82
+ if ( jsonBlob . size > 2 * MB ) {
83
+ this . myAlertOnValium . show ( {
84
+ type : "danger" ,
85
+ content : `Pipeline size is ${ blobSizeInMBRounded } MB. Pipelines larger than 2MB are not supported.` ,
86
+ } ) ;
87
+ return false ;
88
+ }
89
+ } catch ( e ) {
90
+ // pass
91
+ }
92
+ return true ;
93
+ }
73
94
emitChange ( ) {
95
+ this . checkPipelineJsonSize ( ) ;
74
96
this . changeListeners . forEach ( callback => callback ( ) ) ;
75
97
}
76
98
setDefaults ( config ) {
@@ -1208,6 +1230,8 @@ class HydratorPlusPlusConfigStore {
1208
1230
return ;
1209
1231
}
1210
1232
1233
+ if ( ! this . HydratorPlusPlusConfigStore . checkPipelineJsonSize ( ) ) return ;
1234
+
1211
1235
let config = this . getConfigForExport ( { shouldPruneProperties : false } ) ;
1212
1236
const draftId = this . getDraftId ( ) || this . uuid . v4 ( ) ;
1213
1237
const params = {
0 commit comments