1515 */
1616
1717class 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 ) {
1919 'ngInject' ;
2020 this . state = { } ;
2121 this . mySettings = mySettings ;
@@ -36,6 +36,7 @@ class HydratorPlusPlusConfigStore {
3636 this . myPipelineApi = myPipelineApi ;
3737 this . myAppsApi = myAppsApi ;
3838 this . isDistributed = MY_CONFIG . isEnterprise ? true : false ;
39+ this . myAlertOnValium = myAlertOnValium ;
3940
4041 this . changeListeners = [ ] ;
4142 this . setDefaults ( ) ;
@@ -70,7 +71,28 @@ class HydratorPlusPlusConfigStore {
7071 this . changeListeners . splice ( index , 1 ) ;
7172 } ;
7273 }
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+ }
7394 emitChange ( ) {
95+ this . checkPipelineJsonSize ( ) ;
7496 this . changeListeners . forEach ( callback => callback ( ) ) ;
7597 }
7698 setDefaults ( config ) {
@@ -1208,6 +1230,8 @@ class HydratorPlusPlusConfigStore {
12081230 return ;
12091231 }
12101232
1233+ if ( ! this . HydratorPlusPlusConfigStore . checkPipelineJsonSize ( ) ) return ;
1234+
12111235 let config = this . getConfigForExport ( { shouldPruneProperties : false } ) ;
12121236 const draftId = this . getDraftId ( ) || this . uuid . v4 ( ) ;
12131237 const params = {
0 commit comments